Search in sources :

Example 11 with Application

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

the class SecurityDeployer method load.

@Override
public DummyApplication load(SecurityContainer container, DeploymentContext context) {
    DeployCommandParameters dparams = context.getCommandParameters(DeployCommandParameters.class);
    Application app = context.getModuleMetaData(Application.class);
    handleCNonceCacheBSInit(app.getAppName(), app.getBundleDescriptors(WebBundleDescriptor.class), dparams.availabilityenabled);
    return new DummyApplication();
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) DummyApplication(org.glassfish.deployment.common.DummyApplication) DummyApplication(org.glassfish.deployment.common.DummyApplication) Application(com.sun.enterprise.deployment.Application)

Example 12 with Application

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

the class SecurityDeployer method generateArtifacts.

// creates security policy if needed
@Override
protected void generateArtifacts(DeploymentContext dc) throws DeploymentException {
    OpsParams params = dc.getCommandParameters(OpsParams.class);
    if (params.origin.isArtifactsPresent()) {
        return;
    }
    String appName = params.name();
    try {
        Application app = dc.getModuleMetaData(Application.class);
        Set<WebBundleDescriptor> webDesc = app.getBundleDescriptors(WebBundleDescriptor.class);
        if (webDesc == null) {
            return;
        }
        for (WebBundleDescriptor webBD : webDesc) {
            loadPolicy(webBD, false);
        }
    } catch (Exception se) {
        String msg = "Error in generating security policy for " + appName;
        throw new DeploymentException(msg, se);
    }
}
Also used : OpsParams(org.glassfish.api.deployment.OpsParams) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) DeploymentException(org.glassfish.deployment.common.DeploymentException) DummyApplication(org.glassfish.deployment.common.DummyApplication) Application(com.sun.enterprise.deployment.Application) IASSecurityException(com.sun.enterprise.security.util.IASSecurityException) DeploymentException(org.glassfish.deployment.common.DeploymentException)

Example 13 with Application

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

the class CMPDeployerImpl method deploy.

/**
 * Generates the concrete impls for all CMPs in the application.
 *
 * @throws DeploymentException if this exception was thrown while generating concrete impls
 */
