Cuga
Cuga

Reputation: 17904

Is it ok to have a service or endpoint proxy as a static member instance?

Is it ok to have a static member instance of a javax.xml.ws.Service or a handle to an endpoint proxy in a utility class I'm making?

I ask to be sure there won't be any connection timeout issues or something if I do this (being that I'm in the dark as to what else would be involved behind the scenes).

Here's an example of the service I would have:

public class MyWebService extends Service
{
    public ProxyObject getPort() { return super.getPort(qname, interface); }
}

And how I'd like to use it, so long as there's nothing wrong with this idea:

public class MyServiceApi {

  private final static ProxyObject serviceProxy = new MyWebService().getPort();

  public static void doSomething() {
    serviceProxy.doSomething("Hello World!");
  }
}

Are there any potential drawbacks I should be aware of, like long running connections or something?

Thanks for any help?

Upvotes: 0

Views: 59

Answers (1)

cdeszaq
cdeszaq

Reputation: 31280

The biggest issue you will run into is with threading. In the example, you are not accessing any variables so you won't run into any problems, but in general, static things and web things don't play well together.

Upvotes: 1

Related Questions