KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > ejb > session > AbstractSessionContext


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.ejb.session;
30
31 import com.caucho.ejb.AbstractContext;
32 import com.caucho.ejb.AbstractServer;
33
34 import javax.ejb.EJBObject JavaDoc;
35 import javax.ejb.Handle JavaDoc;
36 import javax.ejb.SessionContext JavaDoc;
37
38 import javax.xml.rpc.handler.MessageContext JavaDoc;
39
40 /**
41  * Abstract base class for an session context
42  */

43 abstract public class AbstractSessionContext extends AbstractContext
44   implements SessionContext JavaDoc
45 {
46   protected final SessionServer _server;
47   
48   private String JavaDoc _primaryKey;
49   private EJBObject JavaDoc _remote;
50
51   protected AbstractSessionContext(SessionServer server)
52   {
53     _server = server;
54   }
55   
56   /**
57    * Returns the owning server.
58    */

59   public AbstractServer getServer()
60   {
61     return _server;
62   }
63
64   /**
65    * Returns the owning server.
66    */

67   public SessionServer getSessionServer()
68   {
69     return _server;
70   }
71
72   /**
73    * Returns the object's handle.
74    */

75   public Handle JavaDoc getHandle()
76   {
77     return getSessionServer().createHandle(this);
78   }
79
80   /**
81    * For session beans, returns the object. For the home, return an
82    * illegal state exception.
83    */

84   public EJBObject JavaDoc getEJBObject()
85     throws IllegalStateException JavaDoc
86   {
87     return getRemoteView();
88   }
89
90   public String JavaDoc getPrimaryKey()
91   {
92     if (_primaryKey == null)
93       _primaryKey = getSessionServer().createSessionKey(this);
94
95     return _primaryKey;
96   }
97   
98   public <T> T getBusinessObject(Class JavaDoc<T> businessInterface)
99   {
100     throw new UnsupportedOperationException JavaDoc();
101   }
102   
103   public Class JavaDoc getInvokedBusinessInterface()
104   {
105     throw new UnsupportedOperationException JavaDoc();
106   }
107   
108   public MessageContext JavaDoc getMessageContext()
109   {
110     throw new UnsupportedOperationException JavaDoc();
111   }
112 }
113
Popular Tags