Blueprint Advanced Features –Lin Sun –Apache Aries and Geronimo committer and PMC member –OSGi Enterprise Expert Group (EEG) member –Software Engineer.

Slides:



Advertisements
Similar presentations
AspectWerkz 2 - and the road to AspectJ 5 Jonas Bonér Senior Software Engineer BEA Systems.
Advertisements

21 Copyright © 2005, Oracle. All rights reserved. Oracle Application Server 10g Transaction Support.
Introduce OSGi BlueDavy
Web Development with Karsten Schulz Terp-Nielsen Master Principal Sales Consultant Oracle Denmark.
Apache Aries An Open Source project for Enterprise OSGi Applications.
Component Patterns – Architecture and Applications with EJB copyright © 2001, MATHEMA AG Component Patterns Architecture and Applications with EJB JavaForum.
Why OSGi matters for Enterprise Java Infrastructures
JBoss Seam: Contextual Components Jason Bechtel
OSGi: Open Services Gateway Initiative Richard Chapman 5 Sept
Enterprise Applications & Java/J2EE Technologies Dr. Douglas C. Schmidt Professor of EECS.
Struts Basics SSE USTC Qing Ding. Agenda What is and Why Struts? Struts architecture – Controller: Focus of this presentation – Model – View Struts tag.
Version # Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Sponsored by the U.S. Department of Defense © 1999 by Carnegie.
Introduction to EJB INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J
Apache Aries An Open Source project for Enterprise OSGi Applications OSGi Tooling Demo for EclipseDemoCamp.
Struts 2.0 an Overview ( )
CSE446 S OFTWARE Q UALITY M ANAGEMENT Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi Orhan Başar Evren.
OSGi.
Spring Overview, Application demo -Midhila Paineni 09/23/2011 Spring Overview, Application demo9/8/20151.
INTRODUCING SCA Byungwook Cho Nov.2007.
Agenda What is Hibernate Spring Integration Questions Overview
Parsley Introduction Kui Huang Oct. 13, Topics Background Dependency Injection Object Lifecycle Message Bus Sample FW Extensions.
Message-Driven Beans and EJB Security Lesson 4B / Slide 1 of 37 J2EE Server Components Objectives In this lesson, you will learn about: Identify features.
© 2006 IBM Corporation IBM WebSphere Portlet Factory Architecture.
Spring Framework. Spring Overview Spring is an open source layered Java/J2EE application framework Created by Rod Johnson Based on book “Expert one-on-one.
Deployment with Karaf and ACE
Introduction to Web Dimitar Nenchev Ivan Nakov
Slide 1 Extending Tuscany Raymond Feng Apache Tuscany committer.
Introduction to Exception Handling and Defensive Programming.
Random Logic l Forum.NET l Web Services Enhancements for Microsoft.NET (WSE) Forum.NET ● October 4th, 2006.
Shannon Hastings Multiscale Computing Laboratory Department of Biomedical Informatics.
Enterprise JavaBeans Understanding EJB Components Version 0.1 Kamal Wickramanayake
Transaction Services in Component Frameworks Bruce Kessler Comp250CBS March 2, 2004.
“This presentation is for informational purposes only and may not be incorporated into a contract or agreement.”
Tuscany: a SOA framework Jeffrey Guo Accelrys, Inc.
1 Transactions Michael Brockway Sajjad Shami CG0165: Advanced Applications Development in Java Northumbria University School of Computing, Engineering.
INTEGRATION OF BACKBONE.JS WITH SPRING 3.1. Agenda New Features and Enhancements in Spring 3.1 What is Backbone.js and why I should use it Spring 3.1.
Application Ontology Manager for Hydra IST Ján Hreňo Martin Sarnovský Peter Kostelník TU Košice.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Essentials Getting started.
Slide 1 Extending Tuscany Raymond Feng Apache Tuscany committer.
Spring and DWR Frameworks for Rich Web Enterprise Application Thomas Wiradikusuma Presentation to the 20 th.
Getting Started with the Open Services Gateway Initiative (OSGi) CNT 5517 Dr. Sumi Helal, Ph.D. Professor Computer & Information Science & Engineering.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Data Access with Spring.
JPA Transactions
Component Patterns – Architecture and Applications with EJB copyright © 2001, MATHEMA AG Component Patterns Architecture and Applications with EJB Markus.
v110912Java Persistence: EntityManager2 Overview Earlier versions of EJB Specification defined the persistence layer –javax.ejb.EntityBean Java EE 5 moved.
Introduction to business component technologies. Component definitions Szyperski: A software component is a unit of composition with contractually specified.
红杉树(中国)信息技术有限公司公司 地址:杭州市天目山路 176 号西湖数源软件园 11 号楼 3 层 电话: (86) Transaction & JAVA Fondy Wang 12/7/07.
Lecture VI: SOAP-based Web Service CS 4593 Cloud-Oriented Big Data and Software Engineering.
IS-907 Java EE Introduction to JPA. Java Persistence API A framework for using relational databases in Java programs mapping between tables and classes,
Enterprise Java v121030Java EE Transactions1. Enterprise Java v121030Java EE Transactions2 Goals Understand the basic concepts behind a transaction Be.
EJB Enterprise Java Beans JAVA Enterprise Edition
1 Entity Callbacks and Listeners When you execute EntityManager methods like persist( ), merge( ), remove( ), and find( ), or when you execute EJB QL queries,
Net-centric Computing Web Services. Lecture Outline  What is Web Service  Web Service Architecture  Creating and using Java Web Services  Apache Axis.
Intro to JavaServer Faces Mimi Opkins CECS 493 Fall 2016.
Apache Aries An Open Source project for Enterprise OSGi Applications.
Joe Bohn Apache Aries and IBM Original slides created by Graham Charters for OSGi DevCon US 2010, March 22, 2010 with minor updates by Joe Bohn for BarCampRDU.
Graham Charters Apache Aries and IBM Apache Aries An Open Source project for Enterprise OSGi Applications.
Overall Architecture and Component Model
CS520 Web Programming Spring – Inversion of Control
JAsCo an Aspect-Oriented approach tailored for
Introduction to Web Services
Could Jiro™ Extend the Jini™ Pattern Lanuguage?
Component Technology Bina Ramamurthy 2/25/2019 B.Ramamurthy.
Developing and testing enterprise Java applications
J2EE Lecture 13: JMS and WebSocket
Objectives In this lesson, you will learn about:
Presentation transcript:

