summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/core-spi/src/main
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2011-03-18 03:00:29 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2011-03-18 03:00:29 +0000
commit148ad1144183b0e24cc214dfa527f09efa7585d4 (patch)
tree11f2ce9c6a1ff43b0c9c57cfd86fb84759728545 /sca-java-2.x/trunk/modules/core-spi/src/main
parent0f30fc3fd36913f58c179176b55100623e4dadcb (diff)
Add servlet scoped Node lifecycle support for web applications
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1082810 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/core-spi/src/main')
-rw-r--r--sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java60
1 files changed, 47 insertions, 13 deletions
diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java
index 6605ff3fc7..6e6df507c2 100644
--- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java
+++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java
@@ -19,6 +19,9 @@
package org.apache.tuscany.sca.context;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.EndpointReference;
@@ -35,7 +38,6 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentContext;
* @version $Rev$ $Date$
*/
public class CompositeContext {
-
protected ExtensionPointRegistry extensionPointRegistry;
protected EndpointRegistry endpointRegistry;
protected ComponentContextFactory componentContextFactory;
@@ -43,8 +45,15 @@ public class CompositeContext {
protected String nodeURI;
protected String domainURI;
protected Definitions systemDefinitions;
-
- public CompositeContext(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry, Composite domainComposite, String domainURI, String nodeURI, Definitions systemDefinitions) {
+
+ protected Map<String, Object> attributes = new HashMap<String, Object>();
+
+ public CompositeContext(ExtensionPointRegistry registry,
+ EndpointRegistry endpointRegistry,
+ Composite domainComposite,
+ String domainURI,
+ String nodeURI,
+ Definitions systemDefinitions) {
this.extensionPointRegistry = registry;
this.endpointRegistry = endpointRegistry;
ContextFactoryExtensionPoint contextFactories = registry.getExtensionPoint(ContextFactoryExtensionPoint.class);
@@ -53,12 +62,12 @@ public class CompositeContext {
this.domainURI = domainURI;
this.nodeURI = nodeURI;
this.systemDefinitions = systemDefinitions;
- }
-
+ }
+
public CompositeContext(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry) {
this(registry, endpointRegistry, null, "default", "default", null);
}
-
+
/**
* @return
*/
@@ -91,13 +100,14 @@ public class CompositeContext {
RuntimeComponentContext componentContext =
(RuntimeComponentContext)componentContextFactory.createComponentContext(this, runtimeComponent);
runtimeComponent.setComponentContext(componentContext);
- }
+ }
+
/**
*
* @param endpointReference
*/
public void bindEndpointReference(EndpointReference endpointReference) {
-
+
}
/**
@@ -113,13 +123,13 @@ public class CompositeContext {
* @return The EndpointRegistry for this node
*/
public EndpointRegistry getEndpointRegistry() {
- return endpointRegistry;
+ return endpointRegistry;
}
-
+
public Composite getDomainComposite() {
- return domainComposite;
+ return domainComposite;
}
-
+
public String getNodeURI() {
return nodeURI;
}
@@ -127,7 +137,7 @@ public class CompositeContext {
public String getDomainURI() {
return domainURI;
}
-
+
/**
* The system definitions that result from starting the runtime.
* TODO - these can be null when the SCAClient starts the runtime
@@ -137,4 +147,28 @@ public class CompositeContext {
public Definitions getSystemDefinitions() {
return systemDefinitions;
}
+
+ /**
+ * Look up an attribute value by name
+ * @param <T>
+ * @param name The name of the attribute
+ * @return The value of the attribute
+ */
+ @SuppressWarnings("unchecked")
+ public <T> T getAttribute(String name) {
+ return (T)attributes.get(name);
+ }
+
+ /**
+ * Set the value of an attribute
+ * @param name The name of the attribute
+ * @param value
+ */
+ public void setAttribute(String name, Object value) {
+ attributes.put(name, value);
+ }
+
+ public Map<String, Object> getAttributes() {
+ return attributes;
+ }
}