KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > transaction > DefaultInstanceContext


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.transaction;
19
20 import java.util.HashMap JavaDoc;
21 import java.util.Map JavaDoc;
22 import java.util.Set JavaDoc;
23
24
25 /**
26  * Simple implementation of ComponentContext satisfying invariant.
27  *
28  * @version $Rev: 155376 $ $Date: 2005-02-25 15:10:24 -0800 (Fri, 25 Feb 2005) $
29  *
30  * */

31 public class DefaultInstanceContext implements InstanceContext {
32     private final Map JavaDoc connectionManagerMap = new HashMap JavaDoc();
33     private final Set JavaDoc unshareableResources;
34     private final Set JavaDoc applicationManagedSecurityResources;
35     private int callDepth;
36     private boolean dead = false;
37
38     public DefaultInstanceContext(Set JavaDoc unshareableResources, Set JavaDoc applicationManagedSecurityResources) {
39         this.unshareableResources = unshareableResources;
40         this.applicationManagedSecurityResources = applicationManagedSecurityResources;
41     }
42
43     public Object JavaDoc getId() {
44         return null;
45     }
46
47     public Object JavaDoc getContainerId() {
48         return null;
49     }
50
51     public void associate() throws Exception JavaDoc {
52     }
53
54     public void flush() throws Exception JavaDoc {
55     }
56
57     public void beforeCommit() throws Exception JavaDoc {
58     }
59
60     public void afterCommit(boolean status) throws Exception JavaDoc {
61     }
62
63     public void unassociate() throws Throwable JavaDoc {
64     }
65
66     public Map JavaDoc getConnectionManagerMap() {
67         return connectionManagerMap;
68     }
69
70     public Set JavaDoc getUnshareableResources() {
71         return unshareableResources;
72     }
73
74     public Set JavaDoc getApplicationManagedSecurityResources() {
75         return applicationManagedSecurityResources;
76     }
77
78     public boolean isInCall() {
79         return callDepth > 0;
80     }
81
82     public void enter() {
83         callDepth++;
84     }
85
86     public void exit() {
87         assert isInCall();
88         callDepth--;
89     }
90
91     public boolean isDead() {
92         return dead;
93     }
94
95     public void die() {
96         dead = true;
97     }
98 }
99
Popular Tags