Source Code Cross Referenced for EJBMethod.java in  » Workflow-Engines » obe-1.0 » org » obe » runtime » tool » 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 » Workflow Engines » obe 1.0 » org.obe.runtime.tool 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.obe.runtime.tool;
002:
003:        import org.apache.commons.logging.Log;
004:        import org.apache.commons.logging.LogFactory;
005:        import org.obe.XMLException;
006:        import org.obe.client.api.repository.EJBMethodMetaData;
007:        import org.obe.client.api.repository.RepositoryException;
008:
009:        import javax.ejb.EJBHome;
010:        import javax.ejb.EJBMetaData;
011:        import javax.naming.Context;
012:        import javax.naming.NamingException;
013:        import javax.rmi.PortableRemoteObject;
014:        import java.lang.reflect.InvocationTargetException;
015:        import java.lang.reflect.Method;
016:        import java.rmi.RemoteException;
017:
018:        /**
019:         * A tool agent that invokes a home or business method on an EJB.
020:         *
021:         * @author Adrian Price
022:         */
023:        public final class EJBMethod extends JavaMethod {
024:            private static final long serialVersionUID = -8007893008342865647L;
025:            private static final Log _logger = LogFactory
026:                    .getLog(EJBMethod.class);
027:
028:            private final EJBMethodMetaData _metadata;
029:            private Object _home;
030:            private Method _createMethod;
031:
032:            public EJBMethod(EJBMethodMetaData metaData)
033:                    throws ClassNotFoundException, NoSuchMethodException,
034:                    NamingException, RemoteException {
035:
036:                super (metaData);
037:                _metadata = metaData;
038:
039:                // Look up the JNDI object bound to the specified name.
040:                Object jndiObject;
041:                Context ctx = null;
042:                try {
043:                    jndiObject = ctx.lookup(metaData.getJndiName());
044:                } finally {
045:                    if (ctx != null)
046:                        ctx.close();
047:                }
048:
049:                // Extract home and remote interfaces by introspecting the bound object.
050:                Class homeClass;
051:                Class intfClass;
052:                try {
053:                    // The only way to tell whether this is a remote home is to cast it.
054:                    EJBHome home = (EJBHome) PortableRemoteObject.narrow(
055:                            jndiObject, EJBHome.class);
056:                    _home = home;
057:                    EJBMetaData ejbMeta = home.getEJBMetaData();
058:                    homeClass = ejbMeta.getHomeInterfaceClass();
059:                    intfClass = ejbMeta.getRemoteInterfaceClass();
060:
061:                    if (_logger.isDebugEnabled()) {
062:                        _logger.debug("JNDI name '" + metaData.getJndiName()
063:                                + "' is bound to a remote home: " + homeClass);
064:                    }
065:                } catch (ClassCastException e) {
066:                    // This isn't strictly accurate, because it's the class that's
067:                    // implementing the home, not the actual home interface itself, but
068:                    // it's close enough for us to determine the local interface.
069:                    // Typically both will be dynamic proxies.
070:                    _home = jndiObject;
071:                    homeClass = jndiObject.getClass();
072:                    // Cast required to suppress JDK1.5 varargs compiler warning.
073:                    _createMethod = homeClass.getMethod("create",
074:                            (Class[]) null);
075:                    intfClass = _createMethod.getReturnType();
076:
077:                    if (_logger.isDebugEnabled()) {
078:                        _logger.debug("JNDI name '" + metaData.getJndiName()
079:                                + "' is bound to a local home: " + homeClass);
080:                    }
081:                }
082:
083:                // Inform superclass of implementing class, method name and param types.
084:                setMethod(metaData.isHomeMethod() ? homeClass : intfClass,
085:                        metaData.getMethod(), metaData.getMethodSig());
086:            }
087:
088:            protected Object getTarget() throws XMLException,
089:                    RepositoryException, IllegalAccessException,
090:                    InvocationTargetException {
091:
092:                // If this is a business method we'll need a target EJB instance.
093:                // TODO: for SFSBs we need the create method signature & args as well.
094:                Object target;
095:                if (_metadata.isHomeMethod()) {
096:                    target = _home;
097:                } else {
098:                    target = getTargetFromWorkflow();
099:                    if (target == null) {
100:                        target = _target;
101:                        if (target == null) {
102:                            // Cast required to suppress JDK1.5 varargs compiler warning.
103:                            _target = target = _createMethod.invoke(_home,
104:                                    (Object[]) null);
105:                            if (_logger.isDebugEnabled())
106:                                _logger.debug("Created target EJB: " + target);
107:                        }
108:                    }
109:                }
110:                return target;
111:            }
112:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.