Source Code Cross Referenced for IiopProtocol.java in  » EJB-Server-resin-3.1.5 » resin » com » caucho » iiop » 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.iiop 
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.iiop;
031:
032:        import com.caucho.ejb.AbstractEJBObject;
033:        import com.caucho.ejb.AbstractServer;
034:        import com.caucho.log.Log;
035:        import com.caucho.management.j2ee.J2EEManagedObject;
036:        import com.caucho.management.j2ee.RMI_IIOPResource;
037:        import com.caucho.naming.*;
038:        import com.caucho.server.connection.Connection;
039:        import com.caucho.server.port.Protocol;
040:        import com.caucho.server.port.ServerRequest;
041:        import com.caucho.iiop.orb.*;
042:
043:        import java.lang.reflect.Method;
044:        import java.rmi.NoSuchObjectException;
045:        import java.util.ArrayList;
046:        import java.util.logging.*;
047:        import javax.annotation.*;
048:        import javax.naming.*;
049:
050:        /**
051:         * The main class for the HTTP server.
052:         *
053:         * <p>TcpServer handles the main thread control.  HttpServer just needs
054:         * to create the right kind of request when a new thread is spawned.
055:         *
056:         * @see com.caucho.server.TcpServer
057:         */
058:        public class IiopProtocol extends Protocol {
059:            private static final Logger log = Logger
060:                    .getLogger(IiopProtocol.class.getName());
061:
062:            static final String COPYRIGHT = "Copyright (c) 1998-2008 Caucho Technology.  All rights reserved.";
063:
064:            private String _protocolName = "iiop";
065:
066:            private ORBImpl _orb = new ORBImpl();
067:            private boolean _isOrbInit;
068:            private CosServer _cos;
069:
070:            private IiopContext _iiopContext;
071:
072:            /**
073:             * Creates the IIOP protocol.
074:             */
075:            public IiopProtocol() {
076:                _iiopContext = new IiopContext();
077:
078:                try {
079:                    Jndi.rebindDeep("java:comp/ORB", _orb);
080:                } catch (NamingException e) {
081:                    log.log(Level.FINER, e.toString(), e);
082:                }
083:
084:                _cos = new CosServer(this );
085:
086:                IiopContext.setLocalContext(_iiopContext);
087:            }
088:
089:            /**
090:             * Returns the protocol name.
091:             */
092:            public String getProtocolName() {
093:                return _protocolName;
094:            }
095:
096:            /**
097:             * Sets the protocol name.
098:             */
099:            public void setProtocolName(String name) {
100:                _protocolName = name;
101:            }
102:
103:            @PostConstruct
104:            public void init() {
105:                J2EEManagedObject.register(new RMI_IIOPResource(this ));
106:            }
107:
108:            public CosServer getCos() {
109:                return _cos;
110:            }
111:
112:            public IiopSkeleton getService(String host, int port, String oid)
113:                    throws NoSuchObjectException {
114:                return lookupService(host, port, oid);
115:            }
116:
117:            ORBImpl getOrb(String host, int port) {
118:                if (!_isOrbInit) {
119:                    _isOrbInit = true;
120:                    _orb.setHost(host);
121:                    _orb.setPort(port);
122:                }
123:
124:                return _orb;
125:            }
126:
127:            /**
128:             * Returns the service with the given URL.
129:             */
130:            private IiopSkeleton lookupService(String host, int port, String oid)
131:                    throws NoSuchObjectException {
132:                String url;
133:                String local;
134:
135:                int p = oid.indexOf('?');
136:
137:                if (p < 0) {
138:                    url = oid;
139:                    local = null;
140:                } else {
141:                    url = oid.substring(0, p);
142:                    local = oid.substring(p + 1);
143:                }
144:
145:                IiopRemoteService service = _iiopContext.getService(url);
146:
147:                if (service == null)
148:                    return null;
149:                else if (local == null) {
150:                    // ArrayList<Class> apiList = new ArrayList<Class>();
151:                    // apiList.add(service.getHomeAPI());
152:
153:                    // TCK: ejb30/bb/session/stateful/busifacedd/multipleInterfacesTest2
154:                    // ejb/4012: multiple <business-remote> interfaces
155:                    ArrayList<Class> apiList = service.getHomeAPI();
156:
157:                    Object obj = service.getHome();
158:
159:                    if (obj == null)
160:                        throw new IllegalStateException(service
161:                                + " does not have a valid EJB home interface");
162:
163:                    // Restrict the service API to the given business interface.
164:                    // TCK: ejb30/getInvokedBusinessInterfaceRemoteIllegal, needs QA
165:                    if (service.getRemoteInterface() != null) {
166:                        apiList.clear();
167:                        apiList.add(service.getRemoteInterface());
168:
169:                        for (Method method : obj.getClass()
170:                                .getDeclaredMethods()) {
171:                            try {
172:                                // XXX TCK
173:                                if (method.getName().startsWith("create"))
174:                                    obj = method.invoke(obj, null);
175:                            } catch (Exception e) {
176:                                log.config("Remote home "
177:                                        + obj.getClass().getName()
178:                                        + " has no create method");
179:                            }
180:                        }
181:                    }
182:
183:                    // XXX TCK: ejb30/.../remove
184:                    if (obj instanceof  AbstractEJBObject) {
185:                        AbstractEJBObject ejb = (AbstractEJBObject) obj;
186:
187:                        AbstractServer server = ejb.__caucho_getServer();
188:                        local = ejb.__caucho_getId();
189:
190:                        url = url + "?" + local;
191:                    }
192:
193:                    return new IiopSkeleton(obj, apiList, service
194:                            .getClassLoader(), host, port, url);
195:                } else {
196:                    Object obj = service.getObject(local);
197:
198:                    if (obj == null)
199:                        return null;
200:
201:                    ArrayList<Class> apiList = service.getObjectAPI();
202:
203:                    // Restrict the service API to the given business interface.
204:                    // TCK: ejb30/getInvokedBusinessInterfaceRemoteIllegal, needs QA
205:                    if (service.getRemoteInterface() != null) {
206:                        apiList.clear();
207:                        apiList.add(service.getRemoteInterface());
208:
209:                        for (Method method : obj.getClass()
210:                                .getDeclaredMethods()) {
211:                            try {
212:                                // XXX TCK
213:                                if (method.getName().startsWith("create"))
214:                                    obj = method.invoke(obj, null);
215:                            } catch (Exception e) {
216:                                log.config("Remote home "
217:                                        + obj.getClass().getName()
218:                                        + " has no create method");
219:                            }
220:                        }
221:                    }
222:
223:                    return new IiopSkeleton(obj, apiList, service
224:                            .getClassLoader(), host, port, url + '?' + local);
225:                }
226:            }
227:
228:            /**
229:             * Create a HttpRequest object for the new thread.
230:             */
231:            public ServerRequest createRequest(Connection conn) {
232:                return new IiopRequest(this, conn);
233:            }
234:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.