activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r521318 - in /activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi: CamelContainerBootstrap.java CamelContainerDeployer.java CamelEndpointComponent.java CamelServiceEngine.java CamelServiceEngineEndpoint.java
Date Thu, 22 Mar 2007 16:09:55 GMT
Author: rajdavies
Date: Thu Mar 22 09:09:54 2007
New Revision: 521318

URL: http://svn.apache.org/viewvc?view=rev&rev=521318
Log:
Add a ServiceEngine Camel Component Container endpoint Component

Added:
    activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelContainerBootstrap.java
  (with props)
    activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelContainerDeployer.java
  (with props)
    activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelEndpointComponent.java
  (with props)
    activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelServiceEngine.java
  (with props)
    activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelServiceEngineEndpoint.java
  (with props)

Added: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelContainerBootstrap.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelContainerBootstrap.java?view=auto&rev=521318
==============================================================================
--- activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelContainerBootstrap.java
(added)
+++ activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelContainerBootstrap.java
Thu Mar 22 09:09:54 2007
@@ -0,0 +1,164 @@
+/*
+ * 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.camel.component.jbi;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.jbi.JBIException;
+import javax.jbi.component.Bootstrap;
+import javax.jbi.component.InstallationContext;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * Base class for components bootstrap.
+ * @version $Revision: 426415 $
+ */
+public class CamelContainerBootstrap implements Bootstrap {
+
+    protected final transient Log logger = LogFactory.getLog(getClass());
+    
+    protected InstallationContext context;
+    protected ObjectName mbeanName;
+    
+    public CamelContainerBootstrap() {
+    }
+    
+    public ObjectName getExtensionMBeanName() {
+        return mbeanName;
+    }
+
+    protected Object getExtensionMBean() throws Exception {
+        return null;
+    }
+    
+    protected ObjectName createExtensionMBeanName() throws Exception {
+        return this.context.getContext().getMBeanNames().createCustomComponentMBeanName("bootstrap");
+    }
+
+    /* (non-Javadoc)
+     * @see javax.jbi.component.Bootstrap#init(javax.jbi.component.InstallationContext)
+     */
+    public void init(InstallationContext installContext) throws JBIException {
+        try {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Initializing bootstrap");
+            }
+            this.context = installContext;
+            doInit();
+            if (logger.isDebugEnabled()) {
+                logger.debug("Bootstrap initialized");
+            }
+        } catch (JBIException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new JBIException("Error calling init", e);
+        }
+    }
+
+    protected void doInit() throws Exception {
+        Object mbean = getExtensionMBean();
+        if (mbean != null) {
+            this.mbeanName = createExtensionMBeanName();
+            MBeanServer server = this.context.getContext().getMBeanServer();
+            if (server == null) {
+                throw new JBIException("null mBeanServer");
+            }
+            if (server.isRegistered(this.mbeanName)) {
+                server.unregisterMBean(this.mbeanName);
+            }
+            server.registerMBean(mbean, this.mbeanName);
+        }
+    }
+    
+    /* (non-Javadoc)
+     * @see javax.jbi.component.Bootstrap#cleanUp()
+     */
+    public void cleanUp() throws JBIException {
+        try {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Cleaning up bootstrap");
+            }
+            doCleanUp();
+            if (logger.isDebugEnabled()) {
+                logger.debug("Bootstrap cleaned up");
+            }
+        } catch (JBIException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new JBIException("Error calling cleanUp", e);
+        }
+    }
+
+    protected void doCleanUp() throws Exception {
+        if (this.mbeanName != null) {
+            MBeanServer server = this.context.getContext().getMBeanServer();
+            if (server == null) {
+                throw new JBIException("null mBeanServer");
+            }
+            if (server.isRegistered(this.mbeanName)) {
+                server.unregisterMBean(this.mbeanName);
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see javax.jbi.component.Bootstrap#onInstall()
+     */
+    public void onInstall() throws JBIException {
+        try {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Bootstrap onInstall");
+            }
+            doOnInstall();
+            if (logger.isDebugEnabled()) {
+                logger.debug("Bootstrap onInstall done");
+            }
+        } catch (JBIException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new JBIException("Error calling onInstall", e);
+        }
+    }
+
+    protected void doOnInstall() throws Exception {
+    }
+    
+    /* (non-Javadoc)
+     * @see javax.jbi.component.Bootstrap#onUninstall()
+     */
+    public void onUninstall() throws JBIException {
+        try {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Bootstrap onUninstall");
+            }
+            doOnUninstall();
+            if (logger.isDebugEnabled()) {
+                logger.debug("Bootstrap onUninstall done");
+            }
+        } catch (JBIException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new JBIException("Error calling onUninstall", e);
+        }
+    }
+
+    protected void doOnUninstall() throws Exception {
+    }
+    
+}

