geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmcma...@apache.org
Subject svn commit: r520023 [4/10] - in /geronimo/sandbox/j2g: ./ bin/ doc/ src/ src/common/ src/common/META-INF/ src/common/src/ src/common/src/org/ src/common/src/org/apache/ src/common/src/org/apache/apps/ src/common/src/org/apache/apps/j2gmigrator/ src/con...
Date Mon, 19 Mar 2007 17:43:49 GMT
Added: geronimo/sandbox/j2g/src/resources-tool/schema/tool.migrations.exsd
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/resources-tool/schema/tool.migrations.exsd?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/resources-tool/schema/tool.migrations.exsd (added)
+++ geronimo/sandbox/j2g/src/resources-tool/schema/tool.migrations.exsd Mon Mar 19 10:43:27 2007
@@ -0,0 +1,108 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+ <?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="com.ibm.j2g.resources">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="com.ibm.j2g.resources" id="com.ibm.j2g.resources.tool.migrations" name="Descriptors Migrations Extension Point"/>
+      </appInfo>
+      <documentation>
+         [Enter description of this extension point.]
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <complexType>
+         <sequence>
+            <element ref="migration"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="migration">
+      <complexType>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  Descriptor migration plug-in implementation class.
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn="com.ibm.j2g.IFileMigration"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         1.0.0
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         &lt;pre&gt;
+   &lt;extension
+         point=&quot;com.ibm.j2g.resources.tool.migrations&quot;&gt;
+      &lt;migration class=&quot;com.ibm.j2g.resources.jms.JMSResourcesFileMigration&quot;/&gt;
+   &lt;/extension&gt;
+&lt;/pre&gt;
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         
+      </documentation>
+   </annotation>
+
+</schema>

Added: geronimo/sandbox/j2g/src/resources-tool/src/org/apache/apps/j2gmigrator/resources/ResourcesTool.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/resources-tool/src/org/apache/apps/j2gmigrator/resources/ResourcesTool.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/resources-tool/src/org/apache/apps/j2gmigrator/resources/ResourcesTool.java (added)
+++ geronimo/sandbox/j2g/src/resources-tool/src/org/apache/apps/j2gmigrator/resources/ResourcesTool.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,55 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.apps.j2gmigrator.resources;
+
+import org.apache.apps.j2gmigrator.XMLMigrationTool;
+
+/**
+ * Descriptors migration tool.
+ * 
+ * @author Ivan S. Dubrov
+ */
+public class ResourcesTool extends XMLMigrationTool {
+
+	/** Plug-in id */
+	public final static String PLUGIN_ID = "com.ibm.j2g.resources";
+
+	/** Extension point id */
+	public final static String EXTENSION_POINT_ID = PLUGIN_ID
+			+ ".migrations";
+
+	/**
+	 * @see org.apache.apps.j2gmigrator.XMLMigrationTool#getExtensionPointId()
+	 */
+	protected String getExtensionPointId() {
+		return EXTENSION_POINT_ID;
+	}
+
+	/**
+	 * @see org.apache.apps.j2gmigrator.XMLMigrationTool#getPluginId()
+	 */
+	protected String getPluginId() {
+		return PLUGIN_ID;
+	}
+
+	/**
+	 * @see org.apache.apps.j2gmigrator.XMLMigrationTool#getToolName()
+	 */
+	protected String getToolName() {
+		return "jres2g.cmd";
+	}
+}

Propchange: geronimo/sandbox/j2g/src/resources-tool/src/org/apache/apps/j2gmigrator/resources/ResourcesTool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src/resources-tool/src/org/apache/apps/j2gmigrator/resources/ResourcesTool.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src/resources-tool/src/org/apache/apps/j2gmigrator/resources/ResourcesTool.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src/scripts/j2g-configure.cmd
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/scripts/j2g-configure.cmd?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/scripts/j2g-configure.cmd (added)
+++ geronimo/sandbox/j2g/src/scripts/j2g-configure.cmd Mon Mar 19 10:43:27 2007
@@ -0,0 +1,17 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+ java -cp configurator.jar com.ibm.j2g.Configurator %ECLIPSE_HOME%
\ No newline at end of file

Added: geronimo/sandbox/j2g/src/scripts/jdesc2g.cmd
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/scripts/jdesc2g.cmd?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/scripts/jdesc2g.cmd (added)
+++ geronimo/sandbox/j2g/src/scripts/jdesc2g.cmd Mon Mar 19 10:43:27 2007
@@ -0,0 +1,17 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+ java -classpath %ECLIPSE_HOME%\startup.jar org.eclipse.core.launcher.Main -application com.ibm.j2g.descriptors.tool -data @user.home\workspace\ -configuration @user.dir\..\eclipse\configuration %*
\ No newline at end of file

Added: geronimo/sandbox/j2g/src/scripts/jres2g.cmd
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/scripts/jres2g.cmd?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/scripts/jres2g.cmd (added)
+++ geronimo/sandbox/j2g/src/scripts/jres2g.cmd Mon Mar 19 10:43:27 2007
@@ -0,0 +1,17 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+ java -classpath %ECLIPSE_HOME%\startup.jar org.eclipse.core.launcher.Main -application com.ibm.j2g.resources.tool -data @user.home\workspace\ -configuration @user.dir\..\eclipse\configuration %*
\ No newline at end of file

Added: geronimo/sandbox/j2g/src/scripts/jsrc2g.cmd
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/scripts/jsrc2g.cmd?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/scripts/jsrc2g.cmd (added)
+++ geronimo/sandbox/j2g/src/scripts/jsrc2g.cmd Mon Mar 19 10:43:27 2007
@@ -0,0 +1,17 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+ java -classpath %ECLIPSE_HOME%\startup.jar org.eclipse.core.launcher.Main -application com.ibm.j2g.sources.tool -data @user.home\workspace\ -configuration @user.dir\..\eclipse\configuration %*
\ No newline at end of file

Added: geronimo/sandbox/j2g/src/sources-tool/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/sources-tool/META-INF/MANIFEST.MF?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/sources-tool/META-INF/MANIFEST.MF (added)
+++ geronimo/sandbox/j2g/src/sources-tool/META-INF/MANIFEST.MF Mon Mar 19 10:43:27 2007
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: J2G Source Identification Tool Plug-in
+Bundle-SymbolicName: com.ibm.j2g.sources;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Localization: plugin
+Require-Bundle: com.ibm.j2g,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.jdt.core,
+ org.eclipse.jdt.launching,
+ org.eclipse.jface.text,
+ com.ibm.j2g.jasper
+Bundle-Vendor: IBM

Added: geronimo/sandbox/j2g/src/sources-tool/build.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/sources-tool/build.properties?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/sources-tool/build.properties (added)
+++ geronimo/sandbox/j2g/src/sources-tool/build.properties Mon Mar 19 10:43:27 2007
@@ -0,0 +1,22 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+ output.. = bin/
+source.. = src/
+bin.includes = META-INF/,\
+               plugin.xml,\
+               .
+

Propchange: geronimo/sandbox/j2g/src/sources-tool/build.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src/sources-tool/build.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src/sources-tool/build.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src/sources-tool/plugin.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/sources-tool/plugin.xml?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/sources-tool/plugin.xml (added)
+++ geronimo/sandbox/j2g/src/sources-tool/plugin.xml Mon Mar 19 10:43:27 2007
@@ -0,0 +1,29 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+ <?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+   <extension-point id="migrations" name="Java Sources Migration Extension Point" schema="schema/migrations.exsd"/>
+   <extension
+         id="tool"
+         name="Source Identification Tool"
+         point="org.eclipse.core.runtime.applications">
+      <application>
+         <run class="com.ibm.j2g.sources.SourceIdentificationTool"/>
+      </application>
+   </extension>
+</plugin>

