Search in sources :

Example 21 with Application

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

the class ServerSynchronizer method synchronizeApplications.

/**
 * Synchronize all the applications in the applications directory.
 * We use the mod time of the application directory to decide if
 * the application has changed.  If it has changed, we also send
 * any of the generated content.
 */
private void synchronizeApplications(Payload.Outbound payload, Server server, SyncRequest sr) throws URISyntaxException {
    if (logger.isLoggable(Level.FINER))
        logger.finer("ServerSynchronizer: " + "synchronize application instance " + sr.instance);
    Map<String, Application> apps = getApps(server);
    File appsDir = env.getApplicationRepositoryPath();
    for (ModTime mt : sr.files) {
        if (apps.containsKey(mt.name)) {
            syncApp(apps.get(mt.name), appsDir, mt, payload);
            // if client has app, remove it from set
            apps.remove(mt.name);
        } else
            removeApp(apps.get(mt.name), appsDir, mt, payload);
    }
    // now do all the remaining apps the client doesn't have
    for (Map.Entry<String, Application> e : apps.entrySet()) syncApp(e.getValue(), appsDir, new ModTime(e.getKey(), 0), payload);
}
Also used : Application(com.sun.enterprise.config.serverbeans.Application) ModTime(com.sun.enterprise.util.cluster.SyncRequest.ModTime)

Example 22 with Application

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

the class AutoUndeploymentOperation method prepareUndeployActionProperties.

private Properties prepareUndeployActionProperties(String archiveName, String target) {
    DeploymentProperties dProps = new DeploymentProperties();
    // we need to find the application registration name
    // which is not always the same as archive name
    String appName = archiveName;
    List<Application> applications = apps.getApplications();
    for (Application app : applications) {
        String defaultAppName = app.getDeployProperties().getProperty(DeploymentProperties.DEFAULT_APP_NAME);
        if (defaultAppName != null && defaultAppName.equals(archiveName)) {
            appName = app.getName();
        }
    }
    dProps.setName(appName);
    // dProps.setResourceTargetList(target);
    return (Properties) dProps;
}
Also used : DeploymentProperties(org.glassfish.deployment.common.DeploymentProperties) Properties(java.util.Properties) DeploymentProperties(org.glassfish.deployment.common.DeploymentProperties) Application(com.sun.enterprise.config.serverbeans.Application)

Example 23 with Application

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

the class InboundRecoveryHandler method recoverInboundTransactions.

