Search in sources :

Example 41 with Domain

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

the class ConnectorMessageBeanClient method getActivationName.

/**
 * {@inheritDoc}
 * @Override
 */
public String getActivationName() {
    if (activationName == null) {
        String appName = descriptor_.getApplication().getName();
        String moduleID = descriptor_.getEjbBundleDescriptor().getModuleID();
        int pound = moduleID.indexOf('#');
        if (pound >= 0) {
            // the module ID is in the format: appName#ejbName.jar
            // remove the appName part since it is duplicated
            moduleID = moduleID.substring(pound + 1);
        }
        String mdbClassName = descriptor_.getEjbClassName();
        ServerEnvironmentImpl env = Globals.get(ServerEnvironmentImpl.class);
        String instanceName = env.getInstanceName();
        Domain domain = Globals.get(Domain.class);
        String domainName = domain.getName();
        Cluster cluster = domain.getServerNamed(instanceName).getCluster();
        String clusterName = null;
        if (cluster != null) {
            // this application is deployed in a cluster
            clusterName = cluster.getName();
        }
        if (clusterName != null) {
            // this application is deployed in a cluster
            activationName = combineString(domainName, clusterName, appName, moduleID, mdbClassName);
        } else {
            // this application is deployed in a stand-alone server instance.
            activationName = combineString(domainName, instanceName, appName, moduleID, mdbClassName);
        }
    }
    return activationName;
}
Also used : ServerEnvironmentImpl(org.glassfish.server.ServerEnvironmentImpl) Cluster(com.sun.enterprise.config.serverbeans.Cluster) Domain(com.sun.enterprise.config.serverbeans.Domain) MessageEndpoint(javax.resource.spi.endpoint.MessageEndpoint)

Example 42 with Domain

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

the class ManagedConnectionImpl method getJdbcConnectionPool.

private static JdbcConnectionPool getJdbcConnectionPool(javax.resource.spi.ManagedConnectionFactory mcf) {
    if (Globals.getDefaultHabitat().getService(ProcessEnvironment.class).getProcessType() != ProcessEnvironment.ProcessType.Server) {
        // otherwise we bave no domain to draw upon
        return null;
    }
    ManagedConnectionFactoryImpl spiMCF = (ManagedConnectionFactoryImpl) mcf;
    Resources resources = Globals.getDefaultHabitat().getService(Domain.class).getResources();
    ResourcePool pool = (ResourcePool) ConnectorsUtil.getResourceByName(resources, ResourcePool.class, spiMCF.getPoolName());
    if (pool instanceof JdbcConnectionPool) {
        return (JdbcConnectionPool) pool;
    }
    return null;
}
Also used : JdbcConnectionPool(org.glassfish.jdbc.config.JdbcConnectionPool) ResourcePool(com.sun.enterprise.config.serverbeans.ResourcePool) Resources(com.sun.enterprise.config.serverbeans.Resources) Domain(com.sun.enterprise.config.serverbeans.Domain)

Example 43 with Domain

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

the class ListJndiResourcesTest method setUp.

