KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > common > XAServiceBase


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/XAServiceBase.java,v 1.3 2004/07/22 18:41:59 ozeigermann Exp $
3  * $Revision: 1.3 $
4  * $Date: 2004/07/22 18:41:59 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.slide.common;
25
26 import java.util.Hashtable JavaDoc;
27
28 import javax.transaction.xa.XAException JavaDoc;
29 import javax.transaction.xa.XAResource JavaDoc;
30 import javax.transaction.xa.Xid JavaDoc;
31
32 import org.apache.commons.transaction.util.xa.TransactionalResource;
33
34 /**
35  * Slide Service dummy implementation.
36  *
37  * @version $Revision: 1.3 $
38  */

39 public class XAServiceBase extends AbstractXAServiceBase {
40
41     protected boolean started = false;
42
43     public void setParameters(Hashtable JavaDoc parameters)
44             throws ServiceParameterErrorException,
45             ServiceParameterMissingException {
46     }
47
48     public void connect() throws ServiceConnectionFailedException {
49         started = true;
50     }
51
52     public void disconnect() throws ServiceDisconnectionFailedException {
53         started = false;
54     }
55
56     public void reset() throws ServiceResetFailedException {
57     }
58
59     public boolean isConnected() throws ServiceAccessException {
60         return started;
61     }
62
63     public boolean isSameRM(XAResource JavaDoc xares) throws XAException JavaDoc {
64         return (xares == this);
65     }
66
67     public Xid JavaDoc[] recover(int flag) throws XAException JavaDoc {
68         return null;
69     }
70
71     public int getTransactionTimeout() throws XAException JavaDoc {
72         return 0;
73     }
74
75     public boolean setTransactionTimeout(int arg0) throws XAException JavaDoc {
76         return false;
77     }
78
79     protected TransactionalResource createTransactionResource(Xid JavaDoc xid) {
80         return new DummyTxResource(xid);
81     }
82
83     protected boolean includeBranchInXid() {
84         return false;
85     }
86
87     protected class DummyTxResource implements TransactionalResource {
88         Xid JavaDoc xid;
89
90         int status;
91
92         DummyTxResource(Xid JavaDoc xid) {
93             this.xid = xid;
94             status = STATUS_ACTIVE;
95         }
96
97         public void commit() throws XAException JavaDoc {
98         }
99
100         public void rollback() throws XAException JavaDoc {
101         }
102
103         public int prepare() throws XAException JavaDoc {
104             // no check possible
105
return XA_OK;
106         }
107
108         public int getStatus() {
109             return status;
110         }
111
112         public void setStatus(int status) {
113             this.status = status;
114         }
115
116         public Xid JavaDoc getXid() {
117             return xid;
118         }
119
120         public void begin() throws XAException JavaDoc {
121         }
122
123         public void suspend() throws XAException JavaDoc {
124         }
125
126         public void resume() throws XAException JavaDoc {
127         }
128     }
129
130 }
Popular Tags