Source Code Cross Referenced for DiiServer.java in  » Collaboration » JacORB » demo » dii » 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 » Collaboration » JacORB » demo.dii 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package demo.dii;
002:
003:        import org.omg.CORBA.Any;
004:        import org.omg.CosNaming.*;
005:
006:        public class DiiServer extends
007:                org.omg.PortableServer.DynamicImplementation {
008:            private String[] ids = { "IDL:dii/server:1.0" };
009:
010:            // singleton ORB as any factory
011:            org.omg.CORBA.ORB orb = null;
012:
013:            serverImpl impl = new serverImpl();
014:
015:            public DiiServer(org.omg.CORBA.ORB orb) {
016:                this .orb = orb;
017:            }
018:
019:            /** from Servant */
020:
021:            public String[] _all_interfaces(org.omg.PortableServer.POA poa,
022:                    byte[] objectId) {
023:                return ids;
024:            }
025:
026:            public void invoke(org.omg.CORBA.ServerRequest request) {
027:                String op = request.operation();
028:                try {
029:                    if (op.equals("_get_long_number")) {
030:                        Any a = orb.create_any();
031:                        a.insert_long(impl.long_number());
032:                        request.set_result(a);
033:                    } else if (op.equals("_set_long_number")) {
034:                        /* set up an argument list */
035:                        org.omg.CORBA.NVList params = orb.create_list(0);
036:                        /* there is only on argument to this call, i.e. a long */
037:                        Any numAny = orb.create_any();
038:                        numAny
039:                                .type(orb
040:                                        .get_primitive_tc(org.omg.CORBA.TCKind.tk_long));
041:                        params
042:                                .add_value("", numAny,
043:                                        org.omg.CORBA.ARG_IN.value);
044:
045:                        /* extract the argugments */
046:                        request.arguments(params);
047:
048:                        /* make the call */
049:                        impl.long_number(numAny.extract_long());
050:
051:                        /* set up the any for the result */
052:                        Any s = orb.create_any();
053:                        s
054:                                .type(orb
055:                                        .get_primitive_tc(org.omg.CORBA.TCKind.tk_void));
056:                        request.set_result(s);
057:                    } else if (op.equals("writeNumber")) {
058:                        org.omg.CORBA.NVList params = orb.create_list(0);
059:                        Any numAny = orb.create_any();
060:                        numAny
061:                                .type(orb
062:                                        .get_primitive_tc(org.omg.CORBA.TCKind.tk_long));
063:                        params
064:                                .add_value("", numAny,
065:                                        org.omg.CORBA.ARG_IN.value);
066:                        request.arguments(params);
067:                        Any a = orb.create_any();
068:                        a
069:                                .insert_string(impl.writeNumber(numAny
070:                                        .extract_long()));
071:                        request.set_result(a);
072:                    } else if (op.equals("add")) {
073:                        org.omg.CORBA.NVList params = orb.create_list(0);
074:                        Any argOneAny = orb.create_any();
075:                        Any argTwoAny = orb.create_any();
076:                        Any outArgAny = orb.create_any();
077:                        argOneAny
078:                                .type(orb
079:                                        .get_primitive_tc(org.omg.CORBA.TCKind.tk_long));
080:                        argTwoAny
081:                                .type(orb
082:                                        .get_primitive_tc(org.omg.CORBA.TCKind.tk_long));
083:                        outArgAny
084:                                .type(orb
085:                                        .get_primitive_tc(org.omg.CORBA.TCKind.tk_long));
086:
087:                        /* add these anys to the parameter list */
088:                        params.add_value("", argOneAny,
089:                                org.omg.CORBA.ARG_IN.value);
090:                        params.add_value("", argTwoAny,
091:                                org.omg.CORBA.ARG_IN.value);
092:                        params.add_value("", outArgAny,
093:                                org.omg.CORBA.ARG_OUT.value);
094:
095:                        /* read in and inout arguments */
096:                        request.arguments(params);
097:
098:                        /* do the computation and fill it into the out arg */
099:                        org.omg.CORBA.IntHolder iHolder = new org.omg.CORBA.IntHolder();
100:                        impl.add(argOneAny.extract_long(), argTwoAny
101:                                .extract_long(), iHolder);
102:
103:                        outArgAny.insert_long(iHolder.value);
104:
105:                        Any resultAny = orb.create_any();
106:                        resultAny
107:                                .type(orb
108:                                        .get_primitive_tc(org.omg.CORBA.TCKind.tk_void));
109:                        request.set_result(resultAny);
110:                    } else if (op.equals("writeNumberWithEx")) {
111:                        org.omg.CORBA.NVList params = orb.create_list(0);
112:                        Any numAny = orb.create_any();
113:                        numAny
114:                                .type(orb
115:                                        .get_primitive_tc(org.omg.CORBA.TCKind.tk_long));
116:                        params
117:                                .add_value("", numAny,
118:                                        org.omg.CORBA.ARG_IN.value);
119:                        request.arguments(params);
120:                        Any a = orb.create_any();
121:                        a.insert_string(impl.writeNumberWithEx(numAny
122:                                .extract_long()));
123:                        request.set_result(a);
124:                    } else if (op.equals("notify")) {
125:                        org.omg.CORBA.NVList params = orb.create_list(0);
126:                        Any stringAny = orb.create_any();
127:                        stringAny
128:                                .type(orb
129:                                        .get_primitive_tc(org.omg.CORBA.TCKind.tk_string));
130:                        params.add_value("", stringAny,
131:                                org.omg.CORBA.ARG_IN.value);
132:                        request.arguments(params);
133:                        impl._notify(stringAny.extract_string());
134:                        Any s = orb.create_any();
135:                        s
136:                                .type(orb
137:                                        .get_primitive_tc(org.omg.CORBA.TCKind.tk_void));
138:                        request.set_result(s);
139:                    } else if (op.equals("_non_existent")) {
140:                        Any s = orb.create_any();
141:                        s
142:                                .type(orb
143:                                        .get_primitive_tc(org.omg.CORBA.TCKind.tk_boolean));
144:                        s.insert_boolean(_non_existent());
145:                        request.set_result(s);
146:                    }
147:                    /**
148:                     * the following operations would also have to be implemented
149:                     * by delegating to the superclass DynamicImplementation or Servant
150:                     * but are omitted here for brevity
151:                     */
152:                    else if (op.equals("_all_interfaces")) {
153:                        throw new org.omg.CORBA.BAD_OPERATION(
154:                                "Object reference operations not implemented in example!");
155:                    } else if (op.equals("_get_interface")) {
156:                        throw new org.omg.CORBA.BAD_OPERATION(
157:                                "Object reference operations not implemented in example!");
158:                    } else if (op.equals("_is_a")) {
159:                        throw new org.omg.CORBA.BAD_OPERATION(
160:                                "Object reference operations not implemented in example");
161:                    } else {
162:                        throw new org.omg.CORBA.BAD_OPERATION(op
163:                                + " not found.");
164:                    }
165:                } catch (org.omg.CORBA.UserException e) {
166:                    System.out.println("Caught: " + e);
167:
168:                    Any exceptAny = orb.create_any();
169:                    try {
170:                        Class helperClass = Class.forName(e.getClass()
171:                                .getName()
172:                                + "Helper");
173:                        Class anyClass = Class.forName("org.omg.CORBA.Any");
174:                        java.lang.reflect.Method insert = helperClass
175:                                .getDeclaredMethod("insert", new Class[] {
176:                                        anyClass, e.getClass() });
177:
178:                        insert.invoke(null, new java.lang.Object[] { exceptAny,
179:                                e });
180:                    } catch (Exception sfe) {
181:                        sfe.printStackTrace();
182:                    }
183:                    request.set_exception(exceptAny);
184:                } catch (org.omg.CORBA.SystemException e) {
185:                    try {
186:                        ((org.jacorb.orb.dsi.ServerRequest) request)
187:                                .setSystemException(e);
188:                    } catch (Exception sfe) {
189:                        sfe.printStackTrace();
190:                    }
191:                } catch (Exception e) {
192:                    e.printStackTrace();
193:                }
194:            }
195:
196:            public static void main(String[] args) {
197:                try {
198:                    org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);
199:                    org.omg.PortableServer.POA poa = org.omg.PortableServer.POAHelper
200:                            .narrow(orb.resolve_initial_references("RootPOA"));
201:
202:                    poa.the_POAManager().activate();
203:
204:                    org.omg.CORBA.Object o = poa
205:                            .servant_to_reference(new DiiServer(orb));
206:
207:                    // register server with naming context
208:                    NamingContextExt nc = NamingContextExtHelper.narrow(orb
209:                            .resolve_initial_references("NameService"));
210:                    nc.rebind(nc.to_name("dii.example"), o);
211:                    orb.run();
212:                } catch (Exception e) {
213:                    e.printStackTrace();
214:                }
215:            }
216:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.