private void recoverInboundTransactions(List<XAResource> xaresList) {
    List<Application> applications = deployedApplications.getApplications();
    try {
        _logger.log(Level.INFO, "Recovery of Inbound Transactions started.");
        if (applications.size() == 0) {
            _logger.log(Level.FINE, "No applications deployed.");
            return;
        }
        // List of CMT enabled MDB descriptors on the application server instance.
        List<EjbDescriptor> xaEnabledMDBList = new ArrayList<EjbDescriptor>();
        // Done so as to initialize connectors-runtime before loading inbound active RA. need a better way ?
        ConnectorRuntime cr = connectorRuntimeProvider.get();
        for (Application application : applications) {
            Vector ejbDescVec = getEjbDescriptors(application, appsRegistry);
            for (int j = 0; j < ejbDescVec.size(); j++) {
                EjbDescriptor desc = (EjbDescriptor) ejbDescVec.elementAt(j);
                // add it to the list of xaEnabledMDBList.
                if (desc instanceof EjbMessageBeanDescriptor && desc.getTransactionType().equals(EjbDescriptor.CONTAINER_TRANSACTION_TYPE)) {
                    xaEnabledMDBList.add(desc);
                    _logger.log(Level.FINE, "Found a CMT MDB: " + desc.getEjbClassName());
                }
            }
        }
        if (xaEnabledMDBList.size() == 0) {
            _logger.log(Level.FINE, "Found no CMT MDBs in all applications");
            return;
        }
        ConnectorRegistry creg = ConnectorRegistry.getInstance();
        // for each RA (key in the map) get the list (value) of MDB Descriptors
        Map<String, List<EjbDescriptor>> mappings = createRAEjbMapping(xaEnabledMDBList);
        // For each RA
        for (Map.Entry entry : mappings.entrySet()) {
            String raMid = (String) entry.getKey();
            List<EjbDescriptor> respectiveDesc = mappings.get(raMid);
            try {
                createActiveResourceAdapter(raMid);
            } catch (Exception ex) {
                _logger.log(Level.SEVERE, "error.loading.connector.resources.during.recovery", raMid);
                if (_logger.isLoggable(Level.FINE)) {
                    _logger.log(Level.FINE, ex.toString(), ex);
                }
            }
            ActiveInboundResourceAdapter activeInboundRA = (ActiveInboundResourceAdapter) creg.getActiveResourceAdapter(raMid);
            // assert activeInboundRA instanceof ActiveInboundResourceAdapter;
            boolean isSystemJmsRA = false;
            if (ConnectorsUtil.isJMSRA(activeInboundRA.getModuleName())) {
                isSystemJmsRA = true;
            }
            javax.resource.spi.ResourceAdapter resourceAdapter = activeInboundRA.getResourceAdapter();
            // activationSpecList represents the ActivationSpec[] that would be
            // sent to the getXAResources() method.
            ArrayList<ActivationSpec> activationSpecList = new ArrayList<ActivationSpec>();
            try {
                for (int i = 0; i < respectiveDesc.size(); i++) {
                    try {
                        // Get a MessageBeanDescriptor from respectiveDesc ArrayList
                        EjbMessageBeanDescriptor descriptor = (EjbMessageBeanDescriptor) respectiveDesc.get(i);
                        // to be updated J2EE 1.4 style props.
                        if (isSystemJmsRA) {
                            // XXX: Find out the pool descriptor corres to MDB and update
                            // MDBRuntimeInfo with that.
                            activeInboundRA.updateMDBRuntimeInfo(descriptor, null);
                        }
                        // Get the ActivationConfig Properties from the MDB Descriptor
                        Set activationConfigProps = RARUtils.getMergedActivationConfigProperties(descriptor);
                        // get message listener type
                        String msgListenerType = descriptor.getMessageListenerType();
                        // start resource adapter and get ActivationSpec class for
                        // the given message listener type from the ConnectorRuntime
                        ActivationSpec aspec = (ActivationSpec) (Class.forName(cr.getActivationSpecClass(raMid, msgListenerType), false, resourceAdapter.getClass().getClassLoader()).newInstance());
                        aspec.setResourceAdapter(resourceAdapter);
                        // Populate ActivationSpec class with ActivationConfig properties
                        SetMethodAction sma = new SetMethodAction(aspec, activationConfigProps);
                        sma.run();
                        activationSpecList.add(aspec);
                    } catch (Exception e) {
                        _logger.log(Level.WARNING, "error.creating.activationspec", e.getMessage());
                        if (_logger.isLoggable(Level.FINE)) {
                            _logger.log(Level.FINE, e.toString(), e);
                        }
                    }
                }
                // Get XA resources from RA.
                ActivationSpec[] activationSpecArray = activationSpecList.toArray(new ActivationSpec[activationSpecList.size()]);
                XAResource[] xar = resourceAdapter.getXAResources(activationSpecArray);
                // Add the resources to the xaresList which is used by the RecoveryManager
                if (xar != null) {
                    for (int p = 0; p < xar.length; p++) {
                        xaresList.add(xar[p]);
                    }
                }
            // Catch UnsupportedOperationException if a RA does not support XA
            // which is fine.
            } catch (UnsupportedOperationException uoex) {
                _logger.log(Level.FINE, uoex.getMessage());
            // otherwise catch the unexpected exception
            } catch (Exception e) {
                _logger.log(Level.SEVERE, "exception.during.inbound.resource.acqusition", e);
            }
        }
    } catch (Exception e) {
        _logger.log(Level.SEVERE, "exception.during.inbound.recovery", e);
    }
}
Also used : Set(java.util.Set) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ConnectorRegistry(com.sun.enterprise.connectors.ConnectorRegistry) Vector(java.util.Vector) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) XAResource(javax.transaction.xa.XAResource) EjbMessageBeanDescriptor(com.sun.enterprise.deployment.EjbMessageBeanDescriptor) ActivationSpec(javax.resource.spi.ActivationSpec) Application(com.sun.enterprise.config.serverbeans.Application) HashMap(java.util.HashMap) Map(java.util.Map) ConnectorRuntime(com.sun.appserv.connectors.internal.api.ConnectorRuntime) SetMethodAction(com.sun.enterprise.connectors.util.SetMethodAction)