Propchange: geronimo/sandbox/j2g/src/sources-tool/plugin.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src/sources-tool/plugin.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/sandbox/j2g/src/sources-tool/schema/migrations.exsd
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/sources-tool/schema/migrations.exsd?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/sources-tool/schema/migrations.exsd (added)
+++ geronimo/sandbox/j2g/src/sources-tool/schema/migrations.exsd Mon Mar 19 10:43:27 2007
@@ -0,0 +1,126 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+ <?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="com.ibm.j2g.sources">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="com.ibm.j2g.sources" id="com.ibm.j2g.sources.migrations" name="Java Source Migration Point"/>
+      </appInfo>
+      <documentation>
+         [Enter description of this extension point.]
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <complexType>
+         <sequence>
+            <element ref="migration"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="migration">
+      <complexType>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  Source migration plug-in implementation class.
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn="com.ibm.j2g.IJavaMigration"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         1.0.0
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         &lt;pre&gt;
+   &lt;extension
+         point=&quot;com.ibm.j2g.sources.migrations&quot;&gt;
+      &lt;migration class=&quot;com.ibm.j2g.sources.java.JavaSourceMigrator&quot;/&gt;
+   &lt;/extension&gt;
+&lt;/pre&gt;
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiInfo"/>
+      </appInfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         
+      </documentation>
+   </annotation>
+
+</schema>

Added: geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/FileFilterImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/FileFilterImpl.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/FileFilterImpl.java (added)
+++ geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/FileFilterImpl.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,67 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.apps.j2gmigrator.sources;
+
+import java.io.File;
+import java.io.FileFilter;
+
+/**
+ * File filter for JSP files.
+ * 
+ * @author Volkov, Stepan S.
+ */
+public class FileFilterImpl implements FileFilter
+{
+	/**
+	 * Files extensions.
+	 */
+	private String[] extensions;
+
+	/**
+	 * Creates file filter whith specifed extensions.
+	 * 
+	 * @param extentions
+	 */
+	public FileFilterImpl(String[] extentions)
+	{
+		this.extensions = extentions;
+	}
+
+	/**
+	 * @see java.io.FileFilter#accept(java.io.File)
+	 */
+	public boolean accept(File file)
+	{
+		boolean isAllowed = false;
+		if (file.isDirectory())
+		{
+			return true;
+		}
+		else
+		{
+			for (int i = 0; i < extensions.length; i++)
+			{
+				if (file.getName().endsWith(extensions[i]))
+				{
+					isAllowed = true;
+				}
+			}
+		}
+		return isAllowed;
+	}
+}

