Source Code Cross Referenced for DomainParticipantFactoryImpl.java in  » Collaboration » JacORB » org » jacorb » dds » 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 » org.jacorb.dds 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  DDS (Data Distribution Service) for JacORB
003:         *
004:         * Copyright (C) 2005  , Ahmed yehdih <ahmed.yehdih@gmail.com>, fouad
005:         * allaoui <fouad.allaoui@gmail.com>, Didier Donsez (didier.donsez@ieee.org)
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU Library General Public License
009:         * as published by the Free Software Foundation; either version 2
010:         * of the License, or (at your option) any later version.
011:         *
012:         * This program 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
015:         * GNU Library General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Library General Public 
018:         * License along with this program; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
020:         * 02111-1307, USA.
021:         *
022:         * Coontact: Ahmed yehdih <ahmed.yehdih@gmail.com>, fouad allaoui
023:         * <fouad.allaoui@gmail.com>, Didier Donsez (didier.donsez@ieee.org)
024:         * Contributor(s)
025:         *
026:         **/
027:        package org.jacorb.dds;
028:
029:        import java.util.Iterator;
030:        import java.util.Vector;
031:
032:        import org.jacorb.dds.ThreadSubscriber;
033:        import org.jacorb.dds.DomainParticipantImpl;
034:        import org.jacorb.events.EventChannelImpl;
035:        import org.omg.CosNaming.NameComponent;
036:        import org.omg.CosNaming.NamingContextExt;
037:        import org.omg.CosNaming.NamingContextExtHelper;
038:        import org.omg.dds.DomainParticipant;
039:        import org.omg.dds.DomainParticipantFactory;
040:        import org.omg.dds.DomainParticipantFactoryPOA;
041:        import org.omg.dds.DomainParticipantHelper;
042:        import org.omg.dds.RETCODE_OK;
043:        import org.omg.dds.RETCODE_PRECONDITION_NOT_MET;
044:
045:        /**
046:         * The sole purpose of this class is to allow the creation and destruction of
047:         * DomainParticipant objects. DomainParticipantFactory itself has no factory. It
048:         * is either a pre-existing singleton object that can be accessed by means of
049:         * the get_instance class operation on the DomainParticipantFactory.
050:         */
051:        public class DomainParticipantFactoryImpl extends
052:                DomainParticipantFactoryPOA {
053:
054:            private org.omg.CORBA.ORB orb;
055:
056:            private org.omg.PortableServer.POA poa;
057:
058:            private org.omg.dds.DomainParticipantQos defaultqos;
059:
060:            private ThreadSubscriber Consummer;
061:
062:            private Vector allParticipant;
063:
064:            private DomainParticipantFactoryImpl impl;
065:
066:            private DomainParticipantFactory ref;
067:
068:            /**
069:             * Sets the pOA attribute of this object
070:             * 
071:             * @param poa
072:             *            The new pOA value
073:             */
074:            public void setPOA(org.omg.PortableServer.POA poa) {
075:                this .poa = poa;
076:            }
077:
078:            /**
079:             * Sets the oRB attribute of this object
080:             * 
081:             * @param orb
082:             *            The new oRB value
083:             */
084:            public void setORB(org.omg.CORBA.ORB orb) {
085:                this .orb = orb;
086:            }
087:
088:            public DomainParticipantFactoryImpl(org.omg.CORBA.ORB orb,
089:                    org.omg.PortableServer.POA poa) {
090:                this .orb = orb;
091:                this .poa = poa;
092:                try {
093:                    NamingContextExt nc = NamingContextExtHelper.narrow(orb
094:                            .resolve_initial_references("NameService"));
095:                    EventChannelImpl channel = new EventChannelImpl(orb, poa);
096:                    org.omg.CORBA.Object o = poa.servant_to_reference(channel);
097:                    /* event channel used by event service */
098:                    nc.rebind(nc.to_name("eventchannel"), o);
099:                } catch (Exception e) {
100:
101:                }
102:                allParticipant = new Vector();
103:                /* thread send message for all suscriber */
104:                Consummer = new ThreadSubscriber(orb, poa);
105:                Consummer.start();
106:            }
107:
108:            /**
109:             * This operation creates a new DomainParticipant object. The
110:             * DomainParticipant signifies that the calling application intends to join
111:             * the Domain identified by the domainId argument.
112:             */
113:            public org.omg.dds.DomainParticipant create_participant(
114:                    int domainId, org.omg.dds.DomainParticipantQos qos,
115:                    org.omg.dds.DomainParticipantListener a_listener) {
116:
117:                org.omg.dds.DomainParticipant ref = null;
118:                org.jacorb.dds.DomainParticipantImpl impl = new org.jacorb.dds.DomainParticipantImpl(
119:                        domainId, qos, a_listener);
120:                impl.setORB(orb);
121:                impl.setPOA(poa);
122:
123:                try {
124:                    // get the root naming context
125:
126:                    ref = has_domainId(domainId);
127:                    if (ref != null)
128:                        return ref;
129:                    org.omg.CORBA.Object objRef = orb
130:                            .resolve_initial_references("NameService");
131:                    // Use NamingContextExt which is part of the Interoperable
132:                    // Naming Service (INS) specification.
133:                    NamingContextExt ncRef = NamingContextExtHelper
134:                            .narrow(objRef);
135:                    // get object reference from the servant (and implicitly register
136:                    // it)
137:                    org.omg.CORBA.Object oref = poa.servant_to_reference(impl);
138:                    ref = org.omg.dds.DomainParticipantHelper.narrow(oref);
139:
140:                    if (ncRef != null) {
141:                        // bind the Object Reference in Naming
142:                        NameComponent path[] = ncRef.to_name(new Integer(
143:                                domainId).toString());
144:                        ncRef.rebind(path, ref);
145:                        allParticipant.add(ref);
146:                        Consummer.add(ref);
147:                    }
148:                } catch (Exception e) {
149:                }
150:                return ref;
151:            }
152:
153:            /**
154:             * This operation deletes an existing DomainParticipant. This operation can
155:             * only be invoked if all domain entities belonging to the participant have
156:             * already been deleted.
157:             * 
158:             * @param a_participant
159:             * @return RETCODE_OK.value if succes Otherwise the error
160:             *         PRECONDITION_NOT_MET is returned.
161:             */
162:            public int delete_participant(
163:                    org.omg.dds.DomainParticipant a_participant) {
164:
165:                try {
166:                    boolean delete_ok = ((DomainParticipantImpl) poa
167:                            .reference_to_servant(a_participant)).isDeletable();
168:                    if (delete_ok) {
169:                        org.omg.CORBA.Object objRef = orb
170:                                .resolve_initial_references("NameService");
171:                        // Use NamingContextExt which is part of the Interoperable
172:                        // Naming Service (INS) specification.
173:                        NamingContextExt ncRef = NamingContextExtHelper
174:                                .narrow(objRef);
175:                        String id = new Integer(a_participant.get_domain_id())
176:                                .toString();
177:                        NameComponent path[] = ncRef.to_name(id);
178:                        ncRef.unbind(path);
179:                    } else {
180:                        return RETCODE_PRECONDITION_NOT_MET.value;
181:                    }
182:                } catch (Exception e) {
183:                    System.err.println("ERROR: " + e);
184:                    e.printStackTrace(System.out);
185:                }
186:
187:                return RETCODE_OK.value;
188:            }
189:
190:            /**
191:             * @param domainId
192:             * @return a participant has a same domainId
193:             */
194:            public DomainParticipant has_domainId(int domainId) {
195:                Iterator it = allParticipant.iterator();
196:                DomainParticipant temp;
197:                while (it.hasNext()) {
198:                    temp = (DomainParticipant) it.next();
199:                    if (temp.get_domain_id() == domainId)
200:                        return temp;
201:                }
202:                return null;
203:            }
204:
205:            /**
206:             * @param domainId
207:             * @return a Participant has a same domaiId
208:             */
209:            public org.omg.dds.DomainParticipant lookup_participant(int domainId) {
210:
211:                org.omg.dds.DomainParticipant ref = null;
212:                try {
213:                    org.omg.CORBA.Object objRef = orb
214:                            .resolve_initial_references("NameService");
215:                    // Use NamingContextExt instead of NamingContext. This is
216:                    // part of the Interoperable naming Service.
217:                    NamingContextExt ncRef = NamingContextExtHelper
218:                            .narrow(objRef);
219:                    ref = DomainParticipantHelper.narrow(ncRef
220:                            .resolve_str(new Integer(domainId).toString()));
221:                }
222:
223:                catch (Exception e) {
224:                    System.err.println("ERROR: " + e);
225:                    e.printStackTrace(System.out);
226:                }
227:                return ref;
228:            }
229:
230:            /**
231:             * @param qos
232:             * @return
233:             */
234:            public int set_default_participant_qos(
235:                    org.omg.dds.DomainParticipantQos qos) {
236:
237:                this .defaultqos = qos;
238:                return 0;
239:            }
240:
241:            public void get_default_participant_qos(
242:                    org.omg.dds.DomainParticipantQosHolder qos) {
243:
244:                qos.value = this .defaultqos;
245:            }
246:
247:            /**
248:             * @return Returns the orb.
249:             */
250:            public org.omg.CORBA.ORB getOrb() {
251:                return orb;
252:            }
253:
254:            /**
255:             * @return Returns the poa.
256:             */
257:            public org.omg.PortableServer.POA getPoa() {
258:                return poa;
259:            }
260:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.