Example 24 with Application

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

the class JdbcRecoveryResourceHandler method getAllJdbcResources.

private Collection<JdbcResource> getAllJdbcResources() {
    Collection<JdbcResource> allResources = new ArrayList<JdbcResource>();
    Collection<JdbcResource> jdbcResources = domain.getResources().getResources(JdbcResource.class);
    allResources.addAll(jdbcResources);
    for (Application app : applications.getApplications()) {
        if (ResourcesUtil.createInstance().isEnabled(app)) {
            Resources appScopedResources = app.getResources();
            if (appScopedResources != null && appScopedResources.getResources() != null) {
                allResources.addAll(appScopedResources.getResources(JdbcResource.class));
            }
            List<Module> modules = app.getModule();
            if (modules != null) {
                for (Module module : modules) {
                    Resources msr = module.getResources();
                    if (msr != null && msr.getResources() != null) {
                        allResources.addAll(msr.getResources(JdbcResource.class));
                    }
                }
            }
        }
    }
    return allResources;
}
Also used : JdbcResource(org.glassfish.jdbc.config.JdbcResource) ArrayList(java.util.ArrayList) Resources(com.sun.enterprise.config.serverbeans.Resources) Module(com.sun.enterprise.config.serverbeans.Module) Application(com.sun.enterprise.config.serverbeans.Application)

Example 25 with Application

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

the class GetRelativeJWSURICommand method execute.

@Override
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    final Application app = apps.getApplication(appname);
    if (app != null) {
        Module appClient = app.getModule(modulename);
        if (appClient == null) {
            appClient = app.getModule(modulename + ".jar");
        }
        if (appClient != null) {
            String result = appClient.getPropertyValue("jws.user.friendly.path");
            /*
                 * For stand-alone app clients the property is stored at the
                 * application level instead of the module level.
                 */
            if (result == null) {
                result = app.getPropertyValue("jws.user.friendly.path");
            }
            if (result != null) {
                report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
                report.getTopMessagePart().addProperty(URI_PROPERTY_NAME, result);
                report.setMessage(result);
                return;
            }
        }
    }
    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    report.setMessage(localStrings.getLocalString(this.getClass(), "getreljwsuri.appOrModuleNotFound", "Could not find application {0}, module {1}", new Object[] { appname, modulename }));
}
Also used : ActionReport(org.glassfish.api.ActionReport) Module(com.sun.enterprise.config.serverbeans.Module) Application(com.sun.enterprise.config.serverbeans.Application)

Aggregations

Application (com.sun.enterprise.config.serverbeans.Application)44 Module (com.sun.enterprise.config.serverbeans.Module)10 ApplicationRef (com.sun.enterprise.config.serverbeans.ApplicationRef)9 ActionReport (org.glassfish.api.ActionReport)9 ArrayList (java.util.ArrayList)8 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)7 Property (org.jvnet.hk2.config.types.Property)7 Applications (com.sun.enterprise.config.serverbeans.Applications)6 PropertyVetoException (java.beans.PropertyVetoException)6 HashMap (java.util.HashMap)5 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)5 Test (org.junit.Test)4 Server (com.sun.enterprise.config.serverbeans.Server)3 SystemApplications (com.sun.enterprise.config.serverbeans.SystemApplications)3 HashSet (java.util.HashSet)3 Iterator (java.util.Iterator)3 List (java.util.List)3 Logger (java.util.logging.Logger)3 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)3 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)3