summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.x/modules/contribution-jee/src
diff options
context:
space:
mode:
authorvamsic007 <vamsic007@13f79535-47bb-0310-9956-ffa450edef68>2009-04-25 17:17:11 +0000
committervamsic007 <vamsic007@13f79535-47bb-0310-9956-ffa450edef68>2009-04-25 17:17:11 +0000
commitc4bec56bbd6b8d145ecbe4132e899c5bd89f75ed (patch)
treec7770fc6e3c58dd7822e82656b4d953c30ff2c2d /branches/sca-java-1.x/modules/contribution-jee/src
parent7bccdab8b14f561821b9669de0b47d52bae9caa8 (diff)
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 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@768567 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules/contribution-jee/src')
-rw-r--r--branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObject.java32
-rw-r--r--branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObjectModelResolver.java73
-rw-r--r--branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/ModelObjectImpl.java51
-rw-r--r--branches/sca-java-1.x/modules/contribution-jee/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver3
4 files changed, 158 insertions, 1 deletions
diff --git a/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObject.java b/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObject.java
new file mode 100644
index 0000000000..e981339733
--- /dev/null
+++ b/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObject.java
@@ -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);
+}
diff --git a/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObjectModelResolver.java b/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObjectModelResolver.java
new file mode 100644
index 0000000000..aa24dcac2c
--- /dev/null
+++ b/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/ModelObjectModelResolver.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.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;
+ }
+}
diff --git a/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/ModelObjectImpl.java b/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/ModelObjectImpl.java
new file mode 100644
index 0000000000..95050dfd88
--- /dev/null
+++ b/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/ModelObjectImpl.java
@@ -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;
+ }
+}
diff --git a/branches/sca-java-1.x/modules/contribution-jee/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/branches/sca-java-1.x/modules/contribution-jee/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
index 8aae799e5b..90ff87e0b1 100644
--- a/branches/sca-java-1.x/modules/contribution-jee/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
+++ b/branches/sca-java-1.x/modules/contribution-jee/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
@@ -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