Blueprint Advanced Features –Lin Sun –Apache Aries and Geronimo committer and PMC member –OSGi Enterprise Expert Group (EEG) member –Software Engineer at IBM

Agenda –Aries Blueprint Container Overview –Configuration –Beans, Services, Service References –Bean Interceptors –Declarative Transaction –JPA Blueprint Integration –Message Driven Service –Annotation –AriesTrader Application Demo –Conclusion

Aries Blueprint Container –Clean implementation based on Blueprint Specification in OSGi Compendium R4.2 Dependency Injection framework for OSGi Designed to work with plain old Java objects (POJOs) Handle the OSGi dynamics –Integrated in Geronimo, Felix Karaf, etc.

Aries Blueprint Container (cont.) –Extender Pattern –Blueprint XML Definition files and Metadata

Configuration –Blueprint xml uses blueprint namspace blueprint ::= manager* manager ::= | | service reference service-reference ::= | type-converters ::= |

Service & inline bean FooImpl foo = new FooImpl(); foo.setA(5); Hashtable props = new Hashtable(); props.put(“key”, “value”); bundleContext.registerService(org.apache.aries.blueprint.sample.Foo.class.getName(), foo, props); Blueprint top element Blueprint namespace uri Service manager definition

Bean Constructor example Account accountOne = new Account(1);

