KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > jca > support > SimpleBootstrapContext


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

16
17 package org.springframework.jca.support;
18
19 import java.util.Timer JavaDoc;
20
21 import javax.resource.spi.BootstrapContext JavaDoc;
22 import javax.resource.spi.UnavailableException JavaDoc;
23 import javax.resource.spi.XATerminator JavaDoc;
24 import javax.resource.spi.work.WorkManager JavaDoc;
25
26 /**
27  * Simple implementation of the JCA 1.5 {@link javax.resource.spi.BootstrapContext}
28  * interface, used for bootstrapping a JCA ResourceAdapter in a local environment.
29  *
30  * <p>Delegates to the given WorkManager and XATerminator, if any. Creates simple
31  * local instances of <code>java.util.Timer</code>.
32  *
33  * @author Juergen Hoeller
34  * @since 2.0.3
35  * @see javax.resource.spi.ResourceAdapter#start(javax.resource.spi.BootstrapContext)
36  * @see ResourceAdapterFactoryBean
37  */

38 public class SimpleBootstrapContext implements BootstrapContext JavaDoc {
39
40     private WorkManager JavaDoc workManager;
41
42     private XATerminator JavaDoc xaTerminator;
43
44
45     /**
46      * Create a new SimpleBootstrapContext for the given WorkManager,
47      * with no XATerminator available.
48      * @param workManager the JCA WorkManager to use (may be <code>null</code>)
49      */

50     public SimpleBootstrapContext(WorkManager JavaDoc workManager) {
51         this.workManager = workManager;
52     }
53
54     /**
55      * Create a new SimpleBootstrapContext for the given WorkManager and XATerminator.
56      * @param workManager the JCA WorkManager to use (may be <code>null</code>)
57      * @param xaTerminator the JCA XATerminator to use (may be <code>null</code>)
58      */

59     public SimpleBootstrapContext(WorkManager JavaDoc workManager, XATerminator JavaDoc xaTerminator) {
60         this.workManager = workManager;
61         this.xaTerminator = xaTerminator;
62     }
63
64
65     public WorkManager JavaDoc getWorkManager() {
66         if (this.workManager == null) {
67             throw new IllegalStateException JavaDoc("No WorkManager available");
68         }
69         return this.workManager;
70     }
71
72     public XATerminator JavaDoc getXATerminator() {
73         return this.xaTerminator;
74     }
75
76     public Timer JavaDoc createTimer() throws UnavailableException JavaDoc {
77         return new Timer JavaDoc();
78     }
79
80 }
81
Popular Tags