You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by me...@apache.org on 2007/01/01 00:28:10 UTC

svn commit: r491510 - /incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java

Author: meerajk
Date: Sun Dec 31 15:28:07 2006
New Revision: 491510

URL: http://svn.apache.org/viewvc?view=rev&rev=491510
Log:
Added dependency to management service.

Modified:
    incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java

Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java?view=diff&rev=491510&r1=491509&r2=491510
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java Sun Dec 31 15:28:07 2006
@@ -29,6 +29,7 @@
 import org.w3c.dom.Document;
 
 import org.apache.tuscany.spi.CoreRuntimeException;
+import org.apache.tuscany.spi.annotation.Autowire;
 import org.apache.tuscany.spi.builder.Connector;
 import org.apache.tuscany.spi.builder.WiringException;
 import org.apache.tuscany.spi.component.AtomicComponent;
@@ -47,6 +48,7 @@
 import org.apache.tuscany.spi.component.TargetResolutionException;
 import org.apache.tuscany.spi.event.Event;
 import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.services.management.ManagementService;
 import org.apache.tuscany.spi.wire.InboundWire;
 import org.apache.tuscany.spi.wire.OutboundWire;
 
@@ -56,6 +58,7 @@
  * @version $$Rev$$ $$Date$$
  */
 public abstract class CompositeComponentExtension extends AbstractComponentExtension implements CompositeComponent {
+    
     protected final Map<String, SCAObject> children = new ConcurrentHashMap<String, SCAObject>();
     protected final List<Service> services = new ArrayList<Service>();
     protected final List<Reference> references = new ArrayList<Reference>();
@@ -73,6 +76,11 @@
     protected final Map<Class, InboundWire> systemAutowireInternal = new ConcurrentHashMap<Class, InboundWire>();
     protected final Map<Class, InboundWire> systemAutowireExternal = new ConcurrentHashMap<Class, InboundWire>();
 
+    /**
+     * Management service to use.
+     */
+    private ManagementService managementService;
+    
     protected CompositeComponentExtension(String name,
                                           CompositeComponent parent,
                                           Connector connector,
@@ -81,6 +89,15 @@
         this.propertyValues = propertyValues;
         this.connector = connector;
     }
+    
+    /**
+     * Autowires the management service.
+     * @param managementService Management service used for registering components.
+     */
+    @Autowire
+    public final void setManagementService(ManagementService managementService) {
+        this.managementService = managementService;
+    }
 
     public Scope getScope() {
         return Scope.SYSTEM;
@@ -152,7 +169,7 @@
             children.put(child.getName(), child);
         }
         if (child instanceof Service) {
-            Service service = (Service) child;
+            Service service = (Service)child;
             synchronized (services) {
                 if (service.isSystem()) {
                     systemServices.add(service);
@@ -162,7 +179,7 @@
             }
             registerAutowire(service);
         } else if (child instanceof Reference) {
-            Reference reference = (Reference) child;
+            Reference reference = (Reference)child;
             synchronized (references) {
                 if (reference.isSystem()) {
                     systemReferenceBindings.add(reference);
@@ -172,10 +189,10 @@
             }
             registerAutowire(reference);
         } else if (child instanceof AtomicComponent) {
-            AtomicComponent atomic = (AtomicComponent) child;
+            AtomicComponent atomic = (AtomicComponent)child;
             registerAutowire(atomic);
         } else if (child instanceof CompositeComponent) {
-            CompositeComponent component = (CompositeComponent) child;
+            CompositeComponent component = (CompositeComponent)child;
             if (lifecycleState == RUNNING && component.getLifecycleState() == UNINITIALIZED) {
                 component.start();
             }
@@ -184,7 +201,6 @@
         }
     }
 
-
     public void addOutboundWire(OutboundWire wire) {
 
     }
@@ -206,7 +222,7 @@
         if (!(object instanceof Service)) {
             return null;
         }
-        Service service = (Service) object;
+        Service service = (Service)object;
         for (ServiceBinding binding : service.getServiceBindings()) {
             InboundWire wire = binding.getInboundWire();
             if (bindingType.equals(wire.getBindingType())) {
@@ -231,7 +247,7 @@
     public Service getService(String name) {
         SCAObject object = children.get(name);
         if (object instanceof Service) {
-            return (Service) object;
+            return (Service)object;
         }
         return null;
     }
@@ -239,7 +255,7 @@
     public Service getSystemService(String name) {
         SCAObject object = systemChildren.get(name);
         if (object instanceof Service) {
-            return (Service) object;
+            return (Service)object;
         }
         return null;
     }
@@ -248,6 +264,7 @@
         InboundWire wire = autowireInternal.get(instanceInterface);
         if (wire != null) {
             SCAObject parent = wire.getContainer();
+
             if (parent instanceof AtomicComponent || parent instanceof ReferenceBinding
                 || parent instanceof ServiceBinding) {
                 return wire;
@@ -263,7 +280,6 @@
         }
     }
 
-
     public InboundWire resolveSystemAutowire(Class<?> instanceInterface) throws TargetResolutionException {
         InboundWire wire = systemAutowireInternal.get(instanceInterface);
         if (wire != null) {
@@ -278,7 +294,6 @@
         }
     }
 
-
     public InboundWire resolveExternalAutowire(Class<?> instanceInterface) throws TargetResolutionException {
         InboundWire wire = autowireExternal.get(instanceInterface);
         if (wire != null) {
@@ -358,8 +373,7 @@
         }
     }
 
-    protected void registerAutowireExternal(Class<?> interfaze, Service service)
-        throws InvalidAutowireInterface {
+    protected void registerAutowireExternal(Class<?> interfaze, Service service) throws InvalidAutowireInterface {
         if (interfaze == null) {
             // The ServiceContract is not from Java
             return;
@@ -376,8 +390,7 @@
             // pick the first binding until autowire allows multiple interfaces
             InboundWire wire = bindings.get(0).getInboundWire();
             if (!interfaze.isAssignableFrom(wire.getServiceContract().getInterfaceClass())) {
-                throw new InvalidAutowireInterface("Matching inbound wire not found for interface",
-                    interfaze.getName());
+                throw new InvalidAutowireInterface("Matching inbound wire not found for interface", interfaze.getName());
             }
             systemAutowireExternal.put(interfaze, wire);
         } else {
@@ -399,8 +412,7 @@
         }
     }
 
-    protected void registerAutowireInternal(Class<?> interfaze, ServiceBinding binding)
-        throws InvalidAutowireInterface {
+    protected void registerAutowireInternal(Class<?> interfaze, ServiceBinding binding) throws InvalidAutowireInterface {
         if (interfaze == null) {
             // The ServiceContract is not from Java
             return;
@@ -439,8 +451,7 @@
             // pick the first binding until autowire allows multiple interfaces
             InboundWire wire = bindings.get(0).getInboundWire();
             if (!interfaze.isAssignableFrom(wire.getServiceContract().getInterfaceClass())) {
-                throw new InvalidAutowireInterface("Matching inbound wire not found for interface",
-                    interfaze.getName());
+                throw new InvalidAutowireInterface("Matching inbound wire not found for interface", interfaze.getName());
             }
             systemAutowireInternal.put(interfaze, wire);
         } else {



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org