You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2006/03/08 17:14:30 UTC

svn commit: r384246 [2/2] - in /incubator/servicemix/trunk: servicemix-assembly/ servicemix-components/src/test/java/org/apache/servicemix/components/script/ servicemix-components/src/test/resources/org/apache/servicemix/components/email/ servicemix-co...

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Registry.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Registry.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Registry.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Registry.java Wed Mar  8 08:14:26 2006
@@ -20,7 +20,6 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import javax.jbi.JBIException;
 import javax.jbi.component.Component;
@@ -35,7 +34,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.servicemix.jbi.container.ActivationSpec;
 import org.apache.servicemix.jbi.container.EnvironmentContext;
-import org.apache.servicemix.jbi.container.JBIContainer;
 import org.apache.servicemix.jbi.container.SubscriptionSpec;
 import org.apache.servicemix.jbi.deployment.ServiceAssembly;
 import org.apache.servicemix.jbi.deployment.ServiceUnit;
@@ -69,7 +67,7 @@
     public Registry() {
         this.componentRegistry = new ComponentRegistry(this);
         this.endpointRegistry = new EndpointRegistry(this);
-        this.subscriptionRegistry = new SubscriptionRegistry();
+        this.subscriptionRegistry = new SubscriptionRegistry(this);
         this.serviceAssemblyRegistry = new ServiceAssemblyRegistry(this);
         this.serviceUnits = new ConcurrentHashMap();
     }
@@ -82,18 +80,6 @@
         return "Registry of Components/SU's and Endpoints";
     }
 
-    /**
-     * Initialize the Registry
-     * 
-     * @param container
-     * @throws JBIException
-     */
-    public void init(JBIContainer container) throws JBIException {
-        super.init(container);
-        this.componentRegistry.setContainerName(container.getName());
-        this.subscriptionRegistry.init(this);
-    }
-    
     protected Class getServiceMBean() {
         return RegistryMBean.class;
     }
@@ -167,8 +153,9 @@
      * @return EndPointReference
      * @throws JBIException
      */
-    public synchronized ServiceEndpoint activateEndpoint(ComponentContextImpl context, QName serviceName,
-            String endpointName) throws JBIException {
+    public ServiceEndpoint activateEndpoint(ComponentContextImpl context, 
+                                            QName serviceName,
+                                            String endpointName) throws JBIException {
         InternalEndpoint result = endpointRegistry.registerInternalEndpoint(context, serviceName, endpointName);
         return result;
     }
@@ -208,8 +195,8 @@
         }
         AbstractServiceEndpoint se = (AbstractServiceEndpoint) endpoint;
         // TODO: what if the endpoint is linked or dynamic