Propchange: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelContainerBootstrap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelContainerDeployer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelContainerDeployer.java?view=auto&rev=521318
==============================================================================
--- activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelContainerDeployer.java
(added)
+++ activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelContainerDeployer.java
Thu Mar 22 09:09:54 2007
@@ -0,0 +1,73 @@
+/*
+ * 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.camel.component.jbi;
+
+import javax.jbi.management.DeploymentException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.servicemix.common.Deployer;
+import org.apache.servicemix.common.ServiceMixComponent;
+import org.apache.servicemix.common.ServiceUnit;
+
+/**
+ * Deploys service units
+ * @version $Revision: 426415 $
+ */
+public class CamelContainerDeployer implements Deployer {
+
+    private RouteBuilder[] builders;
+    ServiceUnit serviceUnit;
+    CamelContainerDeployer(ServiceMixComponent component,RouteBuilder[] builders){
+        this.serviceUnit = new ServiceUnit(component);
+        this.builders = builders;
+        //need to wire-up here
+    }
+    /**
+     * @param serviceUnitName
+     * @param serviceUnitRootPath
+     * @return
+     * @see org.apache.servicemix.common.Deployer#canDeploy(java.lang.String, java.lang.String)
+     */
+    public boolean canDeploy(String serviceUnitName,String serviceUnitRootPath){
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    /**
+     * @param serviceUnitName
+     * @param serviceUnitRootPath
+     * @return
+     * @throws DeploymentException
+     * @see org.apache.servicemix.common.Deployer#deploy(java.lang.String, java.lang.String)
+     */
+    public ServiceUnit deploy(String serviceUnitName,String serviceUnitRootPath) throws DeploymentException{
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /**
+     * @param su
+     * @throws DeploymentException
+     * @see org.apache.servicemix.common.Deployer#undeploy(org.apache.servicemix.common.ServiceUnit)
+     */
+    public void undeploy(ServiceUnit su) throws DeploymentException{
+        // TODO Auto-generated method stub
+        
+    }
+
+    
+
+}

Propchange: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelContainerDeployer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelEndpointComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelEndpointComponent.java?view=auto&rev=521318
==============================================================================
--- activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelEndpointComponent.java
(added)
+++ activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelEndpointComponent.java
Thu Mar 22 09:09:54 2007
@@ -0,0 +1,39 @@
+/**
+ * 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.camel.component.jbi;
+
+import org.apache.servicemix.components.util.ComponentSupport;
+
+
+
+/**
+ * The Component activated in the JBIContainer
+ * @version $Revision: 426415 $
+ */
+public class CamelEndpointComponent extends ComponentSupport {
+    private JbiEndpoint jbiEndpoint;
+    
+    CamelEndpointComponent(JbiEndpoint jbiEndpoint){
+        this.jbiEndpoint=jbiEndpoint;
+    }
+    
+    public String getName() {
+        return jbiEndpoint.getEndpointUri();
+    }
+    
+
+}

Propchange: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelEndpointComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelServiceEngine.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelServiceEngine.java?view=auto&rev=521318
==============================================================================
--- activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelServiceEngine.java
(added)
+++ activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelServiceEngine.java
Thu Mar 22 09:09:54 2007
@@ -0,0 +1,56 @@
+/**
+ * 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.camel.component.jbi;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.BaseServiceUnitManager;
+import org.apache.servicemix.common.Deployer;
+
+/**
+ * Deploys the camel endpoints within JBI
+ * @version $Revision: 426415 $
+ */
+public class CamelServiceEngine extends BaseComponent {
+    
+    private RouteBuilder[] builders;
+
+    /* (non-Javadoc)
+     * @see org.servicemix.common.BaseComponent#createServiceUnitManager()
+     */
+    public BaseServiceUnitManager createServiceUnitManager() {
+        Deployer[] deployers = new Deployer[] { new CamelContainerDeployer(this,builders)
};
+        return new BaseServiceUnitManager(this, deployers);
+    }
+
+    
+    /**
+     * @return the builders
+     */
+    public RouteBuilder[] getBuilders(){
+        return this.builders;
+    }
+
+    
+    /**
+     * @param builders the builders to set
+     */
+    public void setBuilders(RouteBuilder[] builders){
+        this.builders=builders;
+    }
+
+}

Propchange: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelServiceEngine.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelServiceEngineEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelServiceEngineEndpoint.java?view=auto&rev=521318
==============================================================================
--- activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelServiceEngineEndpoint.java
(added)
+++ activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelServiceEngineEndpoint.java
Thu Mar 22 09:09:54 2007
@@ -0,0 +1,66 @@
+/*
+ * 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.camel.component.jbi;
+
+import javax.jbi.component.ComponentContext;
+import javax.jbi.messaging.MessageExchange.Role;
+import javax.xml.namespace.QName;
+import org.apache.servicemix.common.ExchangeProcessor;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.framework.ComponentContextImpl;
+
+/**
+ * The endpoint in the service engine
+ * @version $Revision: 426415 $
+ */
+public class CamelServiceEngineEndpoint extends org.apache.servicemix.common.Endpoint {
+
+    private static final QName SERVICE_NAME = new QName("http://camel.servicemix.org", "CamelEndpointComponent");
+    
+    private CamelEndpointComponent camelEndpointComponent;
+    
+    public CamelServiceEngineEndpoint(JbiEndpoint jbiEndpoint) {
+        this.camelEndpointComponent = new CamelEndpointComponent(jbiEndpoint);
+        this.service = SERVICE_NAME;
+        this.endpoint=jbiEndpoint.getEndpointUri();
+    }
+    
+    public Role getRole() {
+        throw new UnsupportedOperationException();
+    }
+
+    public void activate() throws Exception {
+        getContainer().activateComponent(camelEndpointComponent,camelEndpointComponent.getName());
+    }
+
+    public void deactivate() throws Exception {
+        getContainer().deactivateComponent(camelEndpointComponent.getName());
+    }
+
+    public ExchangeProcessor getProcessor() {
+        throw new UnsupportedOperationException();
+    }
+
+    public JBIContainer getContainer() {
+        ComponentContext context = getServiceUnit().getComponent().getComponentContext();
+        if( context instanceof ComponentContextImpl ) {
+            return ((ComponentContextImpl) context).getContainer();
+        }
+        throw new IllegalStateException("LwContainer component can only be deployed in ServiceMix");
+    }
+
+}

Propchange: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/CamelServiceEngineEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message