Search in sources :

Example 31 with Application

use of com.sun.enterprise.deployment.Application in project Payara by payara.

the class SingletonLifeCycleManager method normalizeSingletonName.

private String normalizeSingletonName(String origName, EjbSessionDescriptor sessionDesc) {
    String normalizedName;
    boolean fullyQualified = origName.contains("#");
    Application app = sessionDesc.getEjbBundleDescriptor().getApplication();
    if (fullyQualified) {
        int indexOfHash = origName.indexOf("#");
        String ejbName = origName.substring(indexOfHash + 1);
        String relativeJarPath = origName.substring(0, indexOfHash);
        BundleDescriptor bundle = app.getRelativeBundle(sessionDesc.getEjbBundleDescriptor(), relativeJarPath);
        if (bundle == null) {
            throw new IllegalStateException("Invalid @DependOn value = " + origName + " for Singleton " + sessionDesc.getName());
        }
        normalizedName = bundle.getModuleDescriptor().getArchiveUri() + "#" + ejbName;
    } else {
        normalizedName = sessionDesc.getEjbBundleDescriptor().getModuleDescriptor().getArchiveUri() + "#" + origName;
    }
    return normalizedName;
}
Also used : BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) Application(com.sun.enterprise.deployment.Application)

Example 32 with Application

use of com.sun.enterprise.deployment.Application in project Payara by payara.

the class WebBundleRuntimeNode method addDescriptor.

/**
 * Adds  a new DOL descriptor instance to the descriptor instance associated with
 * this XMLNode
 *
 * @param newDescriptor the new descriptor
 */
@Override
public void addDescriptor(Object newDescriptor) {
    SunWebAppImpl sunWebApp = (SunWebAppImpl) descriptor.getSunDescriptor();
    if (newDescriptor instanceof WebComponentDescriptor) {
        WebComponentDescriptor servlet = (WebComponentDescriptor) newDescriptor;
        // for backward compatibility with s1as schema2beans generated desc
        Servlet s1descriptor = new Servlet();
        s1descriptor.setServletName(servlet.getCanonicalName());
        if (servlet.getRunAsIdentity() != null) {
            s1descriptor.setPrincipalName(servlet.getRunAsIdentity().getPrincipal());
        }
        sunWebApp.addServlet(s1descriptor);
    } else if (newDescriptor instanceof ServiceReferenceDescriptor) {
        descriptor.addServiceReferenceDescriptor((ServiceReferenceDescriptor) newDescriptor);
    } else if (newDescriptor instanceof SecurityRoleMapping) {
        SecurityRoleMapping srm = (SecurityRoleMapping) newDescriptor;
        sunWebApp.addSecurityRoleMapping(srm);
        // store it in the application using pure DOL descriptors...
        Application app = descriptor.getApplication();
        if (app != null) {
            Role role = new Role(srm.getRoleName());
            SecurityRoleMapper rm = app.getRoleMapper();
            if (rm != null) {
                List<PrincipalNameDescriptor> principals = srm.getPrincipalNames();
                for (int i = 0; i < principals.size(); i++) {
                    rm.assignRole(principals.get(i).getPrincipal(), role, descriptor);
                }
                List<String> groups = srm.getGroupNames();
                for (int i = 0; i < groups.size(); i++) {
                    rm.assignRole(new Group(groups.get(i)), role, descriptor);
                }
            }
        }
    } else if (newDescriptor instanceof IdempotentUrlPattern) {
        sunWebApp.addIdempotentUrlPattern((IdempotentUrlPattern) newDescriptor);
    } else if (newDescriptor instanceof SessionConfig) {
        sunWebApp.setSessionConfig((SessionConfig) newDescriptor);
    } else if (newDescriptor instanceof Cache) {
        sunWebApp.setCache((Cache) newDescriptor);
    } else if (newDescriptor instanceof ClassLoader) {
        sunWebApp.setClassLoader((ClassLoader) newDescriptor);
    } else if (newDescriptor instanceof JspConfig) {
        sunWebApp.setJspConfig((JspConfig) newDescriptor);
    } else if (newDescriptor instanceof LocaleCharsetInfo) {
        sunWebApp.setLocaleCharsetInfo((LocaleCharsetInfo) newDescriptor);
    } else if (newDescriptor instanceof WebProperty) {
        sunWebApp.addWebProperty((WebProperty) newDescriptor);
    } else if (newDescriptor instanceof Valve) {
        sunWebApp.addValve((Valve) newDescriptor);
    } else
        super.addDescriptor(descriptor);
}
Also used : SunWebAppImpl(org.glassfish.web.deployment.runtime.SunWebAppImpl) Group(org.glassfish.security.common.Group) JspConfig(org.glassfish.web.deployment.runtime.JspConfig) WebProperty(org.glassfish.web.deployment.runtime.WebProperty) SecurityRoleMapping(com.sun.enterprise.deployment.runtime.common.SecurityRoleMapping) SecurityRoleMapper(org.glassfish.deployment.common.SecurityRoleMapper) IdempotentUrlPattern(com.sun.enterprise.deployment.runtime.web.IdempotentUrlPattern) PrincipalNameDescriptor(com.sun.enterprise.deployment.runtime.common.PrincipalNameDescriptor) SessionConfig(org.glassfish.web.deployment.runtime.SessionConfig) ServiceReferenceDescriptor(com.sun.enterprise.deployment.ServiceReferenceDescriptor) Role(org.glassfish.security.common.Role) WebComponentDescriptor(com.sun.enterprise.deployment.WebComponentDescriptor) Servlet(org.glassfish.web.deployment.runtime.Servlet) ClassLoader(org.glassfish.web.deployment.runtime.ClassLoader) Valve(org.glassfish.web.deployment.runtime.Valve) Application(com.sun.enterprise.deployment.Application) LocaleCharsetInfo(org.glassfish.web.deployment.runtime.LocaleCharsetInfo) Cache(org.glassfish.web.deployment.runtime.Cache)

