* @param sdef service definition for mapper to be returned
* @return SOAP mapper instance for service
* @throws WsException on error creating the service
*/
public static Service getInstance(final ServiceFactory sfac, final ServiceDefinition sdef) throws WsException {
ExpandingPool pool;
synchronized (s_factoryMap) {
pool = (ExpandingPool) s_factoryMap.get(sdef);
if (pool == null) {
pool = new ExpandingPool() {
protected Object createInstance() throws WsException {
Service service = sfac.createInstance(sdef);
service.setOwningPool(this);
return service;
}
};
s_factoryMap.put(sdef, pool);
}
}
synchronized (pool) {
return (Service) pool.getInstance();
}
}