Propchange: geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/FileFilterImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/FileFilterImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/FileFilterImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/JavaParser.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/JavaParser.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/JavaParser.java (added)
+++ geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/JavaParser.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,457 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.apps.j2gmigrator.sources;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.apps.j2gmigrator.FatalToolException;
+import org.apache.apps.j2gmigrator.ToolConstants;
+import org.apache.apps.j2gmigrator.jasper.JspCompiler;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.dom.ASTParser;
+import org.eclipse.jdt.launching.JavaRuntime;
+
+
+/**
+ * Parser for java sources. Compiles JSP files to template project and parses specifed sources and
+ * compiled JSPs.
+ * 
+ * @author Volkov, Stepan S.
+ */
+public class JavaParser {
+	/**
+	 * List of sources dirs.
+	 */
+	private String[] sources;
+
+	/**
+	 * List of libraries.
+	 */
+	private String[] libraries;
+
+	/**
+	 * Web sources.
+	 */
+	private String[] webContent;
+
+	/**
+	 * JSP files extensions.
+	 */
+	private String[] extensions = { "jsp" };
+
+	/**
+	 * JSP files filter.
+	 */
+	private FileFilter jspFilter;
+
+	/**
+	 * Project which provides the environment (locations of sources including compiled JSP,
+	 * libraries) to work.
+	 */
+	private IProject project;
+
+	/**
+	 * Java project representation.
+	 */
+	private IJavaProject javaProject;
+
+	/**
+	 * Source folder name.
+	 */
+	private final String SRC_FOLDER_NAME = "src";
+
+	/**
+	 * Binaries folder name.
+	 */
+	private final String BIN_FOLDER_NAME = "bin";
+
+	/**
+	 * Libraies folder name.
+	 */
+	private final String LIB_FOLDER_NAME = "lib";
+
+	/**
+	 * JSP folder name.
+	 */
+	private final String JSP_FOLDER_NAME = "jsp";
+
+	/**
+	 * AST Parser for java sources.
+	 */
+	private ASTParser parser;
+
+	/**
+	 * WEB-INF directory name.
+	 */
+	private final String WEB_INF = "WEB-INF";
+
+	/**
+	 * Classes directory name.
+	 */
+	private final String CLASSES_CAT = "classes";
+
+	/**
+	 * Libraries directory name.
+	 */
+	private final String LIB_CAT = "lib";
+	
+	/**
+	 * Geronimo excluded lib.
+	 */
+	private static final String GERONIMO_EXCLUDED_LIB = "geronimo-j2ee_1.4_spec-1.1.jar"; 
+
+	/**
+	 * Java libraries file filter.
+	 */
+	private FileFilter jarFilter;
+
+	/**
+	 * For sources prepared for parsing.
+	 */
+	private List units;
+
+	/**
+	 * Creates java parser for specifed sources and libraries, compiles jsp files and save compiled
+	 * in temporary project.
+	 * 
+	 * @param sources not null list of source directories.
+	 * @param libraries not null list of jar files or directories.
+	 * @param webContent not null list of web content locations.
+	 * @param jspExt not null list of jsp files extensions.
+	 * @param created and opened project Eclipse project which will be provides sources and
+	 *            libraries.
+	 * @throws FatalToolException if any problems occurs while parser preparing.
+	 */
+
+	public JavaParser(String[] sources, String[] libraries, String[] webContent, String[] jspExt, File geronimoLib, File geronimoRep, IProject project) throws FatalToolException {
+		units = new ArrayList();
+		String[] exts = { "jar", "zip" };
+		jarFilter = new FileFilterImpl(exts);
+		this.sources = sources;
+		ArrayList libs = new ArrayList();
+		for (int i = 0; i < webContent.length; i++) {
+			File webinfCat = new File(webContent[i] + File.separator + WEB_INF);
+			if (webinfCat.exists()) {
+				File classes = new File(webinfCat, CLASSES_CAT);
+
+				if (classes.exists()) {
+					libs.add(classes.getAbsolutePath());
+				}
+
+				File lib = new File(webinfCat, LIB_CAT);
+				if (lib.exists() && lib.isDirectory()) {
+					File[] files = lib.listFiles(jarFilter);
+					for (int j = 0; j < files.length; j++) {
+						libs.add(files[j].getAbsolutePath());
+					}
+				}
+			}
+			else {
+				throw new FatalToolException("Path '" + webContent[i] + "' does not pointed to the web content directory. Could not find " + webinfCat.getAbsolutePath() + " directory.");
+			}
+		}
+
+		for (int i = 0; i < libraries.length; i++) {
+			libs.add(libraries[i]);
+		}
+		this.libraries = (String[]) libs.toArray(new String[libs.size()]);
+		this.webContent = webContent;
+		this.project = project;
+		this.javaProject = JavaCore.create(project);
+
+		try {
+			ArrayList classpathList = new ArrayList();
+			classpathList.addAll(linkSources());
+			classpathList.addAll(linkLibraries());
+			IClasspathEntry jreEntry = JavaCore.newContainerEntry(new Path(JavaRuntime.JRE_CONTAINER), false);
+			classpathList.add(jreEntry);
+			ArrayList repJars = new ArrayList();
+			getJarsRecursively(repJars, geronimoRep);
+			ArrayList libJars = new ArrayList();
+			getJarsRecursively(libJars, geronimoLib);
+			classpathList.addAll(linkGeronimo(repJars, ToolConstants.GERONIMO_REP));
+			classpathList.addAll(linkGeronimo(libJars, ToolConstants.GERONIMO_LIB));
+			IClasspathEntry[] entries = (IClasspathEntry[]) classpathList.toArray(new IClasspathEntry[classpathList.size()]);
+			javaProject.setRawClasspath(entries, null);
+			project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null);
+			project.refreshLocal(IResource.DEPTH_INFINITE, null);
+			classpathList.addAll(compileAndLinkJsp(jspExt));
+			entries = (IClasspathEntry[]) classpathList.toArray(new IClasspathEntry[classpathList.size()]);
+			javaProject.setRawClasspath(entries, null);
+			parser = ASTParser.newParser(AST.JLS3);
+		} catch (CoreException ex) {
+			throw new FatalToolException("Cannot create template project classpath file.", ex);
+		}
+	}
+
+	/**
+	 * Gets paths to the jar-files and puts it to list.
+	 */
+	public void getJarsRecursively(List list, File file) {
+		if (file.isDirectory()) {
+			File[] files = file.listFiles(jarFilter);
+			for (int i = 0; i < files.length; i++) {
+				getJarsRecursively(list, files[i]);
+			}
+		}
+		else {
+			list.add(file);
+		}
+	}
+
+	/**
+	 * Links Geronimo libraries to the temporary project.
+	 * @throws FatalToolException
+	 * 
+	 */
+	private List linkGeronimo(List jars, String baseName) throws FatalToolException {
+		ArrayList libs = new ArrayList();
+		for (int i = 0; i < jars.size(); i++) {
+			File jar = (File) jars.get(i);
+			String libName = jar.getName();
+			if (!libName.equals(GERONIMO_EXCLUDED_LIB)) {
+				String extension = libName.substring(libName.lastIndexOf("."), libName.length());
+				IFile sourceFolderEntry = project.getFile(generateName(baseName, i) + extension);
+				try {
+					sourceFolderEntry.createLink(Path.fromOSString(jar.getAbsolutePath()), IResource.NONE, null);
+					libs.add(JavaCore.newLibraryEntry(sourceFolderEntry.getFullPath(), null, null));
+				} catch (CoreException ex) {
+					throw new FatalToolException("Error occurs while linking geronimo library: " + jar.getAbsolutePath(), ex);
+				}
+			}
+		}
+		return libs;
+	}
+
+	/**
+	 * Compiles jsps to the jsp source folder to the project and returns List of a classpath
+	 * entries.
+	 * @see org.eclipse.jdt.core.IClasspathEntry
+	 * @param webContent paths to a directories with jsps.
+	 * @param jspExt jsp extensions.
+	 * @return List of a classpath entries.
+	 * @throws FatalToolException any errors occurs while jsp compiling.
+	 */
+	private List compileAndLinkJsp(String[] jspExt) throws FatalToolException {
+		ArrayList compiledJsp = new ArrayList();
+		if (webContent != null && webContent.length > 0) {
+			if (jspExt != null && jspExt.length > 0) {
+				extensions = jspExt;
+			}
+			jspFilter = new FileFilterImpl(extensions);
+			ClassLoader savedContextClassLoader = Thread.currentThread().getContextClassLoader();
+			Thread.currentThread().setContextClassLoader(new URLClassLoader(new URL[0]));
+			String classPath = "";
+			for (int i = 0; i < libraries.length; i++) {
+				classPath += File.pathSeparator + libraries[i];
+			}
+			IPath outputFodler = project.getFolder(BIN_FOLDER_NAME).getRawLocation();
+			classPath += File.pathSeparator + outputFodler.toOSString() + "/";
+			try {
+				for (int i = 0; i < webContent.length; i++) {
+					String jspFolderName = generateName(JSP_FOLDER_NAME, i);
+					IFolder compiledJspFolder = project.getFolder(jspFolderName);
+					compiledJspFolder.create(true, true, null);
+					compiledJspFolder.setDerived(true);
+					compiledJsp.add(JavaCore.newSourceEntry(compiledJspFolder.getFullPath()));
+					File jspSourceFolder = new File(webContent[i]);
+					JspCompiler jspCompiler = null;
+					jspCompiler = new JspCompiler(jspFilter);
+					compiledJspFolder.setDefaultCharset(jspCompiler.getEncoding(), null);
+					String jspOutputDir = compiledJspFolder.getLocation().toOSString();
+					String uriRoot = jspSourceFolder.getAbsolutePath();
+					jspCompiler.compileJsp(classPath, jspOutputDir, uriRoot);
+				}
+				project.refreshLocal(IResource.DEPTH_INFINITE, null);
+			} catch (CoreException ex) {
+				throw new FatalToolException("Cannot create jsp source folder in temporary project.", ex);
+			} finally {
+				Thread.currentThread().setContextClassLoader(savedContextClassLoader);
+			}
+		}
+		return compiledJsp;
+	}
+
+	/**
+	 * Preapres java sources for parsing.
+	 * @throws FatalToolException if any problems occurs while preparing sources.
+	 */
+	public void prepareSources() throws FatalToolException {
+		for (int i = 0; i < sources.length; i++) {
+			File sourceFile = new File(sources[i]);
+			IFolder srcFolder = project.getFolder(generateName(SRC_FOLDER_NAME, i));
+			String basePackage = srcFolder.getFullPath().toPortableString();
+			prepareRecursively(basePackage, sourceFile);
+		}
+	}
+
+	/**
+	 * Prepares compiled jsp sources for parsing.
+	 * @throws FatalToolException if any problems occurs while preparing jsp sources.
+	 */
+	public void prepareJspSources() throws FatalToolException {
+		for (int i = 0; i < webContent.length; i++) {
+			IFolder jspFolder = project.getFolder(generateName(JSP_FOLDER_NAME, i));
+			String basePackage = jspFolder.getFullPath().toPortableString();
+			prepareRecursively(basePackage, jspFolder.getLocation().toFile());
+		}
+	}
+
+	/**
+	 * Recursively find and prepares sources provided by sourceFile variable and puts results into
+	 * units list.
+	 * @param packagePath path to processed package relative to workspace.
+	 * @param sourceFile processed file.
+	 * @throws FatalToolException if any problems occurs while preparing sources.
+	 */
+	private void prepareRecursively(String packagePath, File sourceFile) throws FatalToolException {
+		if (sourceFile.isDirectory()) {
+			File[] files = sourceFile.listFiles(JavaSourceFilter.FILTER);
+			for (int i = 0; i < files.length; i++) {
+				if (files[i].isDirectory()) {
+					prepareRecursively(packagePath + IPath.SEPARATOR + files[i].getName(), files[i]);
+				}
+				else {
+					try {
+						IPath path = Path.fromPortableString(packagePath);
+						IPackageFragment fragment = javaProject.findPackageFragment(path);
+						ICompilationUnit compilationUnit = fragment.getCompilationUnit(files[i].getName());
+						units.add(new ParsedSource(compilationUnit, files[i]));
+					} catch (JavaModelException ex) {
+						throw new FatalToolException("Error occurs while parsing sources.", ex);
+					}
+				}
+			}
+		}
+		else {
+			if (sourceFile.exists()) {
+				throw new FatalToolException("'" + sourceFile.getAbsolutePath() + "'; Source directories allowed only.");
+			}
+			else {
+				throw new FatalToolException("'" + sourceFile.getAbsolutePath() + "' directory does not exists.");
+			}
+		}
+	}
+
+	/**
+	 * Parse next in the list of sources.
+	 * @return parsed source or null if list is empty.
+	 */
+	public ParsedSource parseNext() {
+		if (!units.isEmpty()) {
+			ParsedSource unit = (ParsedSource) units.get(0);
+			units.remove(unit);
+			parser.setResolveBindings(true);
+			parser.setSource(unit.getCompilationUnit());
+			ASTNode node = parser.createAST(null);
+			unit.setNode(node);
+			return unit;
+		}
+		return null;
+	}
+
+	/**
+	 * Links sources paths to a temporary projects sources folder.
+	 * @throws FatalToolException if any problems occurs while linking source folders.
+	 */
+	private List linkSources() throws FatalToolException {
+		ArrayList srcList = new ArrayList();
+		for (int i = 0; i < sources.length; i++) {
+			File file = new File(sources[i]);
+			if (!file.exists()) {
+				throw new FatalToolException("Source directory '" + file.getAbsolutePath() + "' does not exists.");
+			}
+			IFolder sourceFolderEntry = project.getFolder(generateName(SRC_FOLDER_NAME, i));
+			try {
+				sourceFolderEntry.createLink(Path.fromOSString(file.getAbsolutePath()), IResource.NONE, null);
+				srcList.add(JavaCore.newSourceEntry(sourceFolderEntry.getFullPath()));
+			} catch (CoreException ex) {
+				throw new FatalToolException("Error occurs while linking source directory: " + file.getAbsolutePath(), ex);
+			}
+		}
+		return srcList;
+	}
+
+	/**
+	 * Links libraries paths to a temporary projects libraries folder.
+	 * @throws FatalToolException if any problems occurs while linking libraries.
+	 */
+	private List linkLibraries() throws FatalToolException {
+		ArrayList libList = new ArrayList();
+		if (libraries != null) {
+			for (int i = 0; i < libraries.length; i++) {
+				File file = new File(libraries[i]);
+				try {
+					if (file.isDirectory()) {
+						if (!file.exists()) {
+							throw new FatalToolException("Directory '" + file.getAbsolutePath() + "' does not exists.");
+						}
+						IFolder libFolderEntry = project.getFolder(generateName(LIB_FOLDER_NAME, i));
+						libFolderEntry.createLink(Path.fromOSString(file.getAbsolutePath()), IResource.NONE, null);
+						IClasspathEntry libDir = JavaCore.newLibraryEntry(libFolderEntry.getFullPath(), null, null);
+						libList.add(libDir);
+					}
+					else {
+						if (!file.exists()) {
+							throw new FatalToolException("File '" + file.getAbsolutePath() + "' does not exists.");
+						}
+						String libName = file.getName();
+						String extension = libName.substring(libName.lastIndexOf("."), libName.length());
+						IFile libJarEntry = project.getFile(generateName(LIB_FOLDER_NAME, i) + extension);
+						libJarEntry.createLink(Path.fromOSString(file.getAbsolutePath()), IResource.NONE, null);
+						IClasspathEntry libJar = JavaCore.newLibraryEntry(libJarEntry.getFullPath(), null, null);
+						libList.add(libJar);
+					}
+				} catch (CoreException ex) {
+					throw new FatalToolException("Error occurs while linking library: " + file.getAbsolutePath(), ex);
+				}
+			}
+		}
+		return libList;
+	}
+
+	/**
+	 * Generates folders names.
+	 * @param base
+	 * @param number
+	 * @return generated folder name. (base_number)
+	 */
+	private String generateName(String base, int number) {
+		return base + "_" + number;
+	}
+}
\ No newline at end of file

