views:

56

answers:

2

I have a set of statements to be executed repeatedly every time a web method is called with a new service.I tried writing in the constructor but, the constructor gets invoked only once when the server starts. Instead, I need the set of stmts to be executed each time a Service is created at the client.

A: 

As per your other quuestion: maybe interceptors will help

djna
A: 

You're looking for @PostConstruct:

@javax.annotation.PostConstruct
public void postConstruct(){
    // initialization code
}

A method annotated with @PostConstruct is called by the container once after the bean is instantiated.

EDIT: I think, I misunderstood your question. You're probably looking for interceptors as suggested by djna, i.e., javax.ejb.Interceptors annotation. You can find a good introduction here (as soon as maintenance of java.net is over).

janko
thanks for ur reply!
Ajay