You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2012/01/23 20:48:12 UTC

svn commit: r1234948 - in /openejb/trunk/camel/camel-openejb: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/openejb/ src/main/java/org/apache/openejb/camel/ src/main/resources/ src/main/resources...

Author: rmannibucau
Date: Mon Jan 23 19:48:11 2012
New Revision: 1234948

URL: http://svn.apache.org/viewvc?rev=1234948&view=rev
Log:
adding camel-openejb component to be able to deploy/undeploy app from camel routes

Added:
    openejb/trunk/camel/camel-openejb/
    openejb/trunk/camel/camel-openejb/pom.xml
    openejb/trunk/camel/camel-openejb/src/
    openejb/trunk/camel/camel-openejb/src/main/
    openejb/trunk/camel/camel-openejb/src/main/java/
    openejb/trunk/camel/camel-openejb/src/main/java/org/
    openejb/trunk/camel/camel-openejb/src/main/java/org/apache/
    openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/
    openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/
    openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/AutoProducer.java
    openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/DeployProducer.java
    openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/DeploymentProducer.java
    openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/OpenEJBComponent.java
    openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/OpenEJBEndpoint.java
    openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/UnDeployProducer.java
    openejb/trunk/camel/camel-openejb/src/main/resources/
    openejb/trunk/camel/camel-openejb/src/main/resources/META-INF/
    openejb/trunk/camel/camel-openejb/src/main/resources/META-INF/services/
    openejb/trunk/camel/camel-openejb/src/main/resources/META-INF/services/org/
    openejb/trunk/camel/camel-openejb/src/main/resources/META-INF/services/org/apache/
    openejb/trunk/camel/camel-openejb/src/main/resources/META-INF/services/org/apache/camel/
    openejb/trunk/camel/camel-openejb/src/main/resources/META-INF/services/org/apache/camel/component/
    openejb/trunk/camel/camel-openejb/src/main/resources/META-INF/services/org/apache/camel/component/openejb
    openejb/trunk/camel/camel-openejb/src/test/
    openejb/trunk/camel/camel-openejb/src/test/additional-resources/
    openejb/trunk/camel/camel-openejb/src/test/additional-resources/test.jar   (with props)
    openejb/trunk/camel/camel-openejb/src/test/java/
    openejb/trunk/camel/camel-openejb/src/test/java/org/
    openejb/trunk/camel/camel-openejb/src/test/java/org/apache/
    openejb/trunk/camel/camel-openejb/src/test/java/org/apache/openejb/
    openejb/trunk/camel/camel-openejb/src/test/java/org/apache/openejb/camel/
    openejb/trunk/camel/camel-openejb/src/test/java/org/apache/openejb/camel/OpenEJBDeploymentCamelTest.java
    openejb/trunk/camel/camel-openejb/src/test/resources/
    openejb/trunk/camel/camel-openejb/src/test/resources/META-INF/
    openejb/trunk/camel/camel-openejb/src/test/resources/META-INF/beans.xml