Propchange: geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/JavaParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/JavaParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/JavaParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/JavaSourceFilter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/JavaSourceFilter.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/JavaSourceFilter.java (added)
+++ geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/JavaSourceFilter.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,47 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.apps.j2gmigrator.sources;
+
+import java.io.File;
+import java.io.FileFilter;
+
+/**
+ * Filter for .java files.
+ * 
+ * @author Volkov, Stepan S.
+ */
+public class JavaSourceFilter implements FileFilter
+{
+	/**
+	 * Java sources suffix.
+	 */
+	public static final String JAVA_SUFFIX = ".java";
+	
+	/**
+	 * Static filter.
+	 */
+	public static final JavaSourceFilter FILTER = new JavaSourceFilter();
+	
+	/**
+	 * @see java.io.FileFilter#accept(java.io.File)
+	 */
+	public boolean accept(File file)
+	{
+		return file.isDirectory() || file.getName().endsWith(JAVA_SUFFIX);
+	}
+}
\ No newline at end of file

Propchange: geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/JavaSourceFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/JavaSourceFilter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/JavaSourceFilter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/ParsedSource.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/ParsedSource.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/ParsedSource.java (added)
+++ geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/ParsedSource.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,89 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.apps.j2gmigrator.sources;
+
+import java.io.File;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.dom.ASTNode;
+
+/**
+ * Class provides parsed source node and file.
+ * @author Volkov, Stepan S.
+ */
+public class ParsedSource
+{
+	/**
+	 * Syntax tree. 
+	 */
+	private ASTNode node;
+	
+	/**
+	 * Source unit.
+	 */
+	private ICompilationUnit compilationUnit;
+	
+	/**
+	 * Source real file.
+	 */
+	private File file;
+	
+	/**
+	 * Creates object with specifed source unit and syntax tree.
+	 * @param node syntax tree.
+	 * @param file source file.
+	 */
+	public ParsedSource(ICompilationUnit compilationUnit, File file)
+	{
+		this.file = file;
+		this.compilationUnit = compilationUnit;
+	}
+
+	/**
+	 * @return the syntax tree.
+	 */
+	public ASTNode getNode()
+	{
+		return node;
+	}
+
+	/**
+	 * @return the compilation unit.
+	 */
+	public ICompilationUnit getCompilationUnit()
+	{
+		return compilationUnit;
+	}
+	
+	/**
+	 * @return the source file.
+	 */
+	public File getFile()
+	{
+		return file;
+	}
+	
+	/**
+	 * Sets parsed AST node for current source.
+	 * @param node
+	 */
+	public void setNode(ASTNode node)
+	{
+		this.node = node;
+	}
+}
\ No newline at end of file

