servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r429658 - in /incubator/servicemix/trunk/servicemix-core/src: main/java/org/apache/servicemix/client/ main/java/org/apache/servicemix/jbi/container/ main/java/org/apache/servicemix/jbi/framework/ main/java/org/apache/servicemix/jbi/resolver...
Date Tue, 08 Aug 2006 14:23:28 GMT
Author: gnodet
Date: Tue Aug  8 07:23:26 2006
New Revision: 429658

URL: http://svn.apache.org/viewvc?rev=429658&view=rev
Log:
SM-495: Provide a jndi factory to create clients and bind it to the JNDI tree when the container
is started
Add a close method to the ServiceMixClient interface

Added:
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/ClientFactory.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ClientFactory.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ClientFactoryMBean.java
    incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/client/ClientFactoryTest.java
    incubator/servicemix/trunk/servicemix-core/src/test/resources/jndi.xml
Modified:
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/DefaultServiceMixClient.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/RemoteServiceMixClient.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/ServiceMixClient.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/ServiceMixClientFacade.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/resolver/URIResolver.java
    incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/client/ClientDestinationTest.java
    incubator/servicemix/trunk/servicemix-core/src/test/resources/jndi.properties

Added: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/ClientFactory.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/ClientFactory.java?rev=429658&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/ClientFactory.java
(added)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/ClientFactory.java
Tue Aug  8 07:23:26 2006
@@ -0,0 +1,42 @@
+/*
+ * 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.client;
+
+import javax.jbi.JBIException;
+
+/**
+ * An interface that defines a factory to create ServiceMixClient.
+ * An implementation should be bound in the JNDI context
+ * 
+ * @author <a href="mailto:gnodet [at] apache.org">Guillaume Nodet</a>
+ */
+public interface ClientFactory {
+
+    /**
+     * Default location to where the object should be looked for in JNDI
+     */
+    public static final String DEFAULT_JNDI_NAME = "java:comp/env/jbi/ClientFactory";
+    
+    /**
+     * Create a new client to interact with the JBI bus
+     * 
+     * @return a client
+     * @throws JBIException if an error occurs
+     */
+    public ServiceMixClient createClient() throws JBIException;
+    
+}

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/DefaultServiceMixClient.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/DefaultServiceMixClient.java?rev=429658&r1=429657&r2=429658&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/DefaultServiceMixClient.java
(original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/DefaultServiceMixClient.java
Tue Aug  8 07:23:26 2006
@@ -59,10 +59,12 @@
 
     private EndpointFilter filter = NullEndpointFilter.getInstance();
     private PojoMarshaler marshaler = new DefaultMarshaler();
+    private JBIContainer container;
+    private ActivationSpec activationSpec;
 
-    public DefaultServiceMixClient() {
+    protected DefaultServiceMixClient() {
     }
-
+    
     /**
      * Provides the JBI container used for message dispatch.
      */
@@ -76,6 +78,8 @@
      * and the client endpoint metadata can be configured to allow services to talk to this
client.
      */
     public DefaultServiceMixClient(JBIContainer container, ActivationSpec activationSpec)
throws JBIException {
+        this.container = container;
+        this.activationSpec = activationSpec;
         activationSpec.setComponent(this);
         container.activateComponent(activationSpec);
     }
@@ -251,6 +255,10 @@
 
     public EndpointResolver createResolverForExternalInterface(QName service, String endpoint)
{
         return new ServiceAndEndpointNameResolver(service, endpoint);
+    }
+    
+    public void close() throws JBIException {
+        container.deactivateComponent(activationSpec.getComponentName());
     }
 
 

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/RemoteServiceMixClient.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/RemoteServiceMixClient.java?rev=429658&r1=429657&r2=429658&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/RemoteServiceMixClient.java
(original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/RemoteServiceMixClient.java
Tue Aug  8 07:23:26 2006
@@ -158,5 +158,9 @@
     public void setContainerName(String name) {
         container.setName(name);
     }
+    
+    public void close() throws JBIException {
+        shutDown();
+    }
 
 }

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/ServiceMixClient.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/ServiceMixClient.java?rev=429658&r1=429657&r2=429658&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/ServiceMixClient.java
(original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/ServiceMixClient.java
Tue Aug  8 07:23:26 2006
@@ -16,7 +16,7 @@
  */
 package org.apache.servicemix.client;
 
-import org.apache.servicemix.jbi.resolver.EndpointResolver;
+import java.util.Map;
 
 import javax.jbi.JBIException;
 import javax.jbi.component.ComponentContext;
@@ -29,21 +29,18 @@
 import javax.jbi.messaging.MessageExchange;
 import javax.jbi.messaging.MessageExchangeFactory;
 import javax.jbi.messaging.MessagingException;
-import javax.jbi.messaging.NormalizedMessage;
 import javax.jbi.messaging.RobustInOnly;
 import javax.xml.namespace.QName;
 
-import java.util.Map;
+import org.apache.servicemix.jbi.resolver.EndpointResolver;
 
 /**
  * Represents a client  API which allows users to programatically send messages into the
JBI
  * container or to receive them using the regular JBI API together with a collection of helper
methods making it
  * easier to interact with the JBI API.
  *
- * 
  * @version $Revision$
  */
-// * @deprecated Please use the {@link Client} interface instead.
 public interface ServiceMixClient {
 
 
@@ -351,4 +348,10 @@
     MessageExchangeFactory getExchangeFactory() throws MessagingException;
 
 
+    /**
+     * Close this client.
+     * 
+     * @throws JBIException
+     */
+    void close() throws JBIException;
 }

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/ServiceMixClientFacade.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/ServiceMixClientFacade.java?rev=429658&r1=429657&r2=429658&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/ServiceMixClientFacade.java
(original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/ServiceMixClientFacade.java
Tue Aug  8 07:23:26 2006
@@ -289,6 +289,9 @@
     public EndpointResolver createResolverForExternalInterface(QName service, String endpoint)
{
         return new ServiceAndEndpointNameResolver(service, endpoint);
     }
+    
+    public void close() throws JBIException {
+    }
 
 
     // Properties

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java?rev=429658&r1=429657&r2=429658&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java
(original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java
Tue Aug  8 07:23:26 2006
@@ -54,7 +54,6 @@
 import org.apache.servicemix.components.util.PojoLifecycleAdaptor;
 import org.apache.servicemix.components.util.PojoSupport;
 import org.apache.servicemix.id.IdGenerator;
-import org.apache.servicemix.jbi.deployment.SharedLibraryList;
 import org.apache.servicemix.jbi.event.ComponentListener;
 import org.apache.servicemix.jbi.event.EndpointListener;
 import org.apache.servicemix.jbi.event.ExchangeEvent;
@@ -63,6 +62,7 @@
 import org.apache.servicemix.jbi.event.ServiceUnitListener;
 import org.apache.servicemix.jbi.framework.AdminCommandsService;
 import org.apache.servicemix.jbi.framework.AutoDeploymentService;
+import org.apache.servicemix.jbi.framework.ClientFactory;
 import org.apache.servicemix.jbi.framework.ComponentContextImpl;
 import org.apache.servicemix.jbi.framework.ComponentMBeanImpl;
 import org.apache.servicemix.jbi.framework.ComponentNameSpace;
@@ -107,6 +107,7 @@
     protected DeploymentService deploymentService = new DeploymentService();
     protected AutoDeploymentService autoDeployService = new AutoDeploymentService();
     protected AdminCommandsService adminCommandsService = new AdminCommandsService();
+    protected ClientFactory clientFactory = new ClientFactory();
     protected Registry registry = new Registry();
     protected WorkManager workManager;
     protected boolean isWorkManagerCreated;
@@ -483,6 +484,10 @@
     public AdminCommandsService getAdminCommandsService() {
         return adminCommandsService;
     }
+    
+    public ClientFactory getClientFactory() {
+        return clientFactory;
+    }
 
 
     /**
@@ -519,6 +524,7 @@
             deploymentService.init(this);
             autoDeployService.init(this);
             adminCommandsService.init(this);
+            clientFactory.init(this);
 
             // register self with the ManagementContext
             try {
@@ -558,6 +564,7 @@
             deploymentService.start();
             autoDeployService.start();
             adminCommandsService.start();
+            clientFactory.start();
             super.start();
         }
     }
@@ -578,6 +585,7 @@
             deploymentService.stop();
             autoDeployService.stop();
             adminCommandsService.stop();
+            clientFactory.stop();
             super.stop();
         }
     }
@@ -596,6 +604,7 @@
             installationService.shutDown();
             deploymentService.shutDown();
             adminCommandsService.shutDown();
+            clientFactory.shutDown();
             // shutdown the management context last, because it will close the mbean server
             super.shutDown();
             managementContext.unregisterMBean(this);

Added: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ClientFactory.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ClientFactory.java?rev=429658&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ClientFactory.java
(added)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ClientFactory.java
Tue Aug  8 07:23:26 2006
@@ -0,0 +1,109 @@
+/*
+ * 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.jbi.framework;
+
+import javax.jbi.JBIException;
+import javax.management.JMException;
+import javax.management.MBeanOperationInfo;
+import javax.naming.NamingException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.client.ServiceMixClient;
+import org.apache.servicemix.jbi.management.BaseSystemService;
+import org.apache.servicemix.jbi.management.OperationInfoHelper;
+
+/**
+ * @author <a href="mailto:gnodet [at] apache.org">Guillaume Nodet</a>
+ */
+public class ClientFactory extends BaseSystemService implements ClientFactoryMBean {
+
+    private static final Log logger = LogFactory.getLog(ClientFactory.class);
+    
+    private String jndiName = DEFAULT_JNDI_NAME;
+    
+    public ClientFactory() {
+    }
+    
+    /**
+     * @return the jndiName
+     */
+    public String getJndiName() {
+        return jndiName;
+    }
+
+    /**
+     * @param jndiName the jndiName to set
+     */
+    public void setJndiName(String jndiName) {
+        this.jndiName = jndiName;
+    }
+
+    public ServiceMixClient createClient() throws JBIException {
+        return new DefaultServiceMixClient(getContainer());
+    }
+
+    protected Class getServiceMBean() {
+        return ClientFactoryMBean.class;
+    }
+
+    public String getDescription() {
+        return "Client Factory Service";
+    }
+
+    public MBeanOperationInfo[] getOperationInfos() throws JMException {
+        OperationInfoHelper helper = new OperationInfoHelper();
+        helper.addOperation(getObjectToManage(), "createClient", 0, "create a new client");
+        return OperationInfoHelper.join(super.getOperationInfos(), helper.getOperationInfos());
+    }
+
+    /**
+     * Start the item.
+     * 
+     * @exception javax.jbi.JBIException if the item fails to start.
+     */
+    public void start() throws javax.jbi.JBIException {
+        try {
+            getContainer().getNamingContext().bind(jndiName, this);
+            super.start();
+        } catch (NamingException e) {
+            logger.error("Cound not start ClientFactory: " + e);
+            if (logger.isDebugEnabled()) {
+                logger.debug("Could not start ClientFactory", e);
+            }
+        }
+    }
+
+    /**
+     * Stop the item. This suspends current messaging activities.
+     * 
+     * @exception javax.jbi.JBIException if the item fails to stop.
+     */
+    public void stop() throws javax.jbi.JBIException {
+        try {
+            super.stop();
+            getContainer().getNamingContext().unbind(jndiName);
+        } catch (NamingException e) {
+            logger.error("Cound not stop ClientFactory: " + e);
+            if (logger.isDebugEnabled()) {
+                logger.debug("Could not stop ClientFactory", e);
+            }
+        }
+    }
+
+}

Added: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ClientFactoryMBean.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ClientFactoryMBean.java?rev=429658&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ClientFactoryMBean.java
(added)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ClientFactoryMBean.java
Tue Aug  8 07:23:26 2006
@@ -0,0 +1,26 @@
+/*
+ * 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.jbi.framework;
+
+import javax.jbi.management.LifeCycleMBean;
+
+/**
+ * @author <a href="mailto:gnodet [at] apache.org">Guillaume Nodet</a>
+ */
+public interface ClientFactoryMBean extends LifeCycleMBean, org.apache.servicemix.client.ClientFactory
{
+
+}

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/resolver/URIResolver.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/resolver/URIResolver.java?rev=429658&r1=429657&r2=429658&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/resolver/URIResolver.java
(original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/resolver/URIResolver.java
Tue Aug  8 07:23:26 2006
@@ -1,3 +1,19 @@
+/*
+ * 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.jbi.resolver;
 
 import javax.jbi.JBIException;

Modified: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/client/ClientDestinationTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/client/ClientDestinationTest.java?rev=429658&r1=429657&r2=429658&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/client/ClientDestinationTest.java
(original)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/client/ClientDestinationTest.java
Tue Aug  8 07:23:26 2006
@@ -16,25 +16,23 @@
  */
 package org.apache.servicemix.client;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.servicemix.client.TestBean;
-import org.apache.servicemix.jbi.container.SpringJBIContainer;
-import org.apache.servicemix.tck.MessageList;
-import org.apache.servicemix.tck.Receiver;
-import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
-import org.springframework.context.support.AbstractXmlApplicationContext;
+import java.io.StringReader;
+import java.util.Arrays;
 
-import javax.jbi.JBIException;
 import javax.jbi.messaging.InOnly;
 import javax.jbi.messaging.InOut;
 import javax.jbi.messaging.NormalizedMessage;
 import javax.xml.transform.stream.StreamSource;
 
-import java.io.StringReader;
-import java.util.Arrays;
-
 import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.jbi.container.SpringJBIContainer;
+import org.apache.servicemix.tck.MessageList;
+import org.apache.servicemix.tck.Receiver;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
 
 /**
  * @version $Revision$

Added: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/client/ClientFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/client/ClientFactoryTest.java?rev=429658&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/client/ClientFactoryTest.java
(added)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/client/ClientFactoryTest.java
Tue Aug  8 07:23:26 2006
@@ -0,0 +1,70 @@
+/*
+ * 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.client;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.servicemix.components.util.EchoComponent;
+import org.apache.servicemix.jbi.container.ActivationSpec;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.springframework.jndi.JndiObjectFactoryBean;
+
+/**
+ * @author <a href="mailto:gnodet [at] apache.org">Guillaume Nodet</a>
+ */
+public class ClientFactoryTest extends TestCase {
+
+    private JBIContainer jbi;
+    
+    protected void setUp() throws Exception {
+        jbi = new JBIContainer();
+        jbi.setEmbedded(true);
+        jbi.init();
+        jbi.start();
+    }
+    
+    protected void shutDown() throws Exception {
+        jbi.shutDown();
+    }
+    
+    public void testClientFactory() throws Exception {
+        ActivationSpec as = new ActivationSpec();
+        as.setId("echo");
+        as.setComponent(new EchoComponent());
+        as.setService(new QName("echo"));
+        jbi.activateComponent(as);
+        
+        JndiObjectFactoryBean fb = new JndiObjectFactoryBean();
+        fb.setJndiName(ClientFactory.DEFAULT_JNDI_NAME);
+        fb.afterPropertiesSet();
+        ClientFactory cf = (ClientFactory) fb.getObject();
+        ServiceMixClient client = cf.createClient();
+        
+        Destination dest = client.createDestination("service::echo");
+        InOut me = dest.createInOutExchange();
+        me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
+        client.sendSync(me);
+        assertEquals(ExchangeStatus.ACTIVE, me.getStatus());
+        client.done(me);
+        client.close();
+    }
+}

Modified: incubator/servicemix/trunk/servicemix-core/src/test/resources/jndi.properties
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/test/resources/jndi.properties?rev=429658&r1=429657&r2=429658&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/resources/jndi.properties (original)
+++ incubator/servicemix/trunk/servicemix-core/src/test/resources/jndi.properties Tue Aug
 8 07:23:26 2006
@@ -1,28 +1,5 @@
 # START SNIPPET: jndi
 
-java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
-
-# use the following property to configure the default connector
-java.naming.provider.url = tcp://localhost:61626
-
-# use the following property to embed a broker inside this JVM
-#useEmbeddedBroker = true
-
-# use the following property to specify a class path resource or URL
-# used to configure an embedded broker using the XML configuration file
-#brokerXmlConfig = file:src/conf/sample-conf/default.xml
-
-# use the following property to specify the JNDI name the connection factory
-# should appear as. 
-#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
-
-# register some queues in JNDI using the form
-# queue.[jndiName] = [physicalName]
-queue.MyQueue = example.MyQueue
-
-
-# register some topics in JNDI using the form
-# topic.[jndiName] = [physicalName]
-topic.MyTopic = example.MyTopic
+java.naming.factory.initial = org.apache.xbean.spring.jndi.SpringInitialContextFactory
 
 # END SNIPPET: jndi

Added: incubator/servicemix/trunk/servicemix-core/src/test/resources/jndi.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/test/resources/jndi.xml?rev=429658&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/resources/jndi.xml (added)
+++ incubator/servicemix/trunk/servicemix-core/src/test/resources/jndi.xml Tue Aug  8 07:23:26
2006
@@ -0,0 +1,11 @@
+<beans>
+  <bean id="jndi" 
+        class="org.apache.xbean.spring.jndi.SpringInitialContextFactory" 
+        factory-method="makeInitialContext"
+        singleton="true">
+    <property name="entries">
+      <map>
+      </map>
+    </property>
+  </bean>
+</beans>    
\ No newline at end of file



Mime
View raw message