1 21 22 25 40 package uk.org.primrose.vendor.jetty; 41 42 import java.util.ArrayList ; 43 import javax.naming.Reference ; 44 import javax.naming.StringRefAddr ; 45 import uk.org.primrose.pool.datasource.MasterPoolDataSourceFactory; 46 import uk.org.primrose.pool.jmx.MBeanUtil; 47 48 import org.mortbay.jetty.plus.*; 50 import javax.transaction.TransactionManager ; 51 import javax.transaction.UserTransaction ; 52 import org.apache.commons.logging.Log; 53 import org.apache.commons.logging.LogFactory; 54 55 public class BindPrimroseFactory extends TMService { 56 private String poolConfigFile = null; 57 private ArrayList pools = null; 58 59 private static Log log = LogFactory.getLog(BindPrimroseFactory.class); 61 public static final String DEFAULT_SERVICE_NAME = "PrimroseService"; 62 63 64 public void setPoolConfigFile(String poolConfigFile) { 65 if (this.poolConfigFile == null) { 66 initialize(poolConfigFile); 67 } 68 69 this.poolConfigFile = poolConfigFile; 70 } 71 72 public String getPoolConfigFile() { 73 return this.poolConfigFile; 74 } 75 76 public void initialize(String poolConfigFile) { 77 try { 79 log.info("Primrose binding using config file : " +poolConfigFile); 80 Reference ref = new Reference ("uk.org.primrose.pool.datasource.MasterPoolDataSourceFactory"); 81 String refType = "configFile"; 82 String refAddr = poolConfigFile; 83 StringRefAddr sra = new StringRefAddr (refType, refAddr); 84 ref.add(sra); 85 MasterPoolDataSourceFactory mpdsf = new MasterPoolDataSourceFactory(); 86 Object o = mpdsf.getObjectInstance(ref, null, null, null); 88 this.pools = (ArrayList )o; 89 90 MBeanUtil.bind("masterPool", this); 91 } catch (Exception e) { 92 e.printStackTrace(System.out); 93 } 94 95 log.info("Primrose started."); 96 } 97 98 public ArrayList getPools() { 99 return pools; 100 } 101 102 103 104 105 107 110 protected org.objectweb.transaction.jta.TMService m_tm; 111 112 113 public BindPrimroseFactory() { 114 m_tm = null; 115 } 116 117 118 123 public TransactionManager getTransactionManager() 124 { 125 if (m_tm == null) 126 { 127 return null; 128 } 129 else 130 { 131 return m_tm.getTransactionManager(); 132 } 133 } 134 135 140 public UserTransaction getUserTransaction() 141 { 142 if (m_tm == null) 143 { 144 return null; 145 } 146 else 147 { 148 return m_tm.getUserTransaction(); 149 } 150 } 151 152 153 154 157 public void start() throws Exception { 158 super.start(); 159 } 160 161 162 170 public void stop() throws InterruptedException { 171 super.stop(); 172 log.info("Primrose stopped."); 173 } 174 175 176 } | Popular Tags |