diff options
Diffstat (limited to 'branches/sca-java-1.x')
8 files changed, 245 insertions, 2 deletions
diff --git a/branches/sca-java-1.x/modules/contribution-jee-impl/src/main/java/org/apache/tuscany/sca/contribution/jee/JEEDefinitionsProvider.java b/branches/sca-java-1.x/modules/contribution-jee-impl/src/main/java/org/apache/tuscany/sca/contribution/jee/JEEDefinitionsProvider.java new file mode 100644 index 0000000000..262875c49a --- /dev/null +++ b/branches/sca-java-1.x/modules/contribution-jee-impl/src/main/java/org/apache/tuscany/sca/contribution/jee/JEEDefinitionsProvider.java @@ -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.tuscany.sca.contribution.jee; + +import java.net.URI; +import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedAction; + +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.definitions.SCADefinitions; +import org.apache.tuscany.sca.definitions.util.SCADefinitionsUtil; +import org.apache.tuscany.sca.provider.SCADefinitionsProvider; +import org.apache.tuscany.sca.provider.SCADefinitionsProviderException; + +/** + * Provider for Policy Intents and PolicySet definitions related to security + * + * @version $Rev$ $Date$ + */ +public class JEEDefinitionsProvider implements SCADefinitionsProvider { + private static final String definitionsFile = "org/apache/tuscany/sca/contribution/jee/definitions.xml"; + + URLArtifactProcessor urlArtifactProcessor = null; + + public JEEDefinitionsProvider(ExtensionPointRegistry registry) { + URLArtifactProcessorExtensionPoint documentProcessors = + registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); + urlArtifactProcessor = (URLArtifactProcessor)documentProcessors.getProcessor(SCADefinitions.class); + } + + public SCADefinitions getSCADefinition() throws SCADefinitionsProviderException { + SCADefinitions scaDefns = null; + try { + // Allow privileged access to load resource. Requires + // RuntimePermssion in security policy. + URL definitionsFileUrl = AccessController.doPrivileged(new PrivilegedAction<URL>() { + public URL run() { + return getClass().getClassLoader().getResource(definitionsFile); + } + }); + + URI uri = new URI(definitionsFile); + + scaDefns = (SCADefinitions)urlArtifactProcessor.read(null, uri, definitionsFileUrl); + + return scaDefns; + + } catch (Exception e) { + throw new SCADefinitionsProviderException(e); + } + } + +} diff --git a/branches/sca-java-1.x/modules/contribution-jee-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider b/branches/sca-java-1.x/modules/contribution-jee-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider new file mode 100644 index 0000000000..cd81aab7a0 --- /dev/null +++ b/branches/sca-java-1.x/modules/contribution-jee-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider @@ -0,0 +1,19 @@ +# 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. + +# Implementation class for SCA Definitions Providers +org.apache.tuscany.sca.contribution.jee.JEEDefinitionsProvider
\ No newline at end of file diff --git a/branches/sca-java-1.x/modules/contribution-jee-impl/src/main/resources/org/apache/tuscany/sca/contribution/jee/definitions.xml b/branches/sca-java-1.x/modules/contribution-jee-impl/src/main/resources/org/apache/tuscany/sca/contribution/jee/definitions.xml new file mode 100644 index 0000000000..bfc7f9097c --- /dev/null +++ b/branches/sca-java-1.x/modules/contribution-jee-impl/src/main/resources/org/apache/tuscany/sca/contribution/jee/definitions.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="ASCII"?> +<!-- + * 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. +--> +<definitions xmlns="http://www.osoa.org/xmlns/sca/1.0" + targetNamespace="http://www.osoa.org/xmlns/sca/1.0" + xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"> + + + <!-- JEE Intents Defined by the SCA Runtime --> + <intent name="ejb" + constrains="sca:service sca:reference"> + <description> + This intent is used to indicate that a message passing + through a service or reference observers the same rules + as if it had been received/sent by a vanilla Java EE EJB. + </description> + </intent> + +</definitions>
\ No newline at end of file diff --git a/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/EJBImplementationGeneratedProcessor.java b/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/EJBImplementationGeneratedProcessor.java new file mode 100644 index 0000000000..bc8bc99770 --- /dev/null +++ b/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/EJBImplementationGeneratedProcessor.java @@ -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.tuscany.sca.contribution.jee.impl; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.monitor.Monitor; + + +/** + * Dummy processor that's used to mark EJBImplementationGeneratedImpl instance + * as resolved at the appropriate point in the resolution processing + * + * @version $Rev$ $Date$ + */ +public class EJBImplementationGeneratedProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<EJBImplementationGeneratedImpl> { + + public EJBImplementationGeneratedProcessor(ExtensionPointRegistry registry, + Monitor monitor) { + } + + public QName getArtifactType() { + return null; + } + + public Class<EJBImplementationGeneratedImpl> getModelType() { + // Returns the type of model processed by this processor + return EJBImplementationGeneratedImpl.class; + } + + public EJBImplementationGeneratedImpl read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + return null; + } + + public void resolve(EJBImplementationGeneratedImpl implementation, ModelResolver resolver) throws ContributionResolveException { + implementation.setUnresolved(false); + } + + public void write(EJBImplementationGeneratedImpl implementation, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { + } +} diff --git a/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/JavaEEExtensionImpl.java b/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/JavaEEExtensionImpl.java index c4e180bf82..6934069516 100644 --- a/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/JavaEEExtensionImpl.java +++ b/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/JavaEEExtensionImpl.java @@ -78,6 +78,8 @@ public class JavaEEExtensionImpl implements JavaEEExtension { e.printStackTrace(); } service.setInterfaceContract(ic); + service.getRequiredIntents().add(EJB_INTENT); + componentType.getServices().add(service); } @@ -124,6 +126,7 @@ public class JavaEEExtensionImpl implements JavaEEExtension { e.printStackTrace(); } service.setInterfaceContract(ic); + service.getRequiredIntents().add(EJB_INTENT); addComponentService(composite, component, service); } @@ -175,6 +178,7 @@ public class JavaEEExtensionImpl implements JavaEEExtension { e.printStackTrace(); } service.setInterfaceContract(ic); + service.getRequiredIntents().add(EJB_INTENT); addComponentService(composite, component, service); } @@ -224,9 +228,11 @@ public class JavaEEExtensionImpl implements JavaEEExtension { if (component == null){ component = assemblyFactory.createComponent(); component.setName(componentName); + component.setUnresolved(true); composite.getComponents().add(component); EJBImplementationGenerated implementation = new EJBImplementationGeneratedImpl(); + implementation.setUnresolved(true); component.setImplementation(implementation); } diff --git a/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/JavaEEOptionalExtensionImpl.java b/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/JavaEEOptionalExtensionImpl.java index ad7e54b84f..d1b22c5631 100644 --- a/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/JavaEEOptionalExtensionImpl.java +++ b/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/JavaEEOptionalExtensionImpl.java @@ -289,9 +289,11 @@ public class JavaEEOptionalExtensionImpl implements JavaEEOptionalExtension { if (component == null){ component = assemblyFactory.createComponent(); component.setName(componentName); + component.setUnresolved(true); composite.getComponents().add(component); EJBImplementationGenerated implementation = new EJBImplementationGeneratedImpl(); + implementation.setUnresolved(true); component.setImplementation(implementation); } diff --git a/branches/sca-java-1.x/modules/contribution-jee/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-1.x/modules/contribution-jee/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..b7e0efa75c --- /dev/null +++ b/branches/sca-java-1.x/modules/contribution-jee/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -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.
+
+# $Rev: 685124 $ $Date: 2008-08-12 12:46:19 +0100 (Tue, 12 Aug 2008) $
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.contribution.jee.impl.EJBImplementationGeneratedProcessor;qname=http://dummy_namespace/#dummy.name,model=org.apache.tuscany.sca.contribution.jee.impl.EJBImplementationGeneratedImpl,factory=dummy
diff --git a/branches/sca-java-1.x/modules/implementation-jee/src/main/java/org/apache/tuscany/sca/implementation/jee/xml/JEEImplementationProcessor.java b/branches/sca-java-1.x/modules/implementation-jee/src/main/java/org/apache/tuscany/sca/implementation/jee/xml/JEEImplementationProcessor.java index 53bc9fab32..8ac32f753c 100644 --- a/branches/sca-java-1.x/modules/implementation-jee/src/main/java/org/apache/tuscany/sca/implementation/jee/xml/JEEImplementationProcessor.java +++ b/branches/sca-java-1.x/modules/implementation-jee/src/main/java/org/apache/tuscany/sca/implementation/jee/xml/JEEImplementationProcessor.java @@ -46,12 +46,16 @@ import org.apache.tuscany.sca.contribution.jee.impl.JavaEEApplicationInfoImpl; import org.apache.tuscany.sca.contribution.jee.impl.WebModuleInfoImpl; import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor; import org.apache.tuscany.sca.contribution.resolver.ModelResolver; import org.apache.tuscany.sca.contribution.service.ContributionReadException; import org.apache.tuscany.sca.contribution.service.ContributionResolveException; import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.implementation.jee.JEEImplementation; import org.apache.tuscany.sca.implementation.jee.JEEImplementationFactory; +import org.apache.tuscany.sca.implementation.node.ConfiguredNodeImplementation; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.policy.PolicyFactory; @@ -69,9 +73,14 @@ public class JEEImplementationProcessor extends BaseStAXArtifactProcessor implem private JavaEEExtension jeeExtension; private JavaEEOptionalExtension jeeOptionalExtension; private Monitor monitor; - private PolicyAttachPointProcessor policyProcessor; + private PolicyAttachPointProcessor policyProcessor; - public JEEImplementationProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + private StAXArtifactProcessorExtensionPoint artifactProcessors; + private StAXArtifactProcessor<Composite> compositeProcessor; + + public JEEImplementationProcessor(ExtensionPointRegistry registry, + Monitor monitor) { + ModelFactoryExtensionPoint modelFactories = registry.getExtensionPoint(ModelFactoryExtensionPoint.class); this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); this.policyFactory = modelFactories.getFactory(PolicyFactory.class); this.implementationFactory = modelFactories.getFactory(JEEImplementationFactory.class); @@ -79,6 +88,9 @@ public class JEEImplementationProcessor extends BaseStAXArtifactProcessor implem this.jeeOptionalExtension = modelFactories.getFactory(JavaEEOptionalExtension.class); this.monitor = monitor; this.policyProcessor = new PolicyAttachPointProcessor(policyFactory); + + artifactProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); + compositeProcessor = artifactProcessors.getProcessor(Composite.class); } public QName getArtifactType() { @@ -96,6 +108,8 @@ public class JEEImplementationProcessor extends BaseStAXArtifactProcessor implem // Read an <implementation.jee> element JEEImplementation implementation = implementationFactory.createJEEImplementation(); implementation.setUnresolved(true); + + implementation.setName(IMPLEMENTATION_JEE); // Read the archive attribute String archive = getString(reader, "archive"); @@ -256,6 +270,12 @@ public class JEEImplementationProcessor extends BaseStAXArtifactProcessor implem } } } + + // now resolve the implementation composite as a real composite. + // Any artifacts from an application composite will already be resolved. + // Composite artifacts created on the fly to represent a non-enhanced JEE + // archive need to be resolved. + compositeProcessor.resolve((Composite)implementation, resolver); } implementation.setUnresolved(false); } |