1 23 package com.sun.enterprise.webservice.spi; 24 25 import java.util.ArrayList ; 26 import java.util.logging.Level ; 27 28 import javax.xml.ws.spi.ServiceDelegate; 29 30 import com.sun.enterprise.webservice.WsUtil; 31 import com.sun.enterprise.webservice.ServiceCreationListenerImpl; 32 33 34 42 public class DefaultServiceDelegateFactory implements ServiceDelegateFactory { 43 44 static ServiceDelegateFactory factory; 45 ArrayList <ServiceDelegateCreationListener> listeners = new ArrayList (); 46 47 52 public static void setFactory(ServiceDelegateFactory f) { 53 factory = f; 54 } 55 56 59 public static ServiceDelegateFactory getFactory() { 60 if (factory==null) { 61 synchronized(DefaultServiceDelegateFactory.class) { 62 if (factory==null) { 63 factory= new DefaultServiceDelegateFactory(); 64 } 65 } 66 } 67 return factory; 68 } 69 70 71 protected DefaultServiceDelegateFactory() { 72 addListener(ServiceCreationListenerImpl.getDefaultListener()); 74 } 75 76 81 public ServiceDelegate create(ServiceDelegate delegate) { 82 ServiceDelegateImpl ourServiceDelegate = new ServiceDelegateImpl(delegate); 83 serviceCreated(ourServiceDelegate); 84 return ourServiceDelegate; 85 } 86 87 91 public void addListener(ServiceDelegateCreationListener listener) { 92 listeners.add(listener); 93 } 94 95 private void serviceCreated(ServiceDelegateImpl delegate) { 97 for (ServiceDelegateCreationListener listener : listeners) { 98 try { 99 listener.serviceCreated(delegate); 100 } catch(Throwable t) { 101 WsUtil.getDefaultLogger().severe("Exception " 102 + t.getMessage() + " in serviceDelegateCreationListener : " + listener); 103 WsUtil.getDefaultLogger().log(Level.FINE, t.getMessage(), t); 104 } 105 } 106 } 107 } 108 | Popular Tags |