Your SlideShare is downloading. ×
Java 5 PSM for DDS: Initial Submission (out of date)
Java 5 PSM for DDS: Initial Submission (out of date)
Java 5 PSM for DDS: Initial Submission (out of date)
Java 5 PSM for DDS: Initial Submission (out of date)
Java 5 PSM for DDS: Initial Submission (out of date)
Java 5 PSM for DDS: Initial Submission (out of date)
Java 5 PSM for DDS: Initial Submission (out of date)
Java 5 PSM for DDS: Initial Submission (out of date)
Java 5 PSM for DDS: Initial Submission (out of date)
Java 5 PSM for DDS: Initial Submission (out of date)
Java 5 PSM for DDS: Initial Submission (out of date)
Java 5 PSM for DDS: Initial Submission (out of date)
Java 5 PSM for DDS: Initial Submission (out of date)
Java 5 PSM for DDS: Initial Submission (out of date)
Java 5 PSM for DDS: Initial Submission (out of date)
Java 5 PSM for DDS: Initial Submission (out of date)
Java 5 PSM for DDS: Initial Submission (out of date)
Java 5 PSM for DDS: Initial Submission (out of date)
Java 5 PSM for DDS: Initial Submission (out of date)
Java 5 PSM for DDS: Initial Submission (out of date)
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Java 5 PSM for DDS: Initial Submission (out of date)

309

Published on

Presentation to the OMG's MARS Task Force in June, 2010 on proposed improvements to the Java API to the OMG's Data Distribution Service specification (DDS).

