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);
}
}
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.");
}
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);
}
}
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);
}
}
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();
}
Aggregations