• Like
Java 5 Language PSM for DDS: Final Submission
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Java 5 Language PSM for DDS: Final Submission

  • 1,010 views
Published

This presentation describes the specification "Java 5 Language PSM for DDS." It was given to the MARS Task Force on Tuesday, December 7, 2010. The specification was recommended for adoption later in …

This presentation describes the specification "Java 5 Language PSM for DDS." It was given to the MARS Task Force on Tuesday, December 7, 2010. The specification was recommended for adoption later in the week. The specification improves code portability, usability, and performance for applications that use Data Distribution Service (DDS) technology. See also http://code.google.com/p/datadistrib4j/.

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,010
On SlideShare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
17
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Java 5 PSM for DDS: Revised Submission 2 MARS – Santa Clara, CA – December 2010 Presenter: Rick Warren, RTI Submitting POCs:  Rick Warren, RTI: rick.warren@rti.com  Angelo Corsaro, PrismTech: angelo.corsaro@prismtech.com document number: mars/2010-12-22Tuesday, December 7, 2010 1
  • 2. Agenda Copyright © 2010 RTI - All rights Reserved 2Tuesday, December 7, 2010 2
  • 3. Agenda Specification Overview  Goals and Principles  Process Better Living Through Source Code  License  Bootstrapping  Publishing Data  Reading Data  Getting and Setting QoS  Java Type Representation Copyright © 2010 RTI - All rights Reserved 2Tuesday, December 7, 2010 2
  • 4. Goals & Design Principles Copyright © 2010 RTI - All rights Reserved 3Tuesday, December 7, 2010 3
  • 5. Goals & Design Principles Improve user experience  standardNamingConvention  Standard containers (e.g. java.util.List)  Standard enumerations  Error conditions reported with exceptions  Serializable, Cloneable value types  Simplified method overloads Copyright © 2010 RTI - All rights Reserved 3Tuesday, December 7, 2010 3
  • 6. Goals & Design Principles Improve user experience  standardNamingConvention  Standard containers (e.g. java.util.List)  Standard enumerations  Error conditions reported with exceptions  Serializable, Cloneable value types  Simplified method overloads Improve type safety  Generics Copyright © 2010 RTI - All rights Reserved 3Tuesday, December 7, 2010 3
  • 7. Goals & Design Principles Improve user experience  standardNamingConvention  Standard containers (e.g. java.util.List)  Standard enumerations  Error conditions reported with exceptions  Serializable, Cloneable value types  Simplified method overloads Improve type safety  Generics Improve performance  Loanable memory  No critical-path memory allocation (unlike IDL PSM) Copyright © 2010 RTI - All rights Reserved 3Tuesday, December 7, 2010 3
  • 8. Goals & Design Principles Improve user experience  standardNamingConvention  Standard containers (e.g. java.util.List)  Standard enumerations  Error conditions reported with exceptions  Serializable, Cloneable value types  Simplified method overloads Improve type safety  Generics Improve performance  Loanable memory  No critical-path memory allocation (unlike IDL PSM) Improve portability  Build apps against standard interfaces; decide at run time which impl to use  Host multiple implementations (or versions) within same JVM  Dynamic loading and unloading  Play nicely with containers, e.g. Java EE and OSGi  Don’t require non-constant static state Copyright © 2010 RTI - All rights Reserved 3Tuesday, December 7, 2010 3
  • 9. State of the Proposal Copyright © 2010 RTI - All rights Reserved 4Tuesday, December 7, 2010 4
  • 10. State of the Proposal Ready for implementation  All mandatory requirements satisfied  User vetting process begun  Private conversations with Java power users  Publicly available code repository at http:// code.google.com/p/datadistrib4j/  So far, reviewers enthusiastic Positive AB review  Doug Tolbert: content  Sridhar Iyengar: license Will ask for vote to recommend adoption this week Copyright © 2010 RTI - All rights Reserved 4Tuesday, December 7, 2010 4
  • 11. Source Code License & Copyright Copyright © 2010 RTI - All rights Reserved 5Tuesday, December 7, 2010 5
  • 12. Source Code License & Copyright Principles  Every vendor, user will receive code from OMG  Need to know their rights  Need free access to spec, according to OMG principles  OMG must not dictate vendors’ business models  Open source, shared source, closed source must be allowed  ...under variety of licenses Copyright © 2010 RTI - All rights Reserved 5Tuesday, December 7, 2010 5
  • 13. Source Code License & Copyright Principles  Every vendor, user will receive code from OMG  Need to know their rights  Need free access to spec, according to OMG principles  OMG must not dictate vendors’ business models  Open source, shared source, closed source must be allowed  ...under variety of licenses License  Apache 2.0 (permissive but GPL-compatible)  Use is royalty-free, unlike BSD (proposed last time)  Requires acknowledgement of license, copyright holders from redistributors Copyright © 2010 RTI - All rights Reserved 5Tuesday, December 7, 2010 5
  • 14. Source Code License & Copyright Principles  Every vendor, user will receive code from OMG  Need to know their rights  Need free access to spec, according to OMG principles  OMG must not dictate vendors’ business models  Open source, shared source, closed source must be allowed  ...under variety of licenses License  Apache 2.0 (permissive but GPL-compatible)  Use is royalty-free, unlike BSD (proposed last time)  Requires acknowledgement of license, copyright holders from redistributors Copyright  OMG, RTI, PrismTech hold copyright  i.e. OMG + submitters, per OMG conventions Copyright © 2010 RTI - All rights Reserved 5Tuesday, December 7, 2010 5
  • 15. Bootstrapping a DDS Java Application Copyright © 2010 RTI - All rights Reserved 6Tuesday, December 7, 2010 6
  • 16. Bootstrapping a DDS Java Application Design pattern: API is abstract, stateless  Interfaces when possible; stateless abstract classes when not  Doesn’t dictate state or other implementation to vendors Design pattern: multiple DDS’s coexist in JVM  i.e. Even “singletons” are not Challenge: How do you create the first object? Copyright © 2010 RTI - All rights Reserved 6Tuesday, December 7, 2010 6
  • 17. Bootstrapping a DDS Java Application Design pattern: API is abstract, stateless  Interfaces when possible; stateless abstract classes when not  Doesn’t dictate state or other implementation to vendors Design pattern: multiple DDS’s coexist in JVM  i.e. Even “singletons” are not Challenge: How do you create the first object? Solution: Bootstrap class  Represents DDS implementation  Step 1: Bootstrap.createInstance(/*system property*/)  Singletons: DomainParticipantFactory.getInstance(myBstrap)  If no PIM factory: Duration.newDuration(myBstrap)  Get back there from anywhere: myDuration.getBootstrap()  * Note: API change since previous submission Copyright © 2010 RTI - All rights Reserved 6Tuesday, December 7, 2010 6
  • 18. Example: Publishing Data import org.omg.dds.domain.*; import …; // Join domain: DomainParticipantFactory factory = DomainParticipantFactory.getInstance( Bootstrap.createInstance()); DomainParticipant dp = factory.createParticipant(); // Create topic with implicit type registration: Topic<Greeting> tp = dp.createTopic( "My Topic", Greeting.class); // Create publishing entities: Publisher pub = dp.createPublisher(); DataWriter<Greeting> dw = pub.createDataWriter(tp); // Publish data: try { dw.write(new Greeting("Hello, World")); } catch (TimeoutException tx) { tx.printStackTrace(); } // Dispose of all entities: dp.close(); Copyright © 2010 RTI - All rights Reserved 7Tuesday, December 7, 2010 7
  • 19. Example: Publishing Data import org.omg.dds.domain.*; import …; // Join domain: DomainParticipantFactory factory = DomainParticipantFactory.getInstance( // Explicit TypeSupport w/ default name: Bootstrap.createInstance()); Topic<Greeting> tp = dp.createTopic( DomainParticipant dp = "My Topic", factory.createParticipant(); TypeSupport.newTypeSupport( } Greeting.class, // Create topic with implicit type registration: dp.getBootstrap())); Topic<Greeting> tp = dp.createTopic( "My Topic", // Explicit TypeSupport w/ custom name: Greeting.class); Topic<Greeting> tp = dp.createTopic( // Create publishing entities: or "My Topic", TypeSupport.newTypeSupport( Publisher pub = dp.createPublisher(); Greeting.class, DataWriter<Greeting> dw = "MyType", pub.createDataWriter(tp); dp.getBootstrap())); // Publish data: try { dw.write(new Greeting("Hello, World")); } catch (TimeoutException tx) { tx.printStackTrace(); } // Dispose of all entities: dp.close(); Copyright © 2010 RTI - All rights Reserved 7Tuesday, December 7, 2010 7
  • 20. Example: Reading Data ... // Create subscribing entities: Subscriber sub = dp.createSubscriber(); DataReader<Greeting> dr = sub.createDataReader( topic, sub.getDefaultDataReaderQos(), listener, null /* all status changes */); ... class MyListener extends DataReaderAdapter<Greeting> { @Override public void onDataAvailable(DataAvailableStatus<Greeting> status) { DataReader<Greeting> dr = status.getSource(); Sample.Iterator<Greeting> it = dr.take(/* loan, or pass List to copy */); try { while (it.hasNext()) { Sample<Greeting> smp = it.next(); // SampleInfo stuff is built into Sample: InstanceHandle inst = smp.getInstanceHandle(); // Data accessible from Sample; null if invalid: Greeting dt = smp.getData(); // ... } } finally { it.returnLoan(); } } } Copyright © 2010 RTI - All rights Reserved 8Tuesday, December 7, 2010 8
  • 21. Example: Reading Data ... // Create subscribing entities: Subscriber sub = dp.createSubscriber(); DataReader<Greeting> dr = sub.createDataReader( topic, “Listener” is interface: sub.getDefaultDataReaderQos(), listener, implement all. null /* all status changes */); “Adapter” is no-op class: override what ... you want. class MyListener extends DataReaderAdapter<Greeting> { @Override public void onDataAvailable(DataAvailableStatus<Greeting> status) { DataReader<Greeting> dr = status.getSource(); Sample.Iterator<Greeting> it = dr.take(/* loan, or pass List to copy */); try { while (it.hasNext()) { Sample<Greeting> smp = it.next(); // SampleInfo stuff is built into Sample: InstanceHandle inst = smp.getInstanceHandle(); // Data accessible from Sample; null if invalid: Greeting dt = smp.getData(); // ... } } finally { it.returnLoan(); } } } Copyright © 2010 RTI - All rights Reserved 8Tuesday, December 7, 2010 8
  • 22. Example: Reading Data ... // Create subscribing entities: Subscriber sub = dp.createSubscriber(); DataReader<Greeting> dr = sub.createDataReader( topic, “Listener” is interface: sub.getDefaultDataReaderQos(), listener, implement all. null /* all status changes */); “Adapter” is no-op class: override what ... you want. class MyListener extends DataReaderAdapter<Greeting> { @Override Statuses extend public void onDataAvailable(DataAvailableStatus<Greeting> status) { java.util.EventObject DataReader<Greeting> dr = status.getSource(); Sample.Iterator<Greeting> it = dr.take(/* loan, or pass List to copy */); try { while (it.hasNext()) { Sample<Greeting> smp = it.next(); // SampleInfo stuff is built into Sample: InstanceHandle inst = smp.getInstanceHandle(); // Data accessible from Sample; null if invalid: Greeting dt = smp.getData(); // ... } } finally { it.returnLoan(); } } } Copyright © 2010 RTI - All rights Reserved 8Tuesday, December 7, 2010 8
  • 23. Example: Get QoS // QoS is a bean-style property of the entity: DataReaderQos qos = myReader.getQos(); // Get specific policy: ReliabilityQosPolicy.Kind rKind = qos.getReliability().getKind(); // EntityQos is a Map from QosPolicy.Id to QosPolicy: for (QosPolicy policy : qos.values()) { // Iterate over all policies, standard or not. // ... } Copyright © 2010 RTI - All rights Reserved 9Tuesday, December 7, 2010 9
  • 24. Example: Set QoS // Call modify() to get a mutable copy of the QoS: ModifiableDataReaderQos qos = myReader.getQos().modify(); // Modifiable version provides setters: qos.getReliability().setKind( ReliabilityQosPolicy.Kind.RELIABLE); // QoS setter accepts modifiable or unmodifiable objects: myReader.setQos(qos); myReader.setQos(myOtherReader.getQos()); Copyright © 2010 RTI - All rights Reserved 10Tuesday, December 7, 2010 10
  • 25. Why the modifiable/unmodifiable pattern? Copyright © 2010 RTI - All rights Reserved 11Tuesday, December 7, 2010 11
  • 26. Why the modifiable/unmodifiable pattern? Easy to use correctly  qos = entity.getQos(); Hard to get wrong  qos = new DataReaderQos(); // ERROR! // What state does ‘qos’ have before the next line? entity.getQos(qos);  What does this mean: myDataReader.getQos().setReliability(…) Copyright © 2010 RTI - All rights Reserved 11Tuesday, December 7, 2010 11
  • 27. Why the modifiable/unmodifiable pattern? Easy to use correctly  qos = entity.getQos(); Hard to get wrong  qos = new DataReaderQos(); // ERROR! // What state does ‘qos’ have before the next line? entity.getQos(qos);  What does this mean: myDataReader.getQos().setReliability(…) Fast to get  Just return a pointer  No allocation or deep copy needed Good for concurrency  Share immutable objects freely without locking Copyright © 2010 RTI - All rights Reserved 11Tuesday, December 7, 2010 11
  • 28. Java Type Representation Copyright © 2010 RTI - All rights Reserved 12Tuesday, December 7, 2010 12
  • 29. Java Type Representation Goal: Write the following code: public class MyPojo /*extends/implements…*/ { private int foo; private Bar[] baz; public void doStuff() { … } } … Topic<MyPojo> t = dp.createTopic( "My Topic", MyPojo.class); Copyright © 2010 RTI - All rights Reserved 12Tuesday, December 7, 2010 12
  • 30. Java Type Representation Copyright © 2010 RTI - All rights Reserved 13Tuesday, December 7, 2010 13
  • 31. Java Type Representation Leverage the knowledge of Java developers Leverage the code they already have Copyright © 2010 RTI - All rights Reserved 13Tuesday, December 7, 2010 13
  • 32. Java Type Representation Leverage the knowledge of Java developers Leverage the code they already have Observations:  JRE already provides type definition constructs  Primitive types, strings, lists (sequences), classes (structures), enumerations, annotations  Types to be sent over network already indicate that  …by implementing java.io.Serializable  …including which fields should not be sent  …with the transient keyword Copyright © 2010 RTI - All rights Reserved 13Tuesday, December 7, 2010 13
  • 33. Java Type Representation Copyright © 2010 RTI - All rights Reserved 14Tuesday, December 7, 2010 14
  • 34. Java Type Representation Approach: Define DDS type on the fly based on run-time introspection of Java class Copyright © 2010 RTI - All rights Reserved 14Tuesday, December 7, 2010 14
  • 35. Java Type Representation Approach: Define DDS type on the fly based on run-time introspection of Java class Convenience feature for non-real-time Java systems  Reflection slower than compiled generated code  If other languages are used, type definitions must be “duplicated” Does not:  ...replace, modify other Language Bindings  ...impact serialization, therefore is interoperable Copyright © 2010 RTI - All rights Reserved 14Tuesday, December 7, 2010 14
  • 36. Java Type Representation: What It Does Copyright © 2010 RTI - All rights Reserved 15Tuesday, December 7, 2010 15
  • 37. Java Type Representation: What It Does Defines mappings JRE concepts  DDS concepts  int  Int32 (IDL long)  double  Float64 (IDL double)  java.util.List  Sequence  Serializable class  Structure Allows customization to support non-Java DDS concepts  e.g. unsigned primitives, narrow vs. wide strings, unions  Mechanism: @SerializeAs and other annotations Copyright © 2010 RTI - All rights Reserved 15Tuesday, December 7, 2010 15
  • 38. Java Type Representation: Example Java IDL Copyright © 2010 RTI - All rights Reserved 16Tuesday, December 7, 2010 16
  • 39. Java Type Representation: Example Java IDL package com.acme; module com { module acme { Copyright © 2010 RTI - All rights Reserved 16Tuesday, December 7, 2010 16
  • 40. Java Type Representation: Example Java IDL package com.acme; module com { module acme { class Foo implements Serializable { struct Foo { Copyright © 2010 RTI - All rights Reserved 16Tuesday, December 7, 2010 16
  • 41. Java Type Representation: Example Java IDL package com.acme; module com { module acme { class Foo implements Serializable { struct Foo { @Key int theInt; @Key long theInt; Copyright © 2010 RTI - All rights Reserved 16Tuesday, December 7, 2010 16
  • 42. Java Type Representation: Example Java IDL package com.acme; module com { module acme { class Foo implements Serializable { struct Foo { @Key int theInt; @Key long theInt; transient float theFlt; Copyright © 2010 RTI - All rights Reserved 16Tuesday, December 7, 2010 16
  • 43. Java Type Representation: Example Java IDL package com.acme; module com { module acme { class Foo implements Serializable { struct Foo { @Key int theInt; @Key long theInt; transient float theFlt; String theStr; string theStr; Copyright © 2010 RTI - All rights Reserved 16Tuesday, December 7, 2010 16
  • 44. Java Type Representation: Example Java IDL package com.acme; module com { module acme { class Foo implements Serializable { struct Foo { @Key int theInt; @Key long theInt; transient float theFlt; String theStr; string theStr; @SerializeAs(UINT_64) BigInteger theUInt; unsigned long theUInt; Copyright © 2010 RTI - All rights Reserved 16Tuesday, December 7, 2010 16
  • 45. Java Type Representation: Example Java IDL package com.acme; module com { module acme { class Foo implements Serializable { struct Foo { @Key int theInt; @Key long theInt; transient float theFlt; String theStr; string theStr; @SerializeAs(UINT_64) BigInteger theUInt; unsigned long theUInt; String[] theArr; sequence<string> theArr; } }; }} Copyright © 2010 RTI - All rights Reserved 16Tuesday, December 7, 2010 16
  • 46. Summary Proposed specification is complete  Provides (the first) run-time-portable API for DDS  Improves performance over IDL-based API  Improves type safety over IDL-based API  Simplifies type handling  Satisfies all mandatory requirements We will ask for your vote on Thursday  Vote to vote  Vote to recommend adoption Copyright © 2010 RTI - All rights Reserved 17Tuesday, December 7, 2010 17
  • 47. Q&A 18Tuesday, December 7, 2010 18
  • 48. Appendix: Changes Since Cambridge Changed license from BSD to Apache Simplified object creation Modified package organization  Renamed Context to Bootstrap to avoid confusion with JNDI  Modifiable value type variants in parallel packages to simplify package lists  Reduced number of entity and condition factory method overloads  Moved contents of org.omg.dds.type.annotation to org.omg.dds.type  Pass Bootstrap as argument to factories; don’t make it the factory for everything (required changing some  Consolidated statuses in org.omg.dds.core.status interfaces into abstract classes) package to match C++ proposal  Moved built-in topic data interfaces to Improved DDS-XTypes APIs, aligned with FTF org.omg.dds.topic package to match C++  Simplified Dynamic Language Binding by removing proposal unneeded methods All new unchecked exceptions now  Improved overloads in built-in type writers extend common base class  Fixed method names in TypeLibraryElement “union” Improvements to value types Added JavaDoc  All setters return enclosing object to facilitate  Added JavaDoc building to packaging script method chaining  Included some documentation from DDS specification  Improvements to Time and Duration (not done yet)  Leverage TimeUnit Made some “enumerations” more extensible  Address Y2038 problem by vendors  Renamed Qos to EntityQos to match C++ proposal  Replaced status kind mask with collection of status classes  Made QosPolicy.Id an abstract class, not an enumeration Copyright © 2010 RTI - All rights Reserved 19Tuesday, December 7, 2010 19