-        Component component = getComponent(se.getComponentNameSpace());
-        return component.getServiceDescription(endpoint);
+        ComponentMBeanImpl component = getComponent(se.getComponentNameSpace());
+        return component.getComponent().getServiceDescription(endpoint);
     }
 
     /**
@@ -225,9 +212,9 @@
      * cannot be resolved.
      */
     public ServiceEndpoint resolveEndpointReference(DocumentFragment epr) {
-        Collection connectors = getLocalComponentConnectors();
+        Collection connectors = getComponents();
         for (Iterator iter = connectors.iterator(); iter.hasNext();) {
-            LocalComponentConnector connector = (LocalComponentConnector) iter.next();
+            ComponentMBeanImpl connector = (ComponentMBeanImpl) iter.next();
             ServiceEndpoint se = connector.getComponent().resolveEndpointReference(epr);
             if (se != null) {
                 return new DynamicEndpoint(connector.getComponentNameSpace(), se, epr);  
@@ -304,121 +291,35 @@
      * @return ComponentConnector
      * @throws JBIException
      */
-    public LocalComponentConnector registerComponent(ComponentNameSpace name, String description,Component component,
-            boolean binding, boolean service) throws JBIException {
-        LocalComponentConnector result = componentRegistry.registerComponent(name,description, component, binding, service);
-        return result;
+    public ComponentMBeanImpl registerComponent(ComponentNameSpace name, 
+                                                String description,
+                                                Component component,
+                                                boolean binding, 
+                                                boolean service) throws JBIException {
+        return componentRegistry.registerComponent(name,description, component, binding, service);
     }
 
     /**
      * @param component
      * @return ComponentConnector
      */
-    public ComponentConnector deregisterComponent(Component component) {
-        ComponentConnector result = componentRegistry.deregisterComponent(component);
-        return result;
+    public void deregisterComponent(ComponentMBeanImpl component) {
+        componentRegistry.deregisterComponent(component);
     }
 
     /**
      * @return all local ComponentConnectors
      */
-    public Collection getLocalComponentConnectors() {
-        return componentRegistry.getLocalComponentConnectors();
-    }
-
-    /**
-     * Get a registered ComponentConnector from it's id
-     * 
-     * @param id
-     * @return the ComponentConnector or null
-     */
-    public ComponentConnector getComponentConnector(ComponentNameSpace id) {
-        return componentRegistry.getComponentConnector(id);
-    }
-    
-    
-    /**
-     * Add a ComponentConnector to ComponentRegistry Should be called for adding remote ComponentConnectors from other
-     * Containers
-     * 
-     * @param connector
-     */
-    public void addRemoteComponentConnector(ComponentConnector connector) {
-        componentRegistry.addComponentConnector(connector);
-    }
-
-    /**
-     * Remove a ComponentConnector
-     * 
-     * @param connector
-     */
-    public void removeRemoteComponentConnector(ComponentConnector connector) {
-        componentRegistry.removeComponentConnector(connector.getComponentNameSpace());
-    }
-
-    /**
-     * Update a ComponentConnector
-     * 
-     * @param connector
-     */
-    public void updateRemoteComponentConnector(ComponentConnector connector) {
-        componentRegistry.updateConnector(connector);
-    }
-
-    /**
-     * Get a locally create ComponentConnector
-     * 
-     * @param id - id of the ComponentConnector
-     * @return ComponentConnector or null if not found
-     */
-    public LocalComponentConnector getLocalComponentConnector(ComponentNameSpace id) {
-        return componentRegistry.getLocalComponentConnector(id);
-    }
-    
-    /**
-     * Get a locally create ComponentConnector
-     * 
-     * @param id - id of the ComponentConnector
-     * @return ComponentConnector or null if not found
-     */
-    public LocalComponentConnector getLocalComponentConnector(String componentName) {
-        ComponentNameSpace cns = new ComponentNameSpace(container.getName(), componentName, componentName);
-        return componentRegistry.getLocalComponentConnector(cns);
-    }
-    
-    /**
-     * Find existence of a Component locally registered to this Container
-     * @param componentName
-     * @return true if the Component exists
-     */
-    public boolean isLocalComponentRegistered(String componentName){
-        return componentRegistry.isLocalComponentRegistered(componentName);
-    }
-
-    /**
-     * Get the ComponentConnector associated with the componet
-     * 
-     * @param component
-     * @return the associated ComponentConnector
-     */
-    public LocalComponentConnector getComponentConnector(Component component) {
-        return componentRegistry.getComponentConnector(component);
+    public Collection getComponents() {
+        return componentRegistry.getComponents();
     }
 
     /**
-     * 
-     * @return Collection of ComponentConnectors held by the registry
-     */
-    public Collection getComponentConnectors() {
-        return componentRegistry.getComponentConnectors();
-    }
-    
-    /**
      * Get a Component
      * @param cns
      * @return the Component
      */
-    public Component getComponent(ComponentNameSpace cns) {
+    public ComponentMBeanImpl getComponent(ComponentNameSpace cns) {
         return componentRegistry.getComponent(cns);
     }
     
@@ -427,66 +328,20 @@
      * @param name
      * @return the Componment
      */
-    public Component getComponent(String name) {
+    public ComponentMBeanImpl getComponent(String name) {
         ComponentNameSpace cns = new ComponentNameSpace(container.getName(), name, name);
         return getComponent(cns);
     }
     
     /**
-     * Get the ObjectName for the MBean managing the Component
-     * @param name
-     * @return ObjectName or null
-     */
-    public ObjectName getComponentObjectName(String name){
-        ObjectName  result = null;
-        ComponentNameSpace cns = new ComponentNameSpace(container.getName(), name, name);
-        LocalComponentConnector lcc = getLocalComponentConnector(cns);
-        if (lcc != null){
-            result = lcc.getMBeanName();
-        }
-        return result;
-        
-    }
-    
-    /**
-     * Check if a given JBI Installable Component is a Binding Component.
-     * @param name - the unique name of the component
-     * @return true if the component is a binding
-     */
-    public boolean isBinding(String name){
-        boolean result = false;
-        ComponentNameSpace cns = new ComponentNameSpace(container.getName(), name, name);
-        LocalComponentConnector lcc = getLocalComponentConnector(cns);
-        if (lcc != null){
-            result = lcc.isBinding();
-        }
-        return result;
-    }
-    
-    /**
-     * Check if a given JBI Component is a service engine.
-     * @param name - the unique name of the component
-     * @return true if the component is a service engine
-     */
-    public boolean isEngine(String name){
-        boolean result = false;
-        ComponentNameSpace cns = new ComponentNameSpace(container.getName(), name, name);
-        LocalComponentConnector lcc = getLocalComponentConnector(cns);
-        if (lcc != null){
-            result = lcc.isService();
-        }
-        return result;
-    }
-    
-    /**
      * Get a list of all engines currently installed.
      * @return array of JMX object names of all installed SEs.
      */
-    public ObjectName[] getEngineComponents(){
+    public ObjectName[] getEngineComponents() {
         ObjectName[] result = null;
         List tmpList = new ArrayList();
-        for (Iterator i = getLocalComponentConnectors().iterator(); i.hasNext();){
-            LocalComponentConnector lcc = (LocalComponentConnector) i.next();
+        for (Iterator i = getComponents().iterator(); i.hasNext();){
+            ComponentMBeanImpl lcc = (ComponentMBeanImpl) i.next();
             if (!lcc.isPojo() && lcc.isService() && lcc.getMBeanName() != null){
                 tmpList.add(lcc.getMBeanName());
             }
@@ -498,50 +353,40 @@
     }
     
     /**
-     * Get a list of all pojos currently installed.
-     * @return array of JMX object names of all installed PJOJO Conponents.
+     * Get a list of all binding components currently installed.
+     * @return array of JMX object names of all installed BCs.
      */
-    public ObjectName[] getPojoComponents(){
+    public ObjectName[] getBindingComponents() {
         ObjectName[] result = null;
         List tmpList = new ArrayList();
-        for (Iterator i = getLocalComponentConnectors().iterator(); i.hasNext();){
-            LocalComponentConnector lcc = (LocalComponentConnector) i.next();
-            if (lcc.isPojo() && lcc.getMBeanName() != null){
+        for (Iterator i = getComponents().iterator(); i.hasNext();){
+            ComponentMBeanImpl lcc = (ComponentMBeanImpl) i.next();
+            if (!lcc.isPojo() && lcc.isBinding() && lcc.getMBeanName() != null){
                 tmpList.add(lcc.getMBeanName());
             }
         }
         result = new ObjectName[tmpList.size()];
         tmpList.toArray(result);
         return result;
-        
     }
-    
+
     /**
-     * Get a list of all binding components currently installed.
-     * @return array of JMX object names of all installed BCs.
+     * Get a list of all pojos currently installed.
+     * @return array of JMX object names of all installed PJOJO Conponents.
      */
-    public ObjectName[] getBindingComponents(){
+    public ObjectName[] getPojoComponents() {
         ObjectName[] result = null;
         List tmpList = new ArrayList();
-        for (Iterator i = getLocalComponentConnectors().iterator(); i.hasNext();){
-            LocalComponentConnector lcc = (LocalComponentConnector) i.next();
-            if (!lcc.isPojo() && lcc.isBinding() && lcc.getMBeanName() != null){
+        for (Iterator i = getComponents().iterator(); i.hasNext();){
+            ComponentMBeanImpl lcc = (ComponentMBeanImpl) i.next();
+            if (lcc.isPojo() && lcc.getMBeanName() != null){
                 tmpList.add(lcc.getMBeanName());
             }
         }
         result = new ObjectName[tmpList.size()];
         tmpList.toArray(result);
         return result;
-    }
-
-
-    /**
-     * Get set of Components
-     * 
-     * @return a Set of Component objects
-     */
-    public Set getComponents() {
-        return componentRegistry.getComponents();
+        
     }
     
     /**

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceAssemblyLifeCycle.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceAssemblyLifeCycle.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceAssemblyLifeCycle.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceAssemblyLifeCycle.java Wed Mar  8 08:14:26 2006
@@ -39,8 +39,9 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.servicemix.jbi.deployment.Connection;
 import org.apache.servicemix.jbi.deployment.Consumes;
-import org.apache.servicemix.jbi.deployment.Descriptor;
+import org.apache.servicemix.jbi.deployment.DescriptorFactory;
 import org.apache.servicemix.jbi.deployment.ServiceAssembly;
+import org.apache.servicemix.jbi.deployment.Services;
 import org.apache.servicemix.jbi.event.ServiceAssemblyEvent;
 import org.apache.servicemix.jbi.event.ServiceAssemblyListener;
 import org.apache.servicemix.jbi.management.AttributeInfoHelper;
@@ -80,10 +81,10 @@
      * @param sa
      * @param stateFile
      */
-    ServiceAssemblyLifeCycle(ServiceAssembly sa, 
-                             String[] suKeys, 
-                             File stateFile,
-                             Registry registry) {
+    public ServiceAssemblyLifeCycle(ServiceAssembly sa, 
+                                    String[] suKeys, 
+                                    File stateFile,
+                                    Registry registry) {
         this.serviceAssembly = sa;
         this.stateFile = stateFile;
         this.registry = registry;
@@ -279,7 +280,7 @@
     
     public String getDescriptor() {
         File saDir = registry.getEnvironmentContext().getSARootDirectory(getName());
-        return AutoDeploymentService.getDescriptorAsText(saDir);
+        return DescriptorFactory.getDescriptorAsText(saDir);
     }
 
     /**
@@ -363,9 +364,9 @@
     
     protected String getLinkType(QName svc, String ep) {
         for (int i = 0; i < sus.length; i++) {
-            Descriptor d = AutoDeploymentService.buildDescriptor(sus[i].getServiceUnitRootPath());
-            if (d != null && d.getServices() != null && d.getServices().getConsumes() != null) {
-                Consumes[] consumes = d.getServices().getConsumes();
+            Services s = sus[i].getServices();
+            if (s != null && s.getConsumes() != null) {
+                Consumes[] consumes = s.getConsumes();
                 for (int j = 0; j < consumes.length; j++) {
                     if (svc.equals(consumes[j].getServiceName()) &&
                         ep.equals(consumes[j].getEndpointName())) {

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceUnitLifeCycle.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceUnitLifeCycle.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceUnitLifeCycle.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceUnitLifeCycle.java Wed Mar  8 08:14:26 2006
@@ -19,7 +19,6 @@
 import java.beans.PropertyChangeListener;
 import java.io.File;
 
-import javax.jbi.component.Component;
 import javax.jbi.component.ServiceUnitManager;
 import javax.jbi.management.DeploymentException;
 import javax.management.JMException;
@@ -28,7 +27,10 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.jbi.deployment.Descriptor;
+import org.apache.servicemix.jbi.deployment.DescriptorFactory;
 import org.apache.servicemix.jbi.deployment.ServiceUnit;
+import org.apache.servicemix.jbi.deployment.Services;
 import org.apache.servicemix.jbi.event.ServiceUnitEvent;
 import org.apache.servicemix.jbi.event.ServiceUnitListener;
 import org.apache.servicemix.jbi.management.AttributeInfoHelper;
@@ -49,12 +51,18 @@
 
     private PropertyChangeListener listener;
     
-    ServiceUnitLifeCycle(ServiceUnit serviceUnit, 
+    private Services services;
+    
+    public ServiceUnitLifeCycle(ServiceUnit serviceUnit, 
                                 String serviceAssembly,
                                 Registry registry) {
         this.serviceUnit = serviceUnit;
         this.serviceAssembly = serviceAssembly;
         this.registry = registry;
+        Descriptor d = DescriptorFactory.buildDescriptor(getServiceUnitRootPath());
+        if (d != null) {
+            services = d.getServices();
+        }
     }
 
     /**
@@ -150,17 +158,21 @@
 
     public String getDescriptor() {
         File suDir = getServiceUnitRootPath();
-        return AutoDeploymentService.getDescriptorAsText(suDir);
+        return DescriptorFactory.getDescriptorAsText(suDir);
+    }
+    
+    public Services getServices() {
+        return services;
     }
 
     protected void checkComponentStarted(String task) throws DeploymentException {
         String componentName = getComponentName();
         String suName = getName();
-        LocalComponentConnector lcc = registry.getLocalComponentConnector(componentName);
+        ComponentMBeanImpl lcc = registry.getComponent(componentName);
         if (lcc == null) {
             throw ManagementSupport.componentFailure("deploy", componentName, "Target component " + componentName + " for service unit " + suName + " is not installed");
         }
-        if (!lcc.getComponentMBean().isStarted()) {
+        if (!lcc.isStarted()) {
             throw ManagementSupport.componentFailure("deploy", componentName, "Target component " + componentName + " for service unit " + suName + " is not started");
         }
         if (lcc.getServiceUnitManager() == null) {
@@ -171,11 +183,11 @@
     protected void checkComponentStartedOrStopped(String task) throws DeploymentException {
         String componentName = getComponentName();
         String suName = getName();
-        LocalComponentConnector lcc = registry.getLocalComponentConnector(componentName);
+        ComponentMBeanImpl lcc = registry.getComponent(componentName);
         if (lcc == null) {
             throw ManagementSupport.componentFailure("deploy", componentName, "Target component " + componentName + " for service unit " + suName + " is not installed");
         }
-        if (!lcc.getComponentMBean().isStarted() && !lcc.getComponentMBean().isStopped()) {
+        if (!lcc.isStarted() && !lcc.isStopped()) {
             throw ManagementSupport.componentFailure("deploy", componentName, "Target component " + componentName + " for service unit " + suName + " is not started");
         }
         if (lcc.getServiceUnitManager() == null) {
@@ -191,8 +203,7 @@
     }
     
     protected ServiceUnitManager getServiceUnitManager() {
-        Component component = registry.getComponent(getComponentName());
-        LocalComponentConnector lcc = registry.getComponentConnector(component);
+        ComponentMBeanImpl lcc = registry.getComponent(getComponentName());
         return lcc.getServiceUnitManager();
     }
 
@@ -256,7 +267,6 @@
                 break;
             }
         }
-        
     }
 
 }

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/SubscriptionRegistry.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/SubscriptionRegistry.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/SubscriptionRegistry.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/SubscriptionRegistry.java Wed Mar  8 08:14:26 2006
@@ -37,7 +37,7 @@
     private Map subscriptions = new ConcurrentHashMap();
     private Registry registry;
     
-    public void init(Registry registry) {
+    public SubscriptionRegistry(Registry registry) {
         this.registry = registry;
     }
 

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/BaseSystemService.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/BaseSystemService.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/BaseSystemService.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/BaseSystemService.java Wed Mar  8 08:14:26 2006
@@ -49,7 +49,6 @@
     public void init(JBIContainer container) throws JBIException {
         this.container = container;
         container.getManagementContext().registerSystemService(this, getServiceMBean());
-
     }
 
     public void shutDown() throws JBIException {

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ManagementContext.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ManagementContext.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ManagementContext.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ManagementContext.java Wed Mar  8 08:14:26 2006
@@ -207,8 +207,9 @@
      * @param name - is the name of the BC or SE.
      * @return the JMX object name of the component's LifeCycle MBean or null.
      */
-    public ObjectName getComponentByName(String name) {
-        return container.getRegistry().getComponentObjectName(name);
+    public ObjectName getComponentByName(String componentName) {
+        ComponentMBeanImpl component = container.getRegistry().getComponent(componentName);
+        return component != null ? component.getMBeanName() : null;
     }
 
     /**
@@ -266,7 +267,8 @@
      * @return true if the component is a binding
      */
     public boolean isBinding(String componentName) {
-        return container.getRegistry().isBinding(componentName);
+        ComponentMBeanImpl component = container.getRegistry().getComponent(componentName);
+        return component != null ? component.isBinding() : false;
     }
 
     /**
@@ -276,7 +278,8 @@
      * @return true if the component is a service engine
      */
     public boolean isEngine(String componentName) {
-        return container.getRegistry().isEngine(componentName);
+        ComponentMBeanImpl component = container.getRegistry().getComponent(componentName);
+        return component != null ? component.isEngine() : false;
     }
 
     /**

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java Wed Mar  8 08:14:26 2006
@@ -41,9 +41,8 @@
 import org.apache.servicemix.jbi.ExchangeTimeoutException;
 import org.apache.servicemix.jbi.container.ActivationSpec;
 import org.apache.servicemix.jbi.container.JBIContainer;
-import org.apache.servicemix.jbi.framework.ComponentConnector;
 import org.apache.servicemix.jbi.framework.ComponentContextImpl;
-import org.apache.servicemix.jbi.framework.LocalComponentConnector;
+import org.apache.servicemix.jbi.framework.ComponentMBeanImpl;
 import org.apache.servicemix.jbi.jaxp.SourceTransformer;
 import org.apache.servicemix.jbi.util.BoundedLinkedQueue;
 import org.apache.servicemix.jbi.util.DOMUtil;
@@ -63,7 +62,7 @@
 
     private JBIContainer container;
     private ComponentContextImpl context;
-    private LocalComponentConnector componentConnector;
+    private ComponentMBeanImpl component;
     private BoundedLinkedQueue queue = new BoundedLinkedQueue();
     private IdGenerator idGenerator = new IdGenerator();
     private MessageExchangeFactory inboundFactory;
@@ -80,8 +79,9 @@
      * @param container
      * @param componentName
      */
-    public DeliveryChannelImpl(JBIContainer container, String componentName) {
-        this.container = container;
+    public DeliveryChannelImpl(ComponentMBeanImpl component) {
+        this.component = component;
+        this.container = component.getContainer();
     }
 
     /**
@@ -132,10 +132,10 @@
                 ((Thread) threads[i]).interrupt();
             }
             // deactivate all endpoints from this component
-            ServiceEndpoint[] endpoints = container.getRegistry().getEndpointsForComponent(componentConnector.getComponentNameSpace());
+            ServiceEndpoint[] endpoints = container.getRegistry().getEndpointsForComponent(component.getComponentNameSpace());
             for (int i = 0; i < endpoints.length; i++) {
                 try {
-                    componentConnector.getContext().deactivateEndpoint(endpoints[i]);
+                    component.getContext().deactivateEndpoint(endpoints[i]);
                 } catch (JBIException e) {
                     log.error("Error deactivating endpoint", e);
                 }
@@ -406,11 +406,11 @@
                 messageExchange.setPersistent(persistent);
             }
 
-            if (componentConnector.isExchangeThrottling()) {
-                if (componentConnector.getThrottlingInterval() > intervalCount) {
+            if (component.isExchangeThrottling()) {
+                if (component.getThrottlingInterval() > intervalCount) {
                     intervalCount = 0;
                     try {
-                        Thread.sleep(componentConnector.getThrottlingTimeout());
+                        Thread.sleep(component.getThrottlingTimeout());
                     }
                     catch (InterruptedException e) {
                         log.warn("throttling failed", e);
@@ -420,18 +420,18 @@
             }
 
             // Update stats
-            MessagingStats messagingStats = componentConnector.getMessagingStats();
+            MessagingStats messagingStats = component.getMessagingStats();
             long currentTime = System.currentTimeMillis();
             if (container.isNotifyStatistics()) {
                 long oldCount = messagingStats.getOutboundExchanges().getCount();
                 messagingStats.getOutboundExchanges().increment();
-                componentConnector.getComponentMBean().firePropertyChanged(
+                component.firePropertyChanged(
                         "outboundExchangeCount",
                         new Long(oldCount),
                         new Long(messagingStats.getOutboundExchanges().getCount()));
                 double oldRate = messagingStats.getOutboundExchangeRate().getAverageTime();
                 messagingStats.getOutboundExchangeRate().addTime(currentTime - lastSendTime);
-                componentConnector.getComponentMBean().firePropertyChanged("outboundExchangeRate",
+                component.firePropertyChanged("outboundExchangeRate",
                         new Double(oldRate),
                         new Double(messagingStats.getOutboundExchangeRate().getAverageTime()));
             } else {
@@ -441,7 +441,7 @@
             lastSendTime = currentTime;
 
             if (messageExchange.getRole() == Role.CONSUMER) {
-                messageExchange.setSourceId(componentConnector.getComponentNameSpace());
+                messageExchange.setSourceId(component.getComponentNameSpace());
             }
 
             // Call the listeners before the ownership changes
@@ -562,17 +562,8 @@
     /**
      * @return Returns the componentConnector.
      */
-    public ComponentConnector getConnector() {
-        return componentConnector;
-    }
-
-    /**
-     * Set the ComponentConnector
-     * 
-     * @param connector context to set.
-     */
-    public void setConnector(LocalComponentConnector connector) {
-        this.componentConnector = connector;
+    public ComponentMBeanImpl getComponent() {
+        return component;
     }
 
     /**
@@ -603,18 +594,18 @@
         checkNotClosed();
 
         // Update stats
-        MessagingStats messagingStats = componentConnector.getMessagingStats();
+        MessagingStats messagingStats = component.getMessagingStats();
         long currentTime = System.currentTimeMillis();
         if (container.isNotifyStatistics()) {
             long oldCount = messagingStats.getInboundExchanges().getCount();
             messagingStats.getInboundExchanges().increment();
-            componentConnector.getComponentMBean().firePropertyChanged(
+            component.firePropertyChanged(
                     "inboundExchangeCount",
                     new Long(oldCount),
                     new Long(messagingStats.getInboundExchanges().getCount()));
             double oldRate = messagingStats.getInboundExchangeRate().getAverageTime();
             messagingStats.getInboundExchangeRate().addTime(currentTime - lastReceiveTime);
-            componentConnector.getComponentMBean().firePropertyChanged("inboundExchangeRate",
+            component.firePropertyChanged("inboundExchangeRate",
                     new Double(oldRate),
                     new Double(messagingStats.getInboundExchangeRate().getAverageTime()));
         } else {
@@ -636,7 +627,7 @@
                 theOriginal.notify();
             }
         } else {
-            Component component = ((LocalComponentConnector) componentConnector).getComponent();
+            Component component = this.component.getComponent();
             // If the component implements the MessageExchangeListener,
             // the delivery can be made synchronously, so we don't need
             // to bother about transactions
@@ -766,6 +757,6 @@
      * @return pretty print
      */
     public String toString() {
-        return "DeliveryChannel{" + componentConnector.getComponentNameSpace() + "}";
+        return "DeliveryChannel{" + component.getName() + "}";
     }
 }

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/Broker.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/Broker.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/Broker.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/Broker.java Wed Mar  8 08:14:26 2006
@@ -33,8 +33,8 @@
 import org.apache.servicemix.jbi.container.ActivationSpec;
 import org.apache.servicemix.jbi.container.JBIContainer;
 import org.apache.servicemix.jbi.framework.ComponentContextImpl;
+import org.apache.servicemix.jbi.framework.ComponentMBeanImpl;
 import org.apache.servicemix.jbi.framework.ComponentNameSpace;
-import org.apache.servicemix.jbi.framework.LocalComponentConnector;
 import org.apache.servicemix.jbi.framework.Registry;
 import org.apache.servicemix.jbi.management.BaseSystemService;
 import org.apache.servicemix.jbi.management.ManagementContext;
@@ -400,12 +400,12 @@
      */
     protected ServiceEndpoint[] getMatchingEndpoints(ServiceEndpoint[] endpoints, MessageExchangeImpl exchange) {
     	List filtered = new ArrayList();
-        LocalComponentConnector consumer = getRegistry().getLocalComponentConnector(exchange.getSourceId());
+        ComponentMBeanImpl consumer = getRegistry().getComponent(exchange.getSourceId());
         
     	for (int i = 0; i < endpoints.length; i++) {
 			ComponentNameSpace id = ((InternalEndpoint) endpoints[i]).getComponentNameSpace();
             if (id != null) {
-    	        LocalComponentConnector provider = getRegistry().getLocalComponentConnector(id);
+                ComponentMBeanImpl provider = getRegistry().getComponent(id);
                 if (provider != null) {
                     if (!consumer.getComponent().isExchangeWithProviderOkay(endpoints[i], exchange) ||
                         !provider.getComponent().isExchangeWithConsumerOkay(endpoints[i], exchange)) {

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/AbstractFlow.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/AbstractFlow.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/AbstractFlow.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/AbstractFlow.java Wed Mar  8 08:14:26 2006
@@ -15,14 +15,22 @@
  */
 package org.apache.servicemix.jbi.nmr.flow;
 
-import edu.emory.mathcs.backport.java.util.concurrent.locks.ReadWriteLock;
-import edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantReadWriteLock;
+import javax.jbi.JBIException;
+import javax.jbi.management.LifeCycleMBean;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.MessageExchange.Role;
+import javax.jbi.servicedesc.ServiceEndpoint;
+import javax.management.JMException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.ObjectName;
+import javax.xml.namespace.QName;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.servicemix.JbiConstants;
+import org.apache.servicemix.jbi.framework.ComponentMBeanImpl;
 import org.apache.servicemix.jbi.framework.ComponentNameSpace;
-import org.apache.servicemix.jbi.framework.LocalComponentConnector;
 import org.apache.servicemix.jbi.management.AttributeInfoHelper;
 import org.apache.servicemix.jbi.management.BaseLifeCycle;
 import org.apache.servicemix.jbi.messaging.ExchangePacket;
@@ -30,16 +38,8 @@
 import org.apache.servicemix.jbi.nmr.Broker;
 import org.apache.servicemix.jbi.servicedesc.InternalEndpoint;
 
-import javax.jbi.JBIException;
-import javax.jbi.management.LifeCycleMBean;
-import javax.jbi.messaging.MessageExchange;
-import javax.jbi.messaging.MessagingException;
-import javax.jbi.messaging.MessageExchange.Role;
-import javax.jbi.servicedesc.ServiceEndpoint;
-import javax.management.JMException;
-import javax.management.MBeanAttributeInfo;
-import javax.management.ObjectName;
-import javax.xml.namespace.QName;
+import edu.emory.mathcs.backport.java.util.concurrent.locks.ReadWriteLock;
+import edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantReadWriteLock;
 
 /**
  * A simple Straight through flow
@@ -166,14 +166,12 @@
     		log.debug("Called Flow doRouting");
         ComponentNameSpace id = me.getRole() == Role.PROVIDER ? me.getDestinationId() : me.getSourceId();
         //As the MessageExchange could come from another container - ensure we get the local Component
-        ComponentNameSpace copy = id.copy();
-        copy.setContainerName(broker.getContainerName());
-        LocalComponentConnector lcc = broker.getRegistry().getLocalComponentConnector(copy);
+        ComponentMBeanImpl lcc = broker.getRegistry().getComponent(id.getName());
         if (lcc != null) {
             lcc.getDeliveryChannel().processInBound(me);
         }
         else {
-            throw new MessagingException("No component with id (" + id + ") - Couldn't route MessageExchange " + me);
+            throw new MessagingException("No component named " + id.getName() + " - Couldn't route MessageExchange " + me);
         }
     }
     

Modified: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/examples/AbstractSpringTestSupport.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/examples/AbstractSpringTestSupport.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/examples/AbstractSpringTestSupport.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/examples/AbstractSpringTestSupport.java Wed Mar  8 08:14:26 2006
@@ -15,18 +15,18 @@
  */
 package org.apache.servicemix.examples;
 
+import javax.jbi.component.Component;
+
+import junit.framework.TestCase;
+
 import org.apache.servicemix.components.util.ComponentAdaptor;
 import org.apache.servicemix.jbi.container.SpringJBIContainer;
-import org.apache.servicemix.jbi.framework.LocalComponentConnector;
+import org.apache.servicemix.jbi.framework.ComponentMBeanImpl;
 import org.apache.servicemix.tck.MessageList;
 import org.apache.servicemix.tck.Receiver;
 import org.apache.servicemix.tck.Sender;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 
-import javax.jbi.component.Component;
-
-import junit.framework.TestCase;
-
 /**
  * A base class for spring related test cases
  *
@@ -88,7 +88,7 @@
     }
     
     protected Component getComponent(String name) {
-        LocalComponentConnector lcc = jbi.getLocalComponentConnector(name);
+        ComponentMBeanImpl lcc = jbi.getComponent(name);
         return lcc != null ? lcc.getComponent() : null;
     }
 

Modified: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/framework/ComponentRegistryTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/framework/ComponentRegistryTest.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/framework/ComponentRegistryTest.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/framework/ComponentRegistryTest.java Wed Mar  8 08:14:26 2006
@@ -15,38 +15,31 @@
  */
 package org.apache.servicemix.jbi.framework;
 
-import org.apache.servicemix.jbi.framework.ComponentNameSpace;
-import org.apache.servicemix.jbi.framework.ComponentRegistry;
-import org.apache.servicemix.jbi.framework.LocalComponentConnector;
-import org.apache.servicemix.tck.SenderComponent;
-
 import javax.jbi.component.Component;
 
 import junit.framework.TestCase;
 
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.tck.SenderComponent;
+
 public class ComponentRegistryTest extends TestCase {
     
-    public void testContainerName() throws Exception {
-        ComponentRegistry reg = new ComponentRegistry(null);
-        reg.setContainerName("containerName");
-        assertEquals("containerName", reg.getContainerName());
-    }
-    
     public void testRegister() throws Exception {
-        ComponentRegistry reg = new ComponentRegistry(new Registry());
+        JBIContainer container = new JBIContainer();
+        container.setEmbedded(true);
+        container.setUseMBeanServer(false);
+        container.init();
+        ComponentRegistry reg = new ComponentRegistry(container.getRegistry());
         Component component = new SenderComponent();
-        LocalComponentConnector con = reg.registerComponent(
+        ComponentMBeanImpl con = reg.registerComponent(
                               new ComponentNameSpace("container", "name", "id"),
                               "description",
                               component,
                               false,
                               false);
         assertNotNull(con);
-        assertEquals(con, reg.getComponentConnector(component));
-        assertEquals(con, reg.getComponentConnector(new ComponentNameSpace("container", null, "id")));
-        assertEquals(component, reg.getComponent(new ComponentNameSpace("container", null, "id")));
-        assertEquals(1, reg.getComponentConnectors().size());
-        assertEquals(1, reg.getLocalComponentConnectors().size());
+        assertEquals(con, reg.getComponent(new ComponentNameSpace("container", null, "id")));
+        assertEquals(component, reg.getComponent(new ComponentNameSpace("container", null, "id")).getComponent());
         assertEquals(1, reg.getComponents().size());
     }
 

Modified: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/HotDeployTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/HotDeployTest.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/HotDeployTest.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/HotDeployTest.java Wed Mar  8 08:14:26 2006
@@ -120,7 +120,7 @@
         	lock.wait(5000);
         }
         Thread.sleep(50);
-        ObjectName lifecycleName = container.getRegistry().getComponentObjectName("component1");
+        ObjectName lifecycleName = container.getComponent("component1").getMBeanName();
         assertNotNull(lifecycleName);
         LifeCycleMBean lifecycleMBean = (LifeCycleMBean)  MBeanServerInvocationHandler.newProxyInstance(container.getMBeanServer(), lifecycleName, LifeCycleMBean.class, false);
         assertEquals(LifeCycleMBean.STARTED, lifecycleMBean.getCurrentState());
@@ -169,7 +169,7 @@
         	lock.wait(5000);
         }
         Thread.sleep(50);
-        ObjectName lifecycleName = container.getRegistry().getComponentObjectName("component1");
+        ObjectName lifecycleName = container.getComponent("component1").getMBeanName();
         assertNotNull(lifecycleName);
         LifeCycleMBean lifecycleMBean = (LifeCycleMBean)  MBeanServerInvocationHandler.newProxyInstance(container.getMBeanServer(), lifecycleName, LifeCycleMBean.class, false);
         assertEquals(LifeCycleMBean.STARTED, lifecycleMBean.getCurrentState());
@@ -190,8 +190,7 @@
         	lock.wait(5000);
         }
         Thread.sleep(50);
-        lifecycleName = container.getRegistry().getComponentObjectName("component1");
-        assertNull(lifecycleName);
+        assertNull(container.getComponent("component1"));
         // check mocks
         verify();
         
@@ -247,7 +246,7 @@
         	lock.wait(5000);
         }
         Thread.sleep(2000);
-        ObjectName lifecycleName = container.getRegistry().getComponentObjectName("component1");
+        ObjectName lifecycleName = container.getComponent("component1").getMBeanName();
         assertNotNull(lifecycleName);
         LifeCycleMBean lifecycleMBean = (LifeCycleMBean)  MBeanServerInvocationHandler.newProxyInstance(container.getMBeanServer(), lifecycleName, LifeCycleMBean.class, false);
         assertEquals(LifeCycleMBean.STARTED, lifecycleMBean.getCurrentState());