Search in sources :

Example 86 with PropertyVetoException

use of java.beans.PropertyVetoException in project Payara by payara.

the class BaseMonitoringNotifierConfigurer method execute.

@Override
public void execute(AdminCommandContext context) {
    final ActionReport actionReport = context.getActionReport();
    Properties extraProperties = actionReport.getExtraProperties();
    if (extraProperties == null) {
        extraProperties = new Properties();
        actionReport.setExtraProperties(extraProperties);
    }
    Config config = targetUtil.getConfig(target);
    final MonitoringServiceConfiguration configuration = config.getExtensionByType(MonitoringServiceConfiguration.class);
    ParameterizedType genericSuperclass = (ParameterizedType) getClass().getGenericSuperclass();
    notifierClass = (Class<C>) genericSuperclass.getActualTypeArguments()[0];
    C c = configuration.getNotifierByType(notifierClass);
    try {
        if (c == null) {
            ConfigSupport.apply(new SingleConfigCode<MonitoringServiceConfiguration>() {

                @Override
                public Object run(final MonitoringServiceConfiguration configurationProxy) throws PropertyVetoException, TransactionFailure {
                    C c = configurationProxy.createChild(notifierClass);
                    applyValues(c);
                    configurationProxy.getNotifierList().add(c);
                    actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
                    return configurationProxy;
                }
            }, configuration);
        } else {
            ConfigSupport.apply(new SingleConfigCode<C>() {

                @Override
                public Object run(C cProxy) throws PropertyVetoException, TransactionFailure {
                    applyValues(cProxy);
                    actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
                    return cProxy;
                }
            }, c);
        }
        if (dynamic) {
            if (server.isDas()) {
                if (targetUtil.getConfig(target).isDas()) {
                    configureDynamically();
                }
            } else {
                configureDynamically();
            }
        }
    } catch (TransactionFailure ex) {
        logger.log(Level.WARNING, "Exception during command ", ex);
        actionReport.setMessage(ex.getCause().getMessage());
        actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
    }
}
Also used : ParameterizedType(java.lang.reflect.ParameterizedType) PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) Config(com.sun.enterprise.config.serverbeans.Config) MonitoringServiceConfiguration(fish.payara.jmx.monitoring.configuration.MonitoringServiceConfiguration) ActionReport(org.glassfish.api.ActionReport) Properties(java.util.Properties)

Example 87 with PropertyVetoException

use of java.beans.PropertyVetoException in project Payara by payara.

the class RestMonitoringLoader method createAndRegisterApplication.

/**
 * Create the system application entry and register the application
 * @throws Exception
 */
private void createAndRegisterApplication() throws Exception {
    LOGGER.log(Level.FINE, "Registering the Rest Monitoring Application...");
    // Create the system application entry and application-ref in the config
    ConfigCode code = new ConfigCode() {

        @Override
        public Object run(ConfigBeanProxy... proxies) throws PropertyVetoException, TransactionFailure {
            // Create the system application
            SystemApplications systemApplications = (SystemApplications) proxies[0];
            Application application = systemApplications.createChild(Application.class);
            // Check if the application name is valid, generating a new one if it isn't
            checkAndResolveApplicationName(systemApplications);
            systemApplications.getModules().add(application);
            application.setName(applicationName);
            application.setEnabled(Boolean.TRUE.toString());
            application.setObjectType("system-admin");
            application.setDirectoryDeployed("true");
            application.setContextRoot(contextRoot);
            try {
                application.setLocation("${com.sun.aas.installRootURI}/lib/install/applications/" + RestMonitoringService.DEFAULT_REST_MONITORING_APP_NAME);
            } catch (Exception me) {
                throw new RuntimeException(me);
            }
            // Set the engine types
            Module singleModule = application.createChild(Module.class);
            application.getModule().add(singleModule);
            singleModule.setName(applicationName);
            Engine webEngine = singleModule.createChild(Engine.class);
            webEngine.setSniffer("web");
            Engine weldEngine = singleModule.createChild(Engine.class);
            weldEngine.setSniffer("weld");
            Engine securityEngine = singleModule.createChild(Engine.class);
            securityEngine.setSniffer("security");
            singleModule.getEngines().add(webEngine);
            singleModule.getEngines().add(weldEngine);
            singleModule.getEngines().add(securityEngine);
            // Create the application-ref
            Server s = (Server) proxies[1];
            List<ApplicationRef> arefs = s.getApplicationRef();
            ApplicationRef aref = s.createChild(ApplicationRef.class);
            aref.setRef(application.getName());
            aref.setEnabled(Boolean.TRUE.toString());
            aref.setVirtualServers(getVirtualServerListAsString());
            arefs.add(aref);
            return true;
        }
    };
    Server server = domain.getServerNamed(serverEnv.getInstanceName());
    ConfigSupport.apply(code, domain.getSystemApplications(), server);
    LOGGER.log(Level.FINE, "Rest Monitoring Application Registered.");
}
Also used : ConfigBeanProxy(org.jvnet.hk2.config.ConfigBeanProxy) Server(com.sun.enterprise.config.serverbeans.Server) ConfigCode(org.jvnet.hk2.config.ConfigCode) SystemApplications(com.sun.enterprise.config.serverbeans.SystemApplications) Module(com.sun.enterprise.config.serverbeans.Module) Application(com.sun.enterprise.config.serverbeans.Application) ApplicationRef(com.sun.enterprise.config.serverbeans.ApplicationRef) PropertyVetoException(java.beans.PropertyVetoException) Engine(com.sun.enterprise.config.serverbeans.Engine)

