120 likes | 272 Views
Simon Gregor Ebner. Paul Scherrer Institute. JCA Extensions. PSI,. 22. August 2014. Contents. Introduction Why JCA-E Architecture Examples Outlook. PSI,. 22. August 2014. Motivation. While using JCA, there are many things that can be done wrong …
E N D
Simon Gregor Ebner Paul Scherrer Institute JCA Extensions PSI, PSI, 22. August 2014
Contents • Introduction • Why JCA-E • Architecture • Examples • Outlook PSI, PSI, 22. August 2014
Motivation • While using JCA, there are many things that can be done wrong … • Need to know details about the Channel Access protocol • Need to open/close channels, set/get values, monitor, … (flushIO/pendIO) • Need to know how to use JCA/CAJ libraries in a single/multithreaded environments • Lots of duplicated code (unless developer creates utility classes) PSI,
JCA-E Benefits • Simplification • Additional layer of abstraction • Developer can think in pure Object Oriented Java • All you have to know is monitored/non monitored • Ease of use • Use of annotations to facilitate development • Provides easy way to hook functions to channel monitors • Facilitates GUI programming while providing events • No need of type conversions due to the use of Java Generics • Optimization • Eliminates duplicated code in Java applications • One can transparently benefit from improvements in the JCA-E library PSI,
JCA-E Architecture Application Application JCA Extensions JCA JCA CAJ CAJ Channel Access Channel Access PSI,
JCA-E Architecture / Components Application Annotations Factory Classes Ca Bean Manager Ca Bean Channel Bean Factory Channel Bean Channel Factory jca.properties Context Factory JCA PSI,
Use Case / Example 1 – Channel Bean • // Retrieve channel bean factory • ChannelBeanFactory factory = ChannelBeanFactory.getFactory(); • // Create channel bean • ChannelBean<String> bean = factory.createChannelBean(String.class, “MYCHANNEL:XYZ”, true); • // Get value • String value = bean.getValue(); • // Set value • bean.setValue(“hello”); • // Wait for a specific value • bean.waitForValue(“world”, 10000); • // Register a function to the monitor • bean.addMonitorListener(this, this.getClass().getMethod(“doIt”)); • // Register an object as PropertyChangeListener • bean.addPropertyChangeListener(listener); • // Destroy bean / close channel • bean.destroy(); PSI,
Use Case / Example 2 – Annotations • // Specify CaBean • public class TestBean{ • @CaChannel(name=“.ACQT”, type=String.class, monitor=true) • private ChannelBean<String> type • @CaChannel(name={“.ONE”, “.TWO”, “.THREE”}, type=Double.class, monitor=true) • private List<ChannelBean<Double>> values; • // Getter and Setters … etc. • } • // Use Ca Bean • CaBeanManager manager = new CaBeanManager(); • TestBean tbean = new TestBean(); • manager.manage(tbean, “PREFIX”); • // Work with Ca Bean • tbean.getType().getValue(); PSI,
Use Case / Example 3 http://people.web.psi.ch/ebner/wordpress PSI,
Outlook • JCA-E need to be reviewed by JCA experts / community • Further improvements like: • Optimizations … • Include alarm states in Channel Bean class • Documentation • … PSI,
Questions • … Questions … • … Suggestions … • … Remarks … • … Feedback … • … Ideas … • simon.ebner@psi.ch PSI,