KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > tm > XidFactory


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.tm;
23
24 import javax.transaction.xa.Xid JavaDoc;
25
26 import org.jboss.system.ServiceMBeanSupport;
27
28 /**
29  * XidFactory.java
30  * <p/>
31  * <p/>
32  * Created: Sat Jun 15 19:01:18 2002
33  *
34  * @author <a HREF="mailto:d_jencks@users.sourceforge.net">David Jencks</a>
35  * @jmx.mbean
36  */

37 public class XidFactory
38       extends ServiceMBeanSupport
39       implements XidFactoryMBean
40 {
41    
42    //default object name of the naming service
43
private static final javax.management.ObjectName JavaDoc NAMING_OBJECT_NAME =
44       org.jboss.mx.util.ObjectNameFactory.create("jboss:service=Naming");
45
46    private XidFactoryImpl factory = new XidFactoryImpl();
47
48    protected void startService()
49          throws Exception JavaDoc
50    {
51       long jndiPortOrStartUpTime;
52       try
53       {
54          Integer JavaDoc jndiPort =
55             (Integer JavaDoc) getServer().getAttribute(NAMING_OBJECT_NAME, "Port");
56          jndiPortOrStartUpTime = jndiPort.intValue();
57       }
58       catch (Exception JavaDoc e)
59       {
60          jndiPortOrStartUpTime = System.currentTimeMillis();
61       }
62       factory.setUniqueInstanceId(jndiPortOrStartUpTime);
63       factory.start();
64    }
65
66    /**
67     * mbean get-set pair for field instance
68     * Get the value of instance
69     *
70     * @return value of instance
71     * @jmx:managed-attribute
72     */

73    public XidFactoryMBean getInstance()
74    {
75       return this;
76    }
77
78    public String JavaDoc getBaseGlobalId()
79    {
80       return factory.getBaseGlobalId();
81    }
82
83    public void setBaseGlobalId(String JavaDoc baseGlobalId)
84    {
85       factory.setBaseGlobalId(baseGlobalId);
86    }
87
88    public long getGlobalIdNumber()
89    {
90       return factory.getGlobalIdNumber();
91    }
92
93    public void setGlobalIdNumber(long globalIdNumber)
94    {
95       factory.setGlobalIdNumber(globalIdNumber);
96    }
97
98    public String JavaDoc getBranchQualifier()
99    {
100       return factory.getBranchQualifier();
101    }
102
103    public void setBranchQualifier(String JavaDoc branchQualifier)
104    {
105       factory.setBranchQualifier(branchQualifier);
106    }
107
108    public boolean isPad()
109    {
110       return factory.isPad();
111    }
112
113    public void setPad(boolean pad)
114    {
115       factory.setPad(pad);
116    }
117
118    public XidImpl newXid()
119    {
120       return factory.newXid();
121    }
122
123    public XidImpl newBranch(GlobalId globalId)
124    {
125       return factory.newBranch(globalId);
126    }
127
128    public XidImpl newBranch(XidImpl xid,long branchIdNum)
129    {
130       return factory.newBranch(xid, branchIdNum);
131    }
132
133    public XidImpl recreateXid(long localId)
134    {
135       return factory.recreateXid(localId);
136    }
137    
138    public XidImpl recreateXid(long localId, GlobalId globalId)
139    {
140       return factory.recreateXid(localId, globalId);
141    }
142
143    public byte[] localIdToGlobalId(long localId)
144    {
145       return factory.localIdToGlobalId(localId);
146    }
147    
148    public long extractLocalIdFrom(byte[] globalId)
149    {
150       return factory.extractLocalIdFrom(globalId);
151    }
152
153    public String JavaDoc getBaseBranchQualifier(byte[] branchQualifier)
154    {
155       return factory.getBaseBranchQualifier(branchQualifier);
156    }
157
158    public String JavaDoc toString(Xid JavaDoc xid)
159    {
160       return factory.toString(xid);
161    }
162
163 }
164
Popular Tags