You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by js...@apache.org on 2006/10/02 17:10:59 UTC

svn commit: r452064 - in /incubator/servicemix/trunk: servicemix-common/src/main/java/org/apache/servicemix/common/ servicemix-common/src/main/java/org/apache/servicemix/common/xbean/ servicemix-saxon/src/main/java/org/apache/servicemix/saxon/

Author: jstrachan
Date: Mon Oct  2 08:10:58 2006
New Revision: 452064

URL: http://svn.apache.org/viewvc?view=rev&rev=452064
Log:
minor refactor introducing ServiceMixComponent to be the API offered by ServiceMix-enhanced JBI components. Added a new base class, DefaultComponent which merges the Component and Lifecycle APIs together into one simple API which also supports configuring a collection of Endpoints on startup along with the associated ServiceUnit. So now a well behaved component only has to extend DefaultComponent and provide an Endpoint implementation

Added:
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/DefaultComponent.java   (with props)
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/ServiceMixComponent.java   (with props)
Modified:
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/AbstractDeployer.java
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseComponent.java
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseLifeCycle.java
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseServiceUnitManager.java
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/Endpoint.java
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/Registry.java
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/ServiceUnit.java
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/AbstractXBeanDeployer.java
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/BaseXBeanDeployer.java
    incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/SaxonComponent.java

Modified: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/AbstractDeployer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/AbstractDeployer.java?view=diff&rev=452064&r1=452063&r2=452064
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/AbstractDeployer.java (original)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/AbstractDeployer.java Mon Oct  2 08:10:58 2006
@@ -32,11 +32,11 @@
 
     protected final transient Log logger;
     
-    protected BaseComponent component;
+    protected ServiceMixComponent component;
     
