FileDocCategorySizeDatePackage
AppServWSRegistry.javaAPI DocExample10693Tue May 29 16:57:12 BST 2007com.sun.xml.ws.transport.tcp.server.glassfish

AppServWSRegistry

public final class AppServWSRegistry extends Object
author
Alexey Stashok

Fields Summary
private static final Logger
logger
private static final AppServWSRegistry
instance
private final Map
registry
Constructors Summary
private AppServWSRegistry()

        registry = new HashMap<String, Map<String, WSEndpointDescriptor>>();
        final WSEndpointLifeCycleListener lifecycleListener = new WSEndpointLifeCycleListener();
        
        final WebServiceEngine engine = WebServiceEngineFactory.getInstance().getEngine();
        engine.addLifecycleListener(lifecycleListener);
        
        populateEndpoints(engine);
    
Methods Summary
private voidaddToRegistry(java.lang.String contextRoot, java.lang.String urlPattern, WSEndpointDescriptor wsDescriptor)

        
        contextRoot = ensureSlash(contextRoot);
        urlPattern = ensureSlash(urlPattern);
        Map<String, WSEndpointDescriptor> endpointMap = registry.get(contextRoot);
        if (endpointMap == null) {
            endpointMap = new HashMap<String, WSEndpointDescriptor>();
            registry.put(contextRoot, endpointMap);
        }
        
        endpointMap.put(urlPattern, wsDescriptor);
    
protected voidderegisterEndpoint(com.sun.enterprise.webservice.monitoring.Endpoint endpoint)
Deregister WS Endpoint

        final WebServiceEndpoint wsServiceDescriptor = endpoint.getDescriptor();
        final String contextRoot = getEndpointContextRoot(wsServiceDescriptor);
        final String urlPattern = getEndpointUrlPattern(wsServiceDescriptor);
        
        // ContextRoot could be represented as leading slash or without (GF API changes from time to time)
        // So we use slashed version for registries
        final String slashedContextRoot = ensureSlash(contextRoot);
        final String slashedUrlPattern = ensureSlash(urlPattern);

        final String path = slashedContextRoot + slashedUrlPattern;
        
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, MessagesMessages.WSTCP_1111_APP_SERV_REG_DEREGISTER_ENDPOINT(
                    wsServiceDescriptor.getWebService().getName(),
                    path, wsServiceDescriptor.implementedByEjbComponent()));
        }
        removeFromRegistry(slashedContextRoot, slashedUrlPattern);
        WSTCPAdapterRegistryImpl.getInstance().deleteTargetFor(path);
    
private java.lang.StringensureSlash(java.lang.String s)

        if (s != null && s.length() > 0 && s.charAt(0) != '/") {
            return "/" + s;
        }
        
        return s;
    
public WSEndpointDescriptorget(java.lang.String wsServiceName, java.lang.String endpointName)
Lookup endpoint's decriptor in registry

        final Map<String, WSEndpointDescriptor> endpointMap = registry.get(wsServiceName);
        if (endpointMap != null) {
            return endpointMap.get(endpointName);
        }
        
        return null;
    
public com.sun.enterprise.webservice.EjbRuntimeEndpointInfogetEjbRuntimeEndpointInfo(java.lang.String service, java.lang.String endpointName)
Method is used by WS invoker to clear some EJB invoker state ???

        
        final WSEndpointDescriptor wsEndpointDescriptor = get(service, endpointName);
        EjbRuntimeEndpointInfo endpointInfo = null;
        
        if (wsEndpointDescriptor.isEJB()) {
            endpointInfo = (EjbRuntimeEndpointInfo) WebServiceEjbEndpointRegistry.
                    getRegistry().getEjbWebServiceEndpoint(wsEndpointDescriptor.getURI(), "POST", null);
        }
        
        return endpointInfo;
    
