diff options
6 files changed, 100 insertions, 80 deletions
diff --git a/branches/sca-java-1.x/modules/binding-ejb-runtime/pom.xml b/branches/sca-java-1.x/modules/binding-ejb-runtime/pom.xml index 07911b3d4b..60bd30e713 100644 --- a/branches/sca-java-1.x/modules/binding-ejb-runtime/pom.xml +++ b/branches/sca-java-1.x/modules/binding-ejb-runtime/pom.xml @@ -49,7 +49,7 @@ <version>2.2</version> <scope>compile</scope> </dependency> - + <dependency> <groupId>backport-util-concurrent</groupId> <artifactId>backport-util-concurrent</artifactId> @@ -87,7 +87,7 @@ <dependency> <groupId>org.apache.geronimo.modules</groupId> <artifactId>geronimo-openejb</artifactId> - <version>2.0.2</version> + <version>2.1.4</version> <scope>test</scope> <exclusions> <exclusion> @@ -136,7 +136,7 @@ </exclusion> </exclusions> </dependency> - + <dependency> <groupId>asm</groupId> <artifactId>asm-all</artifactId> @@ -154,7 +154,7 @@ <artifactId>geronimo-jms_1.1_spec</artifactId> </exclusion> </exclusions> - </dependency> + </dependency> </dependencies> diff --git a/branches/sca-java-1.x/modules/contribution-jee-impl/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/JavaEEIntrospectorImpl.java b/branches/sca-java-1.x/modules/contribution-jee-impl/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/JavaEEIntrospectorImpl.java index 7857eea08e..38a1573e63 100644 --- a/branches/sca-java-1.x/modules/contribution-jee-impl/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/JavaEEIntrospectorImpl.java +++ b/branches/sca-java-1.x/modules/contribution-jee-impl/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/JavaEEIntrospectorImpl.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.contribution.jee.impl; @@ -29,6 +29,7 @@ import java.util.Map; import org.apache.openejb.config.AppModule; import org.apache.openejb.config.EjbModule; import org.apache.openejb.config.UnknownModuleTypeException; +import org.apache.openejb.config.UnsupportedModuleTypeException; import org.apache.openejb.config.WebModule; import org.apache.openejb.jee.EjbJar; import org.apache.openejb.jee.EjbRef; @@ -57,7 +58,7 @@ import org.apache.tuscany.sca.contribution.service.util.IOHelper; * @version $Rev$ $Date$ */ public class JavaEEIntrospectorImpl implements JavaEEIntrospector { - + public WebModuleInfo introspectWebArchive(URL artifactURL) throws ContributionReadException { // Create a temporary file since openejb extracts the archive to process InputStream inp = null; @@ -74,7 +75,7 @@ public class JavaEEIntrospectorImpl implements JavaEEIntrospector { } catch (IOException e) { throw new ContributionReadException(e); } - + JavaEEModuleHelper jmh = new JavaEEModuleHelper(); WebModule wm = jmh.getMetadataCompleteModules(tempFile.getAbsolutePath()).getWebModules().get(0); if(!tempFile.delete()) { @@ -85,10 +86,10 @@ public class JavaEEIntrospectorImpl implements JavaEEIntrospector { private WebModuleInfo createWebModuleInfo(WebModule webModule) { WebModuleInfo wmInfo = new WebModuleInfoImpl(); - + WebApp webApp = webModule.getWebApp(); ClassLoader classLoader = webModule.getClassLoader(); - + // Process Remote EJB References for (Map.Entry<String, EjbRef> entry : webApp.getEjbRefMap().entrySet()) { EjbRef ejbRef = entry.getValue(); @@ -116,12 +117,12 @@ public class JavaEEIntrospectorImpl implements JavaEEIntrospector { e.printStackTrace(); } } - + // Process env-entries to compute properties for (Map.Entry<String, EnvEntry> entry : webApp.getEnvEntryMap().entrySet()) { EnvEntry envEntry = entry.getValue(); wmInfo.getEnvEntries().put(envEntry.getEnvEntryName(), createEnvEntryInfo(envEntry)); - } + } // Process Servlets for(Servlet servlet: webApp.getServlet()) { @@ -152,26 +153,26 @@ public class JavaEEIntrospectorImpl implements JavaEEIntrospector { e.printStackTrace(); } } - + // TODO: Process JSF Managed beans - + // TODO: Process JSP pages - + return wmInfo; } - + private org.apache.tuscany.sca.contribution.jee.EnvEntryInfo createEnvEntryInfo(EnvEntry envEntry) { org.apache.tuscany.sca.contribution.jee.EnvEntryInfo envEntryInfo = new org.apache.tuscany.sca.contribution.jee.EnvEntryInfo(); envEntryInfo.name = envEntry.getEnvEntryName(); envEntryInfo.type = envEntry.getEnvEntryType(); envEntryInfo.value = envEntry.getEnvEntryValue(); - + return envEntryInfo; } private org.apache.tuscany.sca.contribution.jee.EjbReferenceInfo createEjbReferenceInfo(EjbRef ejbRef, ClassLoader classLoader) throws ClassNotFoundException { org.apache.tuscany.sca.contribution.jee.EjbReferenceInfo ejbReferenceInfo = new org.apache.tuscany.sca.contribution.jee.EjbReferenceInfo(); - + ejbReferenceInfo.referenceName = ejbRef.getEjbRefName(); ejbReferenceInfo.referenceType = ejbRef.getRefType().compareTo(EjbReference.Type.REMOTE) == 0 ? org.apache.tuscany.sca.contribution.jee.EjbReferenceInfo.RefType.REMOTE : ejbRef.getRefType().compareTo(EjbReference.Type.LOCAL) == 0 ? org.apache.tuscany.sca.contribution.jee.EjbReferenceInfo.RefType.LOCAL : org.apache.tuscany.sca.contribution.jee.EjbReferenceInfo.RefType.UNKNOWN; ejbReferenceInfo.businessInterface = classLoader.loadClass(ejbRef.getInterface()); @@ -182,10 +183,10 @@ public class JavaEEIntrospectorImpl implements JavaEEIntrospector { ejbReferenceInfo.ejbType = EjbType.SESSION_UNKNOWN; } } - + ejbReferenceInfo.ejbLink = ejbRef.getEjbLink(); ejbReferenceInfo.mappedName = ejbRef.getMappedName(); - + return ejbReferenceInfo; } @@ -205,13 +206,14 @@ public class JavaEEIntrospectorImpl implements JavaEEIntrospector { } catch (IOException e) { throw new ContributionReadException(e); } - + JavaEEModuleHelper jmh = new JavaEEModuleHelper(); EjbModule em; try { em = jmh.getMetadataCompleteModules(tempFile.getAbsolutePath()).getEjbModules().get(0); } catch(ContributionReadException e) { - if(e.getCause() instanceof UnknownModuleTypeException) { + if((e.getCause() instanceof UnknownModuleTypeException) || + (e.getCause() instanceof UnsupportedModuleTypeException)) { // Not an EJB jar return null; } else { @@ -254,7 +256,7 @@ public class JavaEEIntrospectorImpl implements JavaEEIntrospector { ejbModuleInfo.getEjbInfos().put(bean.getEjbName(), ejbInfo); } } - + return ejbModuleInfo; } @@ -268,9 +270,9 @@ public class JavaEEIntrospectorImpl implements JavaEEIntrospector { // Should not happen } EjbInfo ejbInfo = new EjbInfo(); - + ejbInfo.beanName = bean.getEjbName(); - + try { ejbInfo.beanClass = classLoader.loadClass(bean.getEjbClass()); } catch (ClassNotFoundException e) { @@ -279,7 +281,7 @@ public class JavaEEIntrospectorImpl implements JavaEEIntrospector { } ejbInfo.ejbType = org.apache.tuscany.sca.contribution.jee.EjbInfo.EjbType.MESSAGE_DRIVEN; - + ejbInfo.mappedName = bean.getMappedName(); processReferencesEnvEntries(bean, classLoader, ejbInfo); @@ -293,9 +295,9 @@ public class JavaEEIntrospectorImpl implements JavaEEIntrospector { return null; } EjbInfo ejbInfo = new EjbInfo(); - + ejbInfo.beanName = bean.getEjbName(); - + try { ejbInfo.beanClass = classLoader.loadClass(bean.getEjbClass()); } catch (ClassNotFoundException e) { @@ -319,7 +321,7 @@ public class JavaEEIntrospectorImpl implements JavaEEIntrospector { // TODO Auto-generated catch block e.printStackTrace(); } - } + } // Process Local Business interfaces of the SessionBean for (String intfName : bean.getBusinessLocal()) { @@ -329,10 +331,10 @@ public class JavaEEIntrospectorImpl implements JavaEEIntrospector { // TODO Auto-generated catch block e.printStackTrace(); } - } + } processReferencesEnvEntries(bean, classLoader, ejbInfo); - + return ejbInfo; } @@ -363,12 +365,12 @@ public class JavaEEIntrospectorImpl implements JavaEEIntrospector { // TODO Auto-generated catch block e.printStackTrace(); } - } + } // Process env-entries for (Map.Entry<String, EnvEntry> entry : bean.getEnvEntryMap().entrySet()) { EnvEntry envEntry = entry.getValue(); - + ejbInfo.envEntries.put(envEntry.getEnvEntryName(), createEnvEntryInfo(envEntry)); } } @@ -389,7 +391,7 @@ public class JavaEEIntrospectorImpl implements JavaEEIntrospector { } catch (IOException e) { throw new ContributionReadException(e); } - + JavaEEModuleHelper jmh = new JavaEEModuleHelper(); AppModule appModule = jmh.getMetadataCompleteModules(tempFile.getAbsolutePath()); if(!tempFile.delete()) { @@ -411,7 +413,7 @@ public class JavaEEIntrospectorImpl implements JavaEEIntrospector { webModuleInfo.setModuleName(wm.getModuleId()); appInfo.getWebModuleInfos().put(wm.getModuleId(), webModuleInfo); } - + return appInfo; } } diff --git a/branches/sca-java-1.x/modules/host-openejb/pom.xml b/branches/sca-java-1.x/modules/host-openejb/pom.xml index 00ba5326e2..ec185503fa 100644 --- a/branches/sca-java-1.x/modules/host-openejb/pom.xml +++ b/branches/sca-java-1.x/modules/host-openejb/pom.xml @@ -7,15 +7,15 @@ * 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. + * under the License. --> <project> <modelVersion>4.0.0</modelVersion> @@ -34,11 +34,11 @@ <artifactId>tuscany-host-ejb</artifactId> <version>1.5-SNAPSHOT</version> </dependency> - + <dependency> <groupId>org.apache.geronimo.modules</groupId> <artifactId>geronimo-openejb</artifactId> - <version>2.1.1</version> + <version>2.1.4</version> <exclusions> <exclusion> <groupId>org.apache.geronimo.modules</groupId> @@ -66,13 +66,13 @@ </exclusion> </exclusions> </dependency> - + <dependency> <groupId>backport-util-concurrent</groupId> <artifactId>backport-util-concurrent</artifactId> <version>3.1</version> </dependency> - + <dependency> <groupId>asm</groupId> <artifactId>asm-all</artifactId> diff --git a/branches/sca-java-1.x/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/xml/EJBImplementationProcessor.java b/branches/sca-java-1.x/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/xml/EJBImplementationProcessor.java index 286ad01b64..3f207b6ad2 100644 --- a/branches/sca-java-1.x/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/xml/EJBImplementationProcessor.java +++ b/branches/sca-java-1.x/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/xml/EJBImplementationProcessor.java @@ -6,21 +6,22 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.implementation.ejb.xml; import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; import java.net.URI; +import java.util.logging.Logger; import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamException; @@ -32,6 +33,7 @@ import org.apache.tuscany.sca.assembly.ComponentType; import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl; import org.apache.tuscany.sca.assembly.xml.Constants; import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.jee.EjbInfo; import org.apache.tuscany.sca.contribution.jee.EjbModuleInfo; import org.apache.tuscany.sca.contribution.jee.JavaEEExtension; import org.apache.tuscany.sca.contribution.jee.JavaEEOptionalExtension; @@ -64,7 +66,8 @@ import org.apache.tuscany.sca.monitor.Problem.Severity; */ public class EJBImplementationProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<EJBImplementation> { private static final QName IMPLEMENTATION_EJB = new QName(Constants.SCA10_NS, "implementation.ejb"); - + private static final Logger logger = Logger.getLogger(EJBImplementationProcessor.class.getName()); + private AssemblyFactory assemblyFactory; private EJBImplementationFactory implementationFactory; private Monitor monitor; @@ -72,7 +75,7 @@ public class EJBImplementationProcessor extends BaseStAXArtifactProcessor implem private JavaEEOptionalExtension jeeOptionalExtension; private JavaImplementationFactory javaImplementationFactory; private JavaInterfaceFactory javaInterfaceFactory; - + public EJBImplementationProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); this.implementationFactory = modelFactories.getFactory(EJBImplementationFactory.class); @@ -86,7 +89,7 @@ public class EJBImplementationProcessor extends BaseStAXArtifactProcessor implem javaImplementationFactory.addClassVisitor(new PropertyProcessor(assemblyFactory)); javaImplementationFactory.addClassVisitor(new ServiceProcessor(assemblyFactory, javaInterfaceFactory)); } - + /** * Report a error. * @@ -112,7 +115,7 @@ public class EJBImplementationProcessor extends BaseStAXArtifactProcessor implem } public EJBImplementation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - + // Read an <implementation.ejb> element EJBImplementation implementation = implementationFactory.createEJBImplementation(); implementation.setUnresolved(true); @@ -121,8 +124,8 @@ public class EJBImplementationProcessor extends BaseStAXArtifactProcessor implem String ejbLink = getString(reader, "ejb-link"); if (ejbLink != null) { implementation.setEJBLink(ejbLink); - - // Set the URI of the component type + + // Set the URI of the component type //implementation.setURI(ejbLink.replace('#', '/')); int hashPosition = ejbLink.indexOf('#'); if (hashPosition >= 0) { @@ -140,12 +143,12 @@ public class EJBImplementationProcessor extends BaseStAXArtifactProcessor implem break; } } - + return implementation; } public void resolve(EJBImplementation implementation, ModelResolver resolver) throws ContributionResolveException { - + // Resolve the component type String uri = implementation.getURI(); String ejbLink = implementation.getEJBLink(); @@ -155,11 +158,11 @@ public class EJBImplementationProcessor extends BaseStAXArtifactProcessor implem EjbModuleInfo ejbModuleInfo = new EjbModuleInfoImpl(); ejbModuleInfo.setUri(URI.create(module)); ejbModuleInfo = resolver.resolveModel(EjbModuleInfo.class, ejbModuleInfo); - + if(jeeExtension != null) { ComponentType ct = jeeExtension.createImplementationEjbComponentType(ejbModuleInfo, beanName); // TODO - SL - TUSCANY-2944 - these new JEE processors are causing problems with existing contributions - // ct is null if there is no EJBInfo + // ct is null if there is no EJBInfo if (ct != null){ implementation.getServices().addAll(ct.getServices()); } @@ -168,46 +171,54 @@ public class EJBImplementationProcessor extends BaseStAXArtifactProcessor implem if(jeeOptionalExtension != null) { ComponentType ct = jeeOptionalExtension.createImplementationEjbComponentType(ejbModuleInfo, beanName); // TODO - SL - TUSCANY-2944 - these new JEE processors are causing problems with existing contributions - // ct is null if there is no EJBInfo + // ct is null if there is no EJBInfo if (ct != null){ implementation.getReferences().addAll(ct.getReferences()); implementation.getProperties().addAll(ct.getProperties()); } } - // Introspection of bean class - Class<?> beanClass = ejbModuleInfo.getEjbInfo(uri).beanClass; - try { - JavaImplementation ji = javaImplementationFactory.createJavaImplementation(beanClass); - implementation.getReferences().addAll(ji.getReferences()); - implementation.getProperties().addAll(ji.getProperties()); - implementation.getServices().addAll(ji.getServices()); - } catch (IntrospectionException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + EjbInfo ejbInfo = ejbModuleInfo.getEjbInfo(uri); + if (ejbInfo == null) { + // FIXME: + logger.severe("EJB " + uri + " is not found in the module"); + // throw new ContributionResolveException("EJB " + uri + " is not found in the module"); + } else { + // Introspection of bean class + Class<?> beanClass = ejbInfo.beanClass; + try { + JavaImplementation ji = javaImplementationFactory.createJavaImplementation(beanClass); + implementation.getReferences().addAll(ji.getReferences()); + implementation.getProperties().addAll(ji.getProperties()); + implementation.getServices().addAll(ji.getServices()); + } catch (IntrospectionException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } - + // Process componentType side file ComponentType componentType = assemblyFactory.createComponentType(); componentType.setURI(uri + ".componentType"); componentType = resolver.resolveModel(ComponentType.class, componentType); if (!componentType.isUnresolved()) { - + // Initialize the implementation's services, references and properties implementation.getServices().addAll(componentType.getServices()); implementation.getReferences().addAll(componentType.getReferences()); implementation.getProperties().addAll(componentType.getProperties()); } } + implementation.setUnresolved(false); } public void write(EJBImplementation implementation, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - + // Write <implementation.ejb> writeStart(writer, IMPLEMENTATION_EJB.getNamespaceURI(), IMPLEMENTATION_EJB.getLocalPart(), new XAttr("ejb-link", implementation.getEJBLink())); - + writeEnd(writer); } } diff --git a/branches/sca-java-1.x/tutorials/store/catalog-ejb/pom.xml b/branches/sca-java-1.x/tutorials/store/catalog-ejb/pom.xml index 30b5e0f3dd..170cd00fc7 100644 --- a/branches/sca-java-1.x/tutorials/store/catalog-ejb/pom.xml +++ b/branches/sca-java-1.x/tutorials/store/catalog-ejb/pom.xml @@ -7,9 +7,9 @@ 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 @@ -38,7 +38,7 @@ <version>1.0</version> <scope>provided</scope> </dependency> - + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> @@ -49,7 +49,7 @@ <dependency> <groupId>org.apache.geronimo.modules</groupId> <artifactId>geronimo-openejb</artifactId> - <version>2.1.1</version> + <version>2.1.4</version> <scope>test</scope> <exclusions> <exclusion> @@ -87,7 +87,7 @@ <exclusion> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> - </exclusion> + </exclusion> </exclusions> </dependency> diff --git a/branches/sca-java-1.x/tutorials/store/store-test/pom.xml b/branches/sca-java-1.x/tutorials/store/store-test/pom.xml index 89f10c7d45..590fd91c5f 100644 --- a/branches/sca-java-1.x/tutorials/store/store-test/pom.xml +++ b/branches/sca-java-1.x/tutorials/store/store-test/pom.xml @@ -7,15 +7,15 @@ * 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. + * under the License. --> <project> <modelVersion>4.0.0</modelVersion> @@ -139,6 +139,13 @@ <dependency> <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-contribution-jee-impl</artifactId> + <version>1.5-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> <artifactId>tuscany-implementation-ejb</artifactId> <version>1.5-SNAPSHOT</version> <scope>runtime</scope> @@ -166,7 +173,7 @@ </dependency> </dependencies> - + <build> <finalName>${artifactId}</finalName> <testSourceDirectory>${basedir}</testSourceDirectory> |