FileDocCategorySizeDatePackage
EjbWebServiceRegistryListener.javaAPI DocGlassfish v2 API7407Fri May 04 22:36:02 BST 2007com.sun.enterprise.web

EjbWebServiceRegistryListener

public class EjbWebServiceRegistryListener extends Object implements com.sun.enterprise.webservice.monitoring.EndpointLifecycleListener
Listener for EJB webservice endpoint registrations and unregistrations. Upon receiving an EJB webservice endpoint registration event, this listener will register the EJB webservice endpoint's path as an ad-hoc path with the web container, along with information about the ad-hoc servlet responsible for servicing any requests on this path. Upon receiving an EJB webservice endpoint unregistration event, this listener will unregister the EJB webservice endpoint's path as an ad-hoc path from the web container.
author
Jan Luehe

Fields Summary
private static final EjbWebServiceServletInfo
EJB_WEB_SERVICE_SERVLET_INFO
private WebContainer
webContainer
Constructors Summary
public EjbWebServiceRegistryListener(WebContainer webContainer)
Constructor.

param
webContainer The web container with which this EjbWebServiceRegistryListener is associated


                      
       
        this.webContainer = webContainer;
    
Methods Summary
public voidendpointAdded(com.sun.enterprise.webservice.monitoring.Endpoint endpoint)
Receives and processes notification of a new webservice endpoint installation in the appserver. This method extracts the context root from the endpoint's URL, at which it registers an EjbWebServiceWebModule which handles all HTTP requests for the endpoint.

param
endpoint The EJB webservice endpoint that was added


        if (!TransportType.HTTP.equals(endpoint.getTransport())) {
            return;
        }

        if (!EndpointType.EJB_ENDPOINT.equals(endpoint.getEndpointType())) {
            return;
        }

        String epURI = endpoint.getEndpointSelector();
        String epCtxRoot = null;
        String epPath = null;

        int index = epURI.indexOf('/", 1);
        if (index < 0) {
            epCtxRoot = epURI;
            epPath = "";
        } else {
            epCtxRoot = epURI.substring(0, index);
            epPath = epURI.substring(index);
        }

        String epSubtree = epPath + "/__container$publishing$subctx/";

        String epAppName = null;
        WebServiceEndpoint wse = endpoint.getDescriptor();
        if (wse != null) {
            BundleDescriptor bd = wse.getBundleDescriptor();
            if (bd != null) {
                Application app = bd.getApplication();
                if (app != null) {
                    epAppName = app.getRegistrationName();
                }
            }
        }

        webContainer.registerAdHocPathAndSubtree(
            epPath,
            epSubtree,
            epCtxRoot,
            epAppName,
            EJB_WEB_SERVICE_SERVLET_INFO);
    
public voidendpointRemoved(com.sun.enterprise.webservice.monitoring.Endpoint endpoint)
Receives and processes notification of a webservice endpoint removal from the appserver. This method extracts the context root from the endpoint's URL, and unregisters the corresponding EjbWebServiceWebModule from the web container

param
endpoint The EJB webservice endpoint that was removed

  
        if (!TransportType.HTTP.equals(endpoint.getTransport())) {
            return;
        }

        if (!EndpointType.EJB_ENDPOINT.equals(endpoint.getEndpointType())) {
            return;
        }

        String epURI = endpoint.getEndpointSelector();
        String epCtxRoot = null;
        String epPath = null;
        int index = epURI.indexOf('/", 1);
        if (index < 0) {
            epCtxRoot = epURI;
            epPath = "";
        } else {
            epCtxRoot = epURI.substring(0, index);
            epPath = epURI.substring(index);
        }

        String epSubtree = epPath + "/__container$publishing$subctx/";
        webContainer.unregisterAdHocPathAndSubtree(epPath, epSubtree,
                                                   epCtxRoot);
    
public voidregister()
Registers this EjbWebServiceRegistryListener with the EJB webservice registry.


        WebServiceEngineImpl wsEngine = WebServiceEngineImpl.getInstance();

        wsEngine.addLifecycleListener(this);

        /*
         * Process any webservice endpoints that had been added before we've
         * started listening for registration events.
         */
        Iterator<Endpoint> endpoints = wsEngine.getEndpoints();
        if (endpoints != null) {
            while (endpoints.hasNext()) {
                endpointAdded(endpoints.next());
            }
        }
    
public voidunregister()
Unregisters this EjbWebServiceRegistryListener from the EJB webservice registry.

        WebServiceEngineImpl.getInstance().removeLifecycleListener(this);