Added: openejb/trunk/camel/camel-openejb/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/camel/camel-openejb/pom.xml?rev=1234948&view=auto
==============================================================================
--- openejb/trunk/camel/camel-openejb/pom.xml (added)
+++ openejb/trunk/camel/camel-openejb/pom.xml Mon Jan 23 19:48:11 2012
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.openejb</groupId>
+  <artifactId>camel-openejb</artifactId>
+  <version>4.0.0-beta-2-SNAPSHOT</version>
+  <name>Camel :: OpenEJB</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+      <version>${camel.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>openejb-core</artifactId>
+      <version>4.0.0-beta-2-SNAPSHOT</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <version>${camel.version}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <properties>
+    <camel.version>2.9.0</camel.version>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+</project>

Added: openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/AutoProducer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/AutoProducer.java?rev=1234948&view=auto
==============================================================================
--- openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/AutoProducer.java (added)
+++ openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/AutoProducer.java Mon Jan 23 19:48:11 2012
@@ -0,0 +1,43 @@
+/**
+ * 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.openejb.camel;
+
+import org.apache.camel.CamelExchangeException;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Producer;
+import org.apache.openejb.assembler.classic.AppInfo;
+
+import java.util.Map;
+
+public class AutoProducer extends DeploymentProducer {
+    public static final String COMMAND = "command";
+
+    private Map<String, Object> parameters;
+
+    public AutoProducer(final Endpoint ep, final Map<String, Object> parameters) {
+        super(ep, parameters);
+        this.parameters = parameters;
+    }
+
+    @Override
+    protected void doProcess(final Exchange exchange, final String path) throws CamelExchangeException {
+        final String cmd = exchange.getIn().getHeader(COMMAND, String.class);
+        final DeploymentProducer producer = (DeploymentProducer) ((OpenEJBEndpoint) getEndpoint()).createOpenEJBProducer(cmd, getEndpoint(), parameters);
+        producer.doProcess(exchange, path);
+    }
+}

Added: openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/DeployProducer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/DeployProducer.java?rev=1234948&view=auto
==============================================================================
--- openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/DeployProducer.java (added)
+++ openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/DeployProducer.java Mon Jan 23 19:48:11 2012
@@ -0,0 +1,41 @@
+/**
+ * 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.openejb.camel;
+
+import org.apache.camel.CamelExchangeException;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.openejb.assembler.classic.AppInfo;
+
+import java.util.Map;
+
+public class DeployProducer extends DeploymentProducer {
+    public DeployProducer(final Endpoint ep, final Map<String, Object> parameters) {
+        super(ep, parameters);
+    }
+
+    @Override
+    protected void doProcess(final Exchange exchange, final String path) throws CamelExchangeException {
+        try {
+            final AppInfo infos = deployer(exchange).deploy(path);
+            exchange.getIn().setBody(infos);
+            exchange.setProperty(DeploymentProducer.LOCATION_KEY, path);
+        } catch (Exception e) {
+            throw new CamelExchangeException("can't deploy '" + path + "'", exchange);
+        }
+    }
+}

Added: openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/DeploymentProducer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/DeploymentProducer.java?rev=1234948&view=auto
==============================================================================
--- openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/DeploymentProducer.java (added)
+++ openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/DeploymentProducer.java Mon Jan 23 19:48:11 2012
@@ -0,0 +1,85 @@
+/**
+ * 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.openejb.camel;
+
+import org.apache.camel.CamelExchangeException;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.openejb.assembler.Deployer;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.Map;
+import java.util.Properties;
+
+public abstract class DeploymentProducer extends DefaultProducer {
+    public static final String LOCATION_KEY = "location";
+    public static final String INITIAL_CONTEXT_PROPERTIES = "properties";
+
+    private String path;
+    private Properties properties;
+
+    public DeploymentProducer(final Endpoint ep, final Map<String, Object> parameters) {
+        super(ep);
+        if (parameters.containsKey(LOCATION_KEY)) {
+            path = ep.getCamelContext().getTypeConverter().convertTo(String.class, parameters.get(LOCATION_KEY));
+        } else {
+            path = null;
+        }
+        if (parameters.containsKey(INITIAL_CONTEXT_PROPERTIES)) {
+            properties = ep.getCamelContext().getTypeConverter().convertTo(Properties.class, parameters.get(INITIAL_CONTEXT_PROPERTIES));
+        } else {
+            properties = null;
+        }
+    }
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        String location = exchange.getIn().getHeader(LOCATION_KEY, String.class);
+        if (location == null) {
+            location = path;
+        }
+        if (location == null) {
+            location = exchange.getIn().getBody(String.class);
+        }
+        if (location == null) {
+            throw new IllegalArgumentException(LOCATION_KEY + " should be provided by header or parameter");
+        }
+        doProcess(exchange, location);
+    }
+
+    protected abstract void doProcess(final Exchange exchange, final String path) throws CamelExchangeException;
+
+    protected <T> T lookup(final Class<T> clazz, final String jndiName, final Properties exchangeProperties) throws NamingException {
+        final Properties p = new Properties();
+        if (exchangeProperties != null) {
+            p.putAll(exchangeProperties);
+        } else if (properties != null) {
+            p.putAll(properties);
+        } else {
+            p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+        }
+        return (T) new InitialContext(p).lookup(jndiName);
+    }
+
+    protected Deployer deployer(final Exchange exchange) throws NamingException {
+        return lookup(Deployer.class, "openejb/DeployerBusinessRemote",
+                exchange.getIn().getHeader(INITIAL_CONTEXT_PROPERTIES, Properties.class));
+    }
+}

Added: openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/OpenEJBComponent.java
URL: http://svn.apache.org/viewvc/openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/OpenEJBComponent.java?rev=1234948&view=auto
==============================================================================
--- openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/OpenEJBComponent.java (added)
+++ openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/OpenEJBComponent.java Mon Jan 23 19:48:11 2012
@@ -0,0 +1,32 @@
+/**
+ * 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.openejb.camel;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class OpenEJBComponent extends DefaultComponent {
+    @Override
+    protected Endpoint createEndpoint(final String uri, final String command, final Map<String, Object> parameters) throws Exception {
+        final Map<String, Object> params = new HashMap<String, Object>(parameters);
+        parameters.clear();
+        return new OpenEJBEndpoint(uri, command, params);
+    }
+}

Added: openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/OpenEJBEndpoint.java
URL: http://svn.apache.org/viewvc/openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/OpenEJBEndpoint.java?rev=1234948&view=auto
==============================================================================
--- openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/OpenEJBEndpoint.java (added)
+++ openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/OpenEJBEndpoint.java Mon Jan 23 19:48:11 2012
@@ -0,0 +1,68 @@
+/**
+ * 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.openejb.camel;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+
+import java.util.Map;
+
+public class OpenEJBEndpoint extends DefaultEndpoint {
+    private String uri;
+    private String command;
+    private Map<String, Object> parameters;
+
+    public OpenEJBEndpoint(final String uri, final String command, final Map<String, Object> parameters) {
+        this.uri = uri;
+        this.command = command;
+        this.parameters = parameters;
+    }
+
+    @Override
+    public Producer createProducer() throws Exception {
+        return createOpenEJBProducer(command, this, parameters);
+    }
+
+    public Producer createOpenEJBProducer(final String command, final Endpoint endpoint, final Map<String, Object> parameters) {
+        if ("deploy".equals(command)) {
+            return new DeployProducer(this, parameters);
+        } else if ("undeploy".equals(command)) {
+            return new UnDeployProducer(this, parameters);
+        } else if ("auto".equals(command)) {
+            return new AutoProducer(this, parameters);
+        }
+        throw new IllegalArgumentException("command '" + command + "' is not supported");        
+    }
+
+    @Override
+    public Consumer createConsumer(Processor processor) throws Exception {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return false;
+    }
+
+    @Override
+    protected String createEndpointUri() {
+        return uri;
+    }
+}

Added: openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/UnDeployProducer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/UnDeployProducer.java?rev=1234948&view=auto
==============================================================================
--- openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/UnDeployProducer.java (added)
+++ openejb/trunk/camel/camel-openejb/src/main/java/org/apache/openejb/camel/UnDeployProducer.java Mon Jan 23 19:48:11 2012
@@ -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.openejb.camel;
+
+import org.apache.camel.CamelExchangeException;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+
+import java.util.Map;
+
+public class UnDeployProducer extends DeploymentProducer {
+    public UnDeployProducer(final Endpoint ep, final Map<String, Object> parameters) {
+        super(ep, parameters);
+    }
+
+    @Override
+    protected void doProcess(final Exchange exchange, final String path) throws CamelExchangeException {
+        try {
+            deployer(exchange).undeploy(path);
+            exchange.setProperty(LOCATION_KEY, path);
+        } catch (Exception e) {
+            throw new CamelExchangeException("can't undeploy '" + path + "'", exchange);
+        }
+    }
+}

Added: openejb/trunk/camel/camel-openejb/src/main/resources/META-INF/services/org/apache/camel/component/openejb
URL: http://svn.apache.org/viewvc/openejb/trunk/camel/camel-openejb/src/main/resources/META-INF/services/org/apache/camel/component/openejb?rev=1234948&view=auto
==============================================================================
--- openejb/trunk/camel/camel-openejb/src/main/resources/META-INF/services/org/apache/camel/component/openejb (added)
+++ openejb/trunk/camel/camel-openejb/src/main/resources/META-INF/services/org/apache/camel/component/openejb Mon Jan 23 19:48:11 2012
@@ -0,0 +1,17 @@
+#
+# 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.
+#
+class = org.apache.openejb.camel.OpenEJBComponent

Added: openejb/trunk/camel/camel-openejb/src/test/additional-resources/test.jar
URL: http://svn.apache.org/viewvc/openejb/trunk/camel/camel-openejb/src/test/additional-resources/test.jar?rev=1234948&view=auto
==============================================================================
Binary file - no diff available.

Propchange: openejb/trunk/camel/camel-openejb/src/test/additional-resources/test.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: openejb/trunk/camel/camel-openejb/src/test/java/org/apache/openejb/camel/OpenEJBDeploymentCamelTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/camel/camel-openejb/src/test/java/org/apache/openejb/camel/OpenEJBDeploymentCamelTest.java?rev=1234948&view=auto
==============================================================================
--- openejb/trunk/camel/camel-openejb/src/test/java/org/apache/openejb/camel/OpenEJBDeploymentCamelTest.java (added)
+++ openejb/trunk/camel/camel-openejb/src/test/java/org/apache/openejb/camel/OpenEJBDeploymentCamelTest.java Mon Jan 23 19:48:11 2012
@@ -0,0 +1,127 @@
+/**
+ * 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.openejb.camel;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.spi.ContainerSystem;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+
+public class OpenEJBDeploymentCamelTest extends CamelTestSupport {
+    private static EJBContainer container;
+
+    @EndpointInject(uri = "mock:deployResult")
+    protected MockEndpoint deployResult;
+
+    @EndpointInject(uri = "mock:undeployResult")
+    protected MockEndpoint undeployResult;
+
+    @EndpointInject(uri = "mock:autoResult")
+    protected MockEndpoint autoResult;
+
+    @Produce(uri = "direct:deploy")
+    protected ProducerTemplate deployTemplate;
+
+    @Produce(uri = "direct:auto")
+    protected ProducerTemplate autoTemplate;
+
+    @Produce(uri = "direct:undeploy")
+    protected ProducerTemplate undeployTemplate;
+
+    @BeforeClass
+    public static void start() {
+        System.setProperty("openejb.deployments.classpath.filter.systemapps", "false"); // to get the deployer
+        container = EJBContainer.createEJBContainer();
+    }
+
+    @AfterClass
+    public static void close() {
+        if (container != null) {
+            container.close();
+        }
+        System.clearProperty("openejb.deployments.classpath.filter.systemapps");
+    }
+
+    @Test
+    public void deployUndeploy() throws Exception {
+        final int appNbr = nbApp();
+        final String path = "src/test/additional-resources/test.jar";
+
+        deployResult.expectedMessageCount(1);
+        deployResult.expectedPropertyReceived("location", path);
+        deployTemplate.sendBody(path);
+        deployResult.assertIsSatisfied();
+        assertEquals(appNbr + 1, nbApp());
+
+        undeployResult.expectedMessageCount(1);
+        undeployResult.expectedPropertyReceived("location", path);
+        undeployTemplate.sendBody(path);
+        undeployResult.assertIsSatisfied();
+        assertEquals(appNbr, nbApp());
+    }
+
+    @Test
+    public void auto() throws Exception {
+        final int appNbr = nbApp();
+        final String path = "src/test/additional-resources/test.jar";
+
+        autoResult.expectedMessageCount(1);
+        autoResult.expectedPropertyReceived("location", path);
+        autoTemplate.sendBodyAndHeader(path, "command", "deploy");
+        autoResult.assertIsSatisfied();
+        assertEquals(appNbr + 1, nbApp());
+
+        autoResult.reset();
+        autoResult.expectedMessageCount(1);
+        autoResult.expectedPropertyReceived("location", path);
+        autoTemplate.sendBodyAndHeader(path, "command", "undeploy");
+        autoResult.assertIsSatisfied();
+        assertEquals(appNbr, nbApp());
+    }
+
+    private static int nbApp() {
+        return SystemInstance.get().getComponent(ContainerSystem.class).getAppContexts().size();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:deploy")
+                    .to("openejb:deploy")
+                    .to("mock:deployResult");
+
+                from("direct:undeploy")
+                    .to("openejb:undeploy")
+                    .to("mock:undeployResult");
+
+                from("direct:auto")
+                        .to("openejb:auto")
+                        .to("mock:autoResult");
+            }
+        };
+    }
+}

Added: openejb/trunk/camel/camel-openejb/src/test/resources/META-INF/beans.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/camel/camel-openejb/src/test/resources/META-INF/beans.xml?rev=1234948&view=auto
==============================================================================
    (empty)