From 3a569a2f00bf172cddfd567149774ee808a2a242 Mon Sep 17 00:00:00 2001 From: nash Date: Wed, 30 Mar 2011 19:50:51 +0000 Subject: Create branch for 1.6.2 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1087059 13f79535-47bb-0310-9956-ffa450edef68 --- .../jee/TestEJBImplementationProvider.java | 48 +++++++ .../jee/TestEJBImplementationProviderFactory.java | 47 +++++++ .../jee/TestExternalEarModelResolver.java | 141 +++++++++++++++++++++ 3 files changed, 236 insertions(+) create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/itest/contribution-jee/src/main/java/org/apache/tuscany/sca/test/contribution/jee/TestEJBImplementationProvider.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/itest/contribution-jee/src/main/java/org/apache/tuscany/sca/test/contribution/jee/TestEJBImplementationProviderFactory.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/itest/contribution-jee/src/main/java/org/apache/tuscany/sca/test/contribution/jee/TestExternalEarModelResolver.java (limited to 'sca-java-1.x/branches/sca-java-1.6.2/itest/contribution-jee/src/main/java/org/apache/tuscany/sca/test/contribution/jee') diff --git a/sca-java-1.x/branches/sca-java-1.6.2/itest/contribution-jee/src/main/java/org/apache/tuscany/sca/test/contribution/jee/TestEJBImplementationProvider.java b/sca-java-1.x/branches/sca-java-1.6.2/itest/contribution-jee/src/main/java/org/apache/tuscany/sca/test/contribution/jee/TestEJBImplementationProvider.java new file mode 100644 index 0000000000..e7e1d90797 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/itest/contribution-jee/src/main/java/org/apache/tuscany/sca/test/contribution/jee/TestEJBImplementationProvider.java @@ -0,0 +1,48 @@ +/* + * 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.tuscany.sca.test.contribution.jee; + +import org.apache.tuscany.sca.implementation.ejb.EJBImplementation; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + + +class TestEJBImplementationProvider implements ImplementationProvider { + + TestEJBImplementationProvider(RuntimeComponent component, EJBImplementation ejbImplementation) { + } + + public Invoker createInvoker(RuntimeComponentService service, Operation operation) { + return null; + } + + public boolean supportsOneWayInvocation() { + return false; + } + + public void start() { + } + + public void stop() { + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/itest/contribution-jee/src/main/java/org/apache/tuscany/sca/test/contribution/jee/TestEJBImplementationProviderFactory.java b/sca-java-1.x/branches/sca-java-1.6.2/itest/contribution-jee/src/main/java/org/apache/tuscany/sca/test/contribution/jee/TestEJBImplementationProviderFactory.java new file mode 100644 index 0000000000..4660fee7fd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/itest/contribution-jee/src/main/java/org/apache/tuscany/sca/test/contribution/jee/TestEJBImplementationProviderFactory.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.test.contribution.jee; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.implementation.ejb.EJBImplementation; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.provider.ImplementationProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +/** + * A factory for resource implementation providers. + * + * @version $Rev$ $Date$ + */ +public class TestEJBImplementationProviderFactory implements ImplementationProviderFactory { + + /** + * Constructs a resource implementation. + */ + public TestEJBImplementationProviderFactory(ExtensionPointRegistry extensionPoints) { + } + + public ImplementationProvider createImplementationProvider(RuntimeComponent component, EJBImplementation implementation) { + return new TestEJBImplementationProvider(component, implementation); + } + + public Class getModelType() { + return EJBImplementation.class; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/itest/contribution-jee/src/main/java/org/apache/tuscany/sca/test/contribution/jee/TestExternalEarModelResolver.java b/sca-java-1.x/branches/sca-java-1.6.2/itest/contribution-jee/src/main/java/org/apache/tuscany/sca/test/contribution/jee/TestExternalEarModelResolver.java new file mode 100644 index 0000000000..1c4bd34352 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/itest/contribution-jee/src/main/java/org/apache/tuscany/sca/test/contribution/jee/TestExternalEarModelResolver.java @@ -0,0 +1,141 @@ +/* + * 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.tuscany.sca.test.contribution.jee; + +import java.io.File; +import java.net.URI; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.contribution.Artifact; +import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.contribution.jee.ExternalEarInfo; +import org.apache.tuscany.sca.contribution.jee.JavaEEApplicationInfo; +import org.apache.tuscany.sca.contribution.jee.JavaEEIntrospector; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionService; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.UtilityExtensionPoint; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain; + +public class TestExternalEarModelResolver implements ModelResolver { + + private Map map = new HashMap(); + private JavaEEIntrospector jeeIntrospector; + private ContributionService contributionService; + + + public TestExternalEarModelResolver(Contribution contribution, ExtensionPointRegistry extensionPoints) { + jeeIntrospector = extensionPoints.getExtensionPoint(JavaEEIntrospector.class); + UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); + contributionService = utilities.getUtility(ContributionService.class); + + } + + public void addModel(Object resolved) { + ExternalEarInfo jeeApp = (ExternalEarInfo)resolved; + map.put(jeeApp.getAppInfo().getUri(), jeeApp); + } + + public Object removeModel(Object resolved) { + return map.remove(((ExternalEarInfo)resolved).getAppInfo().getUri()); + } + + public T resolveModel(final Class modelClass, T unresolved) { + URI uri = ((ExternalEarInfo)unresolved).getAppInfo().getUri(); + if (uri != null) { + ExternalEarInfo resolved = (ExternalEarInfo) map.get(uri); + if (resolved != null) { + return modelClass.cast(resolved); + } else { + // if you don't care about application composites you can + // simply read the EAR directly + /* + try { + File f = new File(uri.toString()); + final JavaEEApplicationInfo o = jeeIntrospector.introspectJeeArchive(f.toURI().toURL()); + return (T)new ExternalEarInfo() { + public JavaEEApplicationInfo getAppInfo() { + return (JavaEEApplicationInfo)o; + } + }; + } catch (Exception e) { + throw new RuntimeException(e); + } + */ + + // if you do care about the application composite you + // need to process the ear as a contribution + try{ + // find the location of the ear using a very specific algorithm + URL earLocation = null; + if ( uri.toString().equals("itest-contribution-jee-samples-13-ear-nonenhanced.ear")){ + earLocation = new File("../contribution-jee-samples/ear-nonenhanced/target/itest-contribution-jee-samples-13-ear-nonenhanced.ear").toURL(); + } else if ( uri.toString().equals("./itest-contribution-jee-samples-29-ear-appcomp-contrib-implicit.ear")){ + earLocation = new File("../contribution-jee-samples/ear-appcomp-contrib-implicit/target/itest-contribution-jee-samples-29-ear-appcomp-contrib-implicit.ear").toURL(); + } else if ( uri.toString().equals("itest-contribution-jee-samples-30-ear-appcomp-contrib-implicit-war-appcomp.ear")){ + earLocation = new File("../contribution-jee-samples/ear-appcomp-contrib-implicit-war-appcomp/target/itest-contribution-jee-samples-30-ear-appcomp-contrib-implicit-war-appcomp.ear").toURL(); + } else { + return unresolved; + } + + // if you do care about application composites we have + // to process the EAR as a contribution + Contribution contribution = contributionService.contribute(uri.toString(), earLocation, false); + + JavaEEApplicationInfo appInfo = null; + Composite appComposite = null; + + // get the ear info + for (Artifact artifact : contribution.getArtifacts()){ + if (artifact.getModel() instanceof JavaEEApplicationInfo){ + appInfo = (JavaEEApplicationInfo)artifact.getModel(); + } + + if (artifact.getURI().equals("META-INF/application.composite")){ + appComposite = (Composite)artifact.getModel(); + } + } + + + final JavaEEApplicationInfo returnAppInfo = appInfo; + final Composite returnAppComposite = appComposite; + + return (T)new ExternalEarInfo() { + public JavaEEApplicationInfo getAppInfo() { + return returnAppInfo; + } + public Composite getAppComposite() { + return returnAppComposite; + } + }; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + return unresolved; + } + +} -- cgit v1.2.3