Presentation to the OMG's MARS Task Force in June, 2010 on proposed improvements to the Java API to the OMG's Data Distribution Service specification (DDS).

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
309
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
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
  • Benefits of “close” instead of factory method:
    Familiar from java.io, javax.jms
    Can’t get it wrong by using wrong factory
  • Important to keep everything as interface or stateless abstract class:
    Don’t constrain implementations
    Don’t risk bugs
  • Context allows multiple DDS implementations (including multiple versions of the same impl.) to coexist.

    Also allows implementations to be transparently unloaded when no longer used.
  • If you don’t care about the parameters, just use wildcard—less hassle than in C++.

    If you do care, you can bind them to preserve type safety.
  • First, show how it works.
    Then, show why it works that way.
  • Transcript

    • 1. Java 5 PSM for DDS: Initial Submission MARS – Minneapolis, MN – June 2010 Presenter: Rick Warren, RTI Submitting POCs:  Rick Warren, RTI: rick.warren@rti.com  Angelo Corsaro, PrismTech: angelo.corsaro@prismtech.com document number: mars/10-06-09
    • 2. Agenda Specification Overview Specification Highlights  Bootstrapping  Generics  Reading data  QoS TODO for the Revised Submission Copyright © 2010 RTI - All rights Reserved 2
    • 3. Goal Improve user experience  standardNamingConvention  Standard containers (e.g. java.util.List)  Standard enumerations  Serializable value types Improve type safety  Generics Improve performance  Loanable memory  No critical-path memory allocation Copyright © 2010 RTI - All rights Reserved 3
    • 4. State of the Proposal Process moving quickly and efficiently  Submitters have already joined  Most mandatory requirements already satisfied  User vetting process already begun  Private conversations with Java power users  Publicly available code repository at http://code.google.com/p/datadistrib4j/  So far, reviewers enthusiastic Still to go:  DDS-XTypes APIs  Java Type Representation: avoid code generation  JavaDoc? Copyright © 2010 RTI - All rights Reserved 4
    • 5. Design Principles Ease of Use  Align with standard Java technologies and conventions  Conventional camelCase names  Error conditions reported with exceptions  Value types are cloneable, serializable  Provide simplified method overloads Performance  Avoid critical-path memory allocation, unlike IDL PSM Runtime Portability  Build apps against standard interfaces; decide at runtime which implementation to use  Host multiple implementations (or versions) within same JVM Dynamic Loading and Unloading  Play nicely with containers, e.g. Java EE or OSGi  Don’t require non-constant static state Copyright © 2010 RTI - All rights Reserved 5
    • 6. Hello, World import org.omg.dds.*; Topic<Foo> t = …; DataWriter<Foo> dw = myPub.createDataWriter(t); Foo data = …; dw.write(data); dw.close(); DataReader<Foo> dr = mySub.createDataReader(t); Sample.Iterator<Foo> it = dr.take(); Foo data2 = it.next(). getData(); it.returnLoan(); dr.close();  OMG package  Typical naming convention  Overloaded methods  Generics for type safety  Close like JMS, I/O stream  Standard collections Copyright © 2010 RTI - All rights Reserved 6
    • 7. Highlight: Bootstrapping Design pattern: Everything is an interface (if possible) or abstract class (if not). Challenge: How do you create the first object? JMS answer: JNDI import javax.naming.*; import javax.jms.*; Context ctx = new InitialContext(); Topic t = (Topic) ctx.lookup("My Topic"); Copyright © 2010 RTI - All rights Reserved 7
    • 8. Highlight: Bootstrapping DDS complications with lookup:  Lots of “top-level” objects  DomainParticipantFactory  WaitSet, GuardCondition  Statuses  Time, duration  …  DDS is more dynamic  Create topics on the fly  WaitSet is not logically an “administered object” Copyright © 2010 RTI - All rights Reserved 8
    • 9. Highlight: Bootstrapping Solution: JNDI-like DDS Context Create reflectively based on system property:  org.omg.dds.core.Context ctx = Context.getInstance( /* "org.omg.dds.serviceClassName" */); Create everything else from here:  DomainParticipantFactory dpf = ctx.getParticipantFactory();  Duration duration = ctx.createDuration(); Get back here from anywhere:  Context ctx = duration.getContext(); Copyright © 2010 RTI - All rights Reserved 9
    • 10. Highlight: Generics Design pattern: Use generic types wherever they help polymorphic type safety Obvious: DataWriter<Foo> dw = …; Non-obvious: interface Entity<SELF extends Entity, LISTENER extends EventListener, QOS extends Qos> { LISTENER getListener(); QOS getQos(); StatusCondition<SELF> getStatusCondition(); } Copyright © 2010 RTI - All rights Reserved 10
    • 11. Highlight: Generics Example type: interface DataWriter<TYPE> extends Entity<DataWriter<TYPE>, DataWriterListener<TYPE>, DataWriterQos> Example uses: void closeTheEntity(Entity<?, ?, ?> e) { e.close(); } <LS> void setTheListener(Entity<?, LS, ?> e, LS ln) { e.setListener(ln); } Copyright © 2010 RTI - All rights Reserved 11
    • 12. Highlight: Reading Data Take a loan: Sample.Iterator<Foo> it = reader.take(); try { while (it.hasNext()) { Sample<Foo> spl = it.next(); InstanceHandle hdl = spl.getInstanceHandle(); Foo data = spl.getData(); if (data != null) { // ... } } } finally { it.returnLoan(); } Copyright © 2010 RTI - All rights Reserved 12
    • 13. Highlight: Reading Data Take a copy: List<Sample<Foo>> dataList = new ArrayList<Sample<Foo>>(); reader.take(dataList); for (Iterator<Sample<Foo>> it = dataList.iterator(); it.hasNext();) { Sample<Foo> spl = it.next(); InstanceHandle hdl = spl.getInstanceHandle(); Foo data = spl.getData(); if (data != null) { // ... } } Copyright © 2010 RTI - All rights Reserved 13
    • 14. Highlight: QoS Typical Bean property:  Qos getQos();  void setQos(Qos q); By default, QoS are immutable  Getters: myQos.getReliability();  No setters: myQos.setReliability(…); QoS are also Maps:  java.util.Map<QosPolicy.Id, QosPolicy> map = myQos;  ReliabilityQosPolicy p = (ReliabilityQosPolicy) map.get( QosPolicy.Id.RELIABILITY); Modify explicitly:  ModifiableQos mod = myQos.modify(); // new obj  mod.setReliability(myReliability);  myEntity.setQos(mod); // mod interface extends unmod Copyright © 2010 RTI - All rights Reserved 14
    • 15. Highlight: QoS Why the modifiable/unmodifiable pattern?  Easy to use: Bean property  Conventional, intuitive  Works as expected with introspection  Good for concurrency: immutable object freely shared  “Get” is fast: just return pointer  No memory allocation needed  No deep copy needed Cost: “Set” must allocate new object (for next “get”)  …but “set” is slow anyway:  Deeply copies QoS  Sends update on built-in topic  …and setQos is not typically a critical-path operation  RTSJ users must be aware Copyright © 2010 RTI - All rights Reserved 15
    • 16. Highlight: QoS Alternative (discarded) design with modifiable QoS (à la IDL PSM): DataWriterQos qos = ctx.createDataWriterQos();  Requires additional factory methods ReliabilityQosPolicy.Kind k = qos.getReliability().getKind();  Value of “k” is undefined myWriter.getQos(qos);  Unintuitive signature qos.getReliability().setKind(…);  Object “qos” can’t be safely stored, shared Copyright © 2010 RTI - All rights Reserved 16
    • 17. Revised Submission TODO New DDS-XTypes APIs  Built-in types: String, Bytes, KeyedString, KeyedBytes  Dynamic Language Binding: DynamicType, DynamicData  TypeObject Type Representation  New QoS policies Java Type Representation @DdsType interface Employee { @Key int getEmployeeIdNumber(); } Copyright © 2010 RTI - All rights Reserved 17
    • 18. Revised Submission TODO Copy specification into JavaDoc?  Friendly for IDE users  myWriter.setQos| Examples (non-normative)  Application code example  No-op reference implementation Further community review Copyright © 2010 RTI - All rights Reserved 18 void setQos(DataWriterQos q) Set the QoS of this DataWriter. The result of subsequent calls to getQos will be equal to the value set by this method.
    • 19. Summary DDS will have a first-class Java API.  That looks and behaves like a typical Java API.  That performs well.  Soon. Copyright © 2010 RTI - All rights Reserved 19
    • 20. Q & A Copyright © 2010 RTI - All rights Reserved 20

    ×