Search in sources :

Example 1 with WebApplication

use of com.sun.enterprise.web.WebApplication in project Payara by payara.

the class AppServRegistry method getWebModule.

/*
     * This function is called once for every endpoint registration.
     * and the WebModule corresponding to that endpoint is stored.
     */
static WebModule getWebModule(WebServiceEndpoint wsep) {
    ApplicationRegistry appRegistry = org.glassfish.internal.api.Globals.getDefaultHabitat().getService(ApplicationRegistry.class);
    String appName = wsep.getBundleDescriptor().getApplication().getAppName();
    ApplicationInfo appInfo = appRegistry.get(appName);
    WebApplication webApp = null;
    if (appInfo != null) {
        Collection<ModuleInfo> moduleInfos = appInfo.getModuleInfos();
        Set<EngineRef> engineRefs = null;
        WebBundleDescriptor requiredWbd = (WebBundleDescriptor) wsep.getBundleDescriptor();
        for (ModuleInfo moduleInfo : moduleInfos) {
            engineRefs = moduleInfo.getEngineRefs();
            for (EngineRef engineRef : engineRefs) {
                if (engineRef.getApplicationContainer() instanceof WebApplication) {
                    webApp = (WebApplication) engineRef.getApplicationContainer();
                    WebBundleDescriptor wbd = webApp.getDescriptor();
                    if (wbd.equals(requiredWbd)) {
                        // WebApp corresponding to wsep is found.
                        break;
                    } else {
                        webApp = null;
                    }
                }
            }
        }
    }
    // get the required WebModule from the webApp.
    if (webApp != null) {
        String requiredModule = ((WebBundleDescriptor) wsep.getBundleDescriptor()).getModuleName();
        Set<WebModule> webModules = webApp.getWebModules();
        for (WebModule wm : webModules) {
            if (wm.getModuleName().equalsIgnoreCase(requiredModule)) {
                return wm;
            }
        }
    }
    return null;
}
Also used : ApplicationRegistry(org.glassfish.internal.data.ApplicationRegistry) ModuleInfo(org.glassfish.internal.data.ModuleInfo) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) WebModule(com.sun.enterprise.web.WebModule) WebApplication(com.sun.enterprise.web.WebApplication) EngineRef(org.glassfish.internal.data.EngineRef)

Aggregations

WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)1 WebApplication (com.sun.enterprise.web.WebApplication)1 WebModule (com.sun.enterprise.web.WebModule)1 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)1 ApplicationRegistry (org.glassfish.internal.data.ApplicationRegistry)1 EngineRef (org.glassfish.internal.data.EngineRef)1 ModuleInfo (org.glassfish.internal.data.ModuleInfo)1