Source Code Cross Referenced for LocalHomeProxy.java in  » EJB-Server-JBoss-4.2.1 » server » org » jboss » ejb » plugins » local » 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 » server » org.jboss.ejb.plugins.local 
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.ejb.plugins.local;
023:
024:        import javax.ejb.EJBLocalHome;
025:        import javax.ejb.EJBLocalObject;
026:        import javax.ejb.RemoveException;
027:        import java.lang.reflect.InvocationHandler;
028:        import java.lang.reflect.Method;
029:
030:        /**
031:         * The proxy for an EJBLocalHome object.
032:         *
033:         * @author <a href="mailto:docodan@mvcsoft.com">Daniel OConnor</a>
034:         * @author <a href="mailto:scott.stark@jboss.org">Scott Stark</a>
035:         * @version $Revision: 57209 $
036:         */
037:        public class LocalHomeProxy extends LocalProxy implements 
038:                InvocationHandler {
039:            static final long serialVersionUID = 1762319499924478521L;
040:
041:            /** {@link javax.ejb.EJBHome#remove(Object)} method reference. */
042:            protected static final Method REMOVE_BY_PRIMARY_KEY;
043:
044:            /** {@link javax.ejb.EJBObject#remove} method reference. */
045:            protected static final Method REMOVE_OBJECT;
046:
047:            /**
048:             * Initialize {@link javax.ejb.EJBHome} and {@link javax.ejb.EJBObject} method references.
049:             */
050:            static {
051:                try {
052:                    final Class empty[] = {};
053:                    final Class type = EJBLocalHome.class;
054:
055:                    REMOVE_BY_PRIMARY_KEY = type.getMethod("remove",
056:                            new Class[] { Object.class });
057:
058:                    // Get the "remove" method from the EJBObject
059:                    REMOVE_OBJECT = EJBLocalObject.class.getMethod("remove",
060:                            empty);
061:                } catch (Exception e) {
062:                    e.printStackTrace();
063:                    throw new ExceptionInInitializerError(e);
064:                }
065:            }
066:
067:            public LocalHomeProxy(String jndiName, BaseLocalProxyFactory factory) {
068:                super (jndiName, factory);
069:            }
070:
071:            protected Object getId() {
072:                return jndiName;
073:            }
074:
075:            /**
076:             * InvocationHandler implementation.
077:             *
078:             * @param proxy   The proxy object.
079:             * @param m       The method being invoked.
080:             * @param args    The arguments for the method.
081:             *
082:             * @throws Throwable    Any exception or error thrown while processing.
083:             */
084:            public Object invoke(final Object proxy, final Method m,
085:                    Object[] args) throws Throwable {
086:                Object retValue = null;
087:
088:                if (args == null)
089:                    args = EMPTY_ARGS;
090:
091:                // Implement local methods
092:                if (m.equals(TO_STRING)) {
093:                    retValue = jndiName + "Home";
094:                } else if (m.equals(EQUALS)) {
095:                    // equality of the proxy home is based on names...
096:                    Object temp = invoke(proxy, TO_STRING, args);
097:                    retValue = new Boolean(temp.equals(jndiName + "Home"));
098:                } else if (m.equals(HASH_CODE)) {
099:                    retValue = new Integer(this .hashCode());
100:                } else if (m.equals(REMOVE_BY_PRIMARY_KEY)) {
101:                    try {
102:                        // The trick is simple we trick the container in believe it
103:                        // is a remove() on the instance
104:                        Object id = args[0];
105:                        retValue = factory
106:                                .invoke(id, REMOVE_OBJECT, EMPTY_ARGS);
107:                    } catch (Exception e) {
108:                        RemoveException re = new RemoveException(e.getMessage());
109:                        re.initCause(e);
110:                        throw re;
111:                    }
112:                }
113:                // If not taken care of, go on and call the container
114:                else {
115:                    retValue = factory.invokeHome(m, args);
116:                }
117:
118:                return retValue;
119:            }
120:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.