Search in sources :

Example 11 with IiopListener

use of org.glassfish.orb.admin.config.IiopListener in project Payara by payara.

the class CreateIiopListener method execute.

/**
 * Executes the command with the command parameters passed as Properties
 * where the keys are the parameter names and the values the parameter values
 *
 * @param context information
 */
@Override
public void execute(AdminCommandContext context) {
    final Target targetUtil = services.getService(Target.class);
    final Config config = targetUtil.getConfig(target);
    final ActionReport report = context.getActionReport();
    IiopService iiopService = config.getExtensionByType(IiopService.class);
    // check port uniqueness, only for same address
    for (IiopListener listener : iiopService.getIiopListener()) {
        if (listener.getId().equals(listener_id)) {
            String ls = localStrings.getLocalString("create.iiop.listener.duplicate", "IIOP Listener named {0} already exists.", listener_id);
            report.setMessage(ls);
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
        if (listener.getAddress().trim().equals(listeneraddress) && listener.getPort().trim().equals((iiopport))) {
            String def = "Port [{0}] is already taken by another listener: " + "[{1}] for address [{2}], choose another port.";
            String ls = localStrings.getLocalString("create.iiop.listener.port.occupied", def, iiopport, listener.getId(), listeneraddress);
            report.setMessage(ls);
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
    }
    try {
        ConfigSupport.apply(new SingleConfigCode<IiopService>() {

            @Override
            public Object run(IiopService param) throws PropertyVetoException, TransactionFailure {
                IiopListener newListener = param.createChild(IiopListener.class);
                newListener.setId(listener_id);
                newListener.setAddress(listeneraddress);
                newListener.setPort(iiopport);
                newListener.setSecurityEnabled(securityenabled.toString());
                newListener.setEnabled(enabled.toString());
                newListener.setLazyInit(Boolean.toString(lazyInit));
                // add properties
                if (properties != null) {
                    for (java.util.Map.Entry entry : properties.entrySet()) {
                        Property property = newListener.createChild(Property.class);
                        property.setName((String) entry.getKey());
                        property.setValue((String) entry.getValue());
                        newListener.getProperty().add(property);
                    }
                }
                param.getIiopListener().add(newListener);
                return newListener;
            }
        }, iiopService);
        report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    } catch (TransactionFailure e) {
        String actual = e.getMessage();
        String def = "Creation of: " + listener_id + "failed because of: " + actual;
        String msg = localStrings.getLocalString("create.iiop.listener.fail", def, listener_id, actual);
        report.setMessage(msg);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(e);
    }
}
Also used : IiopListener(org.glassfish.orb.admin.config.IiopListener) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) Config(com.sun.enterprise.config.serverbeans.Config) ActionReport(org.glassfish.api.ActionReport) PropertyVetoException(java.beans.PropertyVetoException) Target(org.glassfish.internal.api.Target) CommandTarget(org.glassfish.config.support.CommandTarget) IiopService(org.glassfish.orb.admin.config.IiopService) Property(org.jvnet.hk2.config.types.Property)

Example 12 with IiopListener

use of org.glassfish.orb.admin.config.IiopListener in project Payara by payara.

the class ListIiopListeners method execute.

/**
 * Executes the command
 *
 * @param context information
 */
@Override
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    final Target targetUtil = services.getService(Target.class);
    final Config config = targetUtil.getConfig(target);
    final IiopService iiopService = config.getExtensionByType(IiopService.class);
    try {
        List<IiopListener> listenerList = iiopService.getIiopListener();
        for (IiopListener listener : listenerList) {
            final ActionReport.MessagePart part = report.getTopMessagePart().addChild();
            part.setMessage(listener.getId());
        }
        report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    } catch (Exception e) {
        report.setMessage(localStrings.getLocalString("list.iiop.listener" + ".fail", "List IIOP listeners failed."));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(e);
    }
}
Also used : IiopListener(org.glassfish.orb.admin.config.IiopListener) Target(org.glassfish.internal.api.Target) CommandTarget(org.glassfish.config.support.CommandTarget) Config(com.sun.enterprise.config.serverbeans.Config) IiopService(org.glassfish.orb.admin.config.IiopService) ActionReport(org.glassfish.api.ActionReport)

Example 13 with IiopListener

use of org.glassfish.orb.admin.config.IiopListener in project Payara by payara.

the class IiopSslConfigHandler method create.

