01: package uk.org.primrose.vendor.jboss;
02:
03: import java.util.List;
04:
05: import uk.org.primrose.GeneralException;
06: import uk.org.primrose.pool.core.PoolLoader;
07: import uk.org.primrose.pool.core.Pool;
08: import uk.org.primrose.pool.datasource.*;
09: import javax.naming.*;
10: import java.io.Serializable;
11:
12: public class PrimroseBinding implements PrimroseBindingMBean,
13: Serializable {
14: private static final long serialVersionUID = -7189423090231527848L;
15: private String primroseConfigFile;
16:
17: public void start() throws Exception {
18: try {
19: List<String> loadedPoolNames = PoolLoader.loadPool(
20: primroseConfigFile, true);
21: for (String poolName : loadedPoolNames) {
22: PrimroseDataSource pds = new PrimroseDataSource();
23: pds.setPoolName(poolName);
24: Context initCtx = new InitialContext();
25: initCtx.rebind(poolName, pds);
26: }
27:
28: } catch (GeneralException ge) {
29:
30: ge.printStackTrace();
31: throw new Exception("Cannot start primrose : " + ge);
32: }
33:
34: }
35:
36: public void stop() throws Exception {
37:
38: try {
39: List<Pool> pools = PoolLoader.getLoadedPools();
40: for (Pool pool : pools) {
41: pool.stop(false);
42: }
43:
44: } catch (GeneralException ge) {
45:
46: ge.printStackTrace();
47: throw new Exception("Cannot start primrose : " + ge);
48: }
49: }
50:
51: public void setPrimroseConfigFile(String primroseConfigFile) {
52: this .primroseConfigFile = primroseConfigFile;
53: }
54:
55: public String getPrimroseConfigFile() {
56: return this.primroseConfigFile;
57: }
58:
59: }
|