1 10 11 package org.mule.providers.soap.glue; 12 13 import electric.glue.context.ServiceContext; 14 import electric.registry.Registry; 15 import electric.registry.RegistryException; 16 import electric.service.IService; 17 18 import org.apache.commons.logging.Log; 19 import org.apache.commons.logging.LogFactory; 20 import org.mule.config.i18n.Message; 21 import org.mule.impl.InitialisationCallback; 22 import org.mule.umo.lifecycle.InitialisationException; 23 24 31 public class GlueInitialisationCallback implements InitialisationCallback 32 { 33 36 protected static Log logger = LogFactory.getLog(GlueInitialisationCallback.class); 37 38 private IService service; 39 private ServiceContext context; 40 private String servicePath; 41 private boolean invoked = false; 42 43 public GlueInitialisationCallback(IService service, String path, ServiceContext context) 44 { 45 this.service = service; 46 this.servicePath = path; 47 this.context = context; 48 if (context == null) 49 { 50 this.context = new ServiceContext(); 51 } 52 } 53 54 public void initialise(Object component) throws InitialisationException 55 { 56 if (invoked) 58 { 59 return; 60 } 61 if (component instanceof GlueInitialisable) 62 { 63 logger.debug("Calling Glue initialisation for component: " + component.getClass().getName()); 64 ((GlueInitialisable)component).initialise(service, context); 65 } 66 invoked = true; 67 try 68 { 69 logger.debug("Publishing service " + servicePath + " to Glue registry."); 70 Registry.publish(servicePath, service, context); 71 } 72 catch (RegistryException e) 73 { 74 throw new InitialisationException(new Message("soap", 3, component.getClass().getName()), e, this); 75 } 76 } 77 } 78 | Popular Tags |