KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mortbay > j2ee > session > SerializableUserTransaction


1 // ========================================================================
2
// $Id: SerializableUserTransaction.java,v 1.4 2004/05/09 20:30:47 gregwilkins Exp $
3
// Copyright 2002-2004 Mort Bay Consulting Pty. Ltd.
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
// http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
// ========================================================================
15

16 package org.mortbay.j2ee.session;
17
18 import java.rmi.RemoteException JavaDoc;
19
20 import javax.naming.Context JavaDoc;
21 import javax.naming.InitialContext JavaDoc;
22 import javax.transaction.UserTransaction JavaDoc;
23
24 // utility for unambiguously shipping UserTransactions from node to node..
25

26 // NYI
27

28 // it looks like this will need proprietary info - the J2EE API does
29
// not give us enough... - I'm talking to Ole.
30

31 public class
32   SerializableUserTransaction
33   implements java.io.Serializable JavaDoc
34 {
35   protected void
36     log_warn(String JavaDoc message)
37     {
38       System.err.println("WARNING: "+message);
39     }
40
41   protected void
42     log_error(String JavaDoc message, Exception JavaDoc e)
43     {
44       System.err.println("ERROR: "+message);
45       e.printStackTrace(System.err);
46     }
47
48   protected Context JavaDoc _ctx=null;
49
50   protected
51     SerializableUserTransaction()
52     throws RemoteException JavaDoc
53     {
54     }
55
56   SerializableUserTransaction(UserTransaction JavaDoc userTransaction)
57     throws RemoteException JavaDoc
58     {
59       log_warn("distribution of UserTransaction is NYI/Forbidden");
60     }
61
62   UserTransaction JavaDoc
63     toUserTransaction()
64     throws RemoteException JavaDoc
65     {
66       try
67       {
68     // optimise - TODO
69
return (UserTransaction JavaDoc)new InitialContext JavaDoc().lookup("java:comp/UserTransaction");
70       }
71       catch (Exception JavaDoc e)
72       {
73     log_error("could not lookup UserTransaction", e);
74     return null;
75       }
76     }
77 }
78
Popular Tags