servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r384246 [1/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...
Date Wed, 08 Mar 2006 16:14:30 GMT
Author: gnodet
Date: Wed Mar  8 08:14:26 2006
New Revision: 384246

URL: http://svn.apache.org/viewcvs?rev=384246&view=rev
Log:
Continue o.a.s.jbi.framework refactoring, mainly the components related stuff.
The main class for components is now ComponentMBeanImpl.
Simplify / clean registry according to that.

Added:
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/deployment/DescriptorFactory.java
Removed:
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentConnector.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentPacket.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/LocalComponentConnector.java
Modified:
    incubator/servicemix/trunk/servicemix-assembly/maven.xml
    incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/script/GroovyTransformTest.java
    incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/email/example.xml
    incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/jms/example-cluster.xml
    incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/jms/example.xml
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ComponentEnvironment.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ComponentEvent.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsService.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentService.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentContextImpl.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBeanImpl.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentRegistry.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentStats.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/DeploymentService.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallerMBeanImpl.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/Registry.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceAssemblyLifeCycle.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceUnitLifeCycle.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/SubscriptionRegistry.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/BaseSystemService.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ManagementContext.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/Broker.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/AbstractFlow.java
    incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/examples/AbstractSpringTestSupport.java
    incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/framework/ComponentRegistryTest.java
    incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/installation/HotDeployTest.java

Modified: incubator/servicemix/trunk/servicemix-assembly/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-assembly/maven.xml?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-assembly/maven.xml (original)
+++ incubator/servicemix/trunk/servicemix-assembly/maven.xml Wed Mar  8 08:14:26 2006
@@ -171,7 +171,9 @@
   <goal name="servicemix-web">
     <mkdir dir="${maven.build.dir}/webapp"/>
     <copy todir="${maven.build.dir}/webapp">
-      <fileset dir="${basedir}/src/main/release/examples/servicemix-web" />
+      <fileset dir="${basedir}/src/main/release/examples/servicemix-web" excludes="project.xml"/>
+    </copy>
+    <copy todir="${maven.build.dir}/webapp" file="${basedir}/src/main/release/examples/servicemix-web/project.xml">
       <filterset begintoken="%" endtoken="%">
         <filter token="pom.currentVersion" value="${pom.currentVersion}"/>
       </filterset>

Modified: incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/script/GroovyTransformTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/script/GroovyTransformTest.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/script/GroovyTransformTest.java (original)
+++ incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/script/GroovyTransformTest.java Wed Mar  8 08:14:26 2006
@@ -21,12 +21,12 @@
 import javax.jbi.messaging.NormalizedMessage;
 
 import org.apache.servicemix.components.util.ComponentAdaptor;
-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 org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
 
 /**
  * @version $Revision$
@@ -73,7 +73,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-components/src/test/resources/org/apache/servicemix/components/email/example.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/email/example.xml?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/email/example.xml (original)
+++ incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/email/example.xml Wed Mar  8 08:14:26 2006
@@ -7,7 +7,7 @@
     <sm:activationSpecs>
 
       <!-- START SNIPPET: mime -->
-      <sm:activationSpec componentName="emailSender" service="foo:mimeSender">
+      <sm:activationSpec componentName="mimeSender" service="foo:mimeSender">
         <sm:component><bean class="org.apache.servicemix.components.email.MimeMailSender">
           <property name="sender">
             <bean class="org.springframework.mail.javamail.JavaMailSenderImpl">

Modified: incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/jms/example-cluster.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/jms/example-cluster.xml?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/jms/example-cluster.xml (original)
+++ incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/jms/example-cluster.xml Wed Mar  8 08:14:26 2006
@@ -65,7 +65,7 @@
       </sm:activationSpec>
       -->
 
-      <sm:activationSpec componentName="jmsTrace" service="foo:trace">
+      <sm:activationSpec componentName="trace" service="foo:trace">
         <sm:component><bean class="org.apache.servicemix.components.groovy.GroovyComponent">
           <property name="disableOutput" value="true"/>
           <property name="scriptText">

Modified: incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/jms/example.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/jms/example.xml?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/jms/example.xml (original)
+++ incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/jms/example.xml Wed Mar  8 08:14:26 2006
@@ -64,7 +64,7 @@
       </sm:activationSpec>
       -->
 
-      <sm:activationSpec componentName="jmsTrace" service="foo:trace">
+      <sm:activationSpec componentName="trace" service="foo:trace">
         <sm:component><bean class="org.apache.servicemix.components.groovy.GroovyComponent">
           <property name="disableOutput" value="true"/>
           <property name="scriptText">

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ComponentEnvironment.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ComponentEnvironment.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ComponentEnvironment.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ComponentEnvironment.java Wed Mar  8 08:14:26 2006
@@ -15,16 +15,16 @@
  */
 package org.apache.servicemix.jbi.container;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.servicemix.jbi.framework.LocalComponentConnector;
-import org.apache.servicemix.jbi.messaging.MessagingStats;
-
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.PrintWriter;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.jbi.framework.ComponentMBeanImpl;
+import org.apache.servicemix.jbi.messaging.MessagingStats;
+
 /**
  * Holder for environment infomation
  * 
@@ -36,7 +36,7 @@
     private File workspaceRoot;
     private File componentRoot;
     private PrintWriter statsWriter;
-    private LocalComponentConnector localConnector;
+    private ComponentMBeanImpl localConnector;
 
     /**
      * @return Returns the installRoot.
@@ -69,14 +69,14 @@
     /**
      * @return Returns the localConnector.
      */
-    public LocalComponentConnector getLocalConnector() {
+    public ComponentMBeanImpl getLocalConnector() {
         return localConnector;
     }
 
     /**
      * @param localConnector The localConnector to set.
      */
-    public void setLocalConnector(LocalComponentConnector localConnector) {
+    public void setLocalConnector(ComponentMBeanImpl localConnector) {
         this.localConnector = localConnector;
     }
 

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java Wed Mar  8 08:14:26 2006
@@ -28,7 +28,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.servicemix.jbi.framework.LocalComponentConnector;
+import org.apache.servicemix.jbi.framework.ComponentMBeanImpl;
 import org.apache.servicemix.jbi.management.AttributeInfoHelper;
 import org.apache.servicemix.jbi.management.BaseSystemService;
 import org.apache.servicemix.jbi.util.FileUtil;
@@ -262,7 +262,7 @@
      * @return the CompponentEnvironment
      * @throws JBIException
      */
-    public ComponentEnvironment registerComponent(LocalComponentConnector connector) throws JBIException {
+    public ComponentEnvironment registerComponent(ComponentMBeanImpl connector) throws JBIException {
         ComponentEnvironment result = new ComponentEnvironment();
         return registerComponent(result,connector);
     }
@@ -275,7 +275,7 @@
      * @throws JBIException
      */
     public ComponentEnvironment registerComponent(ComponentEnvironment result,
-                                                  LocalComponentConnector connector) throws JBIException {
+            ComponentMBeanImpl connector) throws JBIException {
         if (result == null) {
             result = new ComponentEnvironment();
         }
@@ -364,8 +364,11 @@
      * @return the state file
      * @throws IOException 
      */
-    public File getComponentStateFile(String componentName) throws IOException {
+    public File getComponentStateFile(String componentName) {
         File result = getComponentRootDirectory(componentName);
+        if (result == null) {
+            return null;
+        }
         FileUtil.buildDirectory(result);
         result = new File(result,"state.xml");
         return result;
@@ -483,7 +486,7 @@
      * @param connector
      * @param doDelete true if component is to be deleted
      */
-    public void unreregister(LocalComponentConnector connector) {
+    public void unreregister(ComponentMBeanImpl connector) {
         ComponentEnvironment ce = (ComponentEnvironment) envMap.remove(connector);
         if (ce != null) {
             ce.close();

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java Wed Mar  8 08:14:26 2006
@@ -62,10 +62,10 @@
 import org.apache.servicemix.jbi.framework.AdminCommandsService;
 import org.apache.servicemix.jbi.framework.AutoDeploymentService;
 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.DeploymentService;
 import org.apache.servicemix.jbi.framework.InstallationService;
-import org.apache.servicemix.jbi.framework.LocalComponentConnector;
 import org.apache.servicemix.jbi.framework.Registry;
 import org.apache.servicemix.jbi.management.BaseLifeCycle;
 import org.apache.servicemix.jbi.management.ManagementContext;
@@ -780,22 +780,20 @@
     /**
      * Used for Simple POJO's
      *
-     * @param id - the unique component ID
+     * @param name - the unique component ID
      * @throws JBIException
      */
-    public void deactivateComponent(String id) throws JBIException {
-        ComponentNameSpace cns = new ComponentNameSpace(name, id, id);
-        Component component = registry.getComponent(cns);
-        LocalComponentConnector lcc = registry.getLocalComponentConnector(cns);
-        if (component != null && lcc != null) {
-            lcc.getComponentMBean().shutDown();
-        	lcc.unregisterMbeans(managementContext);
+    public void deactivateComponent(String name) throws JBIException {
+        ComponentMBeanImpl component = registry.getComponent(name);
+        if (component != null) {
+            component.shutDown();
+        	component.unregisterMbeans(managementContext);
             registry.deregisterComponent(component);
-            environmentContext.unreregister(lcc);
-            log.info("Deactivating component for name: " + id + " component: " + component);
+            environmentContext.unreregister(component);
+            log.info("Deactivating component " + name);
         }
         else {
-            throw new JBIException("Could not find Component with id " + id);
+            throw new JBIException("Could not find component " + name);
         }
     }
 
@@ -813,28 +811,18 @@
     /**
      * Get the component associated with the given component ID
      *
-     * @param id
+     * @param componentName
      * @return the component
      */
-    public Component getComponent(String id) {
-        return registry.getComponent(id);
+    public ComponentMBeanImpl getComponent(String componentName) {
+        return registry.getComponent(componentName);
     }
 
     /**
      * @return all local ComponentConnectors
      */
     public Collection getLocalComponentConnectors() {
-        return registry.getLocalComponentConnectors();
-    }
-
-    /**
-     * Retrive the local component connector for a given name
-     *
-     * @param componentName
-     * @return the LocalComponentConnector
-     */
-    public LocalComponentConnector getLocalComponentConnector(String componentName) {
-        return registry.getLocalComponentConnector(componentName);
+        return registry.getComponents();
     }
 
     /**
@@ -962,6 +950,9 @@
     public ObjectName activateComponent(Component component, String description, ActivationSpec activationSpec,
                                         boolean pojo, boolean binding, boolean service) throws JBIException {
         ComponentNameSpace cns = new ComponentNameSpace(getName(), activationSpec.getComponentName(), activationSpec.getId());
+        if (registry.getComponent(cns) != null) {
+            throw new JBIException("A component is already registered for " + cns);
+        }
         ComponentContextImpl context = new ComponentContextImpl(this, cns);
         return activateComponent(new File("."), component, description, context, activationSpec, pojo, binding, service);
     }
@@ -987,7 +978,7 @@
             log.info("Activating component for: " + cns + " with service: " + activationSpec.getService() + " component: "
                     + component);
         }
-        LocalComponentConnector lcc = registry.registerComponent(cns, description, component, binding, service);
+        ComponentMBeanImpl lcc = registry.registerComponent(cns, description, component, binding, service);
         if (lcc != null) {
             lcc.setPojo(pojo);
             ComponentEnvironment env = environmentContext.registerComponent(context.getEnvironment(),lcc);
@@ -999,12 +990,12 @@
             if (lcc.isPojo()) {
                 //non-pojo's are either started by the auto deployer
                 //or manually
-                lcc.getComponentMBean().init();
+                lcc.init();
                 if (started.get()) {
-                    lcc.getComponentMBean().start();
+                    lcc.start();
                 }
             } else {
-                lcc.getComponentMBean().doShutDown();
+                lcc.doShutDown();
             }
             result = lcc.registerMBeans(managementContext);
         }

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java Wed Mar  8 08:14:26 2006
@@ -20,6 +20,7 @@
 import javax.resource.spi.work.WorkManager;
 
 import org.apache.servicemix.components.util.ComponentAdaptor;
+import org.apache.servicemix.jbi.framework.ComponentMBeanImpl;
 import org.jencks.factory.WorkManagerFactoryBean;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.BeanFactory;
@@ -97,10 +98,10 @@
      * @return the Component
      */
     public Object getBean(String id) {
-        Object bean = getComponent(id);
+        ComponentMBeanImpl component = getComponent(id);
+        Object bean = component != null ? component.getComponent() : null;
         if (bean instanceof ComponentAdaptor) {
-            ComponentAdaptor adaptor = (ComponentAdaptor) bean;
-            return adaptor.getLifeCycle();
+            bean = ((ComponentAdaptor) bean).getLifeCycle();
         }
         return bean;
     }

Added: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/deployment/DescriptorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/deployment/DescriptorFactory.java?rev=384246&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/deployment/DescriptorFactory.java (added)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/deployment/DescriptorFactory.java Wed Mar  8 08:14:26 2006
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.jbi.deployment;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Arrays;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.jbi.config.spring.XBeanProcessor;
+import org.apache.servicemix.jbi.util.FileUtil;
+import org.apache.xbean.spring.context.FileSystemXmlApplicationContext;
+
+/**
+ * @version $Revision: 359151 $
+ */
+public class DescriptorFactory {
+
+    public static final String DESCRIPTOR_FILE = "META-INF/jbi.xml";
+
+    private static Log log = LogFactory.getLog(DescriptorFactory.class);
+    
+    /**
+     * Build a jbi descriptor from a file archive
+     * 
+     * @param descriptorFile path to the jbi descriptor, or to the root directory
+     * @return the Descriptor object
+     */
+    public static Descriptor buildDescriptor(File descriptorFile) {
+        Descriptor root = null;
+        if (descriptorFile.isDirectory()) {
+            descriptorFile = new File(descriptorFile, DESCRIPTOR_FILE);
+        }
+        if (descriptorFile.isFile()) {
+            ClassLoader cl = Thread.currentThread().getContextClassLoader();
+            try {
+                Thread.currentThread().setContextClassLoader(DescriptorFactory.class.getClassLoader());
+                FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext("file:///"
+                        + descriptorFile.getAbsolutePath(), Arrays.asList(new Object[] { new XBeanProcessor() }));
+                root = (Descriptor) context.getBean("jbi");
+            } finally {
+                Thread.currentThread().setContextClassLoader(cl);
+            }
+        }
+        return root;
+    }
+
+    /**
+     * Retrieves the jbi descriptor as a string
+     * 
+     * @param descriptorFile path to the jbi descriptor, or to the root directory
+     * @return the contents of the jbi descriptor
+     */
+    public static String getDescriptorAsText(File descriptorFile) {
+        if (descriptorFile.isDirectory()) {
+            descriptorFile = new File(descriptorFile, DESCRIPTOR_FILE);
+        }
+        if (descriptorFile.isFile()) {
+            try {
+                ByteArrayOutputStream os = new ByteArrayOutputStream();
+                InputStream is = new FileInputStream(descriptorFile);
+                FileUtil.copyInputStream(is, os);
+                return os.toString();
+            } catch (Exception e) {
+                log.debug("Error reading jbi descritor: " + descriptorFile, e);
+            }
+        }
+        return null;
+    }
+
+}

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ComponentEvent.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ComponentEvent.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ComponentEvent.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ComponentEvent.java Wed Mar  8 08:14:26 2006
@@ -17,7 +17,7 @@
 
 import java.util.EventObject;
 
-import org.apache.servicemix.jbi.framework.LocalComponentConnector;
+import org.apache.servicemix.jbi.framework.ComponentMBeanImpl;
 
 public class ComponentEvent extends EventObject {
 
@@ -29,17 +29,17 @@
     public static final int COMPONENT_SHUTDOWN = 3;
     public static final int COMPONENT_UNINSTALLED = 4;
     
-    private LocalComponentConnector lcc;
+    private ComponentMBeanImpl component;
     private int type;
     
-    public ComponentEvent(LocalComponentConnector lcc, int type) {
-        super(lcc);
-        this.lcc = lcc;
+    public ComponentEvent(ComponentMBeanImpl component, int type) {
+        super(component);
+        this.component = component;
         this.type = type;
     }
     
-    public LocalComponentConnector getComponent() {
-        return lcc;
+    public ComponentMBeanImpl getComponent() {
+        return component;
     }
     
     public int getEventType() {

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsService.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsService.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsService.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsService.java Wed Mar  8 08:14:26 2006
@@ -116,12 +116,11 @@
      */
     public String startComponent(String name) throws Exception {
         try {
-            ComponentNameSpace cns = new ComponentNameSpace(container.getName(), name, name);
-            LocalComponentConnector lcc = container.getRegistry().getLocalComponentConnector(cns);
+            ComponentMBeanImpl lcc = container.getComponent(name);
             if (lcc == null) {
                 throw new JBIException("Component " + name + " not found");
             }
-            lcc.getComponentMBean().start();
+            lcc.start();
             return success("startComponent", name);
         } catch (JBIException e) {
             throw new RuntimeException(failure("startComponent", name, e));
@@ -136,12 +135,11 @@
      */
     public String stopComponent(String name) throws Exception {
         try {
-            ComponentNameSpace cns = new ComponentNameSpace(container.getName(), name, name);
-            LocalComponentConnector lcc = container.getRegistry().getLocalComponentConnector(cns);
+            ComponentMBeanImpl lcc = container.getComponent(name);
             if (lcc == null) {
                 throw new JBIException("Component " + name + " not found");
             }
-            lcc.getComponentMBean().stop();
+            lcc.stop();
             return success("stopComponent", name);
         } catch (JBIException e) {
             throw new RuntimeException(failure("stopComponent", name, e));
@@ -156,12 +154,11 @@
      */
     public String shutdownComponent(String name) throws Exception {
         try {
-            ComponentNameSpace cns = new ComponentNameSpace(container.getName(), name, name);
-            LocalComponentConnector lcc = container.getRegistry().getLocalComponentConnector(cns);
+            ComponentMBeanImpl lcc = container.getComponent(name);
             if (lcc == null) {
                 throw new JBIException("Component " + name + " not found");
             }
-            lcc.getComponentMBean().shutDown();
+            lcc.shutDown();
             return success("shutdownComponent", name);
         } catch (JBIException e) {
             throw new RuntimeException(failure("shutdownComponent", name, e));
@@ -276,24 +273,24 @@
                                  String requiredState,
                                  String sharedLibraryName,
                                  String serviceAssemblyName) throws Exception {
-        Collection connectors = container.getRegistry().getLocalComponentConnectors();
+        Collection connectors = container.getRegistry().getComponents();
         List components = new ArrayList();
         for (Iterator iter = connectors.iterator(); iter.hasNext();) {
-            LocalComponentConnector lcc = (LocalComponentConnector) iter.next();
+            ComponentMBeanImpl component = (ComponentMBeanImpl) iter.next();
             // Skip SEs if needed
-            if (excludeSEs && lcc.isService()) {
+            if (excludeSEs && component.isService()) {
                 continue;
             }
             // Skip BCs if needed
-            if (excludeBCs && lcc.isBinding()) {
+            if (excludeBCs && component.isBinding()) {
                 continue;
             }
             // Skip Pojos if needed
-            if (excludePojos && lcc.isPojo()) {
+            if (excludePojos && component.isPojo()) {
                 continue;
             }
             // Check status
-            if (requiredState != null && requiredState.length() > 0 && !requiredState.equals(lcc.getComponentMBean().getCurrentState())) {
+            if (requiredState != null && requiredState.length() > 0 && !requiredState.equals(component.getCurrentState())) {
                 continue;
             }
             // Check shared library
@@ -306,25 +303,25 @@
             if (serviceAssemblyName != null && serviceAssemblyName.length() > 0 && !container.getDeploymentService().isSaDeployed(serviceAssemblyName)) {
                 continue;
             }
-            components.add(lcc);
+            components.add(component);
         }
 
         StringBuffer buffer = new StringBuffer();
         buffer.append("<?xml version='1.0'?>\n");
         buffer.append("<component-info-list xmlns='http://java.sun.com/xml/ns/jbi/component-info-list' version='1.0'>\n");
         for (Iterator iter = components.iterator(); iter.hasNext();) {
-            LocalComponentConnector lcc = (LocalComponentConnector) iter.next();
+            ComponentMBeanImpl component = (ComponentMBeanImpl) iter.next();
             buffer.append("\t<component-info>");
-            if (!lcc.isBinding() && lcc.isService()) {
+            if (!component.isBinding() && component.isService()) {
                 buffer.append(" type='service-engine'");
-            } else if (lcc.isBinding() && !lcc.isService()) {
+            } else if (component.isBinding() && !component.isService()) {
                 buffer.append(" type='binding-component'");
             }
-            buffer.append(" name='" + lcc.getComponentNameSpace().getName() + "'");
-            buffer.append(" state='" + lcc.getComponentMBean().getCurrentState() + "'>");
-            if (lcc.getPacket().getDescription() != null) {
+            buffer.append(" name='" + component.getName() + "'");
+            buffer.append(" state='" + component.getCurrentState() + "'>");
+            if (component.getDescription() != null) {
                 buffer.append("\t\t<description>");
-                buffer.append(lcc.getPacket().getDescription());
+                buffer.append(component.getDescription());
                 buffer.append("<description>\n");
             }
             buffer.append("\t</component-info>\n");

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentService.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentService.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentService.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentService.java Wed Mar  8 08:14:26 2006
@@ -15,15 +15,11 @@
  */
 package org.apache.servicemix.jbi.framework;
 
-import java.io.ByteArrayOutputStream;
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -43,16 +39,15 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.servicemix.jbi.config.spring.XBeanProcessor;
 import org.apache.servicemix.jbi.container.EnvironmentContext;
 import org.apache.servicemix.jbi.container.JBIContainer;
 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.management.AttributeInfoHelper;
 import org.apache.servicemix.jbi.management.BaseSystemService;
 import org.apache.servicemix.jbi.util.FileUtil;
 import org.apache.servicemix.jbi.util.XmlPersistenceSupport;
-import org.apache.xbean.spring.context.FileSystemXmlApplicationContext;
 
 import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
 import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
@@ -65,7 +60,6 @@
 	
     private static final Log log = LogFactory.getLog(AutoDeploymentService.class);
     private EnvironmentContext environmentContext;
-    protected static final String DESCRIPTOR_FILE = "META-INF/jbi.xml";
     private DeploymentService deploymentService;
     private InstallationService installationService;
     private boolean monitorInstallationDirectory = true;
@@ -197,7 +191,7 @@
      */
     public void updateArchive(String location, ArchiveEntry entry, boolean autoStart) throws DeploymentException{
         File tmp=AutoDeploymentService.unpackLocation(environmentContext.getTmpDir(),location);
-        Descriptor root=AutoDeploymentService.buildDescriptor(tmp);
+        Descriptor root = DescriptorFactory.buildDescriptor(tmp);
         if (root != null) {
             try{
                 container.getBroker().suspend();
@@ -233,7 +227,7 @@
                             boolean canDeploy = true;
                             for (Iterator it = entry.componentNames.iterator(); it.hasNext();) {
                             	String componentName = (String) it.next();
-                            	if (!container.getRegistry().isLocalComponentRegistered(componentName)) {
+                            	if (container.getComponent(componentName) == null) {
                             		canDeploy = false;
                             		if (missings != null) {
                             			missings += ", " + componentName;
@@ -330,7 +324,7 @@
             boolean canDeploy = true;
             for (Iterator it2 = entry.componentNames.iterator(); it2.hasNext();) {
             	String componentName = (String) it2.next();
-            	if (!container.getRegistry().isLocalComponentRegistered(componentName)) {
+            	if (container.getComponent(componentName) == null) {
             		canDeploy = false;
             		break;
             	}
@@ -339,7 +333,7 @@
                 File tmp = (File) me.getKey();
                 deployedSas.add(tmp);
                 try {
-	                Descriptor root = AutoDeploymentService.buildDescriptor(tmp);
+	                Descriptor root = DescriptorFactory.buildDescriptor(tmp);
 	                deploymentService.deployServiceAssembly(tmp, root.getServiceAssembly());
 	                deploymentService.start(root.getServiceAssembly().getIdentification().getName());
                 } catch (Exception e) {
@@ -375,45 +369,6 @@
     }
 
     /**
-     * Build a Descriptor from a file archieve
-     * 
-     * @param tmpDir
-     * @return the Descriptor object
-     */
-    protected static Descriptor buildDescriptor(File tmpDir){
-        Descriptor root = null;
-        File descriptorFile = new File(tmpDir, DESCRIPTOR_FILE);
-        if (descriptorFile.exists()) {
-            ClassLoader cl = Thread.currentThread().getContextClassLoader();
-            try {
-                Thread.currentThread().setContextClassLoader(AutoDeploymentService.class.getClassLoader());
-                FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext(
-                        "file:///" + descriptorFile.getAbsolutePath(),
-                        Arrays.asList(new Object[] { new XBeanProcessor() }));
-                root = (Descriptor) context.getBean("jbi");
-            } finally {
-                Thread.currentThread().setContextClassLoader(cl);
-            }
-        }
-        return root;
-    }
-    
-    protected static String getDescriptorAsText(File tmpDir) {
-        File descriptorFile = new File(tmpDir, DESCRIPTOR_FILE);
-        if (descriptorFile.exists()) {
-            try {
-                ByteArrayOutputStream os = new ByteArrayOutputStream();
-                InputStream is = new FileInputStream(descriptorFile);
-                FileUtil.copyInputStream(is, os);
-                return os.toString();
-            } catch (Exception e) {
-                log.debug("Error reading jbi descritor: " + descriptorFile, e);
-            }
-        }
-        return null;
-    }
-
-    /**
      * Unpack a location into a temp file directory.
      * If the location does not contain a jbi descritor, no unpacking occurs.
      * 
@@ -451,7 +406,7 @@
                     throw new DeploymentException(e);
                 }
             }
-            if (FileUtil.archiveContainsEntry(file, AutoDeploymentService.DESCRIPTOR_FILE)) {
+            if (FileUtil.archiveContainsEntry(file, DescriptorFactory.DESCRIPTOR_FILE)) {
                 tmpDir = FileUtil.createUniqueDirectory(tmpRoot, file.getName());
                 FileUtil.unpackArchive(file, tmpDir);
                 if (log.isDebugEnabled()) {

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentContextImpl.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentContextImpl.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentContextImpl.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentContextImpl.java Wed Mar  8 08:14:26 2006
@@ -47,7 +47,9 @@
  * @version $Revision$
  */
 public class ComponentContextImpl implements ComponentContext, MBeanNames {
+    
     private static final Log log = LogFactory.getLog(ComponentContextImpl.class);
+    
     private ComponentNameSpace componentName;
     private ComponentEnvironment environment;
     private JBIContainer container;
@@ -76,8 +78,9 @@
      * @param spec
      * @param installRoot
      */
-    public void activate(Component component, ComponentEnvironment env,
-            ActivationSpec spec) {
+    public void activate(Component component, 
+                         ComponentEnvironment env,
+                         ActivationSpec spec) {
         this.component = component;
         this.environment = env;
         this.activationSpec = spec;
@@ -158,7 +161,7 @@
      * @param context 
      * @param as 
      */
-    public void registerSubscriptions(ComponentContextImpl context,ActivationSpec as) {
+    public void registerSubscriptions(ComponentContextImpl context, ActivationSpec as) {
         checkActivated();
         container.getRegistry().registerSubscriptions(context, as);
     }
@@ -168,7 +171,7 @@
      * @param context
      * @param as
      */
-    public void deregisterSubscriptions(ComponentContextImpl context,ActivationSpec as) {
+    public void deregisterSubscriptions(ComponentContextImpl context, ActivationSpec as) {
         checkActivated();
         container.getRegistry().deregisterSubscriptions(context, as);
     }
@@ -178,7 +181,7 @@
      * @param subscription
      * @param endpoint
      */
-    public void registerSubscription(ComponentContextImpl context,SubscriptionSpec subscription, ServiceEndpoint endpoint) {
+    public void registerSubscription(ComponentContextImpl context, SubscriptionSpec subscription, ServiceEndpoint endpoint) {
         checkActivated();
         container.getRegistry().registerSubscription(context, subscription, endpoint);
     }
@@ -188,7 +191,7 @@
      * @param subscription
      * @return the ServiceEndpoint
      */
-    public InternalEndpoint deregisterSubscription(ComponentContextImpl context,SubscriptionSpec subscription) {
+    public InternalEndpoint deregisterSubscription(ComponentContextImpl context, SubscriptionSpec subscription) {
         checkActivated();
         return container.getRegistry().deregisterSubscription(context, subscription);
     }

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBeanImpl.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBeanImpl.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBeanImpl.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBeanImpl.java Wed Mar  8 08:14:26 2006
@@ -15,8 +15,16 @@
  */
 package org.apache.servicemix.jbi.framework;
 
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
 import javax.jbi.JBIException;
+import javax.jbi.component.Component;
+import javax.jbi.component.ComponentLifeCycle;
+import javax.jbi.component.ServiceUnitManager;
 import javax.jbi.management.DeploymentException;
+import javax.jbi.management.LifeCycleMBean;
 import javax.management.JMException;
 import javax.management.MBeanAttributeInfo;
 import javax.management.MBeanOperationInfo;
@@ -24,12 +32,17 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.jbi.container.ActivationSpec;
 import org.apache.servicemix.jbi.container.JBIContainer;
 import org.apache.servicemix.jbi.event.ComponentEvent;
 import org.apache.servicemix.jbi.event.ComponentListener;
 import org.apache.servicemix.jbi.management.AttributeInfoHelper;
 import org.apache.servicemix.jbi.management.BaseLifeCycle;
+import org.apache.servicemix.jbi.management.ManagementContext;
 import org.apache.servicemix.jbi.management.OperationInfoHelper;
+import org.apache.servicemix.jbi.messaging.DeliveryChannelImpl;
+import org.apache.servicemix.jbi.messaging.MessagingStats;
+import org.apache.servicemix.jbi.util.XmlPersistenceSupport;
 
 /**
  * Defines basic statistics on the Component
@@ -38,16 +51,91 @@
     
     private static Log log = LogFactory.getLog(ComponentMBeanImpl.class);
     
-    private LocalComponentConnector connector;
+    private boolean exchangeThrottling;
+    private long throttlingTimeout = 100;
+    private int throttlingInterval = 1;
        
+    private Component component;
+    private ComponentLifeCycle lifeCycle;
+    private ServiceUnitManager suManager;
+    private ComponentContextImpl context;
+    private ActivationSpec activationSpec;
+    private ObjectName mBeanName;
+    private ComponentStats componentStatsMBean;
+    private ObjectName componentStatsMBeanName;
+    private JBIContainer container;
+    private MessagingStats messagingStats;
+    private ComponentNameSpace componentName;
+    private String description = "POJO Component";
+    private boolean pojo;
+    private boolean binding;
+    private boolean service;
+    private File stateFile;
+
+    /**
+     * Construct with it's id and delivery channel Id
+     * 
+     * @param name
+     * @param description
+     * @param component
+     * @param dc
+     * @param binding
+     * @param service
+     */
+    public ComponentMBeanImpl(JBIContainer container, 
+                              ComponentNameSpace name, 
+                              String description, 
+                              Component component,
+                              boolean binding, 
+                              boolean service) {
+        this.componentName = name;
+        this.container = container;
+        this.component = component;
+        this.description = description;
+        this.binding = binding;
+        this.service = service;
+        this.componentStatsMBean = new ComponentStats(this);
+        this.messagingStats = new MessagingStats(name.getName());
+        this.stateFile = container.getEnvironmentContext().getComponentStateFile(name.getName());
+    }
+
+    /**
+     * Register the MBeans for this Component
+     * @param context
+     * @return ObjectName
+     * @throws JBIException
+     */
+    public ObjectName registerMBeans(ManagementContext context) throws JBIException{
+        try{
+            mBeanName = context.createObjectName(this);
+            context.registerMBean(mBeanName, this, ComponentMBean.class);
+            componentStatsMBeanName = context.createObjectName(componentStatsMBean);
+            context.registerMBean(componentStatsMBeanName, componentStatsMBean, ComponentStatsMBean.class);
+            return mBeanName;
+        }catch(Exception e){
+            String errorStr="Failed to register MBeans";
+            log.error(errorStr,e);
+            throw new JBIException(errorStr,e);
+        }
+    }
+    
+    /**
+     * Unregister Component MBeans
+     * @param context
+     * @throws JBIException
+     */
+    public void unregisterMbeans(ManagementContext context) throws JBIException{
+        context.unregisterMBean(mBeanName);
+        context.unregisterMBean(componentStatsMBeanName);
+    }
 
     /**
-     * Constructor
+     * Set the Context
      * 
-     * @param lcc
+     * @param context
      */
-    public ComponentMBeanImpl(LocalComponentConnector lcc) {
-        this.connector = lcc;
+    public void setContext(ComponentContextImpl context) {
+        this.context = context;
     }
 
     /**
@@ -57,7 +145,7 @@
      */
     public ObjectName getExtensionMBeanName() {
         if (isInitialized() || isStarted() || isStopped()) {
-            return connector.getComponent().getLifeCycle().getExtensionMBeanName();
+            return lifeCycle.getExtensionMBeanName();
         } else {
             return null;
         }
@@ -67,8 +155,8 @@
      * Get the name of the item
      * @return the name
      */
-    public String getName(){
-        return connector.getComponentNameSpace().getName();
+    public String getName() {
+        return componentName.getName();
     }
     
     /**
@@ -88,13 +176,24 @@
      * @return the description
      */
     public String getDescription(){
-        return connector.getComponentPacket().getDescription();
+        return description;
     }
 
     
     public void init() throws JBIException {
-        log.info("Initializing component: " + connector.getContext().getComponentName());
-        connector.init();
+        log.info("Initializing component: " + getName());
+        if (context != null && component != null) {
+            DeliveryChannelImpl channel = new DeliveryChannelImpl(this);
+            channel.setContext(context);
+            context.setDeliveryChannel(channel);
+            ClassLoader loader = Thread.currentThread().getContextClassLoader();
+            try {
+                Thread.currentThread().setContextClassLoader(getLifeCycle().getClass().getClassLoader());
+                getLifeCycle().init(context);
+            } finally {
+                Thread.currentThread().setContextClassLoader(loader);
+            }
+        }
         super.init();
     }
     
@@ -104,10 +203,10 @@
      * @exception javax.jbi.JBIException if the item fails to start.
      */
     public void start() throws javax.jbi.JBIException {
-        log.info("Starting component: " + connector.getContext().getComponentName());
+        log.info("Starting component: " + getName());
         try {
             doStart();
-            connector.writeRunningState();
+            persistRunningState();
         } catch (JBIException e) {
             log.error("Could not start component", e);
             throw e;
@@ -126,10 +225,10 @@
      * @exception javax.jbi.JBIException if the item fails to stop.
      */
     public void stop() throws javax.jbi.JBIException {
-        log.info("Stopping component: " + connector.getContext().getComponentName());
+        log.info("Stopping component: " + getName());
         try {
             doStop();
-            connector.writeRunningState();
+            persistRunningState();
         } catch (JBIException e) {
             log.error("Could not stop component", e);
             throw e;
@@ -148,10 +247,10 @@
      * @exception javax.jbi.JBIException if the item fails to shut down.
      */
     public void shutDown() throws javax.jbi.JBIException {
-        log.info("Shutting down component: " + connector.getContext().getComponentName());
+        log.info("Shutting down component: " + getName());
         try {
             doShutDown();
-            connector.writeRunningState();
+            persistRunningState();
         } catch (JBIException e) {
             log.error("Could not shutDown component", e);
             throw e;
@@ -176,10 +275,10 @@
     public void doStart() throws javax.jbi.JBIException {
         if (isShutDown()) {
             // need to re-initialze before starting
-            connector.init();
+            init();
         }
         if (!isStarted()) {
-            connector.getLifeCycle().start();
+            getLifeCycle().start();
             super.start();
             initServiceAssemblies();
             startServiceAssemblies();
@@ -196,7 +295,7 @@
     public void doStop() throws javax.jbi.JBIException {
         if (isUnknown() || isStarted()) {
             stopServiceAssemblies();
-	        connector.getLifeCycle().stop();
+	        getLifeCycle().stop();
 	        super.stop();
         }
         fireEvent(ComponentEvent.COMPONENT_STOPPED);
@@ -213,10 +312,10 @@
         if (!isUnknown() && !isShutDown()) {
             doStop();
             shutDownServiceAssemblies();
-            connector.getLifeCycle().shutDown();
-            if (connector.getDeliveryChannel() != null) {
-                connector.getDeliveryChannel().close();
-                connector.setDeliveryChannel(null);
+            getLifeCycle().shutDown();
+            if (getDeliveryChannel() != null) {
+                getDeliveryChannel().close();
+                setDeliveryChannel(null);
             }
         }
         super.shutDown();
@@ -229,25 +328,62 @@
      * @throws JBIException
      */
     public void setInitialRunningState() throws JBIException{
-        connector.setRunningStateFromStore();
+        if (!isPojo()) {
+            String componentName = getName();
+            String runningState = getRunningStateFromStore();
+            log.info("Setting running state for Component: " + componentName + " to " + runningState);
+            if (runningState != null) {
+                if (runningState.equals(LifeCycleMBean.STARTED)) {
+                    doStart();
+                } else if (runningState.equals(LifeCycleMBean.STOPPED)) {
+                    doStart();
+                    doStop();
+                } else if (runningState.equals(LifeCycleMBean.SHUTDOWN)) {
+                    doShutDown();
+                }
+            }
+        }
     }
     
     /**
      * Persist the running state
      */
     public void persistRunningState() {
-        connector.writeRunningState();
+        if (!isPojo()) {
+            String componentName = getName();
+            try {
+                String currentState = getCurrentState();
+                Properties props = new Properties();
+                props.setProperty("state", currentState);
+                XmlPersistenceSupport.write(stateFile, props);
+            } catch (IOException e) {
+                log.error("Failed to write current running state for Component: " + componentName, e);
+            }
+        }
     }
    
-    
+    /**
+     * @return the current running state from disk
+     */
+    String getRunningStateFromStore() {
+        String result = LifeCycleMBean.UNKNOWN;
+        String componentName = getName();
+        try {
+            Properties props = (Properties) XmlPersistenceSupport.read(stateFile);
+            result = props.getProperty("state", result);
+        } catch (Exception e) {
+            log.error("Failed to read running state for Component: " + componentName, e);
+        }
+        return result;
+    }
 
     /**
      * @return the capacity of the inbound queue
      */
     public int getInboundQueueCapacity(){
         // TODO: should not be on the delivery channel
-        if (connector.getDeliveryChannel() != null) {
-            return connector.getDeliveryChannel().getQueueCapacity();
+        if (getDeliveryChannel() != null) {
+            return getDeliveryChannel().getQueueCapacity();
         } else {
             return 0;
         }
@@ -259,67 +395,108 @@
      */
     public void setInboundQueueCapacity(int value){
         // TODO: should not be on the delivery channel
-        if (connector.getDeliveryChannel() != null) {
-            connector.getDeliveryChannel().setQueueCapacity(value);
+        if (getDeliveryChannel() != null) {
+            getDeliveryChannel().setQueueCapacity(value);
         }
     }
     
     /**
+     * @return Returns the deliveryChannel.
+     */
+    public DeliveryChannelImpl getDeliveryChannel() {
+        return (DeliveryChannelImpl) context.getDeliveryChannel();
+    }
+
+    /**
+     * @param deliveryChannel
+     *            The deliveryChannel to set.
+     */
+    public void setDeliveryChannel(DeliveryChannelImpl deliveryChannel) {
+        context.setDeliveryChannel(deliveryChannel);
+    }
+
+    /**
+     * @return the ActivateionSpec
+     */
+    public ActivationSpec getActivationSpec() {
+        return activationSpec;
+    }
+
+    /**
+     * @return Returns the pojo.
+     */
+    public boolean isPojo() {
+        return pojo;
+    }
+
+    /**
+     * Set the ActivationSpec
+     * 
+     * @param activationSpec
+     */
+    public void setActivationSpec(ActivationSpec activationSpec) {
+        this.activationSpec = activationSpec;
+    }
+
+    /**
      * Is MessageExchange sender throttling enabled ?
+     * 
      * @return true if throttling enabled
      */
-    public boolean isExchangeThrottling(){
-        return connector.isExchangeThrottling();
+    public boolean isExchangeThrottling() {
+        return exchangeThrottling;
     }
-    
+
     /**
-     * Set exchange throttling
+     * Set message throttling
+     * 
      * @param value
-     *
      */
-    public void setExchangeThrottling(boolean value){
-        connector.setExchangeThrottling(value);
+    public void setExchangeThrottling(boolean value) {
+        this.exchangeThrottling = value;
     }
-    
+
     /**
      * Get the throttling timeout
+     * 
      * @return throttling tomeout (ms)
      */
-    public long getThrottlingTimeout(){
-        return connector.getThrottlingTimeout();
+    public long getThrottlingTimeout() {
+        return throttlingTimeout;
     }
-    
+
     /**
-     * Set the throttling timout 
+     * Set the throttling timout
+     * 
      * @param value (ms)
      */
-    public void setThrottlingTimeout(long value){
-        connector.setThrottlingTimeout(value);
+    public void setThrottlingTimeout(long value) {
+        throttlingTimeout = value;
     }
-    
+
     /**
-     * Get the interval for throttling -
-     * number of Exchanges set before the throttling timeout is applied
+     * Get the interval for throttling - number of Exchanges set before the throttling timeout is applied
+     * 
      * @return interval for throttling
      */
-    public int getThrottlingInterval(){
-        return connector.getThrottlingInterval();
+    public int getThrottlingInterval() {
+        return throttlingInterval;
     }
-    
+
     /**
-     * Set the throttling interval
-     * number of Exchanges set before the throttling timeout is applied
+     * Set the throttling interval number of Exchanges set before the throttling timeout is applied
+     * 
      * @param value
      */
-    public void setThrottlingInterval(int value){
-        connector.setThrottlingInterval(value);
+    public void setThrottlingInterval(int value) {
+        throttlingInterval = value;
     }
-    
+
     /**
      * @return the ObjectName for the stats MBean for this Component - or null if it doesn't exist
      */
     public ObjectName getStatsMBeanName(){
-        return connector.getStatsMBeanName();
+        return componentStatsMBeanName;
     }
     /**
      * Get an array of MBeanAttributeInfo
@@ -360,9 +537,8 @@
     }
 
     protected void stopServiceAssemblies() throws DeploymentException {
-        Registry registry = connector.getContainer().getRegistry();
-        String componentName = connector.getContext().getComponentName();
-        String[] sas = registry.getDeployedServiceAssembliesForComponent(componentName);
+        Registry registry = getContainer().getRegistry();
+        String[] sas = registry.getDeployedServiceAssembliesForComponent(getName());
         for (int i = 0; i < sas.length; i++) {
             ServiceAssemblyLifeCycle sa = registry.getServiceAssembly(sas[i]);
             if (sa.isStarted()) {
@@ -377,10 +553,9 @@
     }
 
     protected void shutDownServiceAssemblies() throws DeploymentException {
-        JBIContainer container = connector.getContainer();
+        JBIContainer container = getContainer();
         Registry registry = container.getRegistry();
-        String componentName = connector.getContext().getComponentName();
-        String[] sas = registry.getDeployedServiceAssembliesForComponent(componentName);
+        String[] sas = registry.getDeployedServiceAssembliesForComponent(getName());
         for (int i = 0; i < sas.length; i++) {
             ServiceAssemblyLifeCycle sa = registry.getServiceAssembly(sas[i]);
             if (sa.isStopped()) {
@@ -395,8 +570,8 @@
     }
     
     protected void fireEvent(int type) {
-        ComponentEvent event = new ComponentEvent(connector, type);
-        ComponentListener[] listeners = (ComponentListener[]) connector.getContainer().getListeners(ComponentListener.class);
+        ComponentEvent event = new ComponentEvent(this, type);
+        ComponentListener[] listeners = (ComponentListener[]) getContainer().getListeners(ComponentListener.class);
         for (int i = 0; i < listeners.length; i++) {
             switch (type) {
             case ComponentEvent.COMPONENT_STARTED:
@@ -411,6 +586,60 @@
             }
         }
         
+    }
+
+    public ComponentLifeCycle getLifeCycle() {
+        if (lifeCycle == null) {
+            lifeCycle = component.getLifeCycle();
+        }
+        return lifeCycle;
+    }
+
+    public ServiceUnitManager getServiceUnitManager() {
+        if (suManager == null) {
+            suManager = component.getServiceUnitManager();
+        }
+        return suManager;
+    }
+
+    public JBIContainer getContainer() {
+        return container;
+    }
+
+    /**
+     * @return Returns the messagingStats.
+     */
+    public MessagingStats getMessagingStats() {
+        return messagingStats;
+    }
+
+    public Component getComponent() {
+        return component;
+    }
+    
+    public ComponentNameSpace getComponentNameSpace() {
+        return componentName;
+    }
+
+    public ComponentContextImpl getContext() {
+        return context;
+    }
+    public ObjectName getMBeanName() {
+        return mBeanName;
+    }
+    public boolean isBinding() {
+        return binding;
+    }
+    public boolean isService() {
+        return service;
+    }
+
+    public void setPojo(boolean pojo) {
+        this.pojo = pojo;
+    }
+
+    public boolean isEngine() {
+        return service;
     }
 
 }

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentRegistry.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentRegistry.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentRegistry.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentRegistry.java Wed Mar  8 08:14:26 2006
@@ -16,10 +16,8 @@
 package org.apache.servicemix.jbi.framework;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.Set;
 
 import javax.jbi.JBIException;
 import javax.jbi.component.Component;
@@ -33,11 +31,7 @@
  */
 public class ComponentRegistry {
     
-    private String containerName;
-    private Map componentMap = new ConcurrentHashMap();
-    private Map componentByNameMap = new ConcurrentHashMap();
     private Map idMap = new ConcurrentHashMap();
-    private Map localIdMap = new ConcurrentHashMap();
     private boolean runningStateInitialized = false;
     private Registry registry;
     
@@ -55,18 +49,15 @@
      * @param service
      * @return an associated ComponentConnector or null if it already exists
      */
-    public LocalComponentConnector registerComponent(ComponentNameSpace name, 
-                                                     String description, 
-                                                     Component component,
-                                                     boolean binding, 
-                                                     boolean service) {
-        LocalComponentConnector result = null;
-        if (!componentMap.containsKey(component)) {
-            result = new LocalComponentConnector(registry.getContainer(), name, description, component, binding, service);
-            componentMap.put(component, result);
-            localIdMap.put(name, result);
-            addComponentConnector(result);
-            componentByNameMap.put(name, component);
+    public ComponentMBeanImpl registerComponent(ComponentNameSpace name, 
+                                                String description, 
+                                                Component component,
+                                                boolean binding, 
+                                                boolean service) {
+        ComponentMBeanImpl result = null;
+        if (!idMap.containsKey(name)) {
+            result = new ComponentMBeanImpl(registry.getContainer(), name, description, component, binding, service);
+            idMap.put(name, result);
         }
         return result;
     }
@@ -76,10 +67,10 @@
      * @throws JBIException
      */
     public void start() throws JBIException{
-        if(!setInitialRunningStateFromStart()){
-            for(Iterator i=getLocalComponentConnectors().iterator();i.hasNext();){
-                LocalComponentConnector lcc=(LocalComponentConnector) i.next();
-                lcc.getComponentMBean().doStart();
+        if (!setInitialRunningStateFromStart()) {
+            for(Iterator i = getComponents().iterator(); i.hasNext();) {
+                ComponentMBeanImpl lcc = (ComponentMBeanImpl) i.next();
+                lcc.doStart();
             }
         }
     }
@@ -91,9 +82,9 @@
      * @throws JBIException
      */
     public void stop() throws JBIException  {
-        for (Iterator i = getLocalComponentConnectors().iterator();i.hasNext();) {
-            LocalComponentConnector lcc = (LocalComponentConnector) i.next();
-            lcc.getComponentMBean().doStop();
+        for (Iterator i = getComponents().iterator();i.hasNext();) {
+            ComponentMBeanImpl lcc = (ComponentMBeanImpl) i.next();
+            lcc.doStop();
         }
         runningStateInitialized = false;
     }
@@ -104,10 +95,10 @@
      * @throws JBIException
      */
     public void shutDown() throws JBIException {
-        for (Iterator i = getLocalComponentConnectors().iterator();i.hasNext();) {
-            LocalComponentConnector lcc = (LocalComponentConnector) i.next();
-            lcc.getComponentMBean().persistRunningState();
-            lcc.getComponentMBean().doShutDown();
+        for (Iterator i = getComponents().iterator();i.hasNext();) {
+            ComponentMBeanImpl lcc = (ComponentMBeanImpl) i.next();
+            lcc.persistRunningState();
+            lcc.doShutDown();
         }
     }
     
@@ -119,39 +110,8 @@
      * @param component
      * @return the deregistered component
      */
-    public ComponentConnector deregisterComponent(Component component) {
-        ComponentConnector result = (ComponentConnector) componentMap.remove(component);
-        if (result != null) {
-            removeComponentConnector(result.getComponentNameSpace());
-            localIdMap.remove(result.getComponentNameSpace());
-            componentByNameMap.remove(result.getComponentNameSpace());
-        }
-        return result;
-    }
-    
-    /**
-     * @param cns
-     * @return the Component
-     */
-    public Component getComponent(ComponentNameSpace cns) {
-        return (Component) componentByNameMap.get(cns);
-    }
-    
-    /**
-     * Get set of Components
-     * @return a Set of Component objects
-     */
-    public Set getComponents(){
-        return Collections.unmodifiableSet(componentMap.keySet());
-    }
-    
-    /**
-     * Get the ComponentConnector associated with the componet
-     * @param component
-     * @return the associated ComponentConnector
-     */
-    public LocalComponentConnector getComponentConnector(Component component) {
-        return (LocalComponentConnector) componentMap.get(component);
+    public void deregisterComponent(ComponentMBeanImpl component) {
+        idMap.remove(component.getComponentNameSpace());
     }
     
     /**
@@ -159,100 +119,28 @@
      * @param id
      * @return the ComponentConnector or null
      */
-    public ComponentConnector getComponentConnector(ComponentNameSpace id) {
-        return (ComponentConnector) idMap.get(id);
-    }
-    
-    /**
-     * Add a ComponentConnector
-     * @param connector
-     */
-    public void addComponentConnector(ComponentConnector connector) {
-        if (connector != null && !idMap.containsKey(connector.getComponentNameSpace())) {
-            idMap.put(connector.getComponentNameSpace(), connector);
-        }
-    }
-    
-    /**
-     * remove a ComponentConnector by id
-     * @param id
-     */
-    public void removeComponentConnector(ComponentNameSpace id) {
-        idMap.remove(id);
-    }
-    
-    /**
-     * Update a ComponentConnector
-     * @param connector
-     */
-    public void updateConnector(ComponentConnector connector) {
-        if (connector != null){
-            idMap.put(connector.getComponentNameSpace(), connector);
-        }
-    }
-    
-    
-    /**
-     * Get a locally create ComponentConnector
-     * @param id - id of the ComponentConnector
-     * @return ComponentConnector or null if not found
-     */
-    public LocalComponentConnector getLocalComponentConnector(ComponentNameSpace id) {
-       
-        LocalComponentConnector result = (LocalComponentConnector) localIdMap.get(id);
-        return result;
-    }
-    
-    
-    /**
-     * Find existence of a Component locally registered to this Container
-     * @param componentName
-     * @return true if the Component exists
-     */
-    public boolean isLocalComponentRegistered(String componentName) {
-        ComponentNameSpace cns = new ComponentNameSpace(containerName, componentName,
-                componentName);
-        return localIdMap.containsKey(cns);
-    }
-    
-    /**
-     * @return all local ComponentConnectors 
-     */
-    public Collection getLocalComponentConnectors() {
-        return localIdMap.values();
+    public ComponentMBeanImpl getComponent(ComponentNameSpace id) {
+        return (ComponentMBeanImpl) idMap.get(id);
     }
     
     /**
      * 
      * @return Collection of ComponentConnectors held by the registry
      */
-    public Collection getComponentConnectors() {
+    public Collection getComponents() {
         return idMap.values();
     }
 
-    /**
-     * @return Returns the containerName.
-     */
-    public String getContainerName() {
-        return containerName;
-    }
-    /**
-     * @param containerName The containerName to set.
-     */
-    public void setContainerName(String containerName) {
-        this.containerName = containerName;
-    }
-    
     private boolean setInitialRunningStateFromStart() throws JBIException{
         boolean result = !runningStateInitialized;
         if (!runningStateInitialized){
             runningStateInitialized = true;
-            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() && !registry.isContainerEmbedded()){
-                    lcc.getComponentMBean().setInitialRunningState();
+                    lcc.setInitialRunningState();
                 }else {
-                    lcc.getComponentMBean().doStart();
+                    lcc.doStart();
                 }
             }
         }

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentStats.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentStats.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentStats.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentStats.java Wed Mar  8 08:14:26 2006
@@ -28,15 +28,15 @@
  */
 public class ComponentStats extends BaseLifeCycle implements ComponentStatsMBean {
 
-    private LocalComponentConnector connector;
+    private ComponentMBeanImpl component;
 
     /**
      * Constructor
      * 
      * @param lcc
      */
-    public ComponentStats(LocalComponentConnector lcc) {
-        this.connector = lcc;
+    public ComponentStats(ComponentMBeanImpl component) {
+        this.component = component;
     }
 
     /**
@@ -56,7 +56,7 @@
      * @return the name
      */
     public String getName() {
-        return connector.getComponentNameSpace().getName();
+        return component.getName();
     }
 
     /**
@@ -64,7 +64,7 @@
      * @return the description
      */
     public String getDescription() {
-        return "Statistics for " + connector.getComponentPacket().getDescription();
+        return "Statistics for " + component.getDescription();
     }
 
     /**
@@ -73,7 +73,7 @@
      * @return inbound count
      */
     public long getInboundExchangeCount() {
-        return connector.getMessagingStats().getInboundExchanges().getCount();
+        return component.getMessagingStats().getInboundExchanges().getCount();
     }
 
     /**
@@ -82,7 +82,7 @@
      * @return the inbound exchange rate
      */
     public double getInboundExchangeRate() {
-        return connector.getMessagingStats().getInboundExchangeRate().getAverageTime();
+        return component.getMessagingStats().getInboundExchangeRate().getAverageTime();
     }
 
     /**
@@ -91,7 +91,7 @@
      * @return outbound count
      */
     public long getOutboundExchangeCount() {
-        return connector.getMessagingStats().getOutboundExchanges().getCount();
+        return component.getMessagingStats().getOutboundExchanges().getCount();
     }
 
     /**
@@ -100,15 +100,15 @@
      * @return the outbound exchange rate
      */
     public double getOutboundExchangeRate() {
-        return connector.getMessagingStats().getOutboundExchangeRate().getAverageTime();
+        return component.getMessagingStats().getOutboundExchangeRate().getAverageTime();
     }
 
     /**
      * @return size of the inbound Queue
      */
     public int getInboundQueueSize() {
-        if (connector.getDeliveryChannel() != null) {
-            return connector.getDeliveryChannel().getQueueSize();
+        if (component.getDeliveryChannel() != null) {
+            return component.getDeliveryChannel().getQueueSize();
         } else {
             return 0;
         }
@@ -118,7 +118,7 @@
      * Reset all stats counters
      */
     public void reset() {
-        connector.getMessagingStats().reset();
+        component.getMessagingStats().reset();
     }
 
     /**

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/DeploymentService.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/DeploymentService.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/DeploymentService.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/DeploymentService.java Wed Mar  8 08:14:26 2006
@@ -22,7 +22,6 @@
 import java.util.List;
 
 import javax.jbi.JBIException;
-import javax.jbi.component.Component;
 import javax.jbi.component.ServiceUnitManager;
 import javax.jbi.management.DeploymentException;
 import javax.jbi.management.DeploymentServiceMBean;
@@ -38,6 +37,7 @@
 import org.apache.servicemix.jbi.container.EnvironmentContext;
 import org.apache.servicemix.jbi.container.JBIContainer;
 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.ServiceUnit;
 import org.apache.servicemix.jbi.management.AttributeInfoHelper;
@@ -186,7 +186,7 @@
             }
             Descriptor root = null;
             try {
-                root = AutoDeploymentService.buildDescriptor(tmpDir);
+                root = DescriptorFactory.buildDescriptor(tmpDir);
             } catch (Exception e) {
                 throw ManagementSupport.failure("deploy", "Unable to build jbi descriptor: " + saZipURL, e);
             }
@@ -349,8 +349,8 @@
      * @return boolean value indicating whether the SU can be deployed.
      */
     public boolean canDeployToComponent(String componentName) {
-        LocalComponentConnector lcc = container.getLocalComponentConnector(componentName);
-        return lcc != null && lcc.getComponentMBean().isStarted() && lcc.getServiceUnitManager() != null;
+        ComponentMBeanImpl lcc = container.getComponent(componentName);
+        return lcc != null && lcc.isStarted() && lcc.getServiceUnitManager() != null;
     }
 
     /**
@@ -465,11 +465,11 @@
                 if (!artifactFile.exists()) {
                     throw ManagementSupport.failure("deploy", "Artifact " + artifact + " not found for service unit " + suName);
                 }
-                LocalComponentConnector lcc = container.getLocalComponentConnector(componentName);
+                ComponentMBeanImpl lcc = container.getComponent(componentName);
                 if (lcc == null) {
                     throw ManagementSupport.failure("deploy", "Target component " + componentName + " for service unit " + suName + " is not installed");
                 }
-                if (!lcc.getComponentMBean().isStarted()) {
+                if (!lcc.isStarted()) {
                     throw ManagementSupport.failure("deploy", "Target component " + componentName + " for service unit " + suName + " is not started");
                 }
                 if (lcc.getServiceUnitManager() == null) {
@@ -511,7 +511,7 @@
                 // Deploy it
                 boolean success = false;
                 try {
-                    LocalComponentConnector lcc = container.getLocalComponentConnector(componentName);
+                    ComponentMBeanImpl lcc = container.getComponent(componentName);
                     ServiceUnitManager sum = lcc.getServiceUnitManager();
                     String resultMsg = sum.deploy(suName, targetDir.getAbsolutePath());
                     success = getComponentTaskResult(resultMsg, componentName, componentResults, true);
@@ -615,7 +615,7 @@
         registry.unregisterServiceUnit(su.getKey());
         // unpack the artifact
         // now get the component and give it a SA
-        Component component = container.getComponent(componentName);
+        ComponentMBeanImpl component = container.getComponent(componentName);
         if (component != null) {
             ServiceUnitManager sum = component.getServiceUnitManager();
             if (sum != null) {
@@ -645,7 +645,7 @@
                         String assemblyName = files[i].getName();
                         try {
                         	File assemblyDir = environmentContext.getSARootDirectory(assemblyName);
-	                        Descriptor root = AutoDeploymentService.buildDescriptor(assemblyDir);
+	                        Descriptor root = DescriptorFactory.buildDescriptor(assemblyDir);
 	                        if (root != null) {
 	                            ServiceAssembly sa = root.getServiceAssembly();
 	                            if (sa != null && sa.getIdentification() != null) {

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java Wed Mar  8 08:14:26 2006
@@ -42,6 +42,7 @@
 import org.apache.servicemix.jbi.deployment.ClassPath;
 import org.apache.servicemix.jbi.deployment.Component;
 import org.apache.servicemix.jbi.deployment.Descriptor;
+import org.apache.servicemix.jbi.deployment.DescriptorFactory;
 import org.apache.servicemix.jbi.deployment.InstallationDescriptorExtension;
 import org.apache.servicemix.jbi.deployment.SharedLibrary;
 import org.apache.servicemix.jbi.deployment.SharedLibraryList;
@@ -91,7 +92,7 @@
             }
             File tmpDir=AutoDeploymentService.unpackLocation(environmentContext.getTmpDir(),installJarURL);
             if(tmpDir!=null){
-                Descriptor root=AutoDeploymentService.buildDescriptor(tmpDir);
+                Descriptor root=DescriptorFactory.buildDescriptor(tmpDir);
                 if(root!=null&&root.getComponent()!=null){
                     String componentName=root.getComponent().getIdentification().getName();
                     if(!installers.containsKey(componentName)){
@@ -153,7 +154,7 @@
     
     private InstallerMBeanImpl createInstaller(String componentName) throws IOException, DeploymentException {
         File installationDir = environmentContext.getInstallationDirectory(componentName);
-        Descriptor root = AutoDeploymentService.buildDescriptor(installationDir);
+        Descriptor root = DescriptorFactory.buildDescriptor(installationDir);
         Component descriptor = root.getComponent();
 
         String name = descriptor.getIdentification().getName();
@@ -243,7 +244,7 @@
         try{
             File tmpDir=AutoDeploymentService.unpackLocation(environmentContext.getTmpDir(),aSharedLibURI);
             if(tmpDir!=null){
-                Descriptor root=AutoDeploymentService.buildDescriptor(tmpDir);
+                Descriptor root=DescriptorFactory.buildDescriptor(tmpDir);
                 SharedLibrary sl=root.getSharedLibrary();
                 if(sl!=null){
                     result=doInstallSharedLibrary(tmpDir,sl);
@@ -318,7 +319,7 @@
     public void install(String location, Properties props, boolean autoStart) throws DeploymentException {
         File tmpDir=AutoDeploymentService.unpackLocation(environmentContext.getTmpDir(),location);
         if(tmpDir!=null){
-            Descriptor root=AutoDeploymentService.buildDescriptor(tmpDir);
+            Descriptor root=DescriptorFactory.buildDescriptor(tmpDir);
             if(root!=null){
                 install(tmpDir, props, root, autoStart);
             }else{
@@ -371,16 +372,9 @@
                     }
                     if (autoStart) {
                         try{
-                            ComponentNameSpace cns=new ComponentNameSpace(container.getName(),componentName,
-                                            componentName);
-                            LocalComponentConnector lcc=container.getRegistry().getLocalComponentConnector(cns);
-                            if(container.getRegistry().isLocalComponentRegistered(componentName)){
-                                ComponentMBean mbean=lcc.getComponentMBean();
-                                if(mbean!=null){
-                                    mbean.start();
-                                }else{
-                                    log.warn("No ComponentMBean found for Component "+componentName);
-                                }
+                            ComponentMBeanImpl lcc = container.getComponent(componentName);
+                            if (lcc != null) {
+                                lcc.start();
                             }else{
                                 log.warn("No ComponentConnector found for Component "+componentName);
                             }
@@ -563,7 +557,7 @@
             if(files!=null){
                 for(int i=0;i<files.length;i++){
                     if(files[i].isDirectory()){
-                        Descriptor root=AutoDeploymentService.buildDescriptor(files[i]);
+                        Descriptor root=DescriptorFactory.buildDescriptor(files[i]);
                         if(root!=null){
                             SharedLibrary sl=root.getSharedLibrary();
                             if(sl!=null){

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallerMBeanImpl.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallerMBeanImpl.java?rev=384246&r1=384245&r2=384246&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallerMBeanImpl.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallerMBeanImpl.java Wed Mar  8 08:14:26 2006
@@ -134,9 +134,8 @@
         ObjectName result = null;
         try {
             result = activateComponent();
-            ComponentNameSpace cns = new ComponentNameSpace(container.getName(), context.getComponentName(), null);
-            LocalComponentConnector lcc = container.getRegistry().getLocalComponentConnector(cns);
-            lcc.getComponentMBean().persistRunningState();
+            ComponentMBeanImpl lcc = container.getComponent(context.getComponentName());
+            lcc.persistRunningState();
             installed = true;
         } finally {
             if (bootstrap != null) {



Mime
View raw message