1 23 package com.sun.enterprise.jbi.serviceengine.core; 24 import com.sun.enterprise.jbi.serviceengine.ServiceEngineException; 25 import com.sun.enterprise.jbi.serviceengine.config.ComponentConfiguration; 26 import com.sun.enterprise.jbi.serviceengine.work.WorkManagerImpl; 27 import com.sun.logging.LogDomains; 28 import java.util.Iterator ; 29 import javax.jbi.JBIException; 30 import javax.jbi.component.ComponentContext; 31 import javax.jbi.messaging.DeliveryChannel; 32 import javax.jbi.messaging.MessagingException; 33 import javax.jbi.servicedesc.ServiceEndpoint; 34 import java.util.logging.Logger ; 35 import java.util.logging.Level ; 36 37 41 public class JavaEEServiceEngineContext { 42 43 private ComponentContext jbiContext; 44 45 private EndpointRegistry endpointRegistry; 46 47 private DeliveryChannel seDeliveryChannel; 48 49 private WorkManagerImpl workManager; 50 51 private ComponentConfiguration config ; 52 53 private Bridge bridge; 54 55 private static JavaEEServiceEngineContext serviceEngineContext; 56 59 protected static final Logger logger = 60 LogDomains.getLogger(LogDomains.SERVER_LOGGER); 61 62 63 64 private JavaEEServiceEngineContext() { 65 } 66 67 public static JavaEEServiceEngineContext getInstance() { 68 if (serviceEngineContext == null) 69 serviceEngineContext = new JavaEEServiceEngineContext(); 70 return serviceEngineContext; 71 } 72 73 public void initialize() throws ServiceEngineException { 74 endpointRegistry = EndpointRegistry.getInstance(); 75 config = new ComponentConfiguration(); 76 workManager = new WorkManagerImpl(config); 77 bridge = config.getBridge(); 78 bridge.initialize(); 79 } 80 84 public ComponentContext getJBIContext() { 85 return jbiContext; 86 } 87 88 public DeliveryChannel getDeliveryChannel() { 89 return seDeliveryChannel; 90 } 91 92 public WorkManagerImpl getWorkManager() { 93 return workManager; 94 } 95 96 public Bridge getBridge() { 97 return bridge; 98 } 99 102 public void setJBIContext(ComponentContext context) 103 throws MessagingException { 104 jbiContext = context; 105 seDeliveryChannel = jbiContext.getDeliveryChannel(); 106 debug(Level.FINE, "Delivery Channel is : " + seDeliveryChannel); 107 } 108 109 112 public EndpointRegistry getRegistry() { 113 return endpointRegistry; 114 } 115 116 120 public void activateEndpoints(Iterator endpoints) 121 throws JBIException { 122 if (endpoints != null) { 123 while(endpoints.hasNext()) { 124 ServiceEndpoint endpoint = (ServiceEndpoint)endpoints.next(); 125 jbiContext.activateEndpoint( 126 endpoint.getServiceName(), endpoint.getEndpointName()); 127 } 128 } 129 130 } 131 132 private void debug(Level logLevel, String msgID) { 133 logger.log(logLevel, msgID); 134 } 135 136 } 137 | Popular Tags |