Introduction to JSR-227

JSR-227 defines a standard way for tools to implement the interactions between user interfaces and services, doing this in a way that will work for any user interface and any service technology. MVC is application design pattern in this.Primary supported by Sun+oracle. JSR 227 defines an
abstraction mechanism. We are accessing data from JavaBeans, EJB, JDO or POJO in order to reterive our view. In the world of MVC applications the View and Controller layers need to interact with the Model layer. Until this JSR came along, the developer had to learn the specific API for the technology that implemented its Model layer in order to build his View and Controller layers.
With JSR 227 there is a single standard API that works with any implementation of a Model layer – regardless of the implementing technology which can be EJB, SDO, XML, JavaBeans, etc – as well as with any implementation of View layer, such as JSP, JSF, Struts, Swing or any new technology that might pop up. This will be beneficial for two group one is Developer who design UI interface. The other group is providers of business services. For example I might be a business service provider with an innovative way to implement business service. Now all I need to do is provide a data control implementation to my business service – any tool that supports JSR-227 will be able to use my business services in a transparent way.

JSR-227 influence the future of application development :-
JSR-227 as an enabling standard for Service Oriented Architecture (SOA). The concept of SOA is that you can pick up services from anywhere and use them in your application. What JSR-227 will enable you to do is ignore the specific implementation of the service and easily bind user interfaces to this service. This helps create the needed separation between service developers and application developers.

More information you can find on
:-
1.www.oracle.com
2. http://web1.jcp.org/en/jsr/detail?id=227(JSR 227 home page)

References
http://www.oracle.com/technology/tech/java/newsletter/articles/jsr227_interview.html

pimp it

Implementation of thread Pool in java

In my previous post of thread pool (https://www.techartifact.com/blogs/2009/06/what-is-thread-pool-in-java.html),I have given the theoritcal knowledge.now I came with code.Hope it will help a lot.
Java’s implementation of thread pool is based on an executor. Executor is a generic concept modeled by this interface.

Package java.util.concurrent;
Public interface Executor {
Public void execute(Runnable task);
}

You simple have to create the task and pass it on execute() method of an appropriate executor.The pool is an instance of ThreadPoolExecutor class.this class implements ExecutorService Interface which tell how to put task and how to shut down.
Example of creation of thread pool

package java.util.concurrent;
public class ThreadPoolExecutor implements ExecutorService {
public ThreadPoolExecutor(int CorePoolSize,int maximumPoolSize,
                           long keepAliveTime,timeUnit unit,
                          BlockingQueue workQueue);
public ThreadPoolExecutor(int CorePoolSize,int maximumPoolSize,
                           long keepAliveTime,timeUnit unit,
                          BlockingQueue workQueue,
                           ThreadFactory threadfactory);
public ThreadPoolExecutor(int CorePoolSize,int maximumPoolSize,
                           long keepAliveTime,timeUnit unit,
                          BlockingQueue workQueue
                          RejectedExecutionHandler handler);
public ThreadPoolExecutor(int CorePoolSize,int maximumPoolSize,
                           long keepAliveTime,timeUnit unit,
                          BlockingQueue workQueue
                          ThreadFactory threadfactory
                           RejectedExecutionHandler handler);

CorePoolSize , keepAliveTime, are the part by which we can manage the thread pool.we can use a constructor to create the task and put them in thread pool

Now we will create the task and we will put into the threadpool.here it’s the example.

import java.util.concurrent.*;
 public class ThreadPoolTest {
public static void main(String[] args) {
int nTask =Integer.parseInt(args[0]);
long n = ling.parseLong(args[1]);
int tpSize =Integer.parseInt(args[2]);

ThreadPoolExecutor tpe = new ThreadPoolExecutor(tpSize,tpSize,50000L,
                             TimeUnit.MILLISECONDS,new LinkedBlockingQueue());
Task[] tasks = new Task[nTask];
for(int i =0;itasks[i]= new Task(n,"Task " + i);
tpe.execute(task[i]);
}
tpe.shutdown();
}
}

This is implementation of thread Pool.It is easy to use.Any suggestion would be welcome.

Pin it

Common terminology used in oracle ADF

Entity object – ADF entity object are business components that encapsulate the business model, including data, rules, and persistence behavior, for items that are used in your application. Entity object definitions map to single objects in the data source. In the vast majority of cases, these are tables, views, synonyms, or snapshots in a database. It can allow to do DML operation. Advanced programmers can base entity objects on objects from other data sources, such as spreadsheets, XML files, or flat text files.

ADF view object – are business components that collect data from the data source.It represent the single table..It can also be used To create LOV. View object must have process for retrieving data from the data source.Data source is database and process is Sql query. Oracle ADF Business Components can automatically use JDBC to pass this query to the database and receive the result. Like entity attributes, the values of view attributes can be read or changed using the methods getAttribute() and setAttribute() in the ViewRowImpl class or by using generated getters and setters in a custom view row class

View Link – is the relation between the view object on based of a some common view attribute of each view object. Individual instances of view objects can also be related by individual instances of view links, which create a master-detail relationship between the query result sets.

ADF Application Module – are business components that represent particular application tasks. The application module definition provides a data model for the task by aggregating
the view object and view link instances required for the task. It also provides services that help the client accomplish the task

You can use application module in two different ways:
• As a service object, in which case each instance of the MVC application has access to one
instance of the application module. These root-level application module instances control ADF
BC transaction objects, which in turn control the entity and view caches.
• As a reusable object for nesting, in which case you can create a data model and service methods
on it and then nest one of its instances in other application module definitions. Those application
module definitions can, in turn, access the nested module’s methods and data model. Nested
application modules share the root-level application module’s transaction.

SetActionListener – The setActionListener tag is a declarative way to allow an action source ( , , etc.) to set a value before navigation. It is perhaps most useful in conjunction with the “processScope” EL scope provided b ADF Faces, as it makes it possible to pass details from one page to another without writing any Java code. This tag can be used both with ADF Faces commands and JSF standard tags.
Exmaple of this can be as follows. Suppose we have a table “employee”.We want to fetch the salary of an employee of some particular row and want to send this salary in
Next page in process scope or request scope etc.So using this we can do this.
It have two attributes :
From – the source of the value; can be an EL expression or a constant value
To – the target for the value; must be an EL expression

 
        <af:setActionListener      from="#{row.salary}"
                                  to="#{processScope.salary1}"/>              

This setactionListener will pick value of salary of that row and store this value into salary1 variable.So anyone can use this salary
As processScope.salary1 . It is very simple to use. And very useful.

References – oracle ADF development guidelines (pdf)
– www.oracle.com