Category Archives: Definitions

JAX-RPC Handlers – Why do we use it?

JAX-RPC Handlers – Why do we use it?

A handler is a component that can be associated with an entire Web service or with a particular Web service interface. JAX-RPC handlers allow you to intercept a SOAP message at various times during a service invocation. Several handlers can be combined into what is called a “handler chain”. We use the handlers in order to achieve the below

1. An authentucation component to process SOAP headers containing credentials
2. To encrypt meesagge before we can send it across the network
3. To show SOAP message content specific logging actions can be undertaken
4. To calculate the time taken to process a SOAP message

A handler is a java class that implements the javax.xml.rpc.handler.Handler interface. It has three methods (handleRequest, handleResponse, and handleFault) to handle SOAP requests, responses and faults, respectively.

public abstract interface javax.xml.rpc.handler.Handler extends java.lang.Object {
    public abstract boolean handleRequest(MessageContext context);
    public abstract boolean handleResponse(MessageContext context);
    public abstract boolean handleFault(MessageContext context);
    public abstract void init(HandleInfo info);
    public abstract void destory();
    public abstract QName[] getHeaders;

What is Daemon Thread and User Threads in Java ?

In java we have two type of Threads : Daemon Thread and User Threads. Generally all threads created by programmer are user thread (unless you specify it to be daemon or your parent thread is a daemon thread). User thread are generally meant to run our programm code. JVM doesn’t terminates unless all the user thread terminate.On the other hand we have Daemon threads. Typically these threads are service provider threads. They should not be used to run your program code but some system code. These thread run paralley to your code but survive on the mercy of the JVM. When JVM finds no user threads it stops and all daemon thread terminate instantly. Thus one should never rely on daemon code to perform any program code.

For better understanding consider a well known example of Daemon thread : Java garbage collector. Garbage collector runs as a daemon thread to recalim any unused memory. When all user threads terminates, JVM may stop and garbage collector also terminates instantly.