Update to work with new jms resource factory support

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@704855 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
antelder 2008-10-15 10:50:40 +00:00
parent 6a88a568b2
commit f943cc0e4b
2 changed files with 28 additions and 4 deletions

View file

@ -19,7 +19,9 @@
package org.apache.tuscany.sca.binding.sca.jms;
import java.io.File;
import java.net.URI;
import java.net.URL;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.TransportConnector;
@ -27,8 +29,7 @@ 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
* The JMS broker for the JMS based SCA binding TODO: configure from a binding.jms in definitions.xml
*/
public class JMSBroker implements ModuleActivator {
@ -39,6 +40,7 @@ public class JMSBroker implements ModuleActivator {
public void start(ExtensionPointRegistry arg0) {
if (broker == null) {
ps();
broker = new BrokerService();
broker.setPersistent(false);
broker.setUseJmx(false);
@ -52,6 +54,7 @@ public class JMSBroker implements ModuleActivator {
broker.start();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
@ -67,4 +70,12 @@ public class JMSBroker implements ModuleActivator {
}
}
}
protected void ps() {
URL ps = Thread.currentThread().getContextClassLoader().getResource("domain.properties");
System.out.println("url " + ps);
File f = new File("/domain.properties");
System.out.println("f " + f.toURI());
System.out.println("f " + f.exists());
}
}

View file

@ -21,8 +21,11 @@ package org.apache.tuscany.sca.binding.sca.jms;
import org.apache.tuscany.sca.binding.jms.impl.JMSBinding;
import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants;
import org.apache.tuscany.sca.binding.jms.provider.DefaultJMSResourceFactoryExtensionPoint;
import org.apache.tuscany.sca.binding.jms.provider.JMSBindingReferenceBindingProvider;
import org.apache.tuscany.sca.binding.jms.provider.JMSBindingServiceBindingProvider;
import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactoryExtensionPoint;
import org.apache.tuscany.sca.binding.sca.DistributedSCABinding;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
@ -41,12 +44,17 @@ public class JMSSCABindingProviderFactory implements BindingProviderFactory<Dist
private WorkScheduler workScheduler;
private ExtensionPointRegistry extensionPoints;
private JMSResourceFactoryExtensionPoint jmsRFEP;
public JMSSCABindingProviderFactory(ExtensionPointRegistry extensionPoints) {
this.extensionPoints = extensionPoints;
UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
workScheduler = utilities.getUtility(WorkScheduler.class);
assert workScheduler != null;
jmsRFEP = (JMSResourceFactoryExtensionPoint)extensionPoints.getExtensionPoint(JMSResourceFactoryExtensionPoint.class);
if (jmsRFEP == null) {
jmsRFEP = new DefaultJMSResourceFactoryExtensionPoint();
}
}
public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component,
@ -60,7 +68,8 @@ public class JMSSCABindingProviderFactory implements BindingProviderFactory<Dist
// instead of JNDI
// jmsBinding.setDestinationCreate(JMSBindingConstants.CREATE_NEVER);
return new JMSBindingReferenceBindingProvider(component, reference, jmsBinding, extensionPoints);
JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory(jmsBinding);
return new JMSBindingReferenceBindingProvider(component, reference, jmsBinding, extensionPoints, jmsRF);
}
public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component,
@ -68,13 +77,17 @@ public class JMSSCABindingProviderFactory implements BindingProviderFactory<Dist
DistributedSCABinding binding) {
JMSBinding jmsBinding = createBinding(binding);
jmsBinding.setDestinationCreate(JMSBindingConstants.CREATE_ALWAYS);
return new JMSBindingServiceBindingProvider(component, service, binding.getSCABinding(), jmsBinding, workScheduler, extensionPoints);
JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory(jmsBinding);
return new JMSBindingServiceBindingProvider(component, service, binding.getSCABinding(), jmsBinding, workScheduler, extensionPoints, jmsRF);
}
private JMSBinding createBinding(DistributedSCABinding binding) {
JMSBinding b = new JMSBinding();
b.setInitialContextFactoryName("org.apache.activemq.jndi.ActiveMQInitialContextFactory");
b.setJndiURL("vm://localhost"); // TODO: plug in jndi url from definitions.xml
b.setJMSTimeToLive(9);
b.setRequestMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME);
b.setResponseMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME);
if (binding.getSCABinding().getURI().startsWith("/")) {