use of org.glassfish.internal.api.Target in project Payara by payara.
the class ListTransports method execute.
/**
* Executes the command with the command parameters passed as Properties where the keys are the paramter names and
* the values the parameter values
*
* @param context information
*/
public void execute(AdminCommandContext context) {
Target targetUtil = services.getService(Target.class);
Config newConfig = targetUtil.getConfig(target);
if (newConfig != null) {
config = newConfig;
}
final ActionReport report = context.getActionReport();
List<Transport> list = config.getNetworkConfig().getTransports().getTransport();
for (Transport transport : list) {
report.getTopMessagePart().addChild().setMessage(transport.getName());
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of org.glassfish.internal.api.Target in project Payara by payara.
the class ResourceUtil method deleteResourceRef.
public void deleteResourceRef(String jndiName, String target) throws TransactionFailure {
if (target.equals(DOMAIN)) {
return;
}
Config config = domain.getConfigNamed(target);
if (config != null) {
config.deleteResourceRef(jndiName);
} else {
Server server = configBeansUtilities.getServerNamed(target);
if (server != null) {
if (server.isResourceRefExists(jndiName)) {
// delete ResourceRef for Server
server.deleteResourceRef(jndiName);
}
} else {
Cluster cluster = domain.getClusterNamed(target);
if (cluster != null) {
if (cluster.isResourceRefExists(jndiName)) {
// delete ResourceRef of Cluster
cluster.deleteResourceRef(jndiName);
// delete ResourceRef for all instances of Cluster
Target tgt = targetProvider.get();
List<Server> instances = tgt.getInstances(target);
for (Server svr : instances) {
if (svr.isResourceRefExists(jndiName)) {
svr.deleteResourceRef(jndiName);
}
}
}
}
}
}
}
use of org.glassfish.internal.api.Target 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 org.glassfish.internal.api.Target 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);
}
}
use of org.glassfish.internal.api.Target 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);
}
}
Aggregations