private java.lang.StringgetEndpointContextRoot(com.sun.enterprise.deployment.WebServiceEndpoint wsServiceDescriptor)

        String contextRoot;
        if(!wsServiceDescriptor.implementedByEjbComponent()) {
            contextRoot = wsServiceDescriptor.getWebComponentImpl().
                    getWebBundleDescriptor().getContextRoot();
            logger.log(Level.FINE, MessagesMessages.WSTCP_1112_APP_SERV_REG_GET_ENDP_CR_NON_EJB(contextRoot));
        } else {
            final String[] path = wsServiceDescriptor.getEndpointAddressUri().split("/");
            contextRoot = "/" + path[1];
            logger.log(Level.FINE, MessagesMessages.WSTCP_1113_APP_SERV_REG_GET_ENDP_CR_EJB(contextRoot));
        }
        
        return contextRoot;
    
private java.lang.StringgetEndpointUrlPattern(com.sun.enterprise.deployment.WebServiceEndpoint wsServiceDescriptor)

        String urlPattern;
        if(!wsServiceDescriptor.implementedByEjbComponent()) {
            urlPattern = wsServiceDescriptor.getEndpointAddressUri();
            logger.log(Level.FINE, MessagesMessages.WSTCP_1114_APP_SERV_REG_GET_ENDP_URL_PATTERN_NON_EJB(urlPattern));
        } else {
            final String[] path = wsServiceDescriptor.getEndpointAddressUri().split("/");
            if (path.length < 3) {
                return "";
            }
            
            urlPattern = "/" + path[2];
            logger.log(Level.FINE, MessagesMessages.WSTCP_1115_APP_SERV_REG_GET_ENDP_URL_PATTERN_EJB(urlPattern));
        }
        
        return urlPattern;
    
public static com.sun.xml.ws.transport.tcp.server.glassfish.AppServWSRegistrygetInstance()

    
        
        return instance;
    
private booleanisTCPEnabled(com.sun.enterprise.deployment.WebServiceEndpoint webServiceDesc)

        return true;
    
private voidpopulateEndpoints(com.sun.enterprise.webservice.monitoring.WebServiceEngine engine)
Populate currently registered WS Endpoints and register them

        final Iterator<Endpoint> endpoints = engine.getEndpoints();
        while(endpoints.hasNext()) {
            registerEndpoint(endpoints.next());
        }
    
protected voidregisterEndpoint(com.sun.enterprise.webservice.monitoring.Endpoint endpoint)
Register new WS Endpoint

        final WebServiceEndpoint wsServiceDescriptor = endpoint.getDescriptor();
        
        if(wsServiceDescriptor != null && isTCPEnabled(wsServiceDescriptor)) {
            final String contextRoot = getEndpointContextRoot(wsServiceDescriptor);
            final String urlPattern = getEndpointUrlPattern(wsServiceDescriptor);
            
            // ContextRoot could be represented as leading slash or without (GF API changes from time to time)
            // So we use slashed version for registries
            final String slashedContextRoot = ensureSlash(contextRoot);
            final String slashedUrlPattern = ensureSlash(urlPattern);
            
            final String path = slashedContextRoot + slashedUrlPattern;
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, MessagesMessages.WSTCP_1110_APP_SERV_REG_REGISTER_ENDPOINT(
                        wsServiceDescriptor.getServiceName(), path, wsServiceDescriptor.implementedByEjbComponent()));
            }
            final WSEndpointDescriptor descriptor = new WSEndpointDescriptor(wsServiceDescriptor,
                    contextRoot,
                    urlPattern,
                    endpoint.getEndpointSelector());
            addToRegistry(slashedContextRoot, slashedUrlPattern, descriptor);
        }
    
private WSEndpointDescriptorremoveFromRegistry(java.lang.String wsServiceName, java.lang.String endpointName)

        final Map<String, WSEndpointDescriptor> endpointMap = registry.get(wsServiceName);
        if (endpointMap != null) {
            return endpointMap.remove(endpointName);
        }
        
        return null;