@Before
public void setUp() {
    habitat = getHabitat();
    cr = habitat.getService(CommandRunner.class);
    context = new AdminCommandContextImpl(LogDomains.getLogger(ListJndiResourcesTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
    parameters = new ParameterMap();
    Resources resources = habitat.<Domain>getService(Domain.class).getResources();
    for (Resource resource : resources.getResources()) {
        if (resource instanceof org.glassfish.resources.config.ExternalJndiResource) {
            origNum = origNum + 1;
        }
    }
}
Also used : AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) Resource(com.sun.enterprise.config.serverbeans.Resource) ParameterMap(org.glassfish.api.admin.ParameterMap) Resources(com.sun.enterprise.config.serverbeans.Resources) PropsFileActionReporter(com.sun.enterprise.admin.report.PropsFileActionReporter) Domain(com.sun.enterprise.config.serverbeans.Domain) CommandRunner(org.glassfish.api.admin.CommandRunner) Before(org.junit.Before)

Example 44 with Domain

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

the class SecurityConfigUpgradeService method postConstruct.

@Override
public void postConstruct() {
    if (domain.getExtensionByType(SecurityConfigurations.class) != null) {
        /*
             * The domain already contains a security-configurations setting,
             * so for now that's sufficient to conclude we don't need to upgrade.
             */
        logger.log(Level.INFO, "SecurityConfigUpgradeService bypassing - security-configurations already present");
        return;
    }
    Transaction t = null;
    try {
        t = new Transaction();
        final Domain domain_w = t.enroll(domain);
        /*
             * Create the security configurations element and add it to the domain.
             */
        final SecurityConfigurations sc_w = domain_w.createChild(SecurityConfigurations.class);
        domain_w.getExtensions().add(sc_w);
        /*
             * Create and add the authentication service.
             */
        final AuthenticationService as_w = addAuthenticationService(sc_w);
        /*
             * Next, add the two providers and their children.
             */
        addAdmRealmProvider(as_w);
        addFileRealmProvider(as_w);
        /**
         * Next add the authorization service
         */
        final AuthorizationService authorizationService = addAuthorizationService(sc_w);
        /**
         * Next add the authorization service provider
         */
        addSimpleAuthorizationProvider(authorizationService);
        t.commit();
        logger.log(Level.INFO, "SecurityConfigUpgradeService successfully completed the upgrade");
    } catch (Exception ex) {
        if (t != null) {
            t.rollback();
        }
        logger.log(Level.SEVERE, null, ex);
    }
}
Also used : Transaction(org.jvnet.hk2.config.Transaction) Domain(com.sun.enterprise.config.serverbeans.Domain) PropertyVetoException(java.beans.PropertyVetoException)

Example 45 with Domain

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

the class DeleteModuleConfigCommand method deleteTopLevelExtensionByType.

private void deleteTopLevelExtensionByType(Config config, final String className, Class configBeanType) {
    if (ConfigExtension.class.isAssignableFrom(configBeanType)) {
        if (config.checkIfExtensionExists(configBeanType)) {
            try {
                ConfigSupport.apply(new SingleConfigCode<Config>() {

                    @Override
                    public Object run(Config param) throws PropertyVetoException, TransactionFailure {
                        List<ConfigExtension> configExtensions;
                        configExtensions = param.getExtensions();
                        for (ConfigExtension ext : configExtensions) {
                            String configExtensionClass = GlassFishConfigBean.unwrap(ext).getProxyType().getSimpleName();
                            if (configExtensionClass.equals(className)) {
                                configExtensions.remove(ext);
                                break;
                            }
                        }
                        return configExtensions;
                    }
                }, config);
                report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
            } catch (TransactionFailure e) {
                String actual = e.getMessage();
                String msg = localStrings.getLocalString("delete.module.config.failed.to.delete.config", DEFAULT_FORMAT, serviceName, actual);
                report.setMessage(msg);
                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                report.setFailureCause(e);
            }
        } else {
            report.setMessage(localStrings.getLocalString("delete.module.config.no.configuration", "No customized configuration exist for this service nor the default configuration has been added to the domain.xml."));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        }
    } else if (DomainExtension.class.isAssignableFrom(configBeanType)) {
        if (domain.checkIfExtensionExists(configBeanType)) {
            try {
                ConfigSupport.apply(new SingleConfigCode<Domain>() {

                    @Override
                    public Object run(Domain param) throws PropertyVetoException, TransactionFailure {
                        List<DomainExtension> domainExtensions;
                        domainExtensions = param.getExtensions();
                        for (DomainExtension ext : domainExtensions) {
                            String configExtensionClass = GlassFishConfigBean.unwrap(ext).getProxyType().getSimpleName();
                            if (configExtensionClass.equals(className)) {
                                domainExtensions.remove(ext);
                                break;
                            }
                        }
                        return domainExtensions;
                    }
                }, domain);
                report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
            } catch (TransactionFailure e) {
                String actual = e.getMessage();
                String msg = localStrings.getLocalString("delete.module.config.failed.to.delete.config", DEFAULT_FORMAT, serviceName, actual);
                report.setMessage(msg);
                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                report.setFailureCause(e);
            }
        } else {
            report.setMessage(localStrings.getLocalString("delete.module.config.no.configuration", "No customized configuration exist for this service nor the default configuration has been added to the domain.xml."));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        }
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) SingleConfigCode(org.jvnet.hk2.config.SingleConfigCode) Config(com.sun.enterprise.config.serverbeans.Config) ConfigExtension(org.glassfish.api.admin.config.ConfigExtension) DomainExtension(com.sun.enterprise.config.serverbeans.DomainExtension) PropertyVetoException(java.beans.PropertyVetoException) List(java.util.List) Domain(com.sun.enterprise.config.serverbeans.Domain)

Aggregations

Domain (com.sun.enterprise.config.serverbeans.Domain)70 Test (org.junit.Test)21 Server (com.sun.enterprise.config.serverbeans.Server)15 ConfigApiTest (com.sun.enterprise.configapi.tests.ConfigApiTest)12 Dom (org.jvnet.hk2.config.Dom)11 PropertyVetoException (java.beans.PropertyVetoException)10 Cluster (com.sun.enterprise.config.serverbeans.Cluster)7 Resources (com.sun.enterprise.config.serverbeans.Resources)7 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)7 ServerContext (org.glassfish.internal.api.ServerContext)7 Config (com.sun.enterprise.config.serverbeans.Config)6 Resource (com.sun.enterprise.config.serverbeans.Resource)6 ParameterMap (org.glassfish.api.admin.ParameterMap)6 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)6 DeploymentGroup (fish.payara.enterprise.config.serverbeans.DeploymentGroup)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Before (org.junit.Before)5 ConfigModel (org.jvnet.hk2.config.ConfigModel)5 PropsFileActionReporter (com.sun.enterprise.admin.report.PropsFileActionReporter)4