Source Code Cross Referenced for CORBAAdapter.java in  » Portal » stringbeans-3.5 » com » nabhinc » ws » service » adapter » 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 » Portal » stringbeans 3.5 » com.nabhinc.ws.service.adapter 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * (C) Copyright 2000 - 2005 Nabh Information Systems, Inc.
003:         *
004:         * This program is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU General Public License 
006:         * as published by the Free Software Foundation; either version 2
007:         * of the License, or (at your option) any later version.
008:         * 
009:         * This program is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of 
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
012:         * GNU General Public License for more details.
013:         * 
014:         * You should have received a copy of the GNU General Public License
015:         * along with this program; if not, write to the Free Software 
016:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
017:         * 
018:         */
019:
020:        /*
021:         * This file contains fragments from Apache Axis class.
022:         * 
023:         * Copyright 2001-2004 The Apache Software Foundation.
024:         *
025:         * Licensed under the Apache License, Version 2.0 (the "License");
026:         * you may not use this file except in compliance with the License.
027:         * You may obtain a copy of the License at
028:         *
029:         *      http://www.apache.org/licenses/LICENSE-2.0
030:         *
031:         * Unless required by applicable law or agreed to in writing, software
032:         * distributed under the License is distributed on an "AS IS" BASIS,
033:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
034:         * See the License for the specific language governing permissions and
035:         * limitations under the License.
036:         */
037:
038:        package com.nabhinc.ws.service.adapter;
039:
040:        import java.lang.reflect.InvocationTargetException;
041:        import java.lang.reflect.Method;
042:        import java.util.Properties;
043:
044:        import org.omg.CORBA.ORB;
045:        import org.omg.CORBA.ORBPackage.InvalidName;
046:        import org.omg.CosNaming.NameComponent;
047:        import org.omg.CosNaming.NamingContext;
048:        import org.omg.CosNaming.NamingContextHelper;
049:        import org.omg.CosNaming.NamingContextPackage.CannotProceed;
050:        import org.omg.CosNaming.NamingContextPackage.NotFound;
051:
052:        import com.nabhinc.ws.core.WebServiceException;
053:        import com.nabhinc.ws.service.core.JavaDelegateWebService;
054:
055:        /**
056:         * A Web service implementation that delegates operation
057:         * execution to the corresponding method on a CORBA proxy.
058:         * <p/>
059:         * Service Properties (* indicates required properties):<br/>
060:         * <ul>
061:         * <li>scope - "service", "session", "request". The
062:         * default is "service".</li>
063:         * <li>attributeName - Specifies name of the session/appliaction attribute
064:         * used for caching the implementation object. Applicable only when
065:         * the scope is "session" or "application". </li>
066:         * <li>orbInitialHost - Host name or IP address of ORB host. Default is localhost.</li>
067:         * <li>orbInitialPort - ORB port number. Default is 900.</li>
068:         * <li>nameID* - Name of the CORBA object. </li> 
069:         * <li>nameKind* - Kind of the CORBA object. </li> 
070:         * <li>helperClass* - Name of the helper class used in narrowing the proxy object. </li> 
071:         * <li>interfaceClass* - CORBA interface class name </li> 
072:         * </ul>
073:         * <p/>
074:         * In addition you can specify properties to be set on the delegate
075:         * Java bean object. These properties will depend on the particular
076:         * Java bean class you are using and cannot be enumerated here.
077:         * 
078:         * @author Padmanabh Dabke
079:         * (c) 2005 Nabh Information Systems, Inc. All Rights Reserved.
080:         */
081:        public class CORBAAdapter extends JavaDelegateWebService {
082:
083:            private static final Class[] CORBA_OBJECT_CLASS = new Class[] { org.omg.CORBA.Object.class };
084:
085:            private String orbInitialHost = "localhost";
086:            private String orbInitialPort = "900";
087:            private String nameID = null;
088:            private String nameKind = null;
089:            private String helperClassName = null;
090:            private String interfaceClassName = null;
091:
092:            public String getHelperClass() {
093:                return helperClassName;
094:            }
095:
096:            public void setHelperClass(String helperClass) {
097:                this .helperClassName = helperClass;
098:            }
099:
100:            public String getNameID() {
101:                return nameID;
102:            }
103:
104:            public void setNameID(String nameID) {
105:                this .nameID = nameID;
106:            }
107:
108:            public String getNameKind() {
109:                return nameKind;
110:            }
111:
112:            public void setNameKind(String nameKind) {
113:                this .nameKind = nameKind;
114:            }
115:
116:            public String getOrbInitialHost() {
117:                return orbInitialHost;
118:            }
119:
120:            public void setOrbInitialHost(String orbInitialHost) {
121:                this .orbInitialHost = orbInitialHost;
122:            }
123:
124:            public String getOrbInitialPort() {
125:                return orbInitialPort;
126:            }
127:
128:            public void setOrbInitialPort(String orbInitialPort) {
129:                this .orbInitialPort = orbInitialPort;
130:            }
131:
132:            public String getInterfaceClass() {
133:                return interfaceClassName;
134:            }
135:
136:            public void setInterfaceClass(String cl) {
137:                interfaceClassName = cl;
138:            }
139:
140:            protected void checkProperties() throws WebServiceException {
141:                super .checkProperties();
142:                if (nameID == null)
143:                    throw new WebServiceException("Missing name ID.");
144:                if (nameKind == null)
145:                    throw new WebServiceException("Missing name kind.");
146:                if (helperClassName == null)
147:                    throw new WebServiceException("Missing helper class name.");
148:            }
149:
150:            public Object createDelegateInstance() throws WebServiceException {
151:
152:                // Initialize ORB
153:                Properties orbProps = new Properties();
154:                orbProps.put("org.omg.CORBA.ORBInitialHost", orbInitialHost);
155:                orbProps.put("org.omg.CORBA.ORBInitialPort", orbInitialPort);
156:                ORB orb = ORB.init(new String[0], orbProps);
157:
158:                try {
159:                    // Find the object
160:                    NamingContext root = NamingContextHelper.narrow(orb
161:                            .resolve_initial_references("NameService"));
162:                    NameComponent nc = new NameComponent(nameID, nameKind);
163:                    NameComponent[] ncs = { nc };
164:                    org.omg.CORBA.Object corbaObject = root.resolve(ncs);
165:
166:                    Class helperClass = Class.forName(helperClassName);
167:
168:                    // Narrow the object reference
169:                    Method narrowMethod = helperClass.getMethod("narrow",
170:                            CORBA_OBJECT_CLASS);
171:                    Object targetObject = narrowMethod.invoke(null,
172:                            new Object[] { corbaObject });
173:
174:                    return targetObject;
175:                } catch (ClassNotFoundException e) {
176:                    throw new WebServiceException("Invalid helper class name.",
177:                            e);
178:                } catch (InvalidName e) {
179:                    throw new WebServiceException(
180:                            "Failed to resolve initial reference to naming service.",
181:                            e);
182:                } catch (NotFound e) {
183:                    throw new WebServiceException("CORBA object not found.", e);
184:                } catch (CannotProceed e) {
185:                    throw new WebServiceException(
186:                            "Failed to resolve CORBA object.", e);
187:                } catch (org.omg.CosNaming.NamingContextPackage.InvalidName e) {
188:                    throw new WebServiceException(
189:                            "Failed to lookup CORBA object.", e);
190:                } catch (SecurityException e) {
191:                    throw new WebServiceException(
192:                            "Security exception in finding narrow method.", e);
193:                } catch (NoSuchMethodException e) {
194:                    throw new WebServiceException(
195:                            "Failed to find narrow method on helper class.", e);
196:                } catch (IllegalArgumentException e) {
197:                    throw new WebServiceException(
198:                            "Failed to narrow target object.", e);
199:                } catch (IllegalAccessException e) {
200:                    throw new WebServiceException(
201:                            "Failed to narrow target object.", e);
202:                } catch (InvocationTargetException e) {
203:                    throw new WebServiceException(
204:                            "Failed to narrow target object.", e);
205:                }
206:            }
207:
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.