Search in sources :

Example 81 with Server

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

the class DomainXml method decorate.

protected void decorate() {
    Server server = habitat.getService(Server.class, env.getInstanceName());
    if (server == null) {
        LogRecord lr = new LogRecord(Level.SEVERE, badEnv);
        lr.setLoggerName(getClass().getName());
        EarlyLogHandler.earlyMessages.add(lr);
        return;
    }
    ServiceLocatorUtilities.addOneConstant(habitat, server, ServerEnvironment.DEFAULT_INSTANCE_NAME, Server.class);
    server.getConfig().addIndex(habitat, ServerEnvironment.DEFAULT_INSTANCE_NAME);
    Cluster c = server.getCluster();
    if (c != null) {
        ServiceLocatorUtilities.addOneConstant(habitat, c, ServerEnvironment.DEFAULT_INSTANCE_NAME, Cluster.class);
    }
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server) LogRecord(java.util.logging.LogRecord) Cluster(com.sun.enterprise.config.serverbeans.Cluster)

Example 82 with Server

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

the class AttributeRemovalTest method deprecatedWrite.

@Test
public void deprecatedWrite() throws TransactionFailure {
    final Server server = getHabitat().getService(Server.class);
    final String value = server.getNodeRef();
    logger.fine("node-ref is " + server.getNodeRef());
    ConfigSupport.apply(new SingleConfigCode<Server>() {

        @Override
        public Object run(Server s) throws PropertyVetoException, TransactionFailure {
            s.setNodeAgentRef(value);
            return null;
        }
    }, server);
    logger.fine("node-agent-ref is " + server.getNodeAgentRef());
    // restore
    ConfigSupport.apply(new SingleConfigCode<Server>() {

        @Override
        public Object run(Server s) throws PropertyVetoException, TransactionFailure {
            s.setNodeAgentRef(null);
            return null;
        }
    }, server);
    logger.fine("after, node-agent-ref is " + server.getNodeAgentRef());
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) Server(com.sun.enterprise.config.serverbeans.Server) VirtualServer(com.sun.enterprise.config.serverbeans.VirtualServer) Test(org.junit.Test)

Example 83 with Server

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

the class AttributeRemovalTest method readOnlyRemovalTest.

@Test(expected = PropertyVetoException.class)
public void readOnlyRemovalTest() throws TransactionFailure, PropertyVetoException {
    Server server = getHabitat().getService(Server.class);
    logger.fine("config-ref is " + server.getConfigRef());
    try {
        server.setConfigRef(null);
    } catch (PropertyVetoException e) {
        if (logger.isLoggable(Level.FINE))
            e.printStackTrace();
        throw e;
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) Server(com.sun.enterprise.config.serverbeans.Server) VirtualServer(com.sun.enterprise.config.serverbeans.VirtualServer) Test(org.junit.Test)

Example 84 with Server

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

the class ConfigApiTest method decorate.

@Override
public void decorate(ServiceLocator habitat) {
    Server server = habitat.getService(Server.class, "server");
    if (server != null) {
        ActiveDescriptor<Server> serverDescriptor = BuilderHelper.createConstantDescriptor(server, ServerEnvironment.DEFAULT_INSTANCE_NAME, Server.class);
        ServiceLocatorUtilities.addOneDescriptor(habitat, serverDescriptor);
        server.getConfig().addIndex(habitat, ServerEnvironment.DEFAULT_INSTANCE_NAME);
        Cluster c = server.getCluster();
        if (c != null) {
            ActiveDescriptor<Cluster> clusterDescriptor = BuilderHelper.createConstantDescriptor(c, ServerEnvironment.DEFAULT_INSTANCE_NAME, Cluster.class);
            ServiceLocatorUtilities.addOneDescriptor(habitat, clusterDescriptor);
        }
    }
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server) Cluster(com.sun.enterprise.config.serverbeans.Cluster)

Example 85 with Server

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

the class GetGroupNamesCommand method execute.

@Override
public void execute(AdminCommandContext context) {
    Config tmp = null;
    try {
        tmp = configs.getConfigByName(target);
    } catch (Exception ex) {
    }
    if (tmp != null) {
        config = tmp;
    }
    if (tmp == null) {
        Server targetServer = domain.getServerNamed(target);
        if (targetServer != null) {
            config = domain.getConfigNamed(targetServer.getConfigRef());
        }
        com.sun.enterprise.config.serverbeans.Cluster cluster = domain.getClusterNamed(target);
        if (cluster != null) {
            config = domain.getConfigNamed(cluster.getConfigRef());
        }
    }
    ActionReporter report = (ActionReporter) context.getActionReport();
    try {
        String[] list = getGroupNames(realmName, userName);
        List<String> ret = Arrays.asList(list);
        report.setActionExitCode(ExitCode.SUCCESS);
        Properties props = new Properties();
        props.put("groups", ret);
        report.setExtraProperties(props);
        report.setMessage("" + ret);
    } catch (NoSuchRealmException ex) {
        report.setFailureCause(ex);
        report.setActionExitCode(ExitCode.FAILURE);
    } catch (BadRealmException ex) {
        report.setFailureCause(ex);
        report.setActionExitCode(ExitCode.FAILURE);
    } catch (InvalidOperationException ex) {
        report.setFailureCause(ex);
        report.setActionExitCode(ExitCode.FAILURE);
    } catch (NoSuchUserException ex) {
        report.setFailureCause(ex);
        report.setActionExitCode(ExitCode.FAILURE);
    }
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server) Config(com.sun.enterprise.config.serverbeans.Config) NoSuchUserException(com.sun.enterprise.security.auth.realm.NoSuchUserException) Properties(java.util.Properties) BadRealmException(com.sun.enterprise.security.auth.realm.BadRealmException) NoSuchRealmException(com.sun.enterprise.security.auth.realm.NoSuchRealmException) InvalidOperationException(com.sun.enterprise.security.auth.realm.InvalidOperationException) NoSuchUserException(com.sun.enterprise.security.auth.realm.NoSuchUserException) NoSuchRealmException(com.sun.enterprise.security.auth.realm.NoSuchRealmException) BadRealmException(com.sun.enterprise.security.auth.realm.BadRealmException) InvalidOperationException(com.sun.enterprise.security.auth.realm.InvalidOperationException) ActionReporter(com.sun.enterprise.v3.common.ActionReporter)

Aggregations

Server (com.sun.enterprise.config.serverbeans.Server)86 ActionReport (org.glassfish.api.ActionReport)27 Cluster (com.sun.enterprise.config.serverbeans.Cluster)26 Domain (com.sun.enterprise.config.serverbeans.Domain)16 Config (com.sun.enterprise.config.serverbeans.Config)15 ArrayList (java.util.ArrayList)12 DeploymentGroup (fish.payara.enterprise.config.serverbeans.DeploymentGroup)11 PropertyVetoException (java.beans.PropertyVetoException)11 Properties (java.util.Properties)10 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)10 HashMap (java.util.HashMap)9 ApplicationRef (com.sun.enterprise.config.serverbeans.ApplicationRef)8 File (java.io.File)8 IOException (java.io.IOException)8 Test (org.junit.Test)8 Property (org.jvnet.hk2.config.types.Property)8 Node (com.sun.enterprise.config.serverbeans.Node)7 Map (java.util.Map)7 Logger (java.util.logging.Logger)7 ParameterMap (org.glassfish.api.admin.ParameterMap)7