users@glassfish.java.net

Is WebServiceContext injection thread-safe?

From: <glassfish_at_javadesktop.org>
Date: Thu, 09 Sep 2010 01:51:44 PDT

Hi,

I have a web service 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;
    }

}
[Message sent by forum member 'emoya']

http://forums.java.net/jive/thread.jspa?messageID=482159