public void deploy(DeploymentContext ctx) throws DeploymentException {
    // deployment descriptor object representation for the archive
    Application application = null;
    // deployment descriptor object representation for each module
    EjbBundleDescriptorImpl bundle = null;
    // ejb name
    String beanName = null;
    // GeneratorException message if any
    StringBuffer generatorExceptionMsg = null;
    try {
        CMPGenerator gen = new JDOCodeGenerator();
        // stubs dir for the current deployment (generated/ejb)
        // NOI18N
        File stubsDir = ctx.getScratchDir("ejb");
        application = ctx.getModuleMetaData(Application.class);
        if (_logger.isLoggable(Logger.FINE)) {
            // NOI18N
            _logger.fine(// NOI18N
            "cmpc.processing_cmp", application.getRegistrationName());
        }
        List<File> cmpFiles = new ArrayList<File>();
        final ClassLoader jcl = application.getClassLoader();
        bundle = ctx.getModuleMetaData(EjbBundleDescriptorImpl.class);
        // This gives the dir where application is exploded
        String archiveUri = ctx.getSource().getURI().getSchemeSpecificPart();
        if (_logger.isLoggable(Logger.FINE)) {
            _logger.fine(// NOI18N
            "[CMPC] Module Dir name is " + archiveUri);
        }
        // xml dir for the current deployment (generated/xml)
        String generatedXmlsPath = ctx.getScratchDir("xml").getCanonicalPath();
        if (_logger.isLoggable(Logger.FINE)) {
            _logger.fine(// NOI18N
            "[CMPC] Generated XML Dir name is " + generatedXmlsPath);
        }
        try {
            long start = System.currentTimeMillis();
            gen.init(bundle, ctx, archiveUri, generatedXmlsPath);
            Iterator ejbs = bundle.getEjbs().iterator();
            while (ejbs.hasNext()) {
                EjbDescriptor desc = (EjbDescriptor) ejbs.next();
                beanName = desc.getName();
                if (_logger.isLoggable(Logger.FINE)) {
                    _logger.fine(// NOI18N
                    "[CMPC] Ejb Class Name: " + desc.getEjbClassName());
                }
                if (desc instanceof IASEjbCMPEntityDescriptor) {
                    // generate concrete CMP class implementation
                    IASEjbCMPEntityDescriptor entd = (IASEjbCMPEntityDescriptor) desc;
                    if (_logger.isLoggable(Logger.FINE)) {
                        _logger.fine(// NOI18N
                        "[CMPC] Home Object Impl name  is " + entd.getLocalHomeImplClassName());
                    }
                    // The classloader needs to be set else we fail down the road.
                    ClassLoader ocl = entd.getClassLoader();
                    entd.setClassLoader(jcl);
                    try {
                        gen.generate(entd, stubsDir, stubsDir);
                    } catch (GeneratorException e) {
                        String msg = e.getMessage();
                        _logger.warning(msg);
                        generatorExceptionMsg = addGeneratorExceptionMessage(msg, generatorExceptionMsg);
                    } finally {
                        entd.setClassLoader(ocl);
                    }
                /* WARNING: IASRI 4683195
                     * JDO Code failed when there was a relationship involved
                     * because it depends upon the orginal ejbclasname and hence
                     * this code is shifted to just before the Remote Impl is
                     * generated.Remote/Home Impl generation depends upon this
                     * value
                     */
                }
            }
            // end while ejbs.hasNext()
            beanName = null;
            cmpFiles.addAll(gen.cleanup());
            long end = System.currentTimeMillis();
            _logger.fine("CMP Generation: " + (end - start) + " msec");
        } catch (GeneratorException e) {
            String msg = e.getMessage();
            _logger.warning(msg);
            generatorExceptionMsg = addGeneratorExceptionMessage(msg, generatorExceptionMsg);
        }
        // Used in exception processing
        bundle = null;
        // Compile the generated classes
        if (generatorExceptionMsg == null) {
            long start = System.currentTimeMillis();
            compileClasses(ctx, cmpFiles, stubsDir);
            long end = System.currentTimeMillis();
            _logger.fine("Java Compilation: " + (end - start) + " msec");
            // Do Java2DB if needed
            start = System.currentTimeMillis();
            CMPProcessor processor = new CMPProcessor(ctx);
            processor.process();
            end = System.currentTimeMillis();
            _logger.fine("Java2DB processing: " + (end - start) + " msec");
            _logger.fine("cmpc.done_processing_cmp", application.getRegistrationName());
        }
    } catch (GeneratorException e) {
        _logger.warning(e.getMessage());
        throw new DeploymentException(e);
    } catch (Throwable e) {
        String eType = e.getClass().getName();
        String appName = application.getRegistrationName();
        String exMsg = e.getMessage();
        String msg = null;
        if (bundle == null) {
            // Application or compilation error
            msg = I18NHelper.getMessage(messages, "cmpc.cmp_app_error", eType, appName, exMsg);
        } else {
            String bundleName = bundle.getModuleDescriptor().getArchiveUri();
            if (beanName == null) {
                // Module processing error
                msg = I18NHelper.getMessage(messages, "cmpc.cmp_module_error", new Object[] { eType, appName, bundleName, exMsg });
            } else {
                // CMP bean generation error
                msg = I18NHelper.getMessage(messages, "cmpc.cmp_bean_error", new Object[] { eType, beanName, appName, bundleName, exMsg });
            }
        }
        _logger.log(Logger.SEVERE, msg, e);
        throw new DeploymentException(msg);
    }
    if (generatorExceptionMsg != null) {
        // We already logged each separate part.
        throw new DeploymentException(generatorExceptionMsg.toString());
    }
}
Also used : JDOCodeGenerator(com.sun.jdo.spi.persistence.support.ejb.ejbc.JDOCodeGenerator) CMPProcessor(com.sun.jdo.spi.persistence.support.ejb.ejbc.CMPProcessor) ArrayList(java.util.ArrayList) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor) IASEjbCMPEntityDescriptor(org.glassfish.ejb.deployment.descriptor.IASEjbCMPEntityDescriptor) Iterator(java.util.Iterator) DeploymentException(org.glassfish.deployment.common.DeploymentException) Application(com.sun.enterprise.deployment.Application) File(java.io.File) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Example 14 with Application

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