Propchange: geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/ParsedSource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/ParsedSource.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/ParsedSource.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/SourceIdentificationTool.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/SourceIdentificationTool.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/SourceIdentificationTool.java (added)
+++ geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/SourceIdentificationTool.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,373 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.apps.j2gmigrator.sources;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.apps.j2gmigrator.FatalToolException;
+import org.apache.apps.j2gmigrator.IJavaMigration;
+import org.apache.apps.j2gmigrator.RollbackManager;
+import org.apache.apps.j2gmigrator.Tool;
+import org.apache.apps.j2gmigrator.ToolConstants;
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.text.edits.TextEdit;
+
+
+/**
+ * Class coordinates a work of plugins.
+ * 
+ * @author Volkov, Stepan S.
+ */
+public class SourceIdentificationTool extends Tool {
+	/**
+	 * Sources parameter.
+	 */
+	private final static String SRC_PARAM = "-src";
+
+	/**
+	 * Libraries parameter.
+	 */
+	private final static String LIB_PARAM = "-lib";
+
+	/**
+	 * Web sources parameter.
+	 */
+	private final static String WEB_PARAM = "-web";
+
+	/**
+	 * Jsp extensions parameter.
+	 */
+	private final static String JSPEXT_PARAM = "-jspext";
+
+	/**
+	 * Geronimo home path parameter.
+	 */
+	private final static String GERONIMO_PARAM = "-geronimo";
+
+	/**
+	 * Allowed parameters.
+	 */
+	private final static String[] ALLOWED_PARAMS = { SRC_PARAM, LIB_PARAM, WEB_PARAM, JSPEXT_PARAM, GERONIMO_PARAM };
+
+	/**
+	 * Parameters delimeter.
+	 */
+	private final static String DELIMETER = ";";
+
+	/**
+	 * Temporary project.
+	 */
+	private static IProject project;
+
+	/**
+	 * Plug-in id
+	 */
+	public final static String PLUGIN_ID = "com.ibm.j2g.sources";
+
+	/** Geronimo repository. */
+	private final static String REPOSITORY = "repository";
+
+	/** Geronimo common libraries. */
+	private final static String LIBRARIES = "lib";
+
+	/**
+	 * Extension point id
+	 */
+	public final static String EXTENSION_POINT_ID = PLUGIN_ID + ".migrations";
+
+	/**
+	 * Geronimo home system environment variable name.
+	 */
+	private final static String GERONIMO_HOME = "GERONIMO_HOME";
+
+	/**
+	 * Geronimo home.
+	 */
+	private String geronimoHomePath;
+
+	/**
+	 * @see org.eclipse.core.runtime.IPlatformRunnable
+	 */
+	public Object run(Object args) throws Exception {
+		try {
+			String[] arguments = (String[]) args;
+			if (arguments.length == 0) {
+				usage();
+				return new Integer(0);
+			}
+			project = createTemporaryProject();
+			Map params = parseArguments(arguments);
+			List geronimoHome = (List) params.get(GERONIMO_PARAM);
+			if (geronimoHome != null && geronimoHome.size() != 0) {
+				geronimoHomePath = (String) geronimoHome.get(0);
+			}
+			else {
+				geronimoHomePath = System.getProperty(GERONIMO_HOME);
+				if (geronimoHomePath == null) {
+					usage();
+					throw new FatalToolException("Missing mandatory parameter '-geronimo'");
+				}
+			}
+			File geronimo = new File(geronimoHomePath);
+			File geronimoRep = new File(geronimo, REPOSITORY);
+			File geronimoLib = new File(geronimo, LIBRARIES);
+			if (!geronimoRep.exists() || !geronimoLib.exists()) {
+				throw new FatalToolException("Invalid Geronimo installation. Cannot find libaries and repository directories.");
+			}
+
+			List src = (List) params.get(SRC_PARAM);
+			List lib = (List) params.get(LIB_PARAM);
+			List web = (List) params.get(WEB_PARAM);
+			List jspext = (List) params.get(JSPEXT_PARAM);
+			if (src != null) {
+				RollbackManager rollbackManager = new RollbackManager(JavaSourceFilter.FILTER);
+				Iterator sources = src.iterator();
+				while (sources.hasNext()) {
+					File file = new File((String) sources.next());
+					rollbackManager.restore(file);
+				}
+			}
+			JavaParser parser = null;
+			parser = new JavaParser(getStringArray(src), getStringArray(lib), getStringArray(web), getStringArray(jspext), geronimoLib, geronimoRep, project);
+			parser.prepareSources();
+
+			IJavaMigration[] plugs = loadPlugins();
+
+			ParsedSource unit;
+			while ((unit = parser.parseNext()) != null) {
+				migrate(plugs, unit, true);
+			}
+
+			parser.prepareJspSources();
+			while ((unit = parser.parseNext()) != null) {
+				migrate(plugs, unit, false);
+			}
+
+		} catch (FatalToolException ex) {
+			getOutput().fatal(ex.getMessage());
+			return new Integer(1);
+		} finally {
+			IWorkspace workspace = ResourcesPlugin.getWorkspace();
+			IProject project = workspace.getRoot().getProject(ToolConstants.TEMPORARY_PROJECT_NAME);
+			project.refreshLocal(IResource.DEPTH_INFINITE, null);
+			project.delete(true, null);
+		}
+		return new Integer(0);
+	}
+
+	/**
+	 * Print tool usage text.
+	 */
+	protected void usage() {
+		getOutput().fatal("Usage: jsrc2g.cmd {-src dir_name[;dir_nameN]}{-lib dir_or_jar_name[;dir_or_jar_nameN]}{-web dir_name[;dir_nameN]} -geronimo geronimo_home");
+	}
+
+	/**
+	 * Converts List with Strings to String[] array.
+	 * @param list list of strings.
+	 * @return
+	 */
+	private String[] getStringArray(List list) {
+		if (list != null) {
+			return (String[]) list.toArray(new String[list.size()]);
+		}
+		else {
+			return new String[0];
+		}
+	}
+
+	/**
+	 * Parses arguments which was passed to the plugin.
+	 * @param args arguments array.
+	 * @return map of parameters where key - parameter names and values - lists of parameters.
+	 * @throws FatalToolException if wrong parameter was found.
+	 */
+	private Map parseArguments(String[] args) throws FatalToolException {
+		HashMap result = new HashMap();
+		int pointer = 0;
+		while (pointer < args.length) {
+			String key = args[pointer];
+			if (isCorrectParameter(key)) {
+				pointer++;
+				if (args.length > pointer) {
+					result.put(key, parseComplexPath(args[pointer]));
+					pointer++;
+				}
+				else {
+					throw new FatalToolException("Missing parameter for key:" + key);
+				}
+			}
+			else {
+				throw new FatalToolException("Wrong parameter:" + args[pointer]);
+			}
+		}
+		return result;
+	}
+
+	/**
+	 * Checks correctness of parameters.
+	 * @param arg paramter.
+	 * @return true if parameter allowed.
+	 */
+	private boolean isCorrectParameter(String arg) {
+		for (int i = 0; i < ALLOWED_PARAMS.length; i++) {
+			if (arg.equals(ALLOWED_PARAMS[i])) {
+				return true;
+			}
+		}
+		return false;
+	}
+
+	/**
+	 * Parses strings formated follows: some_string_1[;some_string_N]
+	 * @param path string like this "some_string_1[;some_string_N]"
+	 * @return list of parsed strings.
+	 */
+	private List parseComplexPath(String path) {
+		ArrayList result = new ArrayList();
+		int index = path.indexOf(DELIMETER);
+		while (index > 0) {
+			result.add(path.substring(0, index));
+			path = path.substring(index + 1);
+			index = path.indexOf(DELIMETER);
+		}
+		result.add(path);
+		return result;
+	}
+
+	/**
+	 * Creates opened temporary Eclipse project in current workspace.
+	 * @return opened temporary Eclipse project.
+	 * @throws FatalToolException
+	 */
+	private IProject createTemporaryProject() throws FatalToolException {
+		IProject project;
+		IWorkspace workspace = ResourcesPlugin.getWorkspace();
+		try {
+			project = workspace.getRoot().getProject(ToolConstants.TEMPORARY_PROJECT_NAME);
+			IProjectDescription desc = workspace.newProjectDescription(project.getName());
+			desc.setNatureIds(new String[] { JavaCore.NATURE_ID });
+			ICommand command = desc.newCommand();
+			command.setBuilderName(JavaCore.BUILDER_ID);
+			desc.setBuildSpec(new ICommand[] { command });
+			project.create(desc, null);
+			project.open(null);
+		} catch (CoreException ex) {
+			throw new FatalToolException("Cannot create or open temporary project. Please try to clean workspace '" + workspace.getRoot().getLocation().toOSString() + "' manually.", ex);
+		}
+		return project;
+	}
+
+	/**
+	 * Loads java source migration plug-ins from the extension registry.
+	 * @return array of IJavaMigration instaces.
+	 */
+	private IJavaMigration[] loadPlugins() {
+		List plugins = new ArrayList();
+		IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
+		IExtension[] exts = point.getExtensions();
+		for (int i = 0; i < exts.length; ++i) {
+			IConfigurationElement[] els = exts[i].getConfigurationElements();
+			for (int j = 0; j < els.length; ++j) {
+				try {
+					plugins.add(els[j].createExecutableExtension(ToolConstants.CLASS_PROPERTY));
+				} catch (CoreException ex) {
+					ILog log = Platform.getLog(Platform.getBundle(PLUGIN_ID));
+					log.log(new Status(Status.WARNING, PLUGIN_ID, Status.OK, "Failed to instantiate java source migration plug-in.", ex));
+				}
+			}
+		}
+		return (IJavaMigration[]) plugins.toArray(new IJavaMigration[plugins.size()]);
+	}
+
+	/**
+	 * Migrates given source and execute saving if it's necessary.
+	 * 
+	 * @param plugs available migration plug-ins.
+	 * @param source source to migration.
+	 * @param saveMigrated if true then migrated source will be saved.
+	 * @throws FatalToolException
+	 */
+	private void migrate(IJavaMigration[] plugs, ParsedSource source, boolean saveMigrated) throws FatalToolException {
+		boolean isModified = false;
+		CompilationUnit unit = (CompilationUnit) source.getNode();
+		unit.recordModifications();
+		for (int i = 0; i < plugs.length; ++i) {
+			isModified = plugs[i].migrate(source.getNode()) || isModified;
+		}
+		if (isModified && saveMigrated) {
+			saveSource(source);
+		}
+	}
+
+	/**
+	 * Creates buckup copy and saves modified source.
+	 * @param source
+	 * @throws FatalToolException
+	 * @throws IOException
+	 */
+	private void saveSource(ParsedSource source) throws FatalToolException {
+		ICompilationUnit sourceUnit = source.getCompilationUnit();
+		CompilationUnit parsedUnit = (CompilationUnit) source.getNode();
+		try {
+			String contents = sourceUnit.getBuffer().getContents();
+			File file = new File(source.getFile().getAbsolutePath() + RollbackManager.BACKUP_SUFFIX);
+			file.createNewFile();
+			FileOutputStream out = new FileOutputStream(file);
+			out.write(contents.getBytes());
+			out.close();
+			Document document = new Document(contents);
+			TextEdit edits = parsedUnit.rewrite(document, sourceUnit.getJavaProject().getOptions(true));
+			edits.apply(document);
+			String newSource = document.get();
+			sourceUnit.getBuffer().setContents(newSource);
+			sourceUnit.save(null, true);
+		} catch (JavaModelException ex) {
+			getOutput().error("Java element does not exists or it is read-only: " + sourceUnit.getElementName());
+		} catch (IOException ex) {
+			getOutput().error("I/O error occurs while creating backup copy of source file: " + source.getFile().getAbsolutePath());
+		} catch (BadLocationException ex) {
+			getOutput().error("Cannot edit source file: " + source.getFile().getAbsolutePath());
+		}
+	}
+}
\ No newline at end of file

