KickJava   Java API By Example, From Geeks To Geeks.

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


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.AbstractServer;
32 import com.caucho.ejb.EJBExceptionWrapper;
33 import com.caucho.ejb.EjbServerManager;
34 import com.caucho.util.Log;
35
36 import javax.ejb.EJBHome JavaDoc;
37 import javax.ejb.EJBLocalHome JavaDoc;
38 import javax.ejb.SessionBean JavaDoc;
39 import java.rmi.RemoteException JavaDoc;
40 import java.util.logging.Logger JavaDoc;
41
42 /**
43  * Server container for a session bean.
44  */

45 abstract public class AbstractSessionServer extends AbstractServer {
46   protected final static Logger JavaDoc log = Log.open(AbstractSessionServer.class);
47
48   private AbstractSessionContext _homeContext;
49
50   public AbstractSessionServer(EjbServerManager manager)
51     throws Exception JavaDoc
52   {
53     super(manager);
54   }
55
56   /**
57    * Initialize the server
58    */

59   @Override JavaDoc
60   public void init()
61     throws Exception JavaDoc
62   {
63     try {
64       super.init();
65       
66       //generate();
67

68       /*
69       _homeContext = (QSessionContext) _beanSkelClass.newInstance();
70       _homeContext.init(this);
71         
72       if (_config.getLocalHomeClass() != null)
73         _localHome = _homeContext.createLocalHome();
74
75       if (_homeStubClass != null) {
76         _remoteHomeView = _homeContext.createRemoteHomeView();
77
78     if (_config.getJndiName() != null) {
79       Context ic = new InitialContext();
80       ic.rebind(_config.getJndiName(), this);
81     }
82       }
83       */

84       
85       log.config("initialized session bean: " + this);
86     } catch (Exception JavaDoc e) {
87       throw e;
88     }
89   }
90
91   /**
92    * Returns the object key from a handle.
93    */

94   public Class JavaDoc getPrimaryKeyClass()
95   {
96     return String JavaDoc.class;
97   }
98
99   /**
100    * Returns the EJBLocalHome stub for the container
101    */

102   public EJBLocalHome JavaDoc getEJBLocalHome()
103   {
104     return _localHome;
105   }
106
107   /**
108    * Returns the EJBHome stub for the container
109    */

110   public EJBHome JavaDoc getEJBHome()
111     throws RemoteException JavaDoc
112   {
113     if (_remoteHome == null) {
114       try {
115         _remoteHome = _jvmClient.createHomeStub();
116       } catch (Exception JavaDoc e) {
117         EJBExceptionWrapper.createRuntime(e);
118       }
119     }
120     
121     return _remoteHome;
122   }
123
124   public Object JavaDoc getHomeObject()
125   {
126     return _remoteHomeView;
127   }
128
129   /**
130    * Creates the local stub for the object in the context.
131    */

132   SessionObject getEJBLocalObject(SessionBean JavaDoc bean)
133   {
134     try {
135       SessionObject obj = null;
136
137       /*
138       obj = (SessionObject) bean.getLocal();
139       obj._setObject(bean);
140       */

141       if (obj == null)
142         throw new IllegalStateException JavaDoc("bean has no local interface");
143
144       return obj;
145     } catch (Exception JavaDoc e) {
146       throw new EJBExceptionWrapper(e);
147     }
148   }
149 }
150
Popular Tags