Hi,
I have a web service(Netbeans 6.9.1,Glassfish 3.0.1) with webservicecontext injection. I want to know if this class is thread-safe if I use @Singleton annotation.
@WebService()
@Singleton()
public class Proves {
@Resource
WebServiceContext wsContext;
@WebMethod(operationName = "feralgo")
public String feralgo(@WebParam(name = "parametro1") String parametro1) {
//TODO write your implementation code here:
//Get host and ip client
String nomClient,ipClient;
MessageContext msgContext = wsContext.getMessageContext();
HttpServletRequest srvlRequest = (HttpServletRequest) msgContext.get(MessageContext.SERVLET_REQUEST);
nomClient = srvlRequest.getRemoteHost();
ipClient = srvlRequest.getRemoteAddr();
//Get user authenticated
String usuari;
usuari = wsContext.getUserPrincipal().getName();
return nomClient + " " + ipClient + " " + usuari;
}
}