1 / 8

Mapping AR “Entry” to a Java Bean

Mapping AR “Entry” to a Java Bean. Avishay Balderman January 2009. Background. AR data is represented by an object named “Entry” which is a Map of field ID to the field value. Map<Integer,Value>

dirk
Download Presentation

Mapping AR “Entry” to a Java Bean

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Mapping AR “Entry” to a Java Bean Avishay Balderman January 2009

  2. Background • AR data is represented by an object named “Entry” which is a Map of field ID to the field value. Map<Integer,Value> • When a Java developer works with the AR Java API he has to deal with entries on one hand and Java Beans on the other hand. (Unless he decide to work with the Entry all the way…)

  3. The problem • The developer is writing a code which: • Translate an Entry to Java Bean • Translate a Java Bean to an Entry • This code basically looks like this: “Copy an attribute from the entry and populate the corresponding Java Bean attribute”. Again and again…

  4. The solution [1] • The solution I implemented is based on 2 core Java technologies: Annotations and Reflection. All the developer has to do is to annotate the Java Bean attributes like this: public class MyJavaBean { @ARField(1233435090) // the field id of ‘name’ in AR private String name; // more attributes + getters / setters here }

  5. The solution [2] • When a record is fetched from AR all the developer needs to do is: // get the Entry from AR Entry entry = getAnEntryFromAR(); // call the Mapper and get the bean you need MyJavaBean myBean = Mapper.entry2bean(MyJavaBean.class,entry);

  6. Summary • The mapping infrastructure can save development and maintenance time. • Code is cleaner, easy to read and less cumbersome that way and so it’s less error prone • All the developer needs to do is to write a regular Java Bean and annotate it. • Code was written and is used in Discovery 7.6 (working against the product catalog) • Another team in Tel Aviv is interested in using it.

  7. Future directions • I think this code should not stay at the discovery scope. Every developer (in BMC and customers as well) who works with AR Java API can benefit from it. It should be moved to one of the following: • AR Java API • Open source project The first option is the best in my eyes but the second one is not that bad as well.

  8. Detailed Example // The Java Bean public class MyJavaBean { @ARField(1233435090) private String name; @ARField(32302303) private Status status; // Status is a Java enum @ARField(12303732) private Integer counter; } // Application flow Entry entry = getEntryFromAR(); MyJavaBean bean = Mapper.Entry2Bean(MyJavaBean.class,entry); // work with the Java bean bean.setSatus(Status.GREAT); // Update AR with your changes Entry updatedEntry = Mapper.Bean2Entry(bean); pushEntryToAR(updatedEntry);

More Related