KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > connector > BootstrapContext


1 /**
2  *
3  * Copyright 2003-2004 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.connector;
19
20 import java.util.Timer JavaDoc;
21
22 import javax.resource.spi.UnavailableException JavaDoc;
23 import javax.resource.spi.XATerminator JavaDoc;
24 import javax.resource.spi.work.WorkManager JavaDoc;
25
26 import org.apache.geronimo.gbean.GBeanInfo;
27 import org.apache.geronimo.gbean.GBeanInfoBuilder;
28
29 /**
30  * GBean BootstrapContext implementation that refers to externally configured WorkManager
31  * and XATerminator gbeans.
32  *
33  * @version $Rev: 56022 $ $Date: 2004-10-29 22:16:18 -0700 (Fri, 29 Oct 2004) $
34  */

35 public class BootstrapContext implements javax.resource.spi.BootstrapContext JavaDoc {
36     private final WorkManager JavaDoc workManager;
37     private final XATerminator JavaDoc xATerminator;
38
39     /**
40      * Default constructor for use as a GBean Endpoint.
41      */

42     public BootstrapContext() {
43         workManager = null;
44         xATerminator = null;
45     }
46
47     /**
48      * Normal constructor for use as a GBean.
49      * @param workManager
50      * @param xaTerminator
51      */

52     public BootstrapContext(final WorkManager JavaDoc workManager, final XATerminator JavaDoc xaTerminator) {
53         this.workManager = workManager;
54         this.xATerminator = xaTerminator;
55     }
56
57
58     /**
59      * @see javax.resource.spi.BootstrapContext#getWorkManager()
60      */

61     public WorkManager JavaDoc getWorkManager() {
62         return workManager;
63     }
64
65     /**
66      * @see javax.resource.spi.BootstrapContext#getXATerminator()
67      */

68     public XATerminator JavaDoc getXATerminator() {
69         return xATerminator;
70     }
71
72     /**
73      * @see javax.resource.spi.BootstrapContext#createTimer()
74      */

75     public Timer JavaDoc createTimer() throws UnavailableException JavaDoc {
76         return new Timer JavaDoc();
77     }
78
79     public static final GBeanInfo GBEAN_INFO;
80
81     static {
82         GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(BootstrapContext.class);
83           //adding interface does not work, creates attributes for references???
84
// infoFactory.addInterface(javax.resource.spi.BootstrapContext.class);
85

86         infoFactory.addOperation("createTimer");
87         infoFactory.addOperation("getWorkManager");
88         infoFactory.addOperation("getXATerminator");
89
90         infoFactory.addReference("WorkManager", WorkManager JavaDoc.class);
91         infoFactory.addReference("XATerminator", XATerminator JavaDoc.class);
92
93         infoFactory.setConstructor(new String JavaDoc[]{"WorkManager", "XATerminator"});
94
95         GBEAN_INFO = infoFactory.getBeanInfo();
96     }
97
98     public static GBeanInfo getGBeanInfo() {
99         return GBEAN_INFO;
100     }
101
102 }
103
Popular Tags