cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Landslide <xiangm...@landslide.com>
Subject Is it thread safe to use an instance variable @WebServiceProvider?
Date Sat, 01 Mar 2008 20:57:43 GMT

Is it thread safe to use an instance variable "quote" as below?

import javax.xml.ws.Provider;
import javax.xml.ws.Service;
import javax.xml.ws.ServiceMode;
import javax.xml.ws.WebServiceProvider;

@WebServiceProvider(portName="stockQuoteReporterPort"
serviceName="stockQuoteReporter")
@ServiceMode(value="Service.Mode.MESSAGE")
public class  StockQuoteReporterProvider implements Provider<SOAPMessage>
{
private Quote quote;

public StockQuoteReporterProvider()
  {
       quote = new Quote();
  }

public SOAPMessage invoke(SOAPMessage request)
  {
  quote.setIntProperty(123);

  SOAPBody requestBody = request.getSOAPBody();
  if(requestBody.getElementName.getLocalName.equals("getStockPrice"))
    {
    MessageFactory mf = MessageFactory.newInstance();
    SOAPFactory sf = SOAPFactory.newInstance();

    SOAPMessage response = mf.createMessage();
    SOAPBody respBody = response.getSOAPBody();
    Name bodyName = sf.createName("getStockPriceResponse");
    respBody.addBodyElement(bodyName);
    SOAPElement respContent = respBody.addChildElement("price");
    respContent.setValue("123.00");
    response.saveChanges();
    return response;
    }
    ...
  }
}
-- 
View this message in context: http://www.nabble.com/Is-it-thread-safe-to-use-an-instance-variable-%40WebServiceProvider--tp15780748p15780748.html
Sent from the cxf-user mailing list archive at Nabble.com.


Mime
View raw message