the class Java2DBProcessorHelper method getDDLNamePrefix.

/**
 * Returns name prefix for DDL files extracted from the info instance by the
 * Sun-specific code.
 *
 * @param info the instance to use for the name generation.
 * @return name prefix as String.
 */
public static String getDDLNamePrefix(Object info) {
    StringBuffer rc = new StringBuffer();
    if (info instanceof BundleDescriptor && !(info instanceof Application)) {
        BundleDescriptor bundle = (BundleDescriptor) info;
        rc.append(bundle.getApplication().getRegistrationName());
        Application application = bundle.getApplication();
        if (!application.isVirtual()) {
            String modulePath = bundle.getModuleDescriptor().getArchiveUri();
            int l = modulePath.length();
            // Remove ".jar" from the module's jar name.
            rc.append(DatabaseConstants.NAME_SEPARATOR).append(modulePath.substring(0, l - 4));
        }
    }
    return (rc.length() == 0) ? DEFAULT_NAME : rc.toString();
}
Also used : BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) Application(com.sun.enterprise.deployment.Application)

Example 15 with Application

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

the class Java2DBProcessorHelper method init.

/**
 * Initializes the rest of the settings
 */
public void init() {
    if (deploy) {
        // DeployCommandParameters are available only on deploy or deploy
        // part of redeploy
        DeployCommandParameters cliOverrides = ctx.getCommandParameters(DeployCommandParameters.class);
        if (logger.isLoggable(Level.FINE)) {
            logger.fine("---> cliOverrides " + cliOverrides);
        }
        cliCreateTables = cliOverrides.createtables;
        cliDropAndCreateTables = cliOverrides.dropandcreatetables;
        Application application = ctx.getModuleMetaData(Application.class);
        appRegisteredName = application.getRegistrationName();
        deploymentContextProps.setProperty(APPLICATION_NAME, appRegisteredName);
    } else {
        // UndeployCommandParameters are available only on undeploy or undeploy
        // part of redeploy. In the latter case, cliOverrides.droptables
        // is set from cliOverrides.dropandcreatetables passed to redeploy.
        UndeployCommandParameters cliOverrides = ctx.getCommandParameters(UndeployCommandParameters.class);
        if (logger.isLoggable(Level.FINE)) {
            logger.fine("---> cliOverrides " + cliOverrides);
        }
        cliDropTables = cliOverrides.droptables;
        appRegisteredName = deploymentContextProps.getProperty(APPLICATION_NAME);
    }
    try {
        appGeneratedLocation = ctx.getScratchDir("ejb").getCanonicalPath() + File.separator;
    } catch (Exception e) {
        throw new RuntimeException(I18NHelper.getMessage(messages, // NOI18N
        "Java2DBProcessorHelper.generatedlocation", appRegisteredName), e);
    }
    appDeployedLocation = ctx.getSource().getURI().getSchemeSpecificPart() + File.separator;
    ActionReport report = ctx.getActionReport();
    subReport = report.addSubActionsReport();
    subReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) UndeployCommandParameters(org.glassfish.api.deployment.UndeployCommandParameters) ActionReport(org.glassfish.api.ActionReport) Application(com.sun.enterprise.deployment.Application) SQLException(java.sql.SQLException) IOException(java.io.IOException)

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