diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-03 08:27:35 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-03 08:27:35 +0000 |
commit | e36cc3c68c9db5010caf4d43680f2f6456691da4 (patch) | |
tree | 29debda530db2195abf8ca3510d0bf74feb3284e /java/sca/modules/binding-sca-jms/src | |
parent | 2c02c99885adce435d618803ff878513f0ea16ce (diff) |
Automatically start a JMS broker when using the JMS based binding.sca. The broker uses multicast discovery so other SCA nodes get automatically discovered
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@691540 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/binding-sca-jms/src')
3 files changed, 86 insertions, 1 deletions
diff --git a/java/sca/modules/binding-sca-jms/src/main/java/org/apache/tuscany/sca/binding/sca/jms/JMSBroker.java b/java/sca/modules/binding-sca-jms/src/main/java/org/apache/tuscany/sca/binding/sca/jms/JMSBroker.java new file mode 100644 index 0000000000..b4142a65ca --- /dev/null +++ b/java/sca/modules/binding-sca-jms/src/main/java/org/apache/tuscany/sca/binding/sca/jms/JMSBroker.java @@ -0,0 +1,67 @@ +/*
+ * 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.tuscany.sca.binding.sca.jms;
+
+import java.net.URI;
+
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.TransportConnector;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ModuleActivator;
+
+/**
+ * The JMS broker for the JMS based SCA binding
+ * TODO: configure from a binding.jms in definitions.xml
+ */
+public class JMSBroker implements ModuleActivator {
+
+ private static BrokerService broker;
+
+ public void start(ExtensionPointRegistry arg0) {
+ if (broker == null) {
+ broker = new BrokerService();
+ broker.setPersistent(false);
+ broker.setUseJmx(false);
+ try {
+
+ TransportConnector tc = broker.addConnector("tcp://localhost:0");
+ tc.setDiscoveryUri(URI.create("multicast://default"));
+
+ broker.addNetworkConnector("multicast://default");
+
+ broker.start();
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ public void stop(ExtensionPointRegistry arg0) {
+ if (broker != null) {
+ try {
+ broker.stop();
+ broker = null;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+}
diff --git a/java/sca/modules/binding-sca-jms/src/main/java/org/apache/tuscany/sca/binding/sca/jms/JMSSCABindingProviderFactory.java b/java/sca/modules/binding-sca-jms/src/main/java/org/apache/tuscany/sca/binding/sca/jms/JMSSCABindingProviderFactory.java index 5e60ba4607..21da1e5e92 100644 --- a/java/sca/modules/binding-sca-jms/src/main/java/org/apache/tuscany/sca/binding/sca/jms/JMSSCABindingProviderFactory.java +++ b/java/sca/modules/binding-sca-jms/src/main/java/org/apache/tuscany/sca/binding/sca/jms/JMSSCABindingProviderFactory.java @@ -64,7 +64,7 @@ public class JMSSCABindingProviderFactory implements BindingProviderFactory<Dist private JMSBinding createBinding(DistributedSCABinding binding) { JMSBinding b = new JMSBinding(); b.setInitialContextFactoryName("org.apache.activemq.jndi.ActiveMQInitialContextFactory"); - b.setJndiURL("tcp://localhost:61616"); // TODO: plug in jndi url from definitions.xml + b.setJndiURL("vm://localhost"); // TODO: plug in jndi url from definitions.xml b.setRequestMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME); b.setResponseMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME); if (binding.getSCABinding().getURI().startsWith("/")) { diff --git a/java/sca/modules/binding-sca-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator b/java/sca/modules/binding-sca-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator new file mode 100644 index 0000000000..f1b9825130 --- /dev/null +++ b/java/sca/modules/binding-sca-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator @@ -0,0 +1,18 @@ +# 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.
+
+org.apache.tuscany.sca.binding.sca.jms.JMSBroker
|