You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by va...@apache.org on 2009/04/25 19:17:11 UTC
svn commit: r768567 - in /tuscany/branches/sca-java-1.x/modules:
contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/
contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/
contribution-jee/src/main/resources/ME...
Author: vamsic007
Date: Sat Apr 25 17:17:11 2009
New Revision: 768567
URL: http://svn.apache.org/viewvc?rev=768567&view=rev
Log:
TUSCANY-2977 determine implementation.jee component type from application composite if one is available
o Added a model object resolver to obtain application composite using uri
Added:
tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObject.java (with props)
tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObjectModelResolver.java (with props)
tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/ModelObjectImpl.java (with props)
Modified:
tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
tuscany/branches/sca-java-1.x/modules/implementation-jee/src/main/java/org/apache/tuscany/sca/implementation/jee/xml/JEEImplementationProcessor.java
Added: tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObject.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObject.java?rev=768567&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObject.java (added)
+++ tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObject.java Sat Apr 25 17:17:11 2009
@@ -0,0 +1,32 @@
+/*
+ * 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;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface ModelObject {
+ URI getUri();
+ void setUri(URI uri);
+
+ Object getObject();
+ void setObject(Object obj);
+}
Propchange: tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObject.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObject.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObject.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObjectModelResolver.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObjectModelResolver.java?rev=768567&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObjectModelResolver.java (added)
+++ tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObjectModelResolver.java Sat Apr 25 17:17:11 2009
@@ -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.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.jee.impl.ModelObjectImpl;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * A Model Resolver for obtaining any model object using URI.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ModelObjectModelResolver implements ModelResolver {
+
+ private Map<URI, ModelObject> map = new HashMap<URI, ModelObject>();
+ private Contribution contribution;
+
+ public ModelObjectModelResolver(Contribution contribution, ModelFactoryExtensionPoint modelFactories) {
+ this.contribution = contribution;
+ }
+
+ public void addModel(Object resolved) {
+ map.put(((ModelObject)resolved).getUri(), (ModelObject)resolved);
+ }
+
+ public Object removeModel(Object resolved) {
+ return map.remove(((ModelObject)resolved).getUri());
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved) {
+ URI uri = ((ModelObject)unresolved).getUri();
+ if (uri != null) {
+ ModelObject resolved = (ModelObject) map.get(uri);
+ if (resolved != null) {
+ return modelClass.cast(resolved);
+ } else {
+ for(Artifact artifact : contribution.getArtifacts()) {
+ if(artifact.getURI().equals(uri.toString())) {
+ resolved = new ModelObjectImpl();
+ resolved.setUri(uri);
+ resolved.setObject(artifact.getModel());
+ return modelClass.cast(resolved);
+ }
+ }
+ }
+ }
+ return unresolved;
+ }
+}
Propchange: tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObjectModelResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObjectModelResolver.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObjectModelResolver.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/ModelObjectImpl.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/ModelObjectImpl.java?rev=768567&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/ModelObjectImpl.java (added)
+++ tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/ModelObjectImpl.java Sat Apr 25 17:17:11 2009
@@ -0,0 +1,51 @@
+/*
+ * 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 java.net.URI;
+
+import org.apache.tuscany.sca.contribution.jee.ModelObject;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ModelObjectImpl implements ModelObject {
+
+ private URI uri;
+ private Object obj;
+
+ public ModelObjectImpl() {
+ }
+
+ public Object getObject() {
+ return obj;
+ }
+
+ public void setObject(Object obj) {
+ this.obj = obj;
+ }
+
+ public URI getUri() {
+ return uri;
+ }
+
+ public void setUri(URI uri) {
+ this.uri = uri;
+ }
+}
Propchange: tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/ModelObjectImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/ModelObjectImpl.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/ModelObjectImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver?rev=768567&r1=768566&r2=768567&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver (original)
+++ tuscany/branches/sca-java-1.x/modules/contribution-jee/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver Sat Apr 25 17:17:11 2009
@@ -17,4 +17,5 @@
org.apache.tuscany.sca.contribution.jee.WebModuleModelResolver;model=org.apache.tuscany.sca.contribution.jee.WebModuleInfo
org.apache.tuscany.sca.contribution.jee.EjbModuleModelResolver;model=org.apache.tuscany.sca.contribution.jee.EjbModuleInfo
-org.apache.tuscany.sca.contribution.jee.JavaEEApplicationModelResolver;model=org.apache.tuscany.sca.contribution.jee.JavaEEApplicationInfo
\ No newline at end of file
+org.apache.tuscany.sca.contribution.jee.JavaEEApplicationModelResolver;model=org.apache.tuscany.sca.contribution.jee.JavaEEApplicationInfo
+org.apache.tuscany.sca.contribution.jee.ModelObjectModelResolver;model=org.apache.tuscany.sca.contribution.jee.ModelObject
Modified: tuscany/branches/sca-java-1.x/modules/implementation-jee/src/main/java/org/apache/tuscany/sca/implementation/jee/xml/JEEImplementationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/implementation-jee/src/main/java/org/apache/tuscany/sca/implementation/jee/xml/JEEImplementationProcessor.java?rev=768567&r1=768566&r2=768567&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/implementation-jee/src/main/java/org/apache/tuscany/sca/implementation/jee/xml/JEEImplementationProcessor.java (original)
+++ tuscany/branches/sca-java-1.x/modules/implementation-jee/src/main/java/org/apache/tuscany/sca/implementation/jee/xml/JEEImplementationProcessor.java Sat Apr 25 17:17:11 2009
@@ -29,14 +29,17 @@
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.xml.Constants;
import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.jee.ModelObject;
import org.apache.tuscany.sca.contribution.jee.EjbModuleInfo;
import org.apache.tuscany.sca.contribution.jee.ExternalEarInfo;
import org.apache.tuscany.sca.contribution.jee.JavaEEApplicationInfo;
import org.apache.tuscany.sca.contribution.jee.JavaEEExtension;
import org.apache.tuscany.sca.contribution.jee.JavaEEOptionalExtension;
import org.apache.tuscany.sca.contribution.jee.WebModuleInfo;
+import org.apache.tuscany.sca.contribution.jee.impl.ModelObjectImpl;
import org.apache.tuscany.sca.contribution.jee.impl.EjbModuleInfoImpl;
import org.apache.tuscany.sca.contribution.jee.impl.JavaEEApplicationInfoImpl;
import org.apache.tuscany.sca.contribution.jee.impl.WebModuleInfoImpl;
@@ -160,36 +163,84 @@
}
if(moduleInfo instanceof WebModuleInfo) {
- if(jeeOptionalExtension != null) {
- ComponentType ct = jeeOptionalExtension.createImplementationJeeComponentType((WebModuleInfo)moduleInfo);
- implementation.getReferences().addAll(ct.getReferences());
- implementation.getProperties().addAll(ct.getProperties());
+ // Check for web composite
+ ModelObject unresolved = new ModelObjectImpl();
+ unresolved.setUri(URI.create("WEB-INF/web.composite"));
+ ModelObject resolved = resolver.resolveModel(ModelObject.class, unresolved);
+ if(resolved != unresolved) {
+ // Found web composite
+ Composite appComposite = (Composite)resolved.getObject();
+ implementation.getServices().addAll(appComposite.getServices());
+ implementation.getReferences().addAll(appComposite.getReferences());
+ implementation.getProperties().addAll(appComposite.getProperties());
+ }
+
+ // TODO: Obtain includeDefaults value from the composite
+ boolean includeDefaults = false;
+
+ if(includeDefaults || resolved == unresolved) {
+ if(jeeOptionalExtension != null) {
+ ComponentType ct = jeeOptionalExtension.createImplementationJeeComponentType((WebModuleInfo)moduleInfo);
+ implementation.getReferences().addAll(ct.getReferences());
+ implementation.getProperties().addAll(ct.getProperties());
+ }
}
- // TODO: check for web composite
} else if(moduleInfo instanceof EjbModuleInfo) {
- if(jeeExtension != null) {
- ComponentType ct = jeeExtension.createImplementationJeeComponentType((EjbModuleInfo)moduleInfo);
- implementation.getServices().addAll(ct.getServices());
- }
- if(jeeOptionalExtension != null) {
- ComponentType ct = jeeOptionalExtension.createImplementationJeeComponentType((EjbModuleInfo)moduleInfo);
- implementation.getServices().addAll(ct.getServices());
- implementation.getReferences().addAll(ct.getReferences());
- implementation.getProperties().addAll(ct.getProperties());
+ // Check for ejb-jar composite
+ ModelObject unresolved = new ModelObjectImpl();
+ unresolved.setUri(URI.create("META-INF/ejb-jar.composite"));
+ ModelObject resolved = resolver.resolveModel(ModelObject.class, unresolved);
+ if(resolved != unresolved) {
+ // Found ejb-jar composite
+ Composite appComposite = (Composite)resolved.getObject();
+ implementation.getServices().addAll(appComposite.getServices());
+ implementation.getReferences().addAll(appComposite.getReferences());
+ implementation.getProperties().addAll(appComposite.getProperties());
+ }
+
+ // TODO: Obtain includeDefaults value from the composite
+ boolean includeDefaults = false;
+
+ if(includeDefaults || resolved == unresolved) {
+ if(jeeExtension != null) {
+ ComponentType ct = jeeExtension.createImplementationJeeComponentType((EjbModuleInfo)moduleInfo);
+ implementation.getServices().addAll(ct.getServices());
+ }
+ if(jeeOptionalExtension != null) {
+ ComponentType ct = jeeOptionalExtension.createImplementationJeeComponentType((EjbModuleInfo)moduleInfo);
+ implementation.getServices().addAll(ct.getServices());
+ implementation.getReferences().addAll(ct.getReferences());
+ implementation.getProperties().addAll(ct.getProperties());
+ }
}
- // TODO: check for ejb-jar composite
} else if(moduleInfo instanceof JavaEEApplicationInfo) {
- if(jeeExtension != null) {
- ComponentType ct = jeeExtension.createImplementationJeeComponentType((JavaEEApplicationInfo)moduleInfo);
- implementation.getServices().addAll(ct.getServices());
- }
- if(jeeOptionalExtension != null) {
- ComponentType ct = jeeOptionalExtension.createImplementationJeeComponentType((JavaEEApplicationInfo)moduleInfo);
- implementation.getServices().addAll(ct.getServices());
- implementation.getReferences().addAll(ct.getReferences());
- implementation.getProperties().addAll(ct.getProperties());
+ // Check for application composite
+ ModelObject unresolved = new ModelObjectImpl();
+ unresolved.setUri(URI.create("META-INF/application.composite"));
+ ModelObject resolved = resolver.resolveModel(ModelObject.class, unresolved);
+ if(resolved != unresolved) {
+ // Found application composite
+ Composite appComposite = (Composite)resolved.getObject();
+ implementation.getServices().addAll(appComposite.getServices());
+ implementation.getReferences().addAll(appComposite.getReferences());
+ implementation.getProperties().addAll(appComposite.getProperties());
+ }
+
+ // TODO: Obtain includeDefaults value from the composite
+ boolean includeDefaults = false;
+
+ if(includeDefaults || resolved == unresolved) {
+ if(jeeExtension != null) {
+ ComponentType ct = jeeExtension.createImplementationJeeComponentType((JavaEEApplicationInfo)moduleInfo);
+ implementation.getServices().addAll(ct.getServices());
+ }
+ if(jeeOptionalExtension != null) {
+ ComponentType ct = jeeOptionalExtension.createImplementationJeeComponentType((JavaEEApplicationInfo)moduleInfo);
+ implementation.getServices().addAll(ct.getServices());
+ implementation.getReferences().addAll(ct.getReferences());
+ implementation.getProperties().addAll(ct.getProperties());
+ }
}
- // TODO: check for application composite
}
}
implementation.setUnresolved(false);