Search in sources :

Example 36 with Application

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

the class EjbSessionDescriptor method getPortableJndiName.

/**
 * Return the fully-qualified portable JNDI name for a given
 * client view (Remote, Local, or no-interface).
 */
public String getPortableJndiName(String clientViewType) {
    String appName = null;
    Application app = getEjbBundleDescriptor().getApplication();
    if (!app.isVirtual()) {
        appName = app.getAppName();
    }
    String modName = getEjbBundleDescriptor().getModuleDescriptor().getModuleName();
    StringBuffer javaGlobalPrefix = new StringBuffer("java:global/");
    if (appName != null) {
        javaGlobalPrefix.append(appName);
        javaGlobalPrefix.append("/");
    }
    javaGlobalPrefix.append(modName);
    javaGlobalPrefix.append("/");
    javaGlobalPrefix.append(getName());
    javaGlobalPrefix.append("!");
    javaGlobalPrefix.append(clientViewType);
    return javaGlobalPrefix.toString();
}
Also used : Application(com.sun.enterprise.deployment.Application)

Example 37 with Application

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

the class SecurityUtil method createUniquePseudoModuleID.

/**
 * create pseudo module context id, and make sure it is unique, by chacking it against the names of all the other
 * modules in the app.
 *
 * @param ejbDesc
 * @return
 */
private static String createUniquePseudoModuleID(EjbBundleDescriptor ejbDesc) {
    Application app = ejbDesc.getApplication();
    Collection<WebBundleDescriptor> webModules = app.getBundleDescriptors(WebBundleDescriptor.class);
    Collection<EjbBundleDescriptor> ejbModules = app.getBundleDescriptors(EjbBundleDescriptor.class);
    String moduleName = ejbDesc.getUniqueFriendlyId();
    String pseudonym;
    int uniquifier = 0;
    boolean unique;
    do {
        unique = true;
        pseudonym = moduleName + (uniquifier == 0 ? "_internal" : "_internal_" + uniquifier);
        if (webModules != null) {
            for (WebBundleDescriptor w : webModules) {
                if (pseudonym.equals(w.getUniqueFriendlyId())) {
                    unique = false;
                    break;
                }
            }
        }
        if (unique && ejbModules != null) {
            for (EjbBundleDescriptor e : ejbModules) {
                if (pseudonym.equals(e.getUniqueFriendlyId())) {
                    unique = false;
                    break;
                }
            }
        }
        uniquifier += 1;
    } while (!unique);
    return VersioningUtils.getRepositoryName(app.getRegistrationName()) + "/" + pseudonym;
}
Also used : EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) Application(com.sun.enterprise.deployment.Application)

Example 38 with Application

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

the class RoleMapper method getAppDefaultRoleMapping.

private boolean getAppDefaultRoleMapping() {
    if (appDefaultMapping != null) {
        return appDefaultMapping;
    }
    appDefaultMapping = false;
    if (secService != null) {
        appDefaultMapping = Boolean.parseBoolean(secService.getActivateDefaultPrincipalToRoleMapping());
        if (appDefaultMapping) {
            // if set explicitly in the security service allow default mapping
            return appDefaultMapping;
        }
    }
    ApplicationRegistry appRegistry = Globals.getDefaultHabitat().getService(ApplicationRegistry.class);
    ApplicationInfo appInfo = appRegistry.get(appName);
    if (appInfo == null) {
        return appDefaultMapping;
    }
    Application app = appInfo.getMetaData(Application.class);
    BundleDescriptor bd = app.getModuleByUri(appName);
    appDefaultMapping = bd == null ? app.isDefaultGroupPrincipalMapping() : app.getModuleByUri(appName).isDefaultGroupPrincipalMapping();
    return appDefaultMapping;
}
Also used : ApplicationRegistry(org.glassfish.internal.data.ApplicationRegistry) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) Application(com.sun.enterprise.deployment.Application)

Example 39 with Application

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

the class JDOCodeGeneratorHelper method getModuleName.

/**
 * Calculate module name from a bundle.
 * @return module name.
 */
public static String getModuleName(EjbBundleDescriptor bundle) {
    String moduleName = null;
    Application application = bundle.getApplication();
    if (application.isVirtual()) {
        // Stand-alone module is deployed.
        moduleName = application.getRegistrationName();
    } else {
        // Module is deployed as a part of an Application.
        String jarName = bundle.getModuleDescriptor().getArchiveUri();
        int l = jarName.length();
        // Remove ".jar" from the bundle's jar name.
        moduleName = jarName.substring(0, l - 4);
    }
    return moduleName;
}
Also used : Application(com.sun.enterprise.deployment.Application)

Example 40 with Application

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

the class WarHandler method getClassLoader.

@Override
public ClassLoader getClassLoader(final ClassLoader parent, final DeploymentContext context) {
    Application applicationTemp = context.getModuleMetaData(Application.class);
    final Application application = applicationTemp == null ? Application.createApplication() : applicationTemp;
    WebappClassLoader cloader = AccessController.doPrivileged(new PrivilegedAction<WebappClassLoader>() {

        @Override
        public WebappClassLoader run() {
            return new WebappClassLoader(parent, application);
        }
    });
    try {
        WebDirContext r = new WebDirContext();
        File base = new File(context.getSource().getURI());
        r.setDocBase(base.getAbsolutePath());
        cloader.setResources(r);
        cloader.addRepository("WEB-INF/classes/", new File(base, "WEB-INF/classes/"));
        if (context.getScratchDir("ejb") != null) {
            cloader.addRepository(context.getScratchDir("ejb").toURI().toURL().toString().concat("/"));
        }
        if (context.getScratchDir("jsp") != null) {
            cloader.setWorkDir(context.getScratchDir("jsp"));
        }
        // add libraries referenced from manifest
        for (URL url : getManifestLibraries(context)) {
            cloader.addRepository(url.toString());
        }
        WebXmlParser webXmlParser = getWebXmlParser(context.getSource(), application);
        configureLoaderAttributes(cloader, webXmlParser, base);
        configureLoaderProperties(cloader, webXmlParser, base);
        configureContextXmlAttribute(cloader, base, context);
        try {
            final DeploymentContext dc = context;
            final ClassLoader cl = cloader;
            AccessController.doPrivileged(new PermsArchiveDelegate.SetPermissionsAction(SMGlobalPolicyUtil.CommponentType.war, dc, cl));
        } catch (PrivilegedActionException e) {
            throw new SecurityException(e.getException());
        }
    } catch (XMLStreamException xse) {
        logger.log(Level.SEVERE, xse.getMessage());
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, xse.getMessage(), xse);
        }
        xse.printStackTrace();
    } catch (IOException ioe) {
        logger.log(Level.SEVERE, ioe.getMessage());
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, ioe.getMessage(), ioe);
        }
        ioe.printStackTrace();
    }
    cloader.start();
    return cloader;
}
Also used : PermsArchiveDelegate(com.sun.enterprise.security.perms.PermsArchiveDelegate) WebDirContext(org.apache.naming.resources.WebDirContext) PrivilegedActionException(java.security.PrivilegedActionException) URL(java.net.URL) DeploymentContext(org.glassfish.api.deployment.DeploymentContext) WebappClassLoader(org.glassfish.web.loader.WebappClassLoader) XMLStreamException(javax.xml.stream.XMLStreamException) WebappClassLoader(org.glassfish.web.loader.WebappClassLoader) Application(com.sun.enterprise.deployment.Application) JarFile(java.util.jar.JarFile)

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