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