Source Code Cross Referenced for FooConsumer.java in  » Collaboration » JacORB » demo » dds » dcps » foosample » 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.dds.dcps.foosample 
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 demo.dds.dcps.foosample;
028:
029:        import org.omg.CORBA.ORB;
030:        import org.omg.CosNaming.NamingContextExt;
031:        import org.omg.CosNaming.NamingContextExtHelper;
032:        import org.omg.dds.DataReader;
033:        import org.omg.dds.DataReaderListener;
034:        import org.omg.dds.DataReaderListenerHelper;
035:        import org.omg.dds.DataReaderQos;
036:        import org.omg.dds.DeadlineQosPolicy;
037:        import org.omg.dds.DestinationOrderQosPolicyKind;
038:        import org.omg.dds.DomainParticipant;
039:        import org.omg.dds.DomainParticipantFactory;
040:        import org.omg.dds.DomainParticipantFactoryHelper;
041:        import org.omg.dds.DomainParticipantQos;
042:        import org.omg.dds.DurabilityQosPolicy;
043:        import org.omg.dds.DurabilityQosPolicyKind;
044:        import org.omg.dds.Duration_t;
045:        import org.omg.dds.EntityFactoryQosPolicy;
046:        import org.omg.dds.GroupDataQosPolicy;
047:        import org.omg.dds.LivelinessQosPolicyKind;
048:        import org.omg.dds.PartitionQosPolicy;
049:        import org.omg.dds.ReliabilityQosPolicyKind;
050:        import org.omg.dds.Subscriber;
051:        import org.omg.dds.SubscriberQos;
052:        import org.omg.dds.TopicDataQosPolicy;
053:        import org.omg.dds.TopicQos;
054:        import org.omg.dds.UserDataQosPolicy;
055:        import org.omg.PortableServer.POA;
056:        import org.omg.PortableServer.POAHelper;
057:
058:        /**
059:         * Simple example : Receive a Foo data (Integer) 
060:         */
061:        public class FooConsumer implements  Runnable {
062:
063:            private String[] args;
064:
065:            /**
066:             * @param args
067:             */
068:            public static void main(String[] args) {
069:
070:                FooConsumer fooConsumer = new FooConsumer();
071:                fooConsumer.setArgs(args);
072:                new Thread(fooConsumer).start();
073:            }
074:
075:            /**
076:             * 
077:             */
078:            public void run() {
079:                try {
080:                    // create and initialize the ORB            
081:
082:                    ORB orb = ORB.init(args, null);
083:                    POA poa = POAHelper.narrow(orb
084:                            .resolve_initial_references("RootPOA"));
085:                    poa.the_POAManager().activate();
086:                    DomainParticipantFactory domainparticipantFactory;
087:                    DomainParticipant domainparticipant;
088:                    Subscriber suscriber;
089:                    FooDataReader foodatareader;
090:                    DataReader datareader;
091:                    org.omg.dds.Topic topic;
092:                    SubscriberQos suscriberqos;
093:                    DataReaderQos datareaderqos;
094:                    org.omg.CORBA.Object objRef = orb
095:                            .resolve_initial_references("NameService");
096:                    // Use NamingContextExt which is part of the Interoperable
097:                    // Naming Service (INS) specification.
098:                    NamingContextExt ncRef = NamingContextExtHelper
099:                            .narrow(objRef);
100:
101:                    // resolve the Object Reference in Naming
102:                    String rname = "DomainParticipantFactory";
103:                    byte tab[] = new byte[1];
104:                    tab[0] = 1;
105:                    org.omg.dds.UserDataQosPolicy UDQP = new UserDataQosPolicy(
106:                            tab);
107:                    DomainParticipantQos DPQOS = new DomainParticipantQos(UDQP,
108:                            new EntityFactoryQosPolicy());
109:                    domainparticipantFactory = DomainParticipantFactoryHelper
110:                            .narrow(ncRef.resolve_str(rname));
111:                    TopicQos tq = new TopicQos(new TopicDataQosPolicy(tab),
112:                            new DurabilityQosPolicy(DurabilityQosPolicyKind
113:                                    .from_int(0), new Duration_t(0, 0)),
114:                            new DeadlineQosPolicy(new Duration_t(0, 0)),
115:                            new org.omg.dds.LatencyBudgetQosPolicy(
116:                                    new Duration_t(0, 0)),
117:                            new org.omg.dds.LivelinessQosPolicy(
118:                                    LivelinessQosPolicyKind.from_int(0),
119:                                    new Duration_t(0, 0)),
120:                            new org.omg.dds.ReliabilityQosPolicy(
121:                                    ReliabilityQosPolicyKind.from_int(0),
122:                                    new Duration_t(0, 0)),
123:                            new org.omg.dds.DestinationOrderQosPolicy(
124:                                    DestinationOrderQosPolicyKind.from_int(0)),
125:                            new org.omg.dds.HistoryQosPolicy(
126:                                    org.omg.dds.HistoryQosPolicyKind
127:                                            .from_int(0), 0),
128:                            new org.omg.dds.ResourceLimitsQosPolicy(0, 0, 0),
129:                            new org.omg.dds.TransportPriorityQosPolicy(0),
130:                            new org.omg.dds.LifespanQosPolicy(new Duration_t(0,
131:                                    0)), new org.omg.dds.OwnershipQosPolicy(
132:                                    org.omg.dds.OwnershipQosPolicyKind
133:                                            .from_int(0)));
134:                    domainparticipant = domainparticipantFactory
135:                            .create_participant(0, DPQOS, null);
136:                    topic = domainparticipant.create_topic("foo",
137:                            "demo.dds.dcps.foosample.Foo", tq, null);
138:                    String st[] = new String[1];
139:                    st[0] = "";
140:                    suscriberqos = new SubscriberQos(
141:                            new org.omg.dds.PresentationQosPolicy(
142:                                    org.omg.dds.PresentationQosPolicyAccessScopeKind
143:                                            .from_int(0), false, false),
144:                            new PartitionQosPolicy(st), new GroupDataQosPolicy(
145:                                    tab),
146:                            new org.omg.dds.EntityFactoryQosPolicy(false));
147:                    suscriber = domainparticipant.create_subscriber(
148:                            suscriberqos, null);
149:                    datareaderqos = new DataReaderQos(new DurabilityQosPolicy(
150:                            DurabilityQosPolicyKind.from_int(0),
151:                            new Duration_t(0, 0)), new DeadlineQosPolicy(
152:                            new Duration_t(0, 0)),
153:                            new org.omg.dds.LatencyBudgetQosPolicy(
154:                                    new Duration_t(0, 0)),
155:                            new org.omg.dds.LivelinessQosPolicy(
156:                                    LivelinessQosPolicyKind.from_int(0),
157:                                    new Duration_t(0, 0)),
158:                            new org.omg.dds.ReliabilityQosPolicy(
159:                                    ReliabilityQosPolicyKind.from_int(0),
160:                                    new Duration_t(0, 0)),
161:                            new org.omg.dds.DestinationOrderQosPolicy(
162:                                    DestinationOrderQosPolicyKind.from_int(0)),
163:                            new org.omg.dds.HistoryQosPolicy(
164:                                    org.omg.dds.HistoryQosPolicyKind
165:                                            .from_int(0), 0),
166:                            new org.omg.dds.ResourceLimitsQosPolicy(0, 0, 0),
167:                            new org.omg.dds.UserDataQosPolicy(tab),
168:                            new org.omg.dds.TimeBasedFilterQosPolicy(
169:                                    new Duration_t(0, 0)),
170:                            new org.omg.dds.ReaderDataLifecycleQosPolicy(
171:                                    new Duration_t(0, 0)));
172:                    datareader = suscriber.create_datareader(topic,
173:                            datareaderqos, null);
174:                    foodatareader = FooDataReaderHelper.narrow(datareader);
175:                    DataReaderListener listener = DataReaderListenerHelper
176:                            .narrow(poa
177:                                    .servant_to_reference(new FooDataReaderListenerImpl()));
178:                    foodatareader.set_listener(listener, 0);
179:                    orb.run();
180:                } catch (Exception e) {
181:                    System.out.println(" ERROR : " + e);
182:                    e.printStackTrace();
183:                }
184:
185:            }
186:
187:            public void end() {
188:                Thread.currentThread().destroy();
189:            }
190:
191:            /**
192:             * @param args The args to set.
193:             */
194:            public void setArgs(String[] args) {
195:                this.args = args;
196:            }
197:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.