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 2007/06/27 14:09:14 UTC
svn commit: r551136 - in /incubator/servicemix/trunk: ./
deployables/serviceengines/ deployables/serviceengines/servicemix-camel/
deployables/serviceengines/servicemix-camel/src/
deployables/serviceengines/servicemix-camel/src/main/ deployables/service...
Author: jstrachan
Date: Wed Jun 27 05:09:13 2007
New Revision: 551136
URL: http://svn.apache.org/viewvc?view=rev&rev=551136
Log:
added an early SE for Camel
Added:
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/pom.xml (with props)
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelContextComponent.java (with props)
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelEndpoint.java (with props)
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelSpringDeployer.java (with props)
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/package.html (with props)
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/jbi/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/jbi/jboss-service.xml
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/resources/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/java/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/java/org/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/CamelContextComponentTest.java (with props)
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/resources/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/resources/log4j.properties (with props)
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/resources/org/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su1-src/
incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su1-src/camel-context.xml (with props)
Modified:
incubator/servicemix/trunk/deployables/serviceengines/pom.xml
incubator/servicemix/trunk/pom.xml
Modified: incubator/servicemix/trunk/deployables/serviceengines/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/pom.xml?view=diff&rev=551136&r1=551135&r2=551136
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/pom.xml (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/pom.xml Wed Jun 27 05:09:13 2007
@@ -36,6 +36,7 @@
<modules>
<module>servicemix-bean</module>
<module>servicemix-bpe</module>
+ <module>servicemix-camel</module>
<module>servicemix-drools</module>
<module>servicemix-eip</module>
<module>servicemix-jsr181</module>
Added: incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/pom.xml?view=auto&rev=551136
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/pom.xml (added)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/pom.xml Wed Jun 27 05:09:13 2007
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/maven-v4_0_0.xsd">
+
+<!--
+
+ 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.
+-->
+
+ <parent>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>serviceengines</artifactId>
+ <version>3.2-incubating-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-camel</artifactId>
+ <packaging>jbi-component</packaging>
+ <name>ServiceMix :: Came</name>
+ <description>A Camel component</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-shared</artifactId>
+ <version>${servicemix-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-core</artifactId>
+ <version>${servicemix-version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ <version>${camel-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring</artifactId>
+ <version>${camel-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-jbi</artifactId>
+ <version>${camel-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.servicemix.tooling</groupId>
+ <artifactId>jbi-maven-plugin</artifactId>
+ <version>${servicemix-version}</version>
+ <extensions>true</extensions>
+ <configuration>
+ <type>service-engine</type>
+ <component>org.apache.servicemix.camel.CamelContextComponent</component>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <!-- TODO -->
+ <exclude>**/CamelContextComponentTest.*</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ </build>
+
+</project>
Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelContextComponent.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelContextComponent.java?view=auto&rev=551136
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelContextComponent.java (added)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelContextComponent.java Wed Jun 27 05:09:13 2007
@@ -0,0 +1,33 @@
+/*
+ * 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.camel;
+
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.BaseServiceUnitManager;
+import org.apache.servicemix.common.Deployer;
+
+public class CamelContextComponent extends BaseComponent {
+
+ /* (non-Javadoc)
+ * @see org.servicemix.common.BaseComponent#createServiceUnitManager()
+ */
+ public BaseServiceUnitManager createServiceUnitManager() {
+ Deployer[] deployers = new Deployer[] {new CamelSpringDeployer(this) };
+ return new BaseServiceUnitManager(this, deployers);
+ }
+
+}
\ No newline at end of file
Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelContextComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelEndpoint.java?view=auto&rev=551136
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelEndpoint.java (added)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelEndpoint.java Wed Jun 27 05:09:13 2007
@@ -0,0 +1,72 @@
+/*
+ * 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.camel;
+
+import javax.jbi.component.ComponentContext;
+import javax.jbi.messaging.MessageExchange.Role;
+import javax.xml.namespace.QName;
+
+import org.apache.activemq.util.IdGenerator;
+import org.apache.servicemix.common.Endpoint;
+import org.apache.servicemix.common.ExchangeProcessor;
+import org.apache.servicemix.jbi.container.ActivationSpec;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.framework.ComponentContextImpl;
+
+public class CamelEndpoint extends Endpoint {
+
+ private static final QName SERVICE_NAME = new QName("http://lwcontainer.servicemix.org", "LwContainerComponent");
+
+ private ActivationSpec activationSpec;
+
+ public CamelEndpoint(ActivationSpec activationSpec) {
+ this.activationSpec = activationSpec;
+ this.service = SERVICE_NAME;
+ if (activationSpec.getId() != null) {
+ this.endpoint = activationSpec.getId();
+ } else if (activationSpec.getComponentName() != null) {
+ this.endpoint = activationSpec.getComponentName();
+ } else {
+ this.endpoint = new IdGenerator().generateId();
+ }
+ }
+
+ public Role getRole() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void activate() throws Exception {
+ getContainer().activateComponent(activationSpec);
+ }
+
+ public void deactivate() throws Exception {
+ getContainer().deactivateComponent(activationSpec.getId());
+ }
+
+ 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");
+ }
+
+}
\ No newline at end of file
Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelEndpoint.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelSpringDeployer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelSpringDeployer.java?view=auto&rev=551136
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelSpringDeployer.java (added)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelSpringDeployer.java Wed Jun 27 05:09:13 2007
@@ -0,0 +1,98 @@
+/*
+ * 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.camel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.xbean.AbstractXBeanDeployer;
+import org.apache.servicemix.jbi.container.ActivationSpec;
+import org.apache.servicemix.jbi.container.SpringServiceUnitContainer;
+import org.apache.xbean.kernel.Kernel;
+import org.apache.xbean.kernel.StringServiceName;
+/*
+import org.apache.xbean.server.spring.loader.SpringLoader;
+import org.apache.xbean.kernel.ServiceFactory;
+import org.apache.xbean.kernel.ServiceName;
+import org.apache.xbean.server.spring.configuration.SpringConfigurationServiceFactory;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import org.springframework.context.support.FileSystemXmlApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import java.util.Iterator;
+*/
+
+public class CamelSpringDeployer extends AbstractXBeanDeployer {
+ public CamelSpringDeployer(BaseComponent component) {
+ super(component);
+ }
+
+ protected String getXBeanFile() {
+ return "camel-context";
+ }
+
+ protected List getServices(Kernel kernel) {
+ try {
+ Object jbi = kernel.getService(new StringServiceName("jbi"));
+ SpringServiceUnitContainer suContainer = (SpringServiceUnitContainer) jbi;
+ ActivationSpec[] specs = suContainer.getActivationSpecs();
+ List services = new ArrayList();
+ for (int i = 0; i < specs.length; i++) {
+ services.add(new CamelEndpoint(specs[i]));
+ }
+ return services;
+ } catch (Exception e) {
+ throw new RuntimeException("Can not find 'jbi' bean", e);
+ }
+ }
+
+ /*
+ @Override
+ protected SpringLoader createSpringLoader() {
+ return new SpringLoader() {
+ @Override
+ public ServiceName load(String location) throws Exception {
+ String resolvedLocation = getBaseDir().toURI().resolve(location).getPath();
+ String configLocation = "/" + resolvedLocation + ".xml";
+ FileSystemXmlApplicationContext applicationContext = new FileSystemXmlApplicationContext(
+ new String[]{configLocation},
+ false);
+
+ for (Iterator iter = getBeanFactoryPostProcessors().iterator(); iter.hasNext();) {
+ BeanFactoryPostProcessor processor = (BeanFactoryPostProcessor) iter.next();
+ applicationContext.addBeanFactoryPostProcessor(processor);
+ }
+ applicationContext.setDisplayName(location);
+
+ ClassLoader classLoader = applicationContext.getClassLoader();
+ if (classLoader == null) {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ }
+ if (classLoader == null) {
+ classLoader = SpringLoader.class.getClassLoader();
+ }
+
+ ServiceName serviceName = new StringServiceName("configuration:" + location);
+ ServiceFactory springConfigurationServiceFactory = new SpringConfigurationServiceFactory(applicationContext);
+ getKernel().registerService(serviceName, springConfigurationServiceFactory);
+ return serviceName;
+ }
+ };
+ }
+ */
+}
\ No newline at end of file
Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelSpringDeployer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/package.html
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/package.html?view=auto&rev=551136
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/package.html (added)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/package.html Wed Jun 27 05:09:13 2007
@@ -0,0 +1,27 @@
+<!--
+
+ 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.
+
+-->
+<html>
+<head>
+</head>
+<body>
+
+A component for working with <a href="http://activemq.apache.org/camel/">Apache Camel</a> as a routing and mediation engine.
+
+</body>
+</html>
Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/jbi/jboss-service.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/jbi/jboss-service.xml?view=auto&rev=551136
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/jbi/jboss-service.xml (added)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/jbi/jboss-service.xml Wed Jun 27 05:09:13 2007
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!-- The J2EE application client deployer service
-->
<server>
<depends>org.servicemix:service=Deployer</depends>
</server>
\ No newline at end of file
Added: incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/CamelContextComponentTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/CamelContextComponentTest.java?view=auto&rev=551136
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/CamelContextComponentTest.java (added)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/CamelContextComponentTest.java Wed Jun 27 05:09:13 2007
@@ -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.servicemix.camel;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+
+import javax.jbi.messaging.InOut;
+import javax.jbi.messaging.MessagingException;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.client.ServiceMixClient;
+import org.apache.servicemix.jbi.container.JBIContainer;
+
+/**
+ *
+ * @version $Revision: 526407 $
+ */
+public class CamelContextComponentTest extends TestCase {
+ protected JBIContainer container = new JBIContainer();
+
+ private File tempRootDir;
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ container.setCreateMBeanServer(false);
+ container.setMonitorInstallationDirectory(false);
+ tempRootDir = File.createTempFile("servicemix", "rootDir");
+ tempRootDir.delete();
+ File tempTemp = new File(tempRootDir.getAbsolutePath() + "/temp");
+ if (!tempTemp.mkdirs()) {
+ fail("Unable to create temporary working root directory [" + tempTemp.getAbsolutePath() + "]");
+ }
+ System.out.println("Using temporary root directory [" + tempRootDir.getAbsolutePath() + "]");
+
+ container.setRootDir(tempRootDir.getAbsolutePath());
+ container.setMonitorInstallationDirectory(false);
+ container.setUseMBeanServer(false);
+ container.setCreateMBeanServer(false);
+ container.setFlowName("st");
+ container.init();
+ container.start();
+ }
+
+ public void testComponentInstallation() throws Exception {
+ CamelContextComponent component = new CamelContextComponent();
+ container.activateComponent(component, "#ServiceMixComponent#");
+ URL url = getClass().getResource("su1-src/camel-context.xml");
+ File path = new File(new URI(url.toString()));
+ path = path.getParentFile();
+ ServiceMixClient client = new DefaultServiceMixClient(container);
+
+ for (int i = 0; i < 2; i++) {
+ // Deploy and start su
+ component.getServiceUnitManager().deploy("su1", path.getAbsolutePath());
+ component.getServiceUnitManager().init("su1", path.getAbsolutePath());
+ component.getServiceUnitManager().start("su1");
+
+ // Send message
+ InOut inout = client.createInOutExchange();
+ inout.setService(new QName("http://servicemix.apache.org/demo/", "chained"));
+ client.send(inout);
+
+ // Stop and undeploy
+ component.getServiceUnitManager().stop("su1");
+ component.getServiceUnitManager().shutDown("su1");
+ component.getServiceUnitManager().undeploy("su1", path.getAbsolutePath());
+
+ // Send message
+ inout = client.createInOutExchange();
+ inout.setService(new QName("http://servicemix.apache.org/demo/", "chained"));
+ try {
+ client.send(inout);
+ } catch (MessagingException e) {
+ // Ok, the lw component is undeployed
+ }
+
+ }
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ container.stop();
+ container.shutDown();
+ deleteDir(tempRootDir);
+ }
+
+ public static boolean deleteDir(File dir) {
+ System.out.println("Deleting directory : " + dir.getAbsolutePath());
+ if (dir.isDirectory()) {
+ String[] children = dir.list();
+ for (int i = 0; i < children.length; i++) {
+ boolean success = deleteDir(new File(dir, children[i]));
+ if (!success) {
+ return false;
+ }
+ }
+ }
+ // The directory is now empty so delete it
+ return dir.delete();
+ }
+}
\ No newline at end of file
Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/CamelContextComponentTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/resources/log4j.properties?view=auto&rev=551136
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/resources/log4j.properties (added)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/resources/log4j.properties Wed Jun 27 05:09:13 2007
@@ -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.
+#
+#
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=INFO, stdout
+
+log4j.logger.org.springframework=INFO
+log4j.logger.org.apache.activemq=INFO
+log4j.logger.org.apache.activemq.spring=WARN
+
+
+#log4j.logger.org.apache.servicemix=DEBUG
+
+# CONSOLE appender
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/servicemix-test.log
+log4j.appender.out.append=true
Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/resources/log4j.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su1-src/camel-context.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su1-src/camel-context.xml?view=auto&rev=551136
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su1-src/camel-context.xml (added)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su1-src/camel-context.xml Wed Jun 27 05:09:13 2007
@@ -0,0 +1,39 @@
+<?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.
+
+-->
+<!-- START SNIPPET: camel -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+ ">
+
+ <!--
+ from("queue:a").to("queue:b");
+ -->
+ <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
+ <route>
+ <from uri="queue:a"/>
+ <to uri="queue:b"/>
+ </route>
+ </camelContext>
+
+</beans>
+<!-- END SNIPPET: camel -->
Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su1-src/camel-context.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/pom.xml?view=diff&rev=551136&r1=551135&r2=551136
==============================================================================
--- incubator/servicemix/trunk/pom.xml (original)
+++ incubator/servicemix/trunk/pom.xml Wed Jun 27 05:09:13 2007
@@ -201,6 +201,7 @@
<activemq-version>4.1.1</activemq-version>
<activeio-version>3.0.0-incubator</activeio-version>
<backport-util-concurrent-version>2.2</backport-util-concurrent-version>
+ <camel-version>1.0-SNAPSHOT</camel-version>
<jencks-version>2.0</jencks-version>
<jetty-version>6.0.1</jetty-version>
<geronimo-version>1.2-beta</geronimo-version>