Bean Constructor example 2 Account accountTwo = StaticAccountFactory.createAccont(2);

Bean Property example Account accountOne = new Account(1); accountOne.setDescription(“#1 account”);

Bean Wiring example Account accountOne = new Account(); Currency currency = new Currency(); accountOne.setCurrency(currency);

Service example AccountImpl account = new AccountImpl(); bundleContext.registerService(Account.class.getName(), account, new Hashtable());

Reference sample AccountClient accountClient = new AccountClient(); ServiceReference sr = bundleContext.getServiceReference(“org.apache.aries.simple.Account” ); Account account = (Account)bundleContext.getService(sr); accountClient.setAccount(account); –Object injected for reference is a proxy to the service registered in the service registry –A proxy enables the injected object to remain the same while the backing service can come and go.

Reference-list sample –Reference-list provides a List object that contains the service proxy objects or ServiceReference objects –Provided List object is dynamic, as it can grow and shrink as matching services change

Advanced Blueprint Features –Config Admin –Blueprint custom namespace handler –Bean Interceptor –Declarative Transaction –JPA Blueprint Integration –Message Driven Service –Annotation

Bean Interceptor –Why do we need interceptors? Declarative Transaction Security, logging, etc –Features of bean interceptor Interceptor invocation prior to a bean method call(pre-call). Interceptor invocation following a successful bean method call (post-call) Interceptor invocation following an exception result to a method call. Interceptor ordering when 1+ interceptors are registered for the bean method. –Working on standardization in OSGi EEG. RFP has been approved.

Declarative Transaction –Features of declarative transaction Provides container managed transaction for blueprint beans Supports 6 transaction attributes (Required, Mandatory, RequiresNew, Supports, NotSupported, and Never) Manage transaction boundaries in the same manner as defined for the EJB 3.0 container Supports bean level or bundle wide. Bean level comes with higher priority. Detects configuration error at deployment time –Working on standardization in OSGi EEG. RFP has been approved.

Simple bean public class TestBeanImpl { … public void insertRow(String name, int value) throws SQLException { // get the user transaction service UserTransaction ut = getUserTransactionService(); // begin the user transaction ut.begin(); try { // start the operation to insert name, value into the db... } finally { // commit the user transaction ut.commit(); } Blueprint definition XML for the bean Transaction management & application logic

Simple bean with declarative transaction public class TestBeanImpl { … public void insertRow(String name, int value) throws SQLException { // start the operation to insert name, value into the db... } <blueprint xmlns=" xmlns:tx=" Blueprint definition XML including bean level declarative transaction for the bean Focus on application logic

Implementation of declarative transaction –Leverages blueprint bean interceptor Manage the transaction boundary before the method is invoked Manage the transaction boundary after the method is invoked –Leverages blueprint custom namespace handler Transaction namespace is proposed to describe blueprint declarative transaction in blueprint definition XML. Blueprint extender sets the bundle’s dependency on the life cycle of the transaction namespace handler. Blueprint custom namespace handler is to be standardized by OSGi EEG. –Leverage Transaction Specification in OSGi Enterprise R4.2

Priorities of transaction declaration –Priority ordering (from high to low) Bean level transaction element with method attribute Bean level transaction element when method is not specified Top level transaction element with both bean attribute and method attribute Top level transaction element with only the bean attribute Top level transaction element with only the method attribute Top level transaction element without bean or method attribute specified –If the transaction namespace handler is not able to determine the transaction for the bean, the creation of the blueprint container will fail with blueprint FAILURE event emitted.

Declarative Transaction Examples –For the bean requiresNew, all methods have REQUIRESNEW behavior. –For the bean noTx, all methods have NEVER behavior. –For the bean someTx, methods starting with "get" are MANDATORY, and all other methods are REQUIRED. –For the bean anotherBean, all methods that start with "get" are SUPPORTS, and all other methods are REQUIRED. <blueprint xmlns=" xmlns:tx=" Bean level transaction Bundle wide transactions

JPA Blueprint Integration –JPA Blueprint custom namespace for dependency injection of managed JPA resources –Managed persistence units (EntityManagerFactory objects) can be injected with or without a JTA Transaction Services implementation. –Managed persistence contexts (EntityManager objects) are only available with a JTA Transaction services implementation. –Both managed persistence units and managed persistence contexts behave as per the JPA specification. –Both jpa:unit & jpa:context can be used as bean constructor argument or bean property

JPA Sample jpa:unit –Create and close EntityManager in application code (normal return or exception) <blueprint xmlns=" xmlns:jpa=" default-activation="lazy"> <bean id="persistenceImpl" class="org.apache.aries.samples.blog.persistence.jpa.BlogPersistenceServiceImpl"> … <blueprint xmlns=" xmlns:jpa=" default-activation="lazy"> <bean id="persistenceImpl" class="org.apache.aries.samples.blog.persistence.jpa.BlogPersistenceServiceImpl"> <reference interface="javax.persistence.EntityManagerFactory” filter="(&(!(org.apache.aries.jpa.proxy.factory=*))(osgi.unit.name=blogExample))” /> …

JPA Sample jpa:context –Managed persistence contexts (EntityManager objects) are only available with a JTA Transaction services implementation. <blueprint xmlns=" xmlns:tx=" xmlns:jpa=" default-activation="lazy"> <bean id="persistenceImpl" class="org.apache.aries.samples.blog.persistence.jpa.BlogPersistenceServiceImpl"> <bean id="persistenceImpl" class="org.apache.aries.samples.blog.persistence.jpa.BlogPersistenceServiceImpl"> <reference id=”emf” interface="javax.persistence.EntityManagerFactory” filter="(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=blogExample))” />

Message Driven Service(MDS) –Message Driven Service RFP has been approved by OSGi EEG –Contains requirement for generic OSGi service and additional requirement for blueprint OSGi service. –Aries provides a prototype work for message driven service. –A programming model to enable an OSGi service to be a message driven service by using service properties –Message driven service’s message listener method invokes upon arriving of the message in the destination.

MDS Example -Example here to illustrate the programming model to define a service as message-driven service. -It is possible to register service outside of blueprint container <bean id="myMessageDrivenBean" class="org.apache.aries.mds.sample.MyMessageDrivenBean" destroy-method="destory"> Bean definition Service Definition with service properties to identify Service as MDS

MDS Example using custom namespace –Leverage Transaction schema. –Valid transaction value: Required or NotSupported –Provide most configuration via message-driven element < blueprint xmlns=" xmlns:md=" xmlns:tx=" > <md:message-driven id="myMessageDrivenBean" class="org.apache.aries.mds.sample.MyMessageDrivenBean" destroy-method="destory" scope="singleton" interface="javax.jms.MessageListener"> … Simplify the bean and service Configuration

MDS Impl in Aries –Code in sandbox currently –Uses message inflow contract defined in JCA

Aries Blueprint Annotation –Optional service to the blueprint core –Rough Prototype, currently only runtime annotation supported. –Bundle-Blueprint-Annotation manifest header = true if annotation scanning is required –Allow users to annotate the class to define its behavior –Use common configuration file or config admin to describe the values for the instances (TBD)

Annotation Example 1 id is optional Inject blueprint bundle context Register Foo as a service

Annotation Example 2 Annotate class as registration listener Register method for the listener Unregister method for the listener

Annotation Example 3 Annotate class as reference listener Inject the service reference Bind method for the reference listener Unbind method for the reference listener

Conclusion –Aries provides many blueprint add-ons to simplify configuration –Some features are mature while others continue to evolve –Continue drive standardization –More blueprint features ahead Scopes Security Interceptor?