Propchange: geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/SourceIdentificationTool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/SourceIdentificationTool.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src/sources-tool/src/org/apache/apps/j2gmigrator/sources/SourceIdentificationTool.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src2/data-source-plugin/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/data-source-plugin/META-INF/MANIFEST.MF?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/data-source-plugin/META-INF/MANIFEST.MF (added)
+++ geronimo/sandbox/j2g/src2/data-source-plugin/META-INF/MANIFEST.MF Mon Mar 19 10:43:27 2007
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Data_source_plugin Plug-in
+Bundle-SymbolicName: com.ibm.j2g.resources.ds; singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Vendor: ibm
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.core.runtime,
+ com.ibm.j2g.resources,
+ com.ibm.j2g,
+ com.ibm.j2g.util
+Eclipse-LazyStart: true
+Bundle-ClassPath: .

Added: geronimo/sandbox/j2g/src2/data-source-plugin/build.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/data-source-plugin/build.properties?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/data-source-plugin/build.properties (added)
+++ geronimo/sandbox/j2g/src2/data-source-plugin/build.properties Mon Mar 19 10:43:27 2007
@@ -0,0 +1,21 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+ source.. = src/
+output.. = classes/
+bin.includes = plugin.xml,\
+               META-INF/,\
+               .,\

Propchange: geronimo/sandbox/j2g/src2/data-source-plugin/build.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/data-source-plugin/build.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/data-source-plugin/build.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src2/data-source-plugin/plugin.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/data-source-plugin/plugin.xml?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/data-source-plugin/plugin.xml (added)
+++ geronimo/sandbox/j2g/src2/data-source-plugin/plugin.xml Mon Mar 19 10:43:27 2007
@@ -0,0 +1,23 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+ <?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+    <extension point="com.ibm.j2g.resources.migrations">
+      	<migration class="com.ibm.j2g.resources.ds.DSResourcesTool"/>
+   </extension>
+</plugin>

Propchange: geronimo/sandbox/j2g/src2/data-source-plugin/plugin.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/data-source-plugin/plugin.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/data-source-plugin/plugin.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/sandbox/j2g/src2/data-source-plugin/src/commons-logging.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/data-source-plugin/src/commons-logging.properties?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/data-source-plugin/src/commons-logging.properties (added)
+++ geronimo/sandbox/j2g/src2/data-source-plugin/src/commons-logging.properties Mon Mar 19 10:43:27 2007
@@ -0,0 +1,30 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+ # Set root logger level to DEBUG and its only appender to console.
+commons-logging.rootLogger=INFO
+
+#define loggers
+#pluging logger
+lcommons-logging.logger.com.ibm.j2g= DEBUG,console
+
+# console is set to be a ConsoleAppender.
+commons-logging.appender.console=org.apache.log4j.ConsoleAppender
+
+# console uses PatternLayout.
+commons-logging.appender.console.layout=org.apache.log4j.PatternLayout
+#commons-logging.appender.console.layout.ConversionPattern=[%t] %-5p %l - %m%n
+commons-logging.appender.console.layout.ConversionPattern=[%t] %-5p - %m%n
\ No newline at end of file

Propchange: geronimo/sandbox/j2g/src2/data-source-plugin/src/commons-logging.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src2/data-source-plugin/src/commons-logging.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src2/data-source-plugin/src/commons-logging.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src2/data-source-plugin/src/org/apache/apps/j2gmigrator/resources/ds/DSResourcesTool.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src2/data-source-plugin/src/org/apache/apps/j2gmigrator/resources/ds/DSResourcesTool.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src2/data-source-plugin/src/org/apache/apps/j2gmigrator/resources/ds/DSResourcesTool.java (added)
+++ geronimo/sandbox/j2g/src2/data-source-plugin/src/org/apache/apps/j2gmigrator/resources/ds/DSResourcesTool.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,355 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.apps.j2gmigrator.resources.ds;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+
+import org.apache.apps.j2gmigrator.IFileMigration;
+import org.apache.apps.j2gmigrator.IOutput;
+import org.apache.apps.j2gmigrator.Tool;
+import org.apache.apps.j2gmigrator.resources.utils.Constants;
+import org.apache.apps.j2gmigrator.resources.xmlutil.XMLConversionHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.Namespace;
+import org.dom4j.QName;
+
+/**
+ * Class which implement the Data Source File Migration 
+ */
+public class DSResourcesTool implements IFileMigration {
+
+    // Initialization of the IOutput for DSResourcesTool class
+    IOutput out = Tool.getCurrent().getOutput();
+    // Initialization of the logger for DSResourcesTool class
+    Log logger = LogFactory.getLog(DSResourcesTool.class);
+
+    /**
+     * mgration method from data source jboss discripters to geronimo
+     * discriptors
+     * 
+     * @param sourceFile :data source jboss discriptor file
+     * @return status of the migration
+     */
+    public boolean migrate(File sourceFile) {
+        boolean migrated = false;
+            String directoryName = sourceFile.getParent();
+            String jbossDSFileName = sourceFile.getName();
+            logger.debug("Directory Name ==> " + directoryName
+                    + " jboss data source file Name ==> " + jbossDSFileName);
+
+            if (jbossDSFileName.endsWith(Constants.JBOSS_VALID_DS_XML_FILE)) {
+                // Checking wether file is a valid *-ds.xml file
+                String driverType = jbossDSFileName.substring(0, jbossDSFileName.lastIndexOf("-"));
+                out.info("Converting Jboss datasource xml file in " + directoryName);
+                try {
+                    Document jbossDocument = XMLConversionHelper.getJbossDocument(sourceFile);
+                    Document geronimoDocument = migrationFromJboss2Geronimo(jbossDocument
+                            .getRootElement());
+                    String geronimoDSFileName = directoryName + File.separator + driverType
+                            + Constants.GERONIMO_PLAN_FILE;
+                    // Check whether the file already exists if so
+                    // back up at and save that or check the req
+                    // This was done in upper level of the tool
+                    XMLConversionHelper.saveGeronimoDocument(geronimoDSFileName, geronimoDocument);
+                    migrated = true;
+                    out.info("The Datasource Resource File Migration Complete !!!\n");
+                } catch (DocumentException e) {
+                    out.error("Errors occurs while reading xml descriptor "
+    								+ sourceFile.getAbsolutePath()
+    								+ ". It is possible that the migrator cannot download an xml schema or xml file has a wrong syntax. Nested exception:"
+    								+ e.getMessage());
+                } catch (IOException e) {
+                    out.error("IO exception " + e.getMessage());
+                }
+            }
+        return migrated;
+    }
+
+    /**
+     * Accepts the jboss side Elements that holdes the discripter infomation and
+     * return the geronimo discripter
+     * 
+     * @param jbossRootElement
+     * @return geronimo plan
+     */
+    private Document migrationFromJboss2Geronimo(Element jbossRootElement) {
+        Document geronimo_ds_plan = createNewGeronimoDocument(jbossRootElement);
+        return geronimo_ds_plan;
+    }
+
+    /**
+     * Createt the new geronimo document from the given namesppace and the root
+     * elament with default elements
+     * 
+     * @param namespaceName
+     *            String of the namespace
+     * @param rootName
+     *            String root Element name
+     * @return a new dom4j document for geronimo-ds-plan.xml
+     */
+    public Document createNewGeronimoDocument(Element jbossRootElement) {
+        Namespace connectorNamespace = new Namespace("", Constants.NAMESPACE_CONNECTOR);
+        Namespace environmentNamespace = new Namespace(Constants.ENV_NAMESPACE_PREFIX,
+                Constants.NAMESPACE_ENV);
+
+        Element local_tx_datasurceElement = XMLConversionHelper.obtainSubElement(jbossRootElement,
+                "local-tx-datasource");
+        Element jndi_name = XMLConversionHelper.obtainSubElement(local_tx_datasurceElement,
+                "jndi-name");
+        Element connection_url = XMLConversionHelper.obtainSubElement(local_tx_datasurceElement,
+                "connection-url");
+        Element driver_class = XMLConversionHelper.obtainSubElement(local_tx_datasurceElement,
+                "driver-class");
+        Element user_name = XMLConversionHelper.obtainSubElement(local_tx_datasurceElement,
+                "user-name");
+        Element password = XMLConversionHelper.obtainSubElement(local_tx_datasurceElement,
+                "password");
+        Element dependenciesElement = createDependenciesElement(driver_class.getStringValue(),
+                environmentNamespace);
+        Element connectiondefinition_instanceElement = DocumentHelper.createElement(new QName(
+                "connectiondefinition-instance", connectorNamespace));
+        connectiondefinition_instanceElement.add(XMLConversionHelper.createSibling("name",
+                XMLConversionHelper.obtainNameFromJNDINAME(XMLConversionHelper
+                        .readElementValue(jndi_name)), connectorNamespace));
+        connectiondefinition_instanceElement.add(XMLConversionHelper.createSiblingWithAttrib(
+                "config-property-setting", XMLConversionHelper.readElementValue(user_name), "name",
+                "UserName", connectorNamespace));
+        connectiondefinition_instanceElement.add(XMLConversionHelper.createSiblingWithAttrib(
+                "config-property-setting", XMLConversionHelper.readElementValue(password), "name",
+                "Password", connectorNamespace));
+        connectiondefinition_instanceElement.add(XMLConversionHelper.createSiblingWithAttrib(
+                "config-property-setting", XMLConversionHelper.readElementValue(driver_class),
+                "name", "Driver", connectorNamespace));
+        connectiondefinition_instanceElement.add(XMLConversionHelper.createSiblingWithAttrib(
+                "config-property-setting", XMLConversionHelper.readElementValue(connection_url),
+                "name", "ConnectionURL", connectorNamespace));
+        Element connection_managerElement = null;
+        if (checkForConnectionMangerDetails(local_tx_datasurceElement)) {
+            connection_managerElement = createConnectionManagerElement(local_tx_datasurceElement,
+                    connectorNamespace);
+        } else {
+            connection_managerElement = createDefaultConnectionManagerElement(connectorNamespace);
+        }
+        connectiondefinition_instanceElement.add(connection_managerElement);
+        QName connectorQName = new QName("connector", connectorNamespace);
+        QName environmentQName = new QName("environment", environmentNamespace);
+        Element artifactIdElement = DocumentHelper.createElement((new QName("artifactId",
+                environmentNamespace)));
+        artifactIdElement.addText(XMLConversionHelper.obtainNameFromJNDINAME(XMLConversionHelper
+                .readElementValue(jndi_name)));
+        Element moduleIdElement = DocumentHelper.createElement((new QName("moduleId",
+                environmentNamespace)));
+        moduleIdElement.add(artifactIdElement);
+        Element conenctorElement = DocumentHelper.createElement(connectorQName);
+        dependenciesElement.add(environmentNamespace);
+        Element environmentElement = conenctorElement.addElement(environmentQName);
+        environmentElement.add(moduleIdElement);
+        environmentElement.add(dependenciesElement);
+        QName resourceadapterQName = new QName("resourceadapter", connectorNamespace);
+        Element resourceadapterElement = conenctorElement.addElement(resourceadapterQName);
+        Element outbound_resourceadapterElement = DocumentHelper.createElement(new QName(
+                "outbound-resourceadapter", connectorNamespace));
+        Element connector_definitionElement = DocumentHelper.createElement(new QName(
+                "connection-definition", connectorNamespace));
+        Element connecttionfactory_interfaceElement = DocumentHelper.createElement(new QName(
+                "connectionfactory-interface", connectorNamespace));
+        connecttionfactory_interfaceElement.addText(Constants.CONNECTION_FACTORY_INTERFACE);
+        connector_definitionElement.add(connecttionfactory_interfaceElement);
+        connector_definitionElement.add(connectiondefinition_instanceElement);
+        resourceadapterElement.add(outbound_resourceadapterElement);
+        outbound_resourceadapterElement.add(connector_definitionElement);
+        Document document = DocumentHelper.createDocument();
+        document.add(conenctorElement);
+        out.warn("The JAR holding the " + driver_class.getStringValue()
+                + " JDBC Driver should be installed " + "under <GERONIMO_HOME>/repository/");
+        return document;
+    }
+
+    /**
+     * creates the connection manager element by refereing the jboss side
+     * localtxelement
+     * 
+     * @param local_tx_datasurceElement
+     * @param environmentNamespace
+     * @return the connection manager element for geronimo ds plan
+     */
+    public Element createConnectionManagerElement(Element local_tx_datasurceElement,
+            Namespace environmentNamespace) {
+        Element connectionmanagerElement = DocumentHelper.createElement(new QName(
+                "connectionmanager", environmentNamespace));
+        Element local_transactionElement = DocumentHelper.createElement(new QName(
+                "local-transaction", environmentNamespace));
+        Element single_poolElement = DocumentHelper.createElement(new QName("single-pool",
+                environmentNamespace));
+        Element max_sizeElement = DocumentHelper.createElement(new QName("max-size",
+                environmentNamespace));
+        Element min_sizeElement = DocumentHelper.createElement(new QName("min-size",
+                environmentNamespace));
+        Element blocking_timeout_millisecondsElement = DocumentHelper.createElement(new QName(
+                "blocking-timeout-milliseconds", environmentNamespace));
+        Element idle_timeout_minutesElement = DocumentHelper.createElement(new QName(
+                "idle-timeout-minutes", environmentNamespace));
+        Element match_oneElement = DocumentHelper.createElement(new QName("match-one",
+                environmentNamespace));
+        if (XMLConversionHelper.containSubElement(local_tx_datasurceElement, "max-pool-size")) {
+            Element max_sizeElement_jboss = XMLConversionHelper.obtainSubElement(
+                    local_tx_datasurceElement, "max-pool-size");
+            max_sizeElement.addText(XMLConversionHelper.readElementValue(max_sizeElement_jboss));
+        } else {
+            max_sizeElement.addText("10");
+        }
+        if (XMLConversionHelper.containSubElement(local_tx_datasurceElement, "min-pool-size")) {
+            Element min_sizeElement_jboss = XMLConversionHelper.obtainSubElement(
+                    local_tx_datasurceElement, "min-pool-size");
+            min_sizeElement.addText(XMLConversionHelper.readElementValue(min_sizeElement_jboss));
+        } else {
+            min_sizeElement.addText("0");
+        }
+        if (XMLConversionHelper.containSubElement(local_tx_datasurceElement,
+                "blocking-timeout-milliseconds")) {
+            Element blocking_timeout_millisecondsElement_jboss = XMLConversionHelper
+                    .obtainSubElement(local_tx_datasurceElement, "blocking-timeout-milliseconds");
+            blocking_timeout_millisecondsElement.addText(XMLConversionHelper
+                    .readElementValue(blocking_timeout_millisecondsElement_jboss));
+        } else {
+            blocking_timeout_millisecondsElement.addText("5000");
+        }
+        if (XMLConversionHelper
+                .containSubElement(local_tx_datasurceElement, "idle-timeout-minutes")) {
+            Element idle_timeout_minutesElement_jboss = XMLConversionHelper.obtainSubElement(
+                    local_tx_datasurceElement, "idle-timeout-minutes");
+            idle_timeout_minutesElement.addText(XMLConversionHelper
+                    .readElementValue(idle_timeout_minutesElement_jboss));
+        } else {
+            idle_timeout_minutesElement.addText("30");
+        }
+        single_poolElement.add(max_sizeElement);
+        single_poolElement.add(min_sizeElement);
+        single_poolElement.add(blocking_timeout_millisecondsElement);
+        single_poolElement.add(idle_timeout_minutesElement);
+        single_poolElement.add(match_oneElement);
+        connectionmanagerElement.add(local_transactionElement);
+        connectionmanagerElement.add(single_poolElement);
+        return connectionmanagerElement;
+    }
+
+    /**
+     * create the dependencies element by refering the driver class string
+     * 
+     * @param driver_class
+     * @return dependencies element
+     */
+    private Element createDependenciesElement(String driver_class, Namespace environmentNamespace) {
+        String id_combination = null;
+        String groupId = null;
+        String artifactId = null;
+        logger.debug("The input driver class to the Dependancy element : " + driver_class);
+        HashMap driverMap = XMLConversionHelper.createDriverStoreHashMap();
+        // if the driver is already in the driver map or else
+        if (driverMap.containsKey(driver_class)) {
+            id_combination = (String) driverMap.get(driver_class);
+        } else {
+            id_combination = XMLConversionHelper
+                    .createIdConbinationWhenDriverMapRetrnsEmpty(driver_class);
+        }
+        groupId = id_combination.substring(0, id_combination.indexOf("/"));
+        artifactId = id_combination.substring(id_combination.indexOf("/") + 1, id_combination
+                .length());
+        QName groupIdQName = new QName("groupId", environmentNamespace);
+        Element groupIdElement = DocumentHelper.createElement(groupIdQName);
+        groupIdElement.addText(groupId);
+        QName artifactIdQName = new QName("artifactId", environmentNamespace);
+        Element artifactIdElement = DocumentHelper.createElement(artifactIdQName);
+        artifactIdElement.addText(artifactId);
+        QName typeQName = new QName("type", environmentNamespace);
+        Element typeElement = DocumentHelper.createElement(typeQName);
+        typeElement.addText("jar");
+        QName dependenciesQName = new QName("dependencies", environmentNamespace);
+        Element dependenciesElement = DocumentHelper.createElement(dependenciesQName);
+        QName dependencyQName = new QName("dependency", environmentNamespace);
+        Element dependencyElement = DocumentHelper.createElement(dependencyQName);
+        dependencyElement.add(groupIdElement);
+        dependencyElement.add(artifactIdElement);
+        dependencyElement.add(typeElement);
+        dependenciesElement.add(dependencyElement);
+        return dependenciesElement;
+    }
+
+    /**
+     * creates the default connection manager element
+     * 
+     * @param environmentNamespace
+     * @return the connection manager element
+     */
+    public Element createDefaultConnectionManagerElement(Namespace environmentNamespace) {
+        Element connectionmanagerElement = DocumentHelper.createElement(new QName(
+                "connectionmanager", environmentNamespace));
+        Element local_transactionElement = DocumentHelper.createElement(new QName(
+                "local-transaction", environmentNamespace));
+        Element single_poolElement = DocumentHelper.createElement(new QName("single-pool",
+                environmentNamespace));
+        Element max_sizeElement = DocumentHelper.createElement(new QName("max-size",
+                environmentNamespace));
+        Element min_sizeElement = DocumentHelper.createElement(new QName("min-size",
+                environmentNamespace));
+        Element blocking_timeout_millisecondsElement = DocumentHelper.createElement(new QName(
+                "blocking-timeout-milliseconds", environmentNamespace));
+        Element idle_timeout_minutesElement = DocumentHelper.createElement(new QName(
+                "idle-timeout-minutes", environmentNamespace));
+        Element match_oneElement = DocumentHelper.createElement(new QName("match-one",
+                environmentNamespace));
+        max_sizeElement.addText("10");
+        min_sizeElement.addText("0");
+        blocking_timeout_millisecondsElement.addText("5000");
+        idle_timeout_minutesElement.addText("30");
+        single_poolElement.add(max_sizeElement);
+        single_poolElement.add(min_sizeElement);
+        single_poolElement.add(blocking_timeout_millisecondsElement);
+        single_poolElement.add(idle_timeout_minutesElement);
+        single_poolElement.add(match_oneElement);
+        connectionmanagerElement.add(local_transactionElement);
+        connectionmanagerElement.add(single_poolElement);
+        return connectionmanagerElement;
+    }
+
+    /**
+     * retuns true if any of the elements were found on JBoss side
+     * 
+     * @param local_tx_datasurceElement
+     * @return status
+     */
+    private boolean checkForConnectionMangerDetails(Element local_tx_datasurceElement) {
+        if (XMLConversionHelper.containSubElement(local_tx_datasurceElement, "min-pool-size")
+                || XMLConversionHelper
+                        .containSubElement(local_tx_datasurceElement, "max-pool-size")
+                || XMLConversionHelper.containSubElement(local_tx_datasurceElement,
+                        "idle-timeout-minutes")
+                || XMLConversionHelper.containSubElement(local_tx_datasurceElement,
+                        "blocking-timeout-milliseconds")) {
+            return true;
+        }
+        return false;
+    }
+
+}
\ No newline at end of file



Mime
View raw message