Source Code Cross Referenced for StatefulHandleImpl.java in  » EJB-Server-JBoss-4.2.1 » ejb3 » org » jboss » ejb3 » stateful » 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 JBoss 4.2.1 » ejb3 » org.jboss.ejb3.stateful 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source.
003:         * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004:         * as indicated by the @author tags. See the copyright.txt file in the
005:         * distribution for a full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package org.jboss.ejb3.stateful;
023:
024:        import java.rmi.RemoteException;
025:        import java.rmi.ServerException;
026:        import java.security.AccessControlException;
027:        import java.util.Hashtable;
028:        import java.lang.reflect.InvocationHandler;
029:        import java.lang.reflect.Method;
030:        import java.lang.reflect.Proxy;
031:
032:        import javax.ejb.EJBObject;
033:        import javax.ejb.Handle;
034:        import javax.naming.InitialContext;
035:
036:        import org.jboss.invocation.Invoker;
037:        import org.jboss.logging.Logger;
038:        import org.jboss.naming.NamingContextFactory;
039:
040:        /**
041:         * An EJB stateful session bean handle.
042:         *
043:         * @author  <a href="mailto:marc.fleury@jboss.org">Marc Fleury</a>
044:         * @author  <a href="mailto:jason@planet57.com">Jason Dillon</a>
045:         * @author <a href="bill@burkecentral.com">Bill Burke</a>
046:         * @author <a href="bdecoste@jboss.com">William DeCoste</a>
047:         * @version $Revision: 60233 $
048:         */
049:        public class StatefulHandleImpl implements  Handle {
050:            private static final Logger log = Logger
051:                    .getLogger(StatefulHandleImpl.class);
052:
053:            /** Serial Version Identifier. */
054:            static final long serialVersionUID = -6324520755180597156L;
055:
056:            /** A reference to {@link Handle#getEJBObject}. */
057:            protected static final Method GET_EJB_OBJECT;
058:
059:            /** The value of our local Invoker.ID to detect when we are local. */
060:            private Object invokerID = null;
061:
062:            /**
063:             * Initialize <tt>Handle</tt> method references.
064:             */
065:            static {
066:                try {
067:                    GET_EJB_OBJECT = Handle.class.getMethod("getEJBObject",
068:                            new Class[0]);
069:                } catch (Exception e) {
070:                    e.printStackTrace();
071:                    throw new ExceptionInInitializerError(e);
072:                }
073:            }
074:
075:            public StatefulHandleImpl() {
076:
077:            }
078:
079:            /** The identity of the bean. */
080:            public int objectName;
081:            public String jndiName;
082:            public String invokerProxyBinding;
083:            public Invoker invoker;
084:            public Object id;
085:
086:            /** The JNDI env in effect when the home handle was created */
087:            protected Hashtable jndiEnv;
088:
089:            /** Create an ejb handle for a stateful session bean.
090:             * @param objectName - the session container jmx name
091:             * @param jndiName - the session home ejb name
092:             * @param invoker - the invoker to request the EJBObject from
093:             * @param invokerProxyBinding - the type of invoker binding
094:             * @param id - the session id
095:             */
096:            public StatefulHandleImpl(int objectName, String jndiName,
097:                    Invoker invoker, String invokerProxyBinding, Object id,
098:                    Object invokerID) {
099:                this .jndiName = jndiName;
100:                this .id = id;
101:                this .jndiEnv = (Hashtable) NamingContextFactory.lastInitialContextEnv
102:                        .get();
103:                try {
104:                    String property = System
105:                            .getProperty("org.jboss.ejb.sfsb.handle.V327");
106:                    if (property != null) {
107:                        this .invokerProxyBinding = invokerProxyBinding;
108:                        this .invokerID = invokerID;
109:                        this .objectName = objectName;
110:                        this .invoker = invoker;
111:                    }
112:                } catch (AccessControlException ignored) {
113:                }
114:
115:            }
116:
117:            /**
118:             * @return the internal session identifier
119:             */
120:            public Object getID() {
121:                return id;
122:            }
123:
124:            /**
125:             * @return the jndi name
126:             */
127:            public String getJNDIName() {
128:                return jndiName;
129:            }
130:
131:            /**
132:             * Handle implementation.
133:             *
134:             * This differs from Stateless and Entity handles which just invoke
135:             * standard methods (<tt>create</tt> and <tt>findByPrimaryKey</tt>
136:             * respectively) on the Home interface (proxy).
137:             * There is no equivalent option for stateful SBs, so a direct invocation
138:             * on the container has to be made to locate the bean by its id (the
139:             * stateful SB container provides an implementation of
140:             * <tt>getEJBObject</tt>).
141:             *
142:             * This means the security context has to be set here just as it would
143:             * be in the Proxy.
144:             *
145:             * @return  <tt>EJBObject</tt> reference.
146:             *
147:             * @throws ServerException    Could not get EJBObject.
148:             */
149:            public EJBObject getEJBObject() throws RemoteException {
150:                try {
151:                    InitialContext ic = null;
152:                    if (jndiEnv != null)
153:                        ic = new InitialContext(jndiEnv);
154:                    else
155:                        ic = new InitialContext();
156:
157:                    Proxy proxy = (Proxy) ic.lookup(jndiName);
158:
159:                    return (EJBObject) proxy;
160:                } catch (Throwable t) {
161:                    t.printStackTrace();
162:                    throw new RemoteException("Error during getEJBObject", t);
163:                }
164:            }
165:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.