-    public AbstractDeployer(BaseComponent component) {
+    public AbstractDeployer(ServiceMixComponent component) {
         this.component = component;
-        this.logger = component.logger;
+        this.logger = component.getLogger();
     }
     
     protected DeploymentException failure(String task, String info, Throwable e) {

Modified: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java?view=diff&rev=452064&r1=452063&r2=452064
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java (original)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java Mon Oct  2 08:10:58 2006
@@ -54,9 +54,9 @@
  */
 public class AsyncBaseLifeCycle implements ComponentLifeCycle {
 
-    protected final transient Log logger;
+    protected transient Log logger;
 
-    protected BaseComponent component;
+    protected ServiceMixComponent component;
 
     protected ComponentContext context;
 
@@ -80,12 +80,19 @@
 
     protected Map processors = new ConcurrentHashMap();
 
-    public AsyncBaseLifeCycle(BaseComponent component) {
-        this.component = component;
-        this.logger = component.logger;
+    public AsyncBaseLifeCycle() {
         this.running = new AtomicBoolean(false);
         this.polling = new AtomicBoolean(false);
         this.processors = new ConcurrentHashMap();
+    }
+
+    public AsyncBaseLifeCycle(ServiceMixComponent component) {
+        setComponent(component);
+    }
+
+    protected void setComponent(ServiceMixComponent component) {
+        this.component = component;
+        this.logger = component.getLogger();
     }
 
     /*

Modified: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseComponent.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseComponent.java?view=diff&rev=452064&r1=452063&r2=452064
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseComponent.java (original)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseComponent.java Mon Oct  2 08:10:58 2006
@@ -37,7 +37,7 @@
  * @version $Revision$
  * @since 3.0
  */
-public abstract class BaseComponent implements Component {
+public abstract class BaseComponent implements ServiceMixComponent {
 
     protected final transient Log logger = LogFactory.getLog(getClass());
     

Modified: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseLifeCycle.java?view=diff&rev=452064&r1=452063&r2=452064
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseLifeCycle.java (original)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseLifeCycle.java Mon Oct  2 08:10:58 2006
@@ -31,7 +31,10 @@
  */
 public class BaseLifeCycle extends AsyncBaseLifeCycle implements MessageExchangeListener {
 
-    public BaseLifeCycle(BaseComponent component) {
+    protected BaseLifeCycle() {
+    }
+    
+    public BaseLifeCycle(ServiceMixComponent component) {
         super(component);
     }
     

Modified: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseServiceUnitManager.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseServiceUnitManager.java?view=diff&rev=452064&r1=452063&r2=452064
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseServiceUnitManager.java (original)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseServiceUnitManager.java Mon Oct  2 08:10:58 2006
@@ -35,19 +35,19 @@
 
     protected final transient Log logger;
     
-    protected BaseComponent component;
+    protected ServiceMixComponent component;
     
     protected Deployer[] deployers;
     
     protected boolean persistent;
     
-    public BaseServiceUnitManager(BaseComponent component, Deployer[] deployers) {
+    public BaseServiceUnitManager(ServiceMixComponent component, Deployer[] deployers) {
         this(component, deployers, false);
     }
 
-    public BaseServiceUnitManager(BaseComponent component, Deployer[] deployers, boolean persistent) {
+    public BaseServiceUnitManager(ServiceMixComponent component, Deployer[] deployers, boolean persistent) {
         this.component = component;
-        this.logger = component.logger;
+        this.logger = component.getLogger();
         this.deployers = deployers;
         this.persistent = persistent;
     }

Added: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/DefaultComponent.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/DefaultComponent.java?view=auto&rev=452064
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/DefaultComponent.java (added)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/DefaultComponent.java Mon Oct  2 08:10:58 2006
@@ -0,0 +1,288 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.common;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.common.xbean.XBeanServiceUnit;
+import org.apache.servicemix.common.xbean.BaseXBeanDeployer;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+
+import javax.jbi.component.ComponentContext;
+import javax.jbi.component.ComponentLifeCycle;
+import javax.jbi.component.ServiceUnitManager;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.servicedesc.ServiceEndpoint;
+import java.util.Arrays;
+
+/**
+ * A useful base class for writing new JBI components which includes the {@link ComponentLifeCycle} interface methods so that
+ * you can write a new component in a single class with minimal overloading.
+ *
+ * @version $Revision$
+ */
+public abstract class DefaultComponent extends BaseLifeCycle implements ServiceMixComponent {
+
+    protected final transient Log logger = LogFactory.getLog(getClass());
+
+    protected Registry registry;
+    protected BaseServiceUnitManager serviceUnitManager;
+    protected ServiceUnit serviceUnit;
+    private Endpoint[] endpoints;
+
+    public DefaultComponent() {
+        setComponent(this);
+        registry = createRegistry();
+        serviceUnitManager = createServiceUnitManager();
+    }
+
+    /* (non-Javadoc)
+     * @see javax.jbi.component.Component#getLifeCycle()
+     */
+    public ComponentLifeCycle getLifeCycle() {
+        return this;
+    }
+
+    /* (non-Javadoc)
+     * @see javax.jbi.component.Component#getServiceUnitManager()
+     */
+    public ServiceUnitManager getServiceUnitManager() {
+        return serviceUnitManager;
+    }
+
+    /* (non-Javadoc)
+     * @see javax.jbi.component.Component#getServiceDescription(javax.jbi.servicedesc.ServiceEndpoint)
+     */
+    public Document getServiceDescription(ServiceEndpoint endpoint) {
+        if (logger.isDebugEnabled()) {
+            logger.debug("Querying service description for " + endpoint);
+        }
+        String key = EndpointSupport.getKey(endpoint);
+        Endpoint ep = this.registry.getEndpoint(key);
+        if (ep != null) {
+            Document doc = ep.getDescription();
+            if (doc == null) {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("No description found for " + key);
+                }
+            }
+            return doc;
+        }
+        else {
+            if (logger.isDebugEnabled()) {
+                logger.debug("No endpoint found for " + key);
+            }
+            return null;
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see javax.jbi.component.Component#isExchangeWithConsumerOkay(javax.jbi.servicedesc.ServiceEndpoint, javax.jbi.messaging.MessageExchange)
+     */
+    public boolean isExchangeWithConsumerOkay(ServiceEndpoint endpoint, MessageExchange exchange) {
+        String key = EndpointSupport.getKey(endpoint);
+        Endpoint ep = this.registry.getEndpoint(key);
+        if (ep != null) {
+            if (ep.getRole() != MessageExchange.Role.PROVIDER) {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("Endpoint " + key + " is a consumer. Refusing exchange with consumer.");
+                }
+                return false;
+            }
+            else {
+                return ep.isExchangeOkay(exchange);
+            }
+        }
+        else {
+            if (logger.isDebugEnabled()) {
+                logger.debug("No endpoint found for " + key + ". Refusing exchange with consumer.");
+            }
+            return false;
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see javax.jbi.component.Component#isExchangeWithProviderOkay(javax.jbi.servicedesc.ServiceEndpoint, javax.jbi.messaging.MessageExchange)
+     */
+    public boolean isExchangeWithProviderOkay(ServiceEndpoint endpoint, MessageExchange exchange) {
+        // TODO: check if the selected endpoint is good for us
+        return true;
+    }
+
+    /* (non-Javadoc)
+     * @see javax.jbi.component.Component#resolveEndpointReference(org.w3c.dom.DocumentFragment)
+     */
+    public ServiceEndpoint resolveEndpointReference(DocumentFragment epr) {
+        return null;
+    }
+
+
+    /**
+     * Create the service unit manager.
+     * Derived classes should override this method and return a
+     * BaseServiceUnitManager so that the component is able to
+     * handle service unit deployment.
+     *
+     * The default implementation will create a @{link BaseXBeanDeployer} instance
+     * using the value of @{link #getEndpointClasses()} if that method returns a non-null value
+     * otherwise it returns null.
+     *
+     * @return a newly created service unit manager
+     */
+    protected BaseServiceUnitManager createServiceUnitManager() {
+        Class[] classes = getEndpointClasses();
+        if (classes == null) {
+            return null;
+        }
+        Deployer[] deployers = new Deployer[] { new BaseXBeanDeployer(this, classes) };
+        return new BaseServiceUnitManager(this, deployers);
+    }
+
+
+    protected Registry createRegistry() {
+        return new Registry(this);
+    }
+
+    public ComponentContext getComponentContext() {
+        return getContext();
+    }
+
+    public String getComponentName() {
+        if (getComponentContext() == null) {
+            return "Component (" + getClass().getName() + ") not yet initialized";
+        }
+        return getComponentContext().getComponentName();
+    }
+
+    /**
+     * @return Returns the logger.
+     */
+    public Log getLogger() {
+        return logger;
+    }
+
+    /**
+     * @return Returns the registry.
+     */
+    public Registry getRegistry() {
+        return registry;
+    }
+
+    /**
+     * Returns the statically defined endpoints of this component
+     */
+    public Endpoint[] getEndpoints() {
+        return endpoints;
+    }
+
+    public void setEndpoints(Endpoint[] endpoints) {
+        for (int i = 0; i < endpoints.length; i++) {
+            Endpoint endpoint = endpoints[i];
+            validateEndpoint(endpoint);
+        }
+        this.endpoints = endpoints;
+    }
+
+    /**
+     * Provides a hook to validate the statically configured endpoint
+     */
+    protected void validateEndpoint(Endpoint endpoint) {
+        Class[] endpointClasses = getEndpointClasses();
+        if (endpointClasses != null) {
+            boolean valid = false;
+            for (int i = 0; i < endpointClasses.length; i++) {
+                Class endpointClass = endpointClasses[i];
+                if (endpointClass.isInstance(endpoint)) {
+                    valid = true;
+                }
+            }
+            if (!valid) {
+                throw new IllegalArgumentException("The endpoint: " + endpoint
+                        + " is not an instance of any of the allowable types: " + Arrays.asList(endpointClasses));
+            }
+        }
+    }
+
+    /**
+     * Returns the service unit if applicable
+     *
+     * @return the service unit if one is being used.
+     */
+    public ServiceUnit getServiceUnit() {
+        return serviceUnit;
+    }
+
+    /**
+     * Returns a list of valid endpoint classes or null if the component does not wish to programmatically
+     * restrict the list of possible endpoint classes
+     *
+     * @return the endpoint classes used to validate configuration or null to disable the validation
+     */
+    protected abstract Class[] getEndpointClasses();
+
+    /* (non-Javadoc)
+    * @see org.servicemix.common.BaseLifeCycle#doInit()
+    */
+    protected void doInit() throws Exception {
+        super.doInit();
+        Endpoint[] endpoints = getEndpoints();
+        if (endpoints != null && endpoints.length > 0) {
+            serviceUnit = new XBeanServiceUnit();
+            serviceUnit.setComponent(this);
+            for (int i = 0; i < endpoints.length; i++) {
+                endpoints[i].setServiceUnit(serviceUnit);
+                endpoints[i].validate();
+                serviceUnit.addEndpoint(endpoints[i]);
+            }
+            getRegistry().registerServiceUnit(serviceUnit);
+        }
+    }
+
+    /* (non-Javadoc)
+    * @see org.servicemix.common.BaseLifeCycle#doStart()
+    */
+    protected void doStart() throws Exception {
+        super.doStart();
+        if (serviceUnit != null) {
+            serviceUnit.start();
+        }
+    }
+
+    /* (non-Javadoc)
+    * @see org.servicemix.common.BaseLifeCycle#doStop()
+    */
+    protected void doStop() throws Exception {
+        if (serviceUnit != null) {
+            serviceUnit.stop();
+        }
+        super.doStop();
+    }
+
+    /* (non-Javadoc)
+    * @see org.servicemix.common.BaseLifeCycle#doShutDown()
+    */
+    protected void doShutDown() throws Exception {
+        if (serviceUnit != null) {
+            serviceUnit.shutDown();
+        }
+        super.doShutDown();
+    }
+
+
+}

Propchange: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/DefaultComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/DefaultComponent.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/DefaultComponent.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/Endpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/Endpoint.java?view=diff&rev=452064&r1=452063&r2=452064
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/Endpoint.java (original)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/Endpoint.java Mon Oct  2 08:10:58 2006
@@ -108,7 +108,7 @@
      */
     public void setServiceUnit(ServiceUnit serviceUnit) {
         this.serviceUnit = serviceUnit;
-        this.logger = serviceUnit.component.logger;
+        this.logger = serviceUnit.component.getLogger();
     }
 
     public boolean isExchangeOkay(MessageExchange exchange) {

Modified: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/Registry.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/Registry.java?view=diff&rev=452064&r1=452063&r2=452064
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/Registry.java (original)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/Registry.java Mon Oct  2 08:10:58 2006
@@ -16,6 +16,7 @@
  */
 package org.apache.servicemix.common;
 
+import javax.jbi.component.Component;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -23,11 +24,11 @@
 
 public class Registry {
 
-    protected BaseComponent component;
+    protected ServiceMixComponent component;
     protected Map endpoints;
     protected Map serviceUnits;
     
-    public Registry(BaseComponent component) {
+    public Registry(ServiceMixComponent component) {
         this.component = component;
         this.endpoints = new HashMap();
         this.serviceUnits = new HashMap();

Added: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/ServiceMixComponent.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/ServiceMixComponent.java?view=auto&rev=452064
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/ServiceMixComponent.java (added)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/ServiceMixComponent.java Mon Oct  2 08:10:58 2006
@@ -0,0 +1,57 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.common;
+
+import org.apache.commons.logging.Log;
+import org.apache.servicemix.executors.Executor;
+
+import javax.jbi.component.Component;
+import javax.jbi.component.ComponentContext;
+
+/**
+ * Represents an extended JBI Component implementation which exposes some extra features
+ *
+ * @version $Revision$
+ */
+public interface ServiceMixComponent extends Component {
+
+    /**
+     * @return Returns the logger.
+     */
+    public Log getLogger();
+
+    /**
+     * @return Returns the registry.
+     */
+    public Registry getRegistry();
+
+    /**
+     * @return Returns the executor for this component
+     */
+    public Executor getExecutor();
+
+    /**
+     * @return Returns the components context
+     */
+    public ComponentContext getComponentContext();
+
+    /**
+     * @return Returns the name of the component
+     */
+    public String getComponentName();
+}

Propchange: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/ServiceMixComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/ServiceMixComponent.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/ServiceMixComponent.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/ServiceUnit.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/ServiceUnit.java?view=diff&rev=452064&r1=452063&r2=452064
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/ServiceUnit.java (original)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/ServiceUnit.java Mon Oct  2 08:10:58 2006
@@ -28,7 +28,7 @@
 
 public class ServiceUnit {
 
-    protected BaseComponent component;
+    protected ServiceMixComponent component;
 
     protected String name;
 
@@ -41,7 +41,7 @@
     public ServiceUnit() {
     }
 
-    public ServiceUnit(BaseComponent component) {
+    public ServiceUnit(ServiceMixComponent component) {
         this.component = component;
     }
 
@@ -113,7 +113,7 @@
     /**
      * @return Returns the component.
      */
-    public BaseComponent getComponent() {
+    public ServiceMixComponent getComponent() {
         return component;
     }
 
@@ -121,7 +121,7 @@
      * @param component
      *            The component to set.
      */
-    public void setComponent(BaseComponent component) {
+    public void setComponent(ServiceMixComponent component) {
         this.component = component;
     }
 

Modified: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/AbstractXBeanDeployer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/AbstractXBeanDeployer.java?view=diff&rev=452064&r1=452063&r2=452064
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/AbstractXBeanDeployer.java (original)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/AbstractXBeanDeployer.java Mon Oct  2 08:10:58 2006
@@ -16,29 +16,28 @@
  */
 package org.apache.servicemix.common.xbean;
 
-import java.io.File;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.jbi.management.DeploymentException;
-
 import org.apache.servicemix.common.AbstractDeployer;
-import org.apache.servicemix.common.BaseComponent;
 import org.apache.servicemix.common.Endpoint;
+import org.apache.servicemix.common.ServiceMixComponent;
 import org.apache.servicemix.common.ServiceUnit;
-import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
-import org.springframework.core.io.FileSystemResource;
 import org.apache.xbean.kernel.Kernel;
 import org.apache.xbean.kernel.KernelFactory;
 import org.apache.xbean.kernel.ServiceName;
 import org.apache.xbean.server.repository.FileSystemRepository;
 import org.apache.xbean.server.spring.configuration.ClassLoaderXmlPreprocessor;
 import org.apache.xbean.server.spring.loader.SpringLoader;
+import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
+import org.springframework.core.io.FileSystemResource;
+
+import javax.jbi.management.DeploymentException;
+import java.io.File;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
 
 public class AbstractXBeanDeployer extends AbstractDeployer {
 
-    public AbstractXBeanDeployer(BaseComponent component) {
+    public AbstractXBeanDeployer(ServiceMixComponent component) {
         super(component);
     }
     

Modified: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/BaseXBeanDeployer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/BaseXBeanDeployer.java?view=diff&rev=452064&r1=452063&r2=452064
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/BaseXBeanDeployer.java (original)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/BaseXBeanDeployer.java Mon Oct  2 08:10:58 2006
@@ -16,24 +16,24 @@
  */
 package org.apache.servicemix.common.xbean;
 
-import javax.jbi.management.DeploymentException;
-
-import org.apache.servicemix.common.BaseComponent;
 import org.apache.servicemix.common.Endpoint;
+import org.apache.servicemix.common.ServiceMixComponent;
+
+import javax.jbi.management.DeploymentException;
 
 public class BaseXBeanDeployer extends AbstractXBeanDeployer {
 
     private final Class[] endpointClasses;
     
-    public BaseXBeanDeployer(BaseComponent component) {
+    public BaseXBeanDeployer(ServiceMixComponent component) {
         this(component, new Class[0]);
     }
     
-    public BaseXBeanDeployer(BaseComponent component, Class endpointClass) {
+    public BaseXBeanDeployer(ServiceMixComponent component, Class endpointClass) {
         this(component, new Class[] { endpointClass });
     }
     
-    public BaseXBeanDeployer(BaseComponent component, Class[] endpointClasses) {
+    public BaseXBeanDeployer(ServiceMixComponent component, Class[] endpointClasses) {
         super(component);
         if (endpointClasses == null) {
             throw new NullPointerException("endpointClasses must be non null");

Modified: incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/SaxonComponent.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/SaxonComponent.java?view=diff&rev=452064&r1=452063&r2=452064
==============================================================================
--- incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/SaxonComponent.java (original)
+++ incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/SaxonComponent.java Mon Oct  2 08:10:58 2006
@@ -21,6 +21,8 @@
 import org.apache.servicemix.common.BaseServiceUnitManager;
 import org.apache.servicemix.common.Deployer;
 import org.apache.servicemix.common.ServiceUnit;
+import org.apache.servicemix.common.DefaultComponent;
+import org.apache.servicemix.common.Endpoint;
 import org.apache.servicemix.common.xbean.BaseXBeanDeployer;
 import org.apache.servicemix.common.xbean.XBeanServiceUnit;
 
@@ -30,97 +32,10 @@
  *                  description="XSLT component"
  * @author <a href="mailto:gnodet [at] gmail.com">Guillaume Nodet</a>
  */
-public class SaxonComponent extends BaseComponent {
+public class SaxonComponent extends DefaultComponent {
 
-    private SaxonEndpoint[] endpoints;
-
-    /**
-     * @return Returns the endpoints.
-     */
-    public SaxonEndpoint[] getEndpoints() {
-        return endpoints;
-    }
-
-    /**
-     * @param endpoints The endpoints to set.
-     */
-    public void setEndpoints(SaxonEndpoint[] endpoints) {
-        this.endpoints = endpoints;
-    }
-    
-    /* (non-Javadoc)
-     * @see org.servicemix.common.BaseComponent#createLifeCycle()
-     */
-    protected BaseLifeCycle createLifeCycle() {
-        return new LifeCycle();
-    }
-
-    /* (non-Javadoc)
-     * @see org.servicemix.common.BaseComponent#createServiceUnitManager()
-     */
-    public BaseServiceUnitManager createServiceUnitManager() {
-        Class[] classes = new Class[] { SaxonEndpoint.class };
-        Deployer[] deployers = new Deployer[] { new BaseXBeanDeployer(this, classes) };
-        return new BaseServiceUnitManager(this, deployers);
-    }
-
-    /**
-     * @author <a href="mailto:gnodet [at] gmail.com">Guillaume Nodet</a>
-     */
-    public class LifeCycle extends BaseLifeCycle {
-
-        protected ServiceUnit su;
-        
-        public LifeCycle() {
-            super(SaxonComponent.this);
-        }
-        
-        /* (non-Javadoc)
-         * @see org.servicemix.common.BaseLifeCycle#doInit()
-         */
-        protected void doInit() throws Exception {
-            super.doInit();
-            if (endpoints != null && endpoints.length > 0) {
-                su = new XBeanServiceUnit();
-                su.setComponent(SaxonComponent.this);
-                for (int i = 0; i < endpoints.length; i++) {
-                    endpoints[i].setServiceUnit(su);
-                    endpoints[i].validate();
-                    su.addEndpoint(endpoints[i]);
-                }
-                getRegistry().registerServiceUnit(su);
-            }
-        }
-
-        /* (non-Javadoc)
-         * @see org.servicemix.common.BaseLifeCycle#doStart()
-         */
-        protected void doStart() throws Exception {
-            super.doStart();
-            if (su != null) {
-                su.start();
-            }
-        }
-        
-        /* (non-Javadoc)
-         * @see org.servicemix.common.BaseLifeCycle#doStop()
-         */
-        protected void doStop() throws Exception {
-            if (su != null) {
-                su.stop();
-            }
-            super.doStop();
-        }
-        
-        /* (non-Javadoc)
-         * @see org.servicemix.common.BaseLifeCycle#doShutDown()
-         */
-        protected void doShutDown() throws Exception {
-            if (su != null) {
-                su.shutDown();
-            }
-            super.doShutDown();
-        }
+    protected Class[] getEndpointClasses() {
+        return new Class[] { SaxonEndpoint.class };
     }
 
 }