Example 33 with Application

use of com.sun.enterprise.deployment.Application in project Payara by payara.

the class ManagedBeanManagerImpl method event.

public void event(Event event) {
    if (event.is(Deployment.APPLICATION_LOADED)) {
        ApplicationInfo info = Deployment.APPLICATION_LOADED.getHook(event);
        loadManagedBeans(info);
        registerAppLevelDependencies(info);
    } else if (event.is(Deployment.APPLICATION_UNLOADED)) {
        ApplicationInfo info = Deployment.APPLICATION_UNLOADED.getHook(event);
        Application app = info.getMetaData(Application.class);
        doCleanup(app);
    } else if (event.is(Deployment.DEPLOYMENT_FAILURE)) {
        Application app = Deployment.DEPLOYMENT_FAILURE.getHook(event).getModuleMetaData(Application.class);
        doCleanup(app);
    }
}
Also used : ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) Application(com.sun.enterprise.deployment.Application)

Example 34 with Application

use of com.sun.enterprise.deployment.Application in project Payara by payara.

the class AppSpecificConnectorClassLoaderUtil method detectReferredRARs.

/**
 * {@inheritDoc}
 */
public void detectReferredRARs(String appName) {
    ApplicationInfo appInfo = appRegistry.get(appName);
    // call to detectReferredRAs can be called only when appInfo is available
    if (appInfo == null) {
        throw new IllegalStateException("ApplicationInfo is not available for application [ " + appName + " ]");
    }
    Application app = appInfo.getMetaData(Application.class);
    if (!appInfo.isJavaEEApp()) {
        if (_logger.isLoggable(Level.FINEST)) {
            _logger.finest("Application [" + appName + "] is not a Java EE application, skipping " + "resource-adapter references detection");
        }
        return;
    }
    // Iterate through all bundle descriptors, ejb-descriptors, managed-bean descriptors
    // for references to resource-adapters
    // 
    // References can be via :
    // resource-ref
    // resource-env-ref
    // ra-mid
    // 
    // Resource definition can be found in :
    // domain.xml
    // sun-ra.xml
    // default connector resource
    // handle application.xml bundle descriptor
    processDescriptorForRAReferences(app, null, app);
    Collection<BundleDescriptor> bundleDescriptors = app.getBundleDescriptors();
    // bundle descriptors
    for (BundleDescriptor bundleDesc : bundleDescriptors) {
        String moduleName = getModuleName(bundleDesc, app);
        processDescriptorForRAReferences(app, bundleDesc, moduleName);
        Collection<RootDeploymentDescriptor> dds = bundleDesc.getExtensionsDescriptors();
        if (dds != null) {
            for (RootDeploymentDescriptor dd : dds) {
                processDescriptorForRAReferences(app, dd, moduleName);
            }
        }
    }
}
Also used : BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) Application(com.sun.enterprise.deployment.Application)