@Override
public void create(final CreateSsl command, ActionReport report) {
    IiopService iiopService = command.config.getExtensionByType(IiopService.class);
    // ensure we have the specified listener
    IiopListener iiopListener = null;
    for (IiopListener listener : iiopService.getIiopListener()) {
        if (listener.getId().equals(command.listenerId)) {
            iiopListener = listener;
        }
    }
    if (iiopListener == null) {
        report.setMessage(localStrings.getLocalString("create.ssl.iiop.notfound", "IIOP Listener named {0} to which this ssl element is " + "being added does not exist.", command.listenerId));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    if (iiopListener.getSsl() != null) {
        report.setMessage(localStrings.getLocalString("create.ssl.iiop.alreadyExists", "IIOP Listener named {0} to which this ssl element is " + "being added already has an ssl element.", command.listenerId));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    try {
        ConfigSupport.apply(new SingleConfigCode<IiopListener>() {

            public Object run(IiopListener param) throws PropertyVetoException, TransactionFailure {
                Ssl newSsl = param.createChild(Ssl.class);
                command.populateSslElement(newSsl);
                param.setSsl(newSsl);
                return newSsl;
            }
        }, iiopListener);
    } catch (TransactionFailure e) {
        command.reportError(report, e);
    }
    command.reportSuccess(report);
}
Also used : IiopListener(org.glassfish.orb.admin.config.IiopListener) PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) IiopService(org.glassfish.orb.admin.config.IiopService) CreateSsl(com.sun.enterprise.admin.commands.CreateSsl) DeleteSsl(com.sun.enterprise.admin.commands.DeleteSsl) Ssl(org.glassfish.grizzly.config.dom.Ssl)

Example 14 with IiopListener

use of org.glassfish.orb.admin.config.IiopListener in project Payara by payara.

the class IiopSslConfigHandler method delete.

@Override
public void delete(DeleteSsl command, ActionReport report) {
    IiopService iiopService = command.config.getExtensionByType(IiopService.class);
    IiopListener iiopListener = null;
    for (IiopListener listener : iiopService.getIiopListener()) {
        if (listener.getId().equals(command.listenerId)) {
            iiopListener = listener;
        }
    }
    if (iiopListener == null) {
        report.setMessage(localStrings.getLocalString("delete.ssl.iiop.listener.notfound", "Iiop Listener named {0} not found", command.listenerId));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    if (iiopListener.getSsl() == null) {
        report.setMessage(localStrings.getLocalString("delete.ssl.element.doesnotexist", "Ssl element does " + "not exist for Listener named {0}", command.listenerId));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    try {
        ConfigSupport.apply(new SingleConfigCode<IiopListener>() {

            public Object run(IiopListener param) throws PropertyVetoException {
                param.setSsl(null);
                return null;
            }
        }, iiopListener);
    } catch (TransactionFailure e) {
        command.reportError(report, e);
    }
}
Also used : IiopListener(org.glassfish.orb.admin.config.IiopListener) PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) IiopService(org.glassfish.orb.admin.config.IiopService)

Example 15 with IiopListener

use of org.glassfish.orb.admin.config.IiopListener in project Payara by payara.

the class CreateIiopListenerTest method testExecuteSuccessDefaultValues.

/**
 * Test of execute method, of class CreateIiopListener.
 * asadmin create-iiop-listener --listeneraddress localhost
 * --iiopport 4440 iiop_1
 */
@Test
public void testExecuteSuccessDefaultValues() {
    parameters.set("listeneraddress", "localhost");
    parameters.set("iiopport", "4440");
    parameters.set("listener_id", "iiop_1");
    CreateIiopListener command = services.getService(CreateIiopListener.class);
    cr.getCommandInvocation("create-iiop-listener", context.getActionReport(), adminSubject()).parameters(parameters).execute(command);
    checkActionReport(context.getActionReport());
    boolean isCreated = false;
    List<IiopListener> listenerList = iiopService.getIiopListener();
    for (IiopListener listener : listenerList) {
        if (listener.getId().equals("iiop_1")) {
            assertEquals("localhost", listener.getAddress());
            assertEquals("4440", listener.getPort());
            isCreated = true;
            logger.fine("IIOPListener name iiop_1 is created.");
            break;
        }
    }
    assertTrue(isCreated);
    logger.fine("msg: " + context.getActionReport().getMessage());
}
Also used : IiopListener(org.glassfish.orb.admin.config.IiopListener) Test(org.junit.Test)

Aggregations

IiopListener (org.glassfish.orb.admin.config.IiopListener)24 IiopService (org.glassfish.orb.admin.config.IiopService)9 Test (org.junit.Test)7 PropertyVetoException (java.beans.PropertyVetoException)5 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)5 ParameterMap (org.glassfish.api.admin.ParameterMap)4 Config (com.sun.enterprise.config.serverbeans.Config)3 ActionReport (org.glassfish.api.ActionReport)3 CommandTarget (org.glassfish.config.support.CommandTarget)3 Ssl (org.glassfish.grizzly.config.dom.Ssl)3 Target (org.glassfish.internal.api.Target)3 List (java.util.List)2 TransientNameService (com.sun.corba.ee.impl.naming.cosnaming.TransientNameService)1 ClusterInstanceInfo (com.sun.corba.ee.spi.folb.ClusterInstanceInfo)1 SocketInfo (com.sun.corba.ee.spi.folb.SocketInfo)1 NoSuchWorkQueueException (com.sun.corba.ee.spi.threadpool.NoSuchWorkQueueException)1 ThreadPool (com.sun.corba.ee.spi.threadpool.ThreadPool)1 ThreadPoolManager (com.sun.corba.ee.spi.threadpool.ThreadPoolManager)1 Acceptor (com.sun.corba.ee.spi.transport.Acceptor)1 CreateSsl (com.sun.enterprise.admin.commands.CreateSsl)1