1 17 package org.apache.servicemix.components.jms; 18 19 import javax.jbi.JBIException; 20 import javax.resource.spi.ActivationSpec ; 21 import javax.transaction.TransactionManager ; 22 23 import org.jencks.JCAConnector; 24 import org.jencks.JCAContainer; 25 import org.jencks.SingletonEndpointFactory; 26 27 32 public class JmsInUsingJCABinding extends JmsInBinding { 33 34 private JCAContainer jcaContainer; 35 private ActivationSpec activationSpec; 36 private TransactionManager transactionManager; 37 private JCAConnector jcaConnector; 38 39 protected void init() throws JBIException { 40 if (jcaContainer == null) { 41 throw new IllegalArgumentException ("Must specify a jcaContainer property"); 42 } 43 if (activationSpec == null) { 44 throw new IllegalArgumentException ("Must specify an activationSpec property"); 45 } 46 jcaConnector = jcaContainer.addConnector(); 47 jcaConnector.setActivationSpec(activationSpec); 48 if (transactionManager == null) { 49 transactionManager = (TransactionManager ) getContext().getTransactionManager(); 50 } 51 if (transactionManager != null) { 52 jcaConnector.setTransactionManager(transactionManager); 53 } 54 jcaConnector.setEndpointFactory(new SingletonEndpointFactory(this, transactionManager)); 55 try { 56 jcaConnector.afterPropertiesSet(); 57 } catch (Exception e) { 58 throw new JBIException("Unable to initialize jca connector", e); 59 } 60 super.init(); 61 } 62 63 public void start() throws JBIException { 64 try { 65 jcaConnector.start(); 66 } catch (Exception e) { 67 throw new JBIException("Unable to start jca connector", e); 68 } 69 super.start(); 70 } 71 72 public void stop() throws JBIException { 73 super.stop(); 74 try { 75 jcaConnector.destroy(); 76 } catch (Exception e) { 77 throw new JBIException("Unable to stop jca connector", e); 78 } 79 } 80 81 public JCAContainer getJcaContainer() { 82 return jcaContainer; 83 } 84 85 public void setJcaContainer(JCAContainer jcaContainer) { 86 this.jcaContainer = jcaContainer; 87 } 88 89 public ActivationSpec getActivationSpec() { 90 return activationSpec; 91 } 92 93 public void setActivationSpec(ActivationSpec activationSpec) { 94 this.activationSpec = activationSpec; 95 } 96 97 public TransactionManager getTransactionManager() { 98 return transactionManager; 99 } 100 101 public void setTransactionManager(TransactionManager transactionManager) { 102 this.transactionManager = transactionManager; 103 } 104 105 public JCAConnector getJcaConnector() { 106 return jcaConnector; 107 } 108 } 109 | Popular Tags |