Example 88 with PropertyVetoException

use of java.beans.PropertyVetoException in project Payara by payara.

the class CreateHTTPLBRefCommand method addServerToLBConfig.

private void addServerToLBConfig(final LbConfigs lbconfigs, final String configName, final String serverName) {
    LbConfig lbConfig = lbconfigs.getLbConfig(configName);
    ServerRef sRef = lbConfig.getRefByRef(ServerRef.class, serverName);
    if (sRef != null) {
        String msg = localStrings.getLocalString("LBServerRefExists", "LB config already contains a server-ref for target {0}", target);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setMessage(msg);
        return;
    }
    Server server = domain.getServerNamed(serverName);
    boolean isStandAlone = server.getCluster() == null && server.isInstance();
    if (!isStandAlone) {
        String msg = localStrings.getLocalString("NotStandAloneInstance", "[{0}] is not a stand alone instance. Only stand alone instance can be added to a load balancer.", serverName);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setMessage(msg);
        return;
    }
    try {
        ConfigSupport.apply(new SingleConfigCode<LbConfig>() {

            @Override
            public Object run(LbConfig param) throws PropertyVetoException, TransactionFailure {
                ServerRef ref = param.createChild(ServerRef.class);
                ref.setRef(serverName);
                param.getClusterRefOrServerRef().add(ref);
                return Boolean.TRUE;
            }
        }, lbConfig);
    } catch (TransactionFailure ex) {
        String msg = localStrings.getLocalString("FailedToAddServerRef", "Failed to add server-ref");
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setMessage(msg);
        report.setFailureCause(ex);
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) Server(com.sun.enterprise.config.serverbeans.Server) LbConfig(org.glassfish.loadbalancer.config.LbConfig) ServerRef(com.sun.enterprise.config.serverbeans.ServerRef)

Example 89 with PropertyVetoException

use of java.beans.PropertyVetoException in project Payara by payara.

the class DeleteIiopListener 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);
    ActionReport report = context.getActionReport();
    IiopService iiopService = config.getExtensionByType(IiopService.class);
    if (!isIIOPListenerExists(iiopService)) {
        report.setMessage(localStrings.getLocalString("delete.iiop.listener" + ".notexists", "IIOP Listener {0} does not exist.", listener_id));
        report.setActionExitCode(ExitCode.FAILURE);
        return;
    }
    try {
        ConfigSupport.apply(new SingleConfigCode<IiopService>() {

            @Override
            public Object run(IiopService param) throws PropertyVetoException, TransactionFailure {
                List<IiopListener> listenerList = param.getIiopListener();
                for (IiopListener listener : listenerList) {
                    String currListenerId = listener.getId();
                    if (currListenerId != null && currListenerId.equals(listener_id)) {
                        listenerList.remove(listener);
                        break;
                    }
                }
                return listenerList;
            }
        }, iiopService);
        report.setActionExitCode(ExitCode.SUCCESS);
    } catch (TransactionFailure e) {
        String actual = e.getMessage();
        report.setMessage(localStrings.getLocalString("delete.iiop.listener.fail", "failed", listener_id, actual));
        report.setActionExitCode(ExitCode.FAILURE);
        report.setFailureCause(e);
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) 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) List(java.util.List) ActionReport(org.glassfish.api.ActionReport)

Example 90 with PropertyVetoException

use of java.beans.PropertyVetoException in project Payara by payara.

the class CreateIiopListenerTest method tearDown.

@After
public void tearDown() throws TransactionFailure {
    ConfigSupport.apply(new SingleConfigCode<IiopService>() {

        public Object run(IiopService param) throws PropertyVetoException, TransactionFailure {
            List<IiopListener> listenerList = param.getIiopListener();
            for (IiopListener listener : listenerList) {
                String currListenerId = listener.getId();
                if (currListenerId != null && currListenerId.equals("iiop_1")) {
                    listenerList.remove(listener);
                    break;
                }
            }
            return listenerList;
        }
    }, iiopService);
    parameters = new ParameterMap();
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) IiopListener(org.glassfish.orb.admin.config.IiopListener) IiopService(org.glassfish.orb.admin.config.IiopService) List(java.util.List) ParameterMap(org.glassfish.api.admin.ParameterMap) After(org.junit.After)

Aggregations

PropertyVetoException (java.beans.PropertyVetoException)342 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)118 ActionReport (org.glassfish.api.ActionReport)64 Expression (cbit.vcell.parser.Expression)41 ExpressionException (cbit.vcell.parser.ExpressionException)40 ArrayList (java.util.ArrayList)40 Config (com.sun.enterprise.config.serverbeans.Config)31 ModelException (cbit.vcell.model.ModelException)26 Structure (cbit.vcell.model.Structure)25 Property (org.jvnet.hk2.config.types.Property)25 ModelVetoException (com.sun.jdo.api.persistence.model.ModelVetoException)24 List (java.util.List)24 Model (cbit.vcell.model.Model)22 DataAccessException (org.vcell.util.DataAccessException)19 SpeciesContext (cbit.vcell.model.SpeciesContext)18 ExpressionBindingException (cbit.vcell.parser.ExpressionBindingException)18 Resources (com.sun.enterprise.config.serverbeans.Resources)18 Element (org.jdom.Element)18 MathException (cbit.vcell.math.MathException)16 IOException (java.io.IOException)16