Source Code Cross Referenced for StatelessServer.java in  » EJB-Server-resin-3.1.5 » resin » com » caucho » ejb » session » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server resin 3.1.5 » resin » com.caucho.ejb.session 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003:         *
004:         * This file is part of Resin(R) Open Source
005:         *
006:         * Each copy or derived work must preserve the copyright notice and this
007:         * notice unmodified.
008:         *
009:         * Resin Open Source is free software; you can redistribute it and/or modify
010:         * it under the terms of the GNU General Public License as published by
011:         * the Free Software Foundation; either version 2 of the License, or
012:         * (at your option) any later version.
013:         *
014:         * Resin Open Source is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017:         * of NON-INFRINGEMENT.  See the GNU General Public License for more
018:         * details.
019:         *
020:         * You should have received a copy of the GNU General Public License
021:         * along with Resin Open Source; if not, write to the
022:         * 
023:         *   Free Software Foundation, Inc.
024:         *   59 Temple Place, Suite 330
025:         *   Boston, MA 02111-1307  USA
026:         *
027:         * @author Scott Ferguson
028:         */
029:
030:        package com.caucho.ejb.session;
031:
032:        import com.caucho.ejb.AbstractContext;
033:        import com.caucho.ejb.EJBExceptionWrapper;
034:        import com.caucho.ejb.manager.EjbContainer;
035:        import com.caucho.ejb.protocol.*;
036:        import com.caucho.webbeans.component.*;
037:
038:        import javax.ejb.*;
039:        import javax.webbeans.*;
040:        import java.lang.reflect.Constructor;
041:        import java.util.*;
042:        import java.util.logging.Level;
043:        import java.util.logging.Logger;
044:
045:        /**
046:         * Server home container for a stateless session bean
047:         */
048:        public class StatelessServer extends SessionServer {
049:            protected static Logger log = Logger
050:                    .getLogger(StatelessServer.class.getName());
051:
052:            private StatelessContext _homeContext;
053:            private StatelessProvider _remoteProvider;
054:
055:            /**
056:             * Creates a new stateless server.
057:             *
058:             * @param urlPrefix the url prefix for any request to the server
059:             * @param allowJVMCall allows fast calls to the same JVM (with serialization)
060:             * @param config the session configuration from the ejb.xml
061:             */
062:            public StatelessServer(EjbContainer ejbContainer) {
063:                super (ejbContainer);
064:            }
065:
066:            @Override
067:            protected String getType() {
068:                return "stateless:";
069:            }
070:
071:            /**
072:             * Returns the JNDI proxy object to create instances of the
073:             * local interface.
074:             */
075:            @Override
076:            public Object getLocalProxy(Class api) {
077:                StatelessProvider provider = getStatelessContext().getProvider(
078:                        api);
079:
080:                return new StatelessProviderProxy(provider);
081:            }
082:
083:            /**
084:             * Returns the object implementation
085:             */
086:            @Override
087:            public Object getLocalObject(Class api) {
088:                return getStatelessContext().getProvider(api);
089:            }
090:
091:            protected ComponentImpl createSessionComponent(Class api) {
092:                StatelessProvider provider = getStatelessContext().getProvider(
093:                        api);
094:
095:                return new StatelessComponent(provider, api);
096:            }
097:
098:            /**
099:             * Returns the ejb home.
100:             */
101:            @Override
102:            public EJBHome getEJBHome() {
103:                return _remoteHomeView;
104:            }
105:
106:            /**
107:             * Returns the 3.0 remote stub for the container
108:             */
109:            public Object getRemoteObject() {
110:                if (_remoteProvider != null)
111:                    return _remoteProvider.__caucho_get();
112:                else
113:                    return null;
114:            }
115:
116:            /**
117:             * Returns the remote stub for the container
118:             */
119:            @Override
120:            public Object getRemoteObject(Class api, String protocol) {
121:                if (api == null)
122:                    return null;
123:
124:                StatelessProvider provider = getStatelessContext().getProvider(
125:                        api);
126:
127:                if (provider != null) {
128:                    Object result = provider.__caucho_get();
129:
130:                    return result;
131:                } else {
132:                    log.fine(this  + " unknown api " + api.getName());
133:                    return null;
134:                }
135:            }
136:
137:            /**
138:             * Returns the remote object.
139:             */
140:            @Override
141:            public Object getRemoteObject(Object key) {
142:                if (_remoteProvider != null)
143:                    return _remoteProvider.__caucho_get();
144:                else
145:                    return null;
146:            }
147:
148:            @Override
149:            public void init() throws Exception {
150:                super .init();
151:
152:                ArrayList<Class> remoteApiList = getRemoteApiList();
153:
154:                if (remoteApiList != null && remoteApiList.size() > 0) {
155:                    Class api = remoteApiList.get(0);
156:
157:                    _remoteProvider = getStatelessContext().getProvider(api);
158:                }
159:            }
160:
161:            /**
162:             * Finds the remote bean by its key.
163:             *
164:             * @param key the remote key
165:             *
166:             * @return the remote interface of the entity.
167:             */
168:            @Override
169:            public EJBObject getEJBObject(Object key) throws FinderException {
170:                return getStatelessContext().getEJBObject();
171:            }
172:
173:            public AbstractContext getContext() {
174:                return getStatelessContext();
175:            }
176:
177:            @Override
178:            public AbstractContext getContext(Object key, boolean forceLoad) {
179:                return getStatelessContext();
180:            }
181:
182:            @Override
183:            public AbstractSessionContext getSessionContext() {
184:                return getStatelessContext();
185:            }
186:
187:            private StatelessContext getStatelessContext() {
188:                synchronized (this ) {
189:                    if (_homeContext == null) {
190:                        try {
191:                            Class[] param = new Class[] { StatelessServer.class };
192:                            Constructor cons = _contextImplClass
193:                                    .getConstructor(param);
194:
195:                            _homeContext = (StatelessContext) cons
196:                                    .newInstance(this );
197:                        } catch (Exception e) {
198:                            throw new EJBExceptionWrapper(e);
199:                        }
200:                    }
201:                }
202:
203:                return _homeContext;
204:            }
205:
206:            /**
207:             * Returns the object serialization handle for the given api
208:             */
209:            Object getObjectHandle(StatelessObject obj, Class api) {
210:                ComponentImpl comp = getComponent(api);
211:
212:                // XXX: remote handle differently
213:                if (comp != null)
214:                    return comp.getHandle();
215:                else
216:                    return new ObjectSkeletonWrapper(obj.getHandle());
217:            }
218:
219:            /**
220:             * Creates a handle for a new session.
221:             */
222:            AbstractHandle createHandle(AbstractContext context) {
223:                String key = createSessionKey(context);
224:
225:                return getHandleEncoder().createHandle(key);
226:            }
227:
228:            /**
229:             * Creates a handle for a new session.
230:             */
231:            /*
232:              JVMObject createEJBObject(Object primaryKey)
233:              {
234:              try {
235:              JVMObject obj = (JVMObject) _remoteStubClass.newInstance();
236:              obj._init(this, createSessionKey(null));
237:
238:              return obj;
239:              } catch (Exception e) {
240:              throw new EJBExceptionWrapper(e);
241:              }
242:              }
243:             */
244:
245:            /**
246:             * Creates a handle for a new session.
247:             */
248:            String createSessionKey(AbstractContext context) {
249:                return "::ejb:stateless";
250:            }
251:
252:            /**
253:             * Cleans up the entity server nicely.
254:             */
255:            @Override
256:            public void destroy() {
257:                if (_homeContext != null) {
258:                    try {
259:                        _homeContext.destroy();
260:                    } catch (Throwable e) {
261:                        log.log(Level.WARNING, e.toString(), e);
262:                    }
263:                }
264:
265:                super.destroy();
266:            }
267:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.