KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > tm > iiop > wrapper > OTSSynchronizationWrapper


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.iiop.wrapper;
23
24 import java.rmi.RemoteException JavaDoc;
25
26 import org.jboss.iiop.CorbaORB;
27 import org.jboss.tm.remoting.interfaces.Status;
28 import org.jboss.tm.remoting.interfaces.Synchronization;
29
30 /**
31  * Implements <code>org.jboss.tm.remoting.interfaces.Synchronization</code> by
32  * wrapping an OTS synchronization and forwarding all method calls to the
33  * wrapped synchronization.
34  *
35  * @author <a HREF="mailto:reverbel@ime.usp.br">Francisco Reverbel</a>
36  * @version $Revision: 37459 $
37  */

38 public class OTSSynchronizationWrapper implements Synchronization
39 {
40    // Private field -------------------------------------------------
41

42    /**
43     * The wrapped OTS synchronization.
44     */

45    private org.omg.CosTransactions.Synchronization otsSynchronization;
46
47    // Constructor ---------------------------------------------------
48

49    /**
50     * Creates an <code>OTSSynchronizationWrapper</code> for a given OTS
51     * synchronization.
52     * @param otsSynchronization the OTS synchronization to be wrapped.
53     */

54    public OTSSynchronizationWrapper(org.omg.CosTransactions.Synchronization otsSynchronization)
55    {
56       this.otsSynchronization = otsSynchronization;
57    }
58    
59    // Attribute -----------------------------------------------------
60

61    public org.omg.CosTransactions.Synchronization getWrappedSynchronization()
62    {
63       return otsSynchronization;
64    }
65    
66    // Conversion to string ------------------------------------------
67

68    public String JavaDoc toString()
69    {
70       return CorbaORB.getInstance().object_to_string(otsSynchronization);
71    }
72    
73    // Static --------------------------------------------------------
74

75    public static OTSSynchronizationWrapper fromString(String JavaDoc s)
76    {
77       org.omg.CORBA.Object JavaDoc obj = CorbaORB.getInstance().string_to_object(s);
78       org.omg.CosTransactions.Synchronization otsSynch =
79          org.omg.CosTransactions.SynchronizationHelper.narrow(obj);
80       return new OTSSynchronizationWrapper(otsSynch);
81    }
82    
83    // org.jboss.tm.remoting.interfaces.Synchronization methods ------
84

85    /**
86     * Calls <code>before_completion</code> on the wrapped OTS synchronization.
87     * @see org.jboss.tm.remoting.interfaces.Synchronization#beforeCompletion()
88     */

89    public void beforeCompletion() throws RemoteException JavaDoc
90    {
91       try
92       {
93          otsSynchronization.before_completion();
94       }
95       catch (org.omg.CORBA.SystemException JavaDoc se)
96       {
97          throw javax.rmi.CORBA.Util.mapSystemException(se);
98       }
99    }
100
101    /**
102     * Calls <code>after_completion</code> on the wrapped OTS synchronization.
103     * @see org.jboss.tm.remoting.interfaces.Synchronization#afterCompletion()
104     */

105    public void afterCompletion(Status s) throws RemoteException JavaDoc
106    {
107       try
108       {
109          otsSynchronization.after_completion(Util.jbossToCosTransactions(s));
110       }
111       catch (org.omg.CORBA.SystemException JavaDoc se)
112       {
113          throw javax.rmi.CORBA.Util.mapSystemException(se);
114       }
115    }
116
117 }
118
Popular Tags