Example 35 with Application

use of com.sun.enterprise.deployment.Application in project Payara by payara.

the class EjbBundleValidator method checkDependsOn.

private void checkDependsOn(EjbDescriptor ejb) {
    if (ejb instanceof EjbSessionDescriptor) {
        EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejb;
        if (sessionDesc.hasDependsOn()) {
            if (!sessionDesc.isSingleton()) {
                throw new RuntimeException("Illegal usage of DependsOn for EJB " + ejb.getName() + ". DependsOn is only supported for Singleton beans");
            }
            String[] dependsOn = sessionDesc.getDependsOn();
            for (String next : dependsOn) {
                // TODO support new EJB 3.1 syntax
                boolean fullyQualified = next.contains("#");
                Application app = sessionDesc.getEjbBundleDescriptor().getApplication();
                if (fullyQualified) {
                    int indexOfHash = next.indexOf("#");
                    String ejbName = next.substring(indexOfHash + 1);
                    String relativeJarPath = next.substring(0, indexOfHash);
                    BundleDescriptor bundle = app.getRelativeBundle(sessionDesc.getEjbBundleDescriptor(), relativeJarPath);
                    if (bundle == null) {
                        throw new IllegalStateException("Invalid @DependOn value = " + next + " for Singleton " + sessionDesc.getName());
                    }
                    EjbBundleDescriptorImpl ejbBundle = (bundle.getModuleType() != null && bundle.getModuleType().equals(DOLUtils.warType())) ? bundle.getExtensionsDescriptors(EjbBundleDescriptorImpl.class).iterator().next() : (EjbBundleDescriptorImpl) bundle;
                    if (!ejbBundle.hasEjbByName(ejbName)) {
                        throw new RuntimeException("Invalid DependsOn dependency '" + next + "' for EJB " + ejb.getName());
                    }
                } else {
                    EjbBundleDescriptorImpl bundle = ejb.getEjbBundleDescriptor();
                    if (!bundle.hasEjbByName(next)) {
                        throw new RuntimeException("Invalid DependsOn dependency '" + next + "' for EJB " + ejb.getName());
                    }
                }
            }
        }
    }
}
Also used : BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) Application(com.sun.enterprise.deployment.Application) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Aggregations

Application (com.sun.enterprise.deployment.Application)66 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)17 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)10 DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)10 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)10 IOException (java.io.IOException)9 File (java.io.File)8 ModuleDescriptor (org.glassfish.deployment.common.ModuleDescriptor)8 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)7 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)7 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)5 DeploymentException (org.glassfish.deployment.common.DeploymentException)5 SAXParseException (org.xml.sax.SAXParseException)5 ApplicationClientDescriptor (com.sun.enterprise.deployment.ApplicationClientDescriptor)4 ArrayList (java.util.ArrayList)4 WebappClassLoader (org.glassfish.web.loader.WebappClassLoader)4 OpsParams (org.glassfish.api.deployment.OpsParams)3 EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)3 Applications (com.sun.enterprise.config.serverbeans.Applications)2 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)2