geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmcma...@apache.org
Subject svn commit: r520023 [3/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
Propchange: geronimo/sandbox/j2g/src/descriptors-tool/plugin.xml
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Added: geronimo/sandbox/j2g/src/descriptors-tool/schema/tool.migrations.exsd
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/descriptors-tool/schema/tool.migrations.exsd?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/descriptors-tool/schema/tool.migrations.exsd (added)
+++ geronimo/sandbox/j2g/src/descriptors-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.descriptors">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="com.ibm.j2g.descriptors" id="com.ibm.j2g.descriptors.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.descriptors.tool.migrations&quot;&gt;
+      &lt;migration class=&quot;com.ibm.j2g.descriptors.web.WebDescriptorFileMigration&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/descriptors-tool/src/org/apache/apps/j2gmigrator/descriptors/DescriptorsTool.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/descriptors-tool/src/org/apache/apps/j2gmigrator/descriptors/DescriptorsTool.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/descriptors-tool/src/org/apache/apps/j2gmigrator/descriptors/DescriptorsTool.java (added)
+++ geronimo/sandbox/j2g/src/descriptors-tool/src/org/apache/apps/j2gmigrator/descriptors/DescriptorsTool.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,56 @@
+/**
+ *  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.descriptors;
+
+import org.apache.apps.j2gmigrator.XMLMigrationTool;
+
+/**
+ * Descriptors migration tool.
+ * 
+ * @author Ivan S. Dubrov
+ */
+public class DescriptorsTool extends XMLMigrationTool {
+
+	/** Plug-in id */
+	public final static String PLUGIN_ID = "com.ibm.j2g.descriptors";
+
+	/** 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 "jdesc2g.cmd";
+	}
+
+}

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

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

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

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

Added: geronimo/sandbox/j2g/src/ejb-environment-plugin/build.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/ejb-environment-plugin/build.properties?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/ejb-environment-plugin/build.properties (added)
+++ geronimo/sandbox/j2g/src/ejb-environment-plugin/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.
+ */
+ source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml
+additional.bundles = com.ibm.j2g

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/build.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/build.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/build.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src/ejb-environment-plugin/plugin.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/ejb-environment-plugin/plugin.xml?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/ejb-environment-plugin/plugin.xml (added)
+++ geronimo/sandbox/j2g/src/ejb-environment-plugin/plugin.xml Mon Mar 19 10:43:27 2007
@@ -0,0 +1,25 @@
+/**
+ *  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.sources.migrations">
+      <migration class="com.ibm.j2g.sources.env.EjbEnvJavaMigration"/>
+   </extension>
+
+</plugin>

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/plugin.xml
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Added: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/AbsoluteNameSolver.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/AbsoluteNameSolver.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/AbsoluteNameSolver.java (added)
+++ geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/AbsoluteNameSolver.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,467 @@
+/**
+ *  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.env;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.apps.j2gmigrator.IOutput;
+import org.apache.apps.j2gmigrator.Tool;
+import org.apache.apps.j2gmigrator.sources.env.NameSolvingException;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.Element;
+import org.dom4j.Node;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.SAXReader;
+import org.dom4j.io.XMLWriter;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.ITypeBinding;
+import org.eclipse.jdt.core.dom.Type;
+
+
+/**
+ * Provides a mechanism to solve absolute JNDI name used in javax.naming.lookup
+ * method.
+ * 
+ * @author Volkov, Stepan S.
+ */
+public class AbsoluteNameSolver {
+	/** Static couner for generating valid ejb names. */
+	private static int counter = 0;
+
+	/** Property file with EJB interfaces */
+	public final static String INTEFACES_PROP = "beans-interfaces.properties";
+
+	/** Property file with paths for searching types in jboss.xml */
+	public final static String BEANS_TYPES_PROP = "beans-types.properties";
+
+	/**
+	 * Property file with paths for searching home and remote interfaces in
+	 * ejb-jar.xml
+	 */
+	public final static String BEANS_REFS_PROP = "beans-references.properties";
+
+	/** References in ejb-jar.xml to be found */
+	private final static String[] EJB_REFS = { "ejb-ref", "ejb-local-ref",
+			"resource-ref", "resource-env-ref" };
+
+	/** Separator string for XPath */
+	private final static String XPATH_SEPARATOR = "/";
+
+	/** Separator string for XPath for access elements by non-full names. */
+	private final static String DOUBLE_XPATH_SEPARATOR = "//";
+
+	/** Ejb classname element int ejb-jar.xml */
+	private final static String EJB_CLASS_ELM = "ejb-class";
+
+	/** Ejb name element. */
+	private final static String EJB_NAME_ELM = "ejb-name";
+
+	/** Ejb reference element for add references to ejb-jar.xml */
+	private final static String EJB_REF_ELM = "ejb-ref";
+
+	/** Ejb reference element for add references to ejb-jar.xml */
+	private final static String EJB_LOCAL_REF_ELM = "ejb-local-ref";
+
+	/** Ejb reference JNDI name element. */
+	private final static String EJB_REF_NAME_ELM = "ejb-ref-name";
+
+	/** Ejb reference type element. (Session | Entity) */
+	private final static String EJB_REF_TYPE_ELM = "ejb-ref-type";
+
+	/** Ejb link element. */
+	private final static String EJB_LINK_ELM = "ejb-link";
+
+	/** Base name for generating full ejb reference name. */
+	private final static String BASE_JNDI_NAME = "ejb/";
+
+	/** Session reference type */
+	private final static String SESSION_TYPE = "Session";
+
+	/** Entity reference type */
+	private final static String ENTITY_TYPE = "Entity";
+
+	/** Property file with EJB interfaces */
+	public static Properties interfaces;
+
+	/** Property file with paths for searching types in jboss.xml */
+	private static Properties beansTypes;
+
+	/**
+	 * Property file with paths for searching home and remote interfaces in
+	 * ejb-jar.xml
+	 */
+	private static Properties beansRefs;
+
+	/** Home interface suffix */
+	private final static String HOME_INTERFACE_SUFFIX = "-home";
+
+	/** XPath to session elements. */
+	private final static String SESSION_XPATH = "/ejb-jar/enterprise-beans/session/";
+
+	/** XPath to entity elements */
+	private final static String ENTITY_XPATH = "/ejb-jar/enterprise-beans/entity/";
+
+	/** Full qualified classname for current class */
+	private String qualifiedClassName;
+
+	/** Superinterfaces for current class. */
+	private List superInterfaces;
+
+	/** Output */
+	private IOutput out;
+
+	/** Current compilation unit */
+	private CompilationUnit unit;
+
+	/** SAX reader */
+	private SAXReader xmlReader;
+
+	/** XPath path for class */
+	private String pathForClass;
+
+	/**
+	 * Constructor.
+	 * 
+	 * @param qualifiedClassName
+	 *            full qualified class name which defined in compilation unit.
+	 * @param unit
+	 *            compilation unit.
+	 * @param superIterfaces
+	 *            super interfaces implemented by class which defined in
+	 *            compilation unit.
+	 * @throws NameSolvingException
+	 */
+	public AbsoluteNameSolver(String qualifiedClassName, List superIterfaces,
+			CompilationUnit unit) throws NameSolvingException {
+		this.out = Tool.getCurrent().getOutput();
+		this.qualifiedClassName = qualifiedClassName;
+		this.superInterfaces = superIterfaces;
+		this.unit = unit;
+		pathForClass = getPathForClass();
+		xmlReader = new SAXReader(true);
+	}
+
+	/**
+	 * Tries to find already existing references to current class. If none
+	 * found, tries to resolve type of the current ejb and to add ejb reference
+	 * for current absolute name.
+	 * 
+	 * @param absoluteName
+	 *            absolute name which should be solved.
+	 * @param position
+	 *            position in compilation unit.
+	 * @param ejbJar
+	 *            existed ejb-jar.xml descriptor. (META-INF/ejb-jar.xml)
+	 * @param jbossXml
+	 *            existed jboss.xml descriptor. (META-INf/jboss.xml)
+	 * @return JNDI name in local context which was referenced in ejb-jar
+	 *         descriptor.
+	 * @throws NameSolvingException
+	 *             if any errors occurs while solving absolute names.
+	 */
+	public String solveName(String absoluteName, int position, File ejbJar,
+			File jbossXml) throws NameSolvingException {
+		loadProperties();
+		if (pathForClass != null) {
+			Document ejbJarDoc = null;
+			try {
+				ejbJarDoc = xmlReader.read(ejbJar);
+			} catch (DocumentException ex) {
+				throw new NameSolvingException(
+						"Errors occurs while reading xml descriptor "
+								+ jbossXml.getAbsolutePath()
+								+ ". It is possible that the migrator cannot download an xml schema or xml file has a wrong syntax. Nested exception:"
+								+ ex.getMessage());
+			}
+
+			List nodes = ejbJarDoc.selectNodes(pathForClass + XPATH_SEPARATOR
+					+ EJB_CLASS_ELM);
+			Iterator nodesIter = nodes.iterator();
+			Node ejbJarNode = null;
+			while (nodesIter.hasNext()) {
+				Node node = (Node) nodesIter.next();
+				if (qualifiedClassName.equals(node.getStringValue().trim())) {
+					ejbJarNode = node.getParent();
+					for (int i = 0; i < EJB_REFS.length; i++) {
+						List refsNodes = ejbJarNode
+								.selectNodes(DOUBLE_XPATH_SEPARATOR
+										+ EJB_REFS[i]);
+						if (!refsNodes.isEmpty()) {
+							Iterator references = refsNodes.iterator();
+
+							while (references.hasNext()) {
+								Node referenceNode = (Node) references.next();
+								String refName = getNodeValueByName(
+										referenceNode, EJB_REF_NAME_ELM);
+								if (refName != null
+										&& absoluteName.equals(refName.trim())) {
+									out
+											.warn(
+													"Cannot add reference to the abolute name '"
+															+ absoluteName
+															+ "' because the reference in ejb-jar.xml descriptor to current class already defined.",
+													unit
+															.getLineNumber(position),
+													unit
+															.getColumnNumber(position));
+									return null;
+								}
+							}
+						}
+					}
+					break;
+				}
+			}
+			if (ejbJarNode != null) {
+				Document jbossXmlDoc = null;
+				try {
+					jbossXmlDoc = xmlReader.read(jbossXml);
+				} catch (DocumentException ex) {
+					throw new NameSolvingException(
+							"Errors occurs while reading xml descriptor "
+									+ jbossXml.getAbsolutePath()
+									+ ". It is possible that the migrator cannot download an xml schema or xml file has a wrong syntax. Nested exception:"
+									+ ex.getMessage());
+				}
+				Enumeration paths = beansTypes.keys();
+				while (paths.hasMoreElements()) {
+					String path = (String) paths.nextElement();
+					List findedNodes = jbossXmlDoc.selectNodes(path);
+					Iterator findedNodesIter = findedNodes.iterator();
+					while (findedNodesIter.hasNext()) {
+						Node jbossXmlNode = (Node) findedNodesIter.next();
+						if (absoluteName.equals(jbossXmlNode.getStringValue()
+								.trim())) {
+							String type = beansTypes.getProperty(path);
+							String ejbName = getNodeValueByName(
+									jbossXmlNode.getParent(), EJB_NAME_ELM)
+									.trim();
+							Node referenceNode = null;
+							String ejbRefType = null;
+							List sessionNodes = ejbJarDoc
+									.selectNodes(SESSION_XPATH + EJB_NAME_ELM);
+							Iterator sessionNodesIter = sessionNodes.iterator();
+							while (sessionNodesIter.hasNext()) {
+								Node ejbNameNode = (Node) sessionNodesIter
+										.next();
+								if (ejbName
+										.equals(ejbNameNode.getStringValue())) {
+									referenceNode = ejbNameNode.getParent();
+									ejbRefType = SESSION_TYPE;
+									break;
+								}
+							}
+							if (ejbRefType == null) {
+								List entityNodes = ejbJarDoc
+										.selectNodes(ENTITY_XPATH
+												+ EJB_NAME_ELM);
+								Iterator entityNodesIter = entityNodes
+										.iterator();
+								while (entityNodesIter.hasNext()) {
+									Node ejbNameNode = (Node) entityNodesIter
+											.next();
+									if (ejbName.equals(ejbNameNode
+											.getStringValue())) {
+										referenceNode = ejbNameNode.getParent();
+										ejbRefType = ENTITY_TYPE;
+										break;
+									}
+								}
+							}
+							if (referenceNode != null) {
+								String homeIterfacePath = beansRefs
+										.getProperty(type
+												+ HOME_INTERFACE_SUFFIX);
+								String homeIterface = getNodeValueByName(
+										referenceNode, homeIterfacePath);
+								String objectIterfacePath = beansRefs
+										.getProperty(type);
+								String objectIterface = getNodeValueByName(
+										referenceNode, objectIterfacePath);
+								Element ejbJarElement = (Element) ejbJarNode;
+								Element ejbRef = null;
+								if (objectIterfacePath.equals("remote")) {
+									ejbRef = ejbJarElement
+											.addElement(EJB_REF_ELM);
+								} else {
+									ejbRef = ejbJarElement
+											.addElement(EJB_LOCAL_REF_ELM);
+								}
+
+								String refName = generateNewRefName();
+								ejbRef.addElement(EJB_REF_NAME_ELM).addText(
+										refName);
+								ejbRef.addElement(EJB_REF_TYPE_ELM).addText(
+										ejbRefType);
+								ejbRef.addElement(homeIterfacePath).addText(
+										homeIterface);
+								ejbRef.addElement(objectIterfacePath).addText(
+										objectIterface);
+								ejbRef.addElement(EJB_LINK_ELM)
+										.addText(ejbName);
+								serializetoXML(ejbJar, ejbJarDoc);
+								return refName;
+							} else {
+								out
+										.error("Cannot find EJB definition in ejb-jar.xml for create reference to it.");
+							}
+						}
+					}
+				}
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * Generates new names for ejb references. It looks like
+	 * 'ejb/SimpleClassName_x'
+	 * 
+	 * @return new generated reference name.
+	 */
+	private String generateNewRefName() {
+		String simpleClassName = qualifiedClassName
+				.substring(qualifiedClassName.lastIndexOf(".") + 1);
+		return BASE_JNDI_NAME + simpleClassName + "_" + (counter++);
+	}
+
+	/**
+	 * Saves document to file.
+	 * 
+	 * @param xmlFile
+	 *            destination file.
+	 * @param doc
+	 *            xml document.
+	 * @throws NameSolvingException
+	 *             if cannot save document.
+	 */
+	private void serializetoXML(File xmlFile, Document doc)
+			throws NameSolvingException {
+		try {
+			OutputStream output = new FileOutputStream(xmlFile);
+			OutputFormat outformat = OutputFormat.createPrettyPrint();
+			XMLWriter writer = new XMLWriter(output, outformat);
+			writer.write(doc);
+			writer.flush();
+		} catch (Exception ex) {
+			throw new NameSolvingException(
+					"Error occurs while xml descriptors saving.", ex);
+		}
+	}
+
+	/**
+	 * Gets string value of element in node by it name.
+	 * 
+	 * @param parent
+	 *            parent node.
+	 * @param name
+	 *            element name.
+	 * @return string value of element in node.
+	 */
+	private String getNodeValueByName(Node parent, String name) {
+		Node node = parent.selectSingleNode(name);
+		if (node != null) {
+			return node.getStringValue();
+		}
+		return null;
+	}
+
+	/**
+	 * Gets XPath where need to search already defined references for current
+	 * class defined in current compilation unit and determines type of
+	 * reference required for current class.
+	 * 
+	 * @return XPath in ejb-jar.xml descriptor.
+	 * @throws NameSolvingException
+	 *             if cannot load properties files.
+	 */
+	private String getPathForClass() throws NameSolvingException {
+		loadProperties();
+		Enumeration enumeration = interfaces.keys();
+		while (enumeration.hasMoreElements()) {
+			String ejbInterface = (String) enumeration.nextElement();
+			Iterator types = superInterfaces.iterator();
+			while (types.hasNext()) {
+				Type superType = (Type) types.next();
+				ITypeBinding bind = superType.resolveBinding();
+				if (bind != null
+						&& bind.getQualifiedName().equals(ejbInterface)) {
+					String path = interfaces.getProperty(ejbInterface);
+					return path;
+				}
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * @return true if class is an EJB bean.
+	 */
+	public boolean isEjbBeanClass() {
+		return (pathForClass != null);
+	}
+
+	/**
+	 * Loads all necessary properties files.
+	 * 
+	 * @throws NameSolvingException
+	 *             if cannot load one or more properts files.
+	 */
+	private void loadProperties() throws NameSolvingException {
+		if (interfaces == null) {
+			interfaces = new Properties();
+			try {
+				interfaces.load(getClass().getResourceAsStream(INTEFACES_PROP));
+			} catch (IOException ex) {
+				throw new NameSolvingException(
+						"Cannot read system property file: " + INTEFACES_PROP,
+						ex);
+			}
+		}
+
+		if (beansTypes == null) {
+			beansTypes = new Properties();
+			try {
+				beansTypes.load(getClass()
+						.getResourceAsStream(BEANS_TYPES_PROP));
+			} catch (IOException ex) {
+				throw new NameSolvingException(
+						"Cannot read system property file: " + BEANS_TYPES_PROP,
+						ex);
+			}
+		}
+
+		if (beansRefs == null) {
+			beansRefs = new Properties();
+			try {
+				beansRefs.load(getClass().getResourceAsStream(BEANS_REFS_PROP));
+			} catch (IOException ex) {
+				throw new NameSolvingException(
+						"Cannot read system property file: " + BEANS_REFS_PROP,
+						ex);
+			}
+		}
+	}
+}

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/AbsoluteNameSolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/AbsoluteNameSolver.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/AbsoluteNameSolver.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/BlockVisitor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/BlockVisitor.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/BlockVisitor.java (added)
+++ geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/BlockVisitor.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,466 @@
+/**
+ *  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.env;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.apps.j2gmigrator.FatalToolException;
+import org.apache.apps.j2gmigrator.IOutput;
+import org.apache.apps.j2gmigrator.Tool;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.dom.ASTVisitor;
+import org.eclipse.jdt.core.dom.Assignment;
+import org.eclipse.jdt.core.dom.CastExpression;
+import org.eclipse.jdt.core.dom.ClassInstanceCreation;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.Expression;
+import org.eclipse.jdt.core.dom.ITypeBinding;
+import org.eclipse.jdt.core.dom.MethodInvocation;
+import org.eclipse.jdt.core.dom.SimpleName;
+import org.eclipse.jdt.core.dom.StringLiteral;
+import org.eclipse.jdt.core.dom.Type;
+import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
+
+
+/**
+ * The algorithm of work as follows: <br>
+ * 1. Searches invocations of the <code>javax.naming.Context#lookup</code> method; <br>
+ * 
+ * 2. If the lookup meets the following conditions: <br>
+ * a) It is performed from an EJB;<br>
+ * b) JNDI name is a string constant;<br>
+ * c) JNDI name is a path in the EJB environment (starts with "java:comp/env" or equals to
+ * "java:comp/UserTransaction", "java:comp/ORB" );<br>
+ * then the plug-in considers this lookup as correct. <br>
+ * 
+ * 3. If the lookup meets the following conditions: <br>
+ * a) It is performed from an EJB;<br>
+ * b) JNDI name is a string constant;<br>
+ * c) JNDI name is a full direct path;<br>
+ * d) EJB does not have any environment references; <br>
+ * then the plug-in should add the resource reference in the EJB component's deployment descriptor
+ * and replace the use of a direct name with this name from the component's environment.<br>
+ * 
+ * 4. Otherwise the plug-in outputs a warning message that the lookup might be incorrect.
+ * 
+ * @author Volkov, Stepan S.
+ */
+public class BlockVisitor extends ASTVisitor {
+
+	/** Lookup method simple name. */
+	private final static String LOOKUP_METHOD_NAME = "lookup";
+
+	/** Full qualified name for Context interface. */
+	private final static String CONTEXT_INTERFACE_NAME = "javax.naming.Context";
+
+	/** Full qualified name for InitialContext class. */
+	private final static String INIT_CONTEXT_CLASSNAME = "javax.naming.InitialContext";
+
+	/** Initial context. */
+	private final static String INITIAL_CONTEXT = "";
+
+	/** Compilation unit. */
+	private CompilationUnit unit;
+
+	/** Tool output. */
+	private IOutput out;
+
+	/** HashMap for the context variables. */
+	private HashMap varsMap;
+
+	/** Solver for absolute JNDI names used in lookup methods. */
+	private AbsoluteNameSolver solver;
+
+	/** Allowed objects for JNDI lookup. */
+	private final static String[] ALLOWED_OBJECTS = { "java:comp/UserTransaction", "java:comp/ORB" };
+
+	/** Local context. */
+	private final static String LOCAL_CONTEXT = "java:comp/env/";
+
+	/** Meta-inf directory default name. */
+	public final static String META_INF_DIR = "META-INF";
+
+	/** EJB deployment descriptor default filename. */
+	public final static String EJB_JAR_FILE = "ejb-jar.xml";
+
+	/** JBoss descriptor default filename. */
+	public final static String JBOSS_XML_FILE = "jboss.xml";
+
+	/** Last catched string literal for lookup method. */
+	private StringLiteral lastStrLiteral;
+
+	/**
+	 * Visitor constructor. Setups compilation unit and output.
+	 * @param unit current compilation unit.
+	 * @param solver initialized absolute names solver for visiting class.
+	 */
+	public BlockVisitor(CompilationUnit unit, AbsoluteNameSolver solver) {
+		super(false);
+		this.unit = unit;
+		this.solver = solver;
+		varsMap = new HashMap();
+		out = Tool.getCurrent().getOutput();
+	}
+
+	/**
+	 * Checks method and if it is a javax.naming.Context#lookup resolves and analizes context.
+	 * @param methodInvocation method invocation.
+	 */
+	public boolean visit(MethodInvocation methodInvocation) {
+		int position = methodInvocation.getStartPosition();
+		if (isLookupMethodInvocation(methodInvocation)) {
+			String jndiName = getLookupArgument(methodInvocation);
+			try {
+				analizeLookupJNDIName(jndiName, position);
+			} catch (FatalToolException ex) {
+				out.error("Cannot check correctness of lookup method using: " + ex.getMessage(), unit.getLineNumber(position), unit.getColumnNumber(position));
+			}
+		}
+		return true;
+	}
+
+	/**
+	 * If it's an assign for a variable which type is javax.naming.Context then analizes correctness
+	 * of initializer and puts variable assignment to the varsMap.
+	 * @param assignment assignment.
+	 */
+	public boolean visit(Assignment assignment) {
+		Expression leftSide = assignment.getLeftHandSide();
+		if (leftSide instanceof SimpleName) {
+			SimpleName varName = (SimpleName) leftSide;
+			if (isValidType(varName)) {
+				Expression rightSide = assignment.getRightHandSide();
+				ASTNode parent = getParentBlock(assignment);
+				int exprEnd = parent.getStartPosition() + parent.getLength();
+				if (isValidContextInitializer(rightSide)) {
+					String key = varName.getIdentifier();
+					VarContext var = new VarContext(INITIAL_CONTEXT, exprEnd, true);
+					varsMap.put(key, var);
+					return false;
+				}
+				else {
+					String cast = checkCastToContext(rightSide);
+					if (cast != null) {
+						String key = varName.getIdentifier();
+						VarContext var = new VarContext(cast, exprEnd, true);
+						varsMap.put(key, var);
+						return false;
+					}
+					else {
+						String key = varName.getIdentifier();
+						VarContext var = new VarContext(INITIAL_CONTEXT, exprEnd, false);
+						varsMap.put(key, var);
+						return true;
+					}
+				}
+			}
+		}
+		return true;
+	}
+
+	/**
+	 * If it's the declaration of the variable which type is javax.naming.Context and initializer
+	 * not null then analizes it correctness and puts variable assignment to the varsMap.
+	 * @param fragment variable declaration fragment.
+	 */
+	public boolean visit(VariableDeclarationFragment fragment) {
+		Expression initializer = fragment.getInitializer();
+		if (initializer != null) {
+			SimpleName varName = fragment.getName();
+			if (isValidType(varName)) {
+				ASTNode parent = getParentBlock(fragment);
+				int exprEnd = parent.getStartPosition() + parent.getLength();
+				if (isValidContextInitializer(initializer)) {
+					String key = varName.getIdentifier();
+					VarContext var = new VarContext(INITIAL_CONTEXT, exprEnd, true);
+					varsMap.put(key, var);
+					return false;
+				}
+				else {
+					String cast = checkCastToContext(fragment.getInitializer());
+					if (cast != null) {
+						String key = varName.getIdentifier();
+						VarContext var = new VarContext(cast, exprEnd, true);
+						varsMap.put(key, var);
+						return false;
+					}
+					else {
+						String key = varName.getIdentifier();
+						VarContext var = new VarContext(INITIAL_CONTEXT, exprEnd, false);
+						varsMap.put(key, var);
+						return true;
+					}
+				}
+			}
+			else {
+				return true;
+			}
+		}
+		return false;
+	}
+
+	/**
+	 * Checks that expression is a creation of <code>InitailContext</code> class instance without
+	 * parameters.
+	 * @param expr initializer expression.
+	 * @return true if expr looks like this <code>new InitialContext()</code>.
+	 */
+	private boolean isValidContextInitializer(Expression expr) {
+		if (expr instanceof ClassInstanceCreation) {
+			ClassInstanceCreation instanceCreation = (ClassInstanceCreation) expr;
+			Type type = instanceCreation.getType();
+			ITypeBinding typeBind = type.resolveBinding();
+			if (typeBind.getQualifiedName().equals(INIT_CONTEXT_CLASSNAME)) {
+				if (instanceCreation.arguments().isEmpty()) {
+					return true;
+				}
+			}
+		}
+		return false;
+	}
+
+	/**
+	 * Checks that expression has <code>javax.naming.Context</code> type or its type implements
+	 * that interface.
+	 * 
+	 * @param expr expression which will be checked.
+	 * @return true if expression has <code>javax.naming.Context</code> type or its type
+	 *         implements that interface.
+	 */
+	private boolean isValidType(Expression expr) {
+		ITypeBinding bind = expr.resolveTypeBinding();
+		if (bind != null) {
+			if (bind.getQualifiedName().equals(CONTEXT_INTERFACE_NAME)) {
+				return true;
+			}
+			else {
+				ITypeBinding[] interfaces = bind.getInterfaces();
+				for (int i = 0; i < interfaces.length; i++) {
+					if (interfaces[i].getQualifiedName().equals(CONTEXT_INTERFACE_NAME)) {
+						return true;
+					}
+				}
+			}
+		}
+		return false;
+	}
+
+	/**
+	 * Checks that expression is cast object returned by <code>javax.naming.Context#lookup</code>
+	 * method to the <code>javax.naming.Context</code> type.
+	 * 
+	 * @param expr expression which will be checked.
+	 * @return JNDI name for Context presented by cast or <code>null</code> if it cannot be
+	 *         unambiguously resolved or if expression is invalid.
+	 */
+	private String checkCastToContext(Expression expr) {
+		if (expr != null && isValidType(expr)) {
+			if (expr instanceof CastExpression) {
+				CastExpression castExpr = (CastExpression) expr;
+				Expression castArg = castExpr.getExpression();
+				if (castArg instanceof MethodInvocation) {
+					MethodInvocation invocation = (MethodInvocation) castArg;
+					if (isLookupMethodInvocation(invocation)) {
+						String name = getLookupArgument(invocation);
+						return name;
+					}
+					else {
+						return null;
+					}
+
+				}
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * Checks a javax.naming.Context#lookup method invocation and tries to resolve context.
+	 * @param invocation lookup method invocation node.
+	 * @return JNDI name for object returned by lookup method or <code>null</code> if it cannot be
+	 *         unambiguously resolved or it is not lookup method.
+	 */
+	private String getLookupArgument(MethodInvocation invocation) {
+		Expression expr = invocation.getExpression();
+		String history = getExpressionHistory(expr);
+		if (history != null) {
+			List arguments = invocation.arguments();
+			if (arguments.size() != 0) {
+				Expression arg = (Expression) arguments.get(0);
+				if (arg instanceof StringLiteral) {
+					StringLiteral literal = (StringLiteral) arg;
+					String resultContext = history + literal.getLiteralValue();
+					this.lastStrLiteral = literal;
+					return resultContext;
+				}
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * Checks is it lookup method or not.
+	 * @param invocation method invocation node.
+	 * @return <code>true</code> if it is a javax.naming.Context#lookup and <code>false</code>
+	 *         in another cases.
+	 */
+	private boolean isLookupMethodInvocation(MethodInvocation invocation) {
+		if (invocation.getName().getIdentifier().equals(LOOKUP_METHOD_NAME)) {
+			Expression expr = invocation.getExpression();
+			if (isValidType(expr)) {
+				return true;
+			}
+		}
+		return false;
+	}
+
+	/**
+	 * If expr is a variable then gets variable context from varsMap and returns its value if it's
+	 * correct.
+	 * @param expr which type is a <code>javax.naming.Context</code>.
+	 * @return JNDI name presented by this expression or <code>null</code> if it cannot be
+	 *         unambiguously resolved
+	 */
+	private String getExpressionHistory(Expression expr) {
+		if (expr instanceof SimpleName) {
+			SimpleName name = (SimpleName) expr;
+			String varName = name.getIdentifier();
+			VarContext var = (VarContext) varsMap.get(varName);
+			if (var != null && var.isValid() && var.getAreaEnd() > name.getStartPosition()) {
+				return var.getJNDIName();
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * Gets parent node for a variable declaration fragment.
+	 * @param fragment
+	 * @return parent block for the specified <code>VariableDeclarationFragment</code>.
+	 */
+	private ASTNode getParentBlock(VariableDeclarationFragment fragment) {
+		return fragment.getParent().getParent().getParent();
+	}
+
+	/**
+	 * Gets parent node for an assignment.
+	 * @param assignment
+	 * @return parent block for the specified <code>Assignment</code>.
+	 */
+	private ASTNode getParentBlock(Assignment assignment) {
+		return assignment.getParent().getParent();
+	}
+
+	/**
+	 * Checks the correctness of the JNDI name.
+	 * @param name JNDI name.
+	 * @param position position in the source file.
+	 * @throws FatalToolException if any exceptions occurs while checks JNDI name.
+	 */
+	private void analizeLookupJNDIName(String name, int position) throws FatalToolException {
+		if (name != null) {
+			if (!isValidJNDIName(name)) {
+				String literalValue = lastStrLiteral.getLiteralValue();
+				if (literalValue.equals(name)) {
+					String solvedName = solveAbsoluteName(name, position);
+					if (solvedName != null) {
+						String localJNDIName = LOCAL_CONTEXT + solvedName;
+						out.info("The reference to current EJB was added to " + EJB_JAR_FILE + " deployment descriptor. Using of direct name '" + name + "' was replaced by '" + localJNDIName + "' local name.", unit.getLineNumber(position), unit.getColumnNumber(position));
+						lastStrLiteral.setLiteralValue(localJNDIName);
+						return;
+					} 
+					else {
+						out.warn("Using of an absolute JNDI name might be incorrect.", unit.getLineNumber(position), unit.getColumnNumber(position));
+						return;
+					}
+				}
+			} else{
+				return;
+			}
+			
+		} 
+		out.warn("Lookup using might be incorrect.", unit.getLineNumber(position), unit.getColumnNumber(position));
+	}
+
+	/**
+	 * Tries to find META-INF/ejb-jar.xml and META-INF/jboss.xml descriptors and if its exests tries
+	 * to add references for JNDI name to its.
+	 * @param absoluteName absolute JNDI name.
+	 * @param position position in the source file.
+	 * @return JNDI name in local context or null if cannot unambiguously solve references.
+	 * @throws FatalToolException if any errors occurs while solving name.
+	 */
+	private String solveAbsoluteName(String absoluteName, int position) throws FatalToolException {
+		if (solver.isEjbBeanClass()) {
+			try {
+				String pack = unit.getPackage().getName().getFullyQualifiedName().replace('.', File.separatorChar);
+				String unitFile = unit.getJavaElement().getUnderlyingResource().getRawLocation().toFile().getAbsolutePath();
+				String rootDir = unitFile.substring(0, unitFile.lastIndexOf(pack));
+				File metaInfDir = new File(rootDir + META_INF_DIR);
+				if (metaInfDir.exists() && metaInfDir.isDirectory()) {
+					File ejbJar = new File(metaInfDir, EJB_JAR_FILE);
+					File jbossXml = new File(metaInfDir, JBOSS_XML_FILE);
+					if (ejbJar.exists()) {
+						if (jbossXml.exists()) {
+							String solvedName = solver.solveName(absoluteName, position, ejbJar, jbossXml);
+							return solvedName;
+						}
+						else {
+							out.error("Cannot add reference for absolute name '" + absoluteName + "' : cannot find " + jbossXml.getAbsolutePath() + " file.", unit.getLineNumber(position), unit.getColumnNumber(position));
+						}
+					}
+					else {
+						out.error("Cannot add reference for absolute name '" + absoluteName + "' : cannot find " + ejbJar.getAbsolutePath() + " file.", unit.getLineNumber(position), unit.getColumnNumber(position));
+					}
+
+				}
+				else {
+					out.error("Cannot add reference for absolute name '" + absoluteName + "' : cannot find " + metaInfDir.getAbsolutePath() + " directory.", unit.getLineNumber(position), unit.getColumnNumber(position));
+					return null;
+				}
+
+			} catch (JavaModelException ex) {
+				throw new FatalToolException("Cannot access to source file.", ex);
+			} catch (NameSolvingException ex) {
+				out.error("Cannot add reference for absolute name '" + absoluteName + "' :" + ex.getMessage());
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * Checks correctness of constant JNDI name.
+	 * @param name JNDI name.
+	 * @return true if it's correct JNDI name (Starts with 'java:comp/env/' or equals to allowed
+	 *         strings).
+	 */
+	private boolean isValidJNDIName(String name) {
+		if (name.startsWith(LOCAL_CONTEXT)) {
+			return true;
+		}
+		for (int i = 0; i < ALLOWED_OBJECTS.length; i++) {
+			if (ALLOWED_OBJECTS[i].equals(name)) {
+				return true;
+			}
+		}
+		return false;
+	}
+}

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/BlockVisitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/BlockVisitor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/BlockVisitor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/EjbEnvJavaMigration.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/EjbEnvJavaMigration.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/EjbEnvJavaMigration.java (added)
+++ geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/EjbEnvJavaMigration.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.env;
+
+import org.apache.apps.j2gmigrator.IJavaMigration;
+import org.apache.apps.j2gmigrator.IOutput;
+import org.apache.apps.j2gmigrator.Tool;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+
+
+/**
+ * @see IJavaMigration
+ * @author Volkov, Stepan S.
+ */
+public class EjbEnvJavaMigration implements IJavaMigration {
+	/**
+	 * Plug-in name.
+	 */
+	private final static String PLUGIN_NAME = "EJB environment plug-in";
+
+	/**
+	 * Tool output.
+	 */
+	private IOutput out;
+
+	/**
+	 * Finds access of a component to the named object in the source code outside of its own
+	 * environment and tries to ascertain is it correct or not.
+	 * @param source compilation unit for migration.
+	 * @throws JavaModelException
+	 */
+	public boolean migrate(ASTNode source) {
+		out = Tool.getCurrent().getOutput();
+		if (source instanceof CompilationUnit) {
+			CompilationUnit unit = (CompilationUnit) source;
+			out.info("[" + PLUGIN_NAME + "] " + "Migration started: " + unit.getJavaElement().getElementName());
+			long initialChanges = unit.getAST().modificationCount();
+			MethodsVisitor methodsVisitor = new MethodsVisitor(unit);
+			unit.accept(methodsVisitor);
+			//methodsVisitor.visit(unit); 
+			long finalChanges = unit.getAST().modificationCount();
+			out.info("[" + PLUGIN_NAME + "] " + "Migration finished: " + unit.getJavaElement().getElementName());
+			return initialChanges != finalChanges;
+		}
+		else {
+			out.error("[" + PLUGIN_NAME + "] " + "Wrong type of source node.");
+		}
+		return false;
+	}
+}

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/EjbEnvJavaMigration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/EjbEnvJavaMigration.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/EjbEnvJavaMigration.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/MethodsVisitor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/MethodsVisitor.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/MethodsVisitor.java (added)
+++ geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/MethodsVisitor.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,84 @@
+/**
+ *  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.env;
+
+import java.util.List;
+
+import org.apache.apps.j2gmigrator.Tool;
+import org.eclipse.jdt.core.dom.ASTVisitor;
+import org.eclipse.jdt.core.dom.Block;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.ITypeBinding;
+import org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.eclipse.jdt.core.dom.SimpleName;
+import org.eclipse.jdt.core.dom.TypeDeclaration;
+
+
+/**
+ * Visits types declarations, creates absolute name solvers and then visits methods declarations of
+ * these types. For each method declaration creates and starts {@link BlockVisitor}.
+ * @author Volkov, Stepan S.
+ */
+public class MethodsVisitor extends ASTVisitor {
+	/** Compilation unit. */
+	private CompilationUnit unit;
+
+	/** Solver for absolute JNDI names. */
+	private AbsoluteNameSolver solver;
+
+	/**
+	 * Constructor.
+	 * @param unit compilation unit.
+	 */
+	public MethodsVisitor(CompilationUnit unit) {
+		super(false);
+		this.unit = unit;
+	}
+
+	/**
+	 * Creates absolute names solver for this type declaration.
+	 * @param declaration type declaration.
+	 */
+	public boolean visit(TypeDeclaration declaration) {
+		List superInterfaces = declaration.superInterfaceTypes();
+		SimpleName className = declaration.getName();
+		ITypeBinding bind = className.resolveTypeBinding();
+		String qualifiedName = bind.getQualifiedName();
+		try {
+			solver = new AbsoluteNameSolver(qualifiedName, superInterfaces, unit);
+			return true;
+		} catch (NameSolvingException e) {
+			Tool.getCurrent().getOutput().fatal("Internal error occurs. " + e.getMessage());
+		}
+		return false;
+	}
+
+	/**
+	 * Creates and starts {@link BlockVisitor} if method is not empty.
+	 * @param methodDeclaration method declaration.
+	 */
+	public boolean visit(MethodDeclaration methodDeclaration) {
+		Block block = methodDeclaration.getBody();
+		if (block != null) {
+			BlockVisitor blockVisitor = new BlockVisitor(unit, solver);
+			methodDeclaration.accept(blockVisitor);
+			//blockVisitor.visit(block); 
+		}
+		return false;
+	}
+}

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/MethodsVisitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/MethodsVisitor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/MethodsVisitor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/NameSolvingException.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/NameSolvingException.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/NameSolvingException.java (added)
+++ geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/NameSolvingException.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,61 @@
+/**
+ *  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.env;
+
+/**
+ * Exception that indicates exceptions occurs while AbsoluteNameSolver works.
+ * @author Volkov, Stepan S.
+ */
+public class NameSolvingException extends Exception {
+
+	/** Serial version UID */
+	private static final long serialVersionUID = 1419666308972177554L;
+
+	/**
+	 * Constructor.
+	 */
+	public NameSolvingException() {
+		super();
+	}
+
+	/**
+	 * Constructor.
+	 * @param msg message.
+	 */
+	public NameSolvingException(String msg) {
+		super(msg);
+	}
+
+	/**
+	 * Constructor.
+	 * @param cause cause.
+	 */
+	public NameSolvingException(Throwable cause) {
+		super(cause);
+	}
+
+	/**
+	 * Constructor.
+	 * @param msg message.
+	 * @param cause cause.
+	 */
+	public NameSolvingException(String msg, Throwable cause) {
+		super(msg, cause);
+	}
+
+}

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/NameSolvingException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/NameSolvingException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/NameSolvingException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/VarContext.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/VarContext.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/VarContext.java (added)
+++ geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/VarContext.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,73 @@
+/**
+ *  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.env;
+
+/**
+ * Class represents JNDI name, scope and correctness  presented by <code>javax.naming.Context</code> variable.  
+ * @author Volkov, Stepan S.
+ */
+public class VarContext
+{
+	/**
+	 * Correctness flag.
+	 */
+	private boolean valid;
+	
+	/**
+	 * Position ends of scope in a compilation unit there variable was declared. 
+	 */
+	private int areaEnd;
+	
+	/**
+	 * JNDI name which variable presents.
+	 */
+	private String jndiName;
+	
+	/**
+	 * Constructor.
+	 */
+	public VarContext(String jndiName, int end, boolean valid)
+	{
+		this.areaEnd = end;
+		this.valid = valid;
+		this.jndiName = jndiName;
+	}
+
+	/**
+	 * @return end of variable scope in a current compilation unit.
+	 */
+	public int getAreaEnd()
+	{
+		return areaEnd;
+	}
+
+	/**
+	 * @return <code>true</code> if variable is correct. 
+	 */
+	public boolean isValid()
+	{
+		return valid;
+	}
+
+	/**
+	 * @return JNDI name which presented by variable.
+	 */
+	public String getJNDIName()
+	{
+		return jndiName;
+	}
+}

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/VarContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/VarContext.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/VarContext.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-interfaces.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-interfaces.properties?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-interfaces.properties (added)
+++ geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-interfaces.properties Mon Mar 19 10:43:27 2007
@@ -0,0 +1,18 @@
+/**
+ *  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.
+ */
+ javax.ejb.SessionBean = /ejb-jar/enterprise-beans/session
+javax.ejb.EntityBean = /ejb-jar/enterprise-beans/entity
\ No newline at end of file

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-interfaces.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-interfaces.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-interfaces.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-references.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-references.properties?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-references.properties (added)
+++ geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-references.properties Mon Mar 19 10:43:27 2007
@@ -0,0 +1,27 @@
+/**
+ *  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.
+ */
+ entity-local-home = local-home
+entity-local = local
+
+entity-remote-home = home
+entity-remote = remote
+
+session-local-home = local-home
+session-local = local
+
+session-remote-home = home 
+session-remote = remote
\ No newline at end of file

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-references.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-references.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-references.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-types.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-types.properties?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-types.properties (added)
+++ geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-types.properties Mon Mar 19 10:43:27 2007
@@ -0,0 +1,20 @@
+/**
+ *  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.
+ */
+ /jboss/enterprise-beans/entity/jndi-name = entity-remote
+/jboss/enterprise-beans/entity/local-jndi-name = entity-local
+/jboss/enterprise-beans/session/jndi-name = session-remote
+/jboss/enterprise-beans/session/local-jndi-name = session-local
\ No newline at end of file

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-types.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-types.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src/ejb-environment-plugin/src/org/apache/apps/j2gmigrator/sources/env/beans-types.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/j2g/src/jasper-plugin/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/jasper-plugin/META-INF/MANIFEST.MF?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/jasper-plugin/META-INF/MANIFEST.MF (added)
+++ geronimo/sandbox/j2g/src/jasper-plugin/META-INF/MANIFEST.MF Mon Mar 19 10:43:27 2007
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Jasper Plug-in
+Bundle-SymbolicName: com.ibm.j2g.jasper;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Vendor: IBM
+Bundle-Localization: plugin
+Bundle-ClassPath: lib/commons-el.jar,
+ lib/commons-logging-1.1.jar,
+ lib/jasper-compiler.jar,
+ lib/jasper-runtime.jar,
+ lib/jsp-api.jar,
+ lib/servlet-api.jar,
+ .,
+ lib/jasper-compiler-jdt.jar
+Eclipse-LazyStart: true
+Export-Package: com.ibm.j2g.jasper
+Require-Bundle: com.ibm.j2g,
+ org.apache.ant

Added: geronimo/sandbox/j2g/src/jasper-plugin/build.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/jasper-plugin/build.properties?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/jasper-plugin/build.properties (added)
+++ geronimo/sandbox/j2g/src/jasper-plugin/build.properties Mon Mar 19 10:43:27 2007
@@ -0,0 +1,27 @@
+/**
+ *  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.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               lib/commons-el.jar,\
+               lib/commons-logging-1.1.jar,\
+               lib/jasper-compiler.jar,\
+               lib/jasper-runtime.jar,\
+               lib/jsp-api.jar,\
+               lib/servlet-api.jar,\
+               lib/jasper-compiler-jdt.jar

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

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

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

Added: geronimo/sandbox/j2g/src/jasper-plugin/lib/commons-el.jar
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/jasper-plugin/lib/commons-el.jar?view=auto&rev=520023
==============================================================================
Binary file - no diff available.

Propchange: geronimo/sandbox/j2g/src/jasper-plugin/lib/commons-el.jar
------------------------------------------------------------------------------
    svn:mime-type = application/java-archive

Added: geronimo/sandbox/j2g/src/jasper-plugin/lib/commons-logging-1.1.jar
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/jasper-plugin/lib/commons-logging-1.1.jar?view=auto&rev=520023
==============================================================================
Binary file - no diff available.

Propchange: geronimo/sandbox/j2g/src/jasper-plugin/lib/commons-logging-1.1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/java-archive

Added: geronimo/sandbox/j2g/src/jasper-plugin/lib/jasper-compiler-jdt.jar
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/jasper-plugin/lib/jasper-compiler-jdt.jar?view=auto&rev=520023
==============================================================================
Binary file - no diff available.

Propchange: geronimo/sandbox/j2g/src/jasper-plugin/lib/jasper-compiler-jdt.jar
------------------------------------------------------------------------------
    svn:mime-type = application/java-archive

Added: geronimo/sandbox/j2g/src/jasper-plugin/lib/jasper-compiler.jar
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/jasper-plugin/lib/jasper-compiler.jar?view=auto&rev=520023
==============================================================================
Binary file - no diff available.

Propchange: geronimo/sandbox/j2g/src/jasper-plugin/lib/jasper-compiler.jar
------------------------------------------------------------------------------
    svn:mime-type = application/java-archive

Added: geronimo/sandbox/j2g/src/jasper-plugin/lib/jasper-runtime.jar
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/jasper-plugin/lib/jasper-runtime.jar?view=auto&rev=520023
==============================================================================
Binary file - no diff available.

Propchange: geronimo/sandbox/j2g/src/jasper-plugin/lib/jasper-runtime.jar
------------------------------------------------------------------------------
    svn:mime-type = application/java-archive

Added: geronimo/sandbox/j2g/src/jasper-plugin/lib/jsp-api.jar
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/jasper-plugin/lib/jsp-api.jar?view=auto&rev=520023
==============================================================================
Binary file - no diff available.

Propchange: geronimo/sandbox/j2g/src/jasper-plugin/lib/jsp-api.jar
------------------------------------------------------------------------------
    svn:mime-type = application/java-archive

Added: geronimo/sandbox/j2g/src/jasper-plugin/lib/servlet-api.jar
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/jasper-plugin/lib/servlet-api.jar?view=auto&rev=520023
==============================================================================
Binary file - no diff available.

Propchange: geronimo/sandbox/j2g/src/jasper-plugin/lib/servlet-api.jar
------------------------------------------------------------------------------
    svn:mime-type = application/java-archive

Added: geronimo/sandbox/j2g/src/jasper-plugin/plugin.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/jasper-plugin/plugin.xml?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/jasper-plugin/plugin.xml (added)
+++ geronimo/sandbox/j2g/src/jasper-plugin/plugin.xml Mon Mar 19 10:43:27 2007
@@ -0,0 +1,20 @@
+/**
+ *  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>
+</plugin>
\ No newline at end of file

Propchange: geronimo/sandbox/j2g/src/jasper-plugin/plugin.xml
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Added: geronimo/sandbox/j2g/src/jasper-plugin/src/org/apache/apps/j2gmigrator/jasper/JspCompiler.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/jasper-plugin/src/org/apache/apps/j2gmigrator/jasper/JspCompiler.java?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/jasper-plugin/src/org/apache/apps/j2gmigrator/jasper/JspCompiler.java (added)
+++ geronimo/sandbox/j2g/src/jasper-plugin/src/org/apache/apps/j2gmigrator/jasper/JspCompiler.java Mon Mar 19 10:43:27 2007
@@ -0,0 +1,100 @@
+/**
+ *  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.jasper;
+
+import java.io.File;
+import java.io.FileFilter;
+
+import org.apache.apps.j2gmigrator.FatalToolException;
+import org.apache.apps.j2gmigrator.Tool;
+import org.apache.jasper.JasperException;
+import org.apache.jasper.JspC;
+
+
+/**
+ * Compiles jsp sources to java sources.
+ * @author Volkov, S. Stepan
+ */
+public class JspCompiler {
+	
+	/** Jasper compiler */
+	private JspC jspCompiler;
+	
+	/** File filter for jsp files */
+	private FileFilter jspFilesFilter;
+	
+	/** Compiler constructor. */
+	public JspCompiler(FileFilter jspFilesFilter){
+		jspCompiler = new JspC();
+		jspCompiler.setCompile(false);
+		jspCompiler.setVerbose(0);
+		this.jspFilesFilter = jspFilesFilter;
+	}
+	
+	/**
+	 * Gets jasper default encoding.
+	 * @return jasper encoding.
+	 */
+	public String getEncoding(){
+		return jspCompiler.getJavaEncoding();
+	}
+	
+	/**
+	 * Compiles jsp sources to java sources and saves its into outputDir.
+	 * @param classPath classpath for compilation.
+	 * @param outputDir output directory.
+	 * @param uriRoot full path to directory with web content.
+	 * @throws FatalToolException if any problems occurs.
+	 */
+	public void compileJsp(String classPath, String outputDir, String uriRoot) throws FatalToolException{
+		jspCompiler.setClassPath(classPath);
+		jspCompiler.setOutputDir(outputDir);
+		jspCompiler.setUriroot(uriRoot);
+		File webSource = new File(uriRoot);
+		searchJspFiles("", webSource);
+		try {
+			jspCompiler.setCompile(false);
+			jspCompiler.execute();
+		} catch (JasperException ex) {
+			Tool.getCurrent().getOutput().fatal("Jasper error: " + ex.getMessage());
+			throw new FatalToolException("Cannot compile jsp sources: " + webSource.getAbsolutePath(), ex);
+		}
+	}
+
+	/**
+	 * Recursively adds jsp files to the jsp compiler relative to the root.
+	 * @param base relative path.
+	 * @param file directory.
+	 * @throws FatalToolException if file is not a web directory.
+	 */
+	private void searchJspFiles(String base, File file) throws FatalToolException {
+		if (file.isDirectory()) {
+			File[] fileList = file.listFiles(jspFilesFilter);
+			for (int i = 0; i < fileList.length; i++) {
+				if (fileList[i].isDirectory()) {
+					searchJspFiles(base + File.separator + fileList[i].getName(), fileList[i]);
+				}
+				else {
+					jspCompiler.setJspFiles(base + File.separator + fileList[i].getName());
+				}
+			}
+		}
+		else {
+			throw new FatalToolException("Wrong parameter: " + file.getAbsolutePath() + "; Only web directories allowed.");
+		}
+	}
+}

Propchange: geronimo/sandbox/j2g/src/jasper-plugin/src/org/apache/apps/j2gmigrator/jasper/JspCompiler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/j2g/src/jasper-plugin/src/org/apache/apps/j2gmigrator/jasper/JspCompiler.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/j2g/src/jasper-plugin/src/org/apache/apps/j2gmigrator/jasper/JspCompiler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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

Added: geronimo/sandbox/j2g/src/resources-tool/build.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/resources-tool/build.properties?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/resources-tool/build.properties (added)
+++ geronimo/sandbox/j2g/src/resources-tool/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.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml

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

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

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

Added: geronimo/sandbox/j2g/src/resources-tool/plugin.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/src/resources-tool/plugin.xml?view=auto&rev=520023
==============================================================================
--- geronimo/sandbox/j2g/src/resources-tool/plugin.xml (added)
+++ geronimo/sandbox/j2g/src/resources-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="Resources Migrations Extension Point" schema="schema/tool.migrations.exsd"/>
+   <extension
+         id="tool"
+         name="Resources Migration Tool"
+         point="org.eclipse.core.runtime.applications">
+      <application>
+         <run class="com.ibm.j2g.resources.ResourcesTool"/>
+      </application>
+   </extension>
+</plugin>

Propchange: geronimo/sandbox/j2g/src/resources-tool/plugin.xml
------------------------------------------------------------------------------
    svn:eol-style = native

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

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



Mime
View raw message