use of org.glassfish.api.naming.DefaultResourceProxy in project Payara by payara.
the class ListJMSResources 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
*/
@Override
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
ArrayList<Map<String, String>> list = new ArrayList<>();
Properties extraProperties = new Properties();
Collection adminObjectResourceList = domain.getResources().getResources(AdminObjectResource.class);
Collection connectorResourcesList = domain.getResources().getResources(ConnectorResource.class);
Object[] connectorResources = connectorResourcesList.toArray();
Object[] adminObjectResources = adminObjectResourceList.toArray();
if (resourceType == null) {
try {
// list all JMS resources
for (Object r : adminObjectResources) {
AdminObjectResource adminObject = (AdminObjectResource) r;
if (JMSRA.equals(adminObject.getResAdapter())) {
Map<String, String> m = new HashMap<>();
m.put("name", adminObject.getJndiName());
list.add(m);
}
}
for (Object c : connectorResources) {
ConnectorResource cr = (ConnectorResource) c;
ConnectorConnectionPool cp = (ConnectorConnectionPool) ConnectorsUtil.getResourceByName(domain.getResources(), ConnectorConnectionPool.class, cr.getPoolName());
if (cp != null && JMSRA.equals(cp.getResourceAdapterName())) {
Map<String, String> m = new HashMap<>();
m.put("name", cr.getJndiName());
list.add(m);
}
}
} catch (Exception e) {
report.setMessage(localStrings.getLocalString("list.jms.resources.fail", "Unable to list JMS Resources") + " " + e.getLocalizedMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
} else {
switch(resourceType) {
case TOPIC_CF:
case QUEUE_CF:
case UNIFIED_CF:
for (Object c : connectorResources) {
ConnectorResource cr = (ConnectorResource) c;
ConnectorConnectionPool cp = (ConnectorConnectionPool) ConnectorsUtil.getResourceByName(domain.getResources(), ConnectorConnectionPool.class, cr.getPoolName());
if (cp != null && resourceType.equals(cp.getConnectionDefinitionName()) && JMSRA.equals(cp.getResourceAdapterName())) {
Map<String, String> m = new HashMap<>();
m.put("name", cr.getJndiName());
list.add(m);
}
}
break;
case TOPIC:
case QUEUE:
for (Object r : adminObjectResources) {
AdminObjectResource res = (AdminObjectResource) r;
if (resourceType.equals(res.getResType()) && JMSRA.equals(res.getResAdapter())) {
Map<String, String> m = new HashMap<>();
m.put("name", res.getJndiName());
list.add(m);
}
}
break;
}
}
if (!list.isEmpty()) {
List<Map<String, String>> resourceList = CommandTarget.DOMAIN.isValid(habitat, target) ? list : filterListForTarget(list);
List<DefaultResourceProxy> drps = habitat.getAllServices(DefaultResourceProxy.class);
for (Map<String, String> m : resourceList) {
String jndiName = m.get("name");
final ActionReport.MessagePart part = report.getTopMessagePart().addChild();
part.setMessage(jndiName);
String logicalName = DefaultResourceProxy.Util.getLogicalName(drps, jndiName);
if (logicalName != null) {
m.put("logical-jndi-name", logicalName);
}
}
extraProperties.put("jmsResources", resourceList);
}
report.setExtraProperties(extraProperties);
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of org.glassfish.api.naming.DefaultResourceProxy in project Payara by payara.
the class ListManagedThreadFactories 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
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
try {
Collection<ManagedThreadFactory> managedThreadFactories = domain.getResources().getResources(ManagedThreadFactory.class);
List<Map<String, String>> resourcesList = new ArrayList<Map<String, String>>();
List<DefaultResourceProxy> drps = habitat.getAllServices(DefaultResourceProxy.class);
for (ManagedThreadFactory managedThreadFactory : managedThreadFactories) {
String jndiName = managedThreadFactory.getJndiName();
if (bindableResourcesHelper.resourceExists(jndiName, target)) {
ActionReport.MessagePart part = report.getTopMessagePart().addChild();
part.setMessage(jndiName);
Map<String, String> resourceNameMap = new HashMap<String, String>();
String logicalName = DefaultResourceProxy.Util.getLogicalName(drps, jndiName);
if (logicalName != null) {
resourceNameMap.put("logical-jndi-name", logicalName);
}
resourceNameMap.put("name", jndiName);
resourcesList.add(resourceNameMap);
}
}
Properties extraProperties = new Properties();
extraProperties.put("managedThreadFactories", resourcesList);
report.setExtraProperties(extraProperties);
} catch (Exception e) {
report.setMessage(localStrings.getLocalString("list.managed.thread.factory.failed", "List managed thread factories failed"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of org.glassfish.api.naming.DefaultResourceProxy in project Payara by payara.
the class ListContextServices 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
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
try {
Collection<ContextService> contextServices = domain.getResources().getResources(ContextService.class);
List<Map<String, String>> resourcesList = new ArrayList<Map<String, String>>();
List<DefaultResourceProxy> drps = habitat.getAllServices(DefaultResourceProxy.class);
for (ContextService contextService : contextServices) {
String jndiName = contextService.getJndiName();
if (bindableResourcesHelper.resourceExists(jndiName, target)) {
ActionReport.MessagePart part = report.getTopMessagePart().addChild();
part.setMessage(jndiName);
Map<String, String> resourceNameMap = new HashMap<String, String>();
String logicalName = DefaultResourceProxy.Util.getLogicalName(drps, jndiName);
if (logicalName != null) {
resourceNameMap.put("logical-jndi-name", logicalName);
}
resourceNameMap.put("name", jndiName);
resourcesList.add(resourceNameMap);
}
}
Properties extraProperties = new Properties();
extraProperties.put("contextServices", resourcesList);
report.setExtraProperties(extraProperties);
} catch (Exception e) {
report.setMessage(localStrings.getLocalString("list.context.service.failed", "List context services failed"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of org.glassfish.api.naming.DefaultResourceProxy in project Payara by payara.
the class ListManagedExecutorServices 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
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
try {
Collection<ManagedExecutorService> managedExecutorServices = domain.getResources().getResources(ManagedExecutorService.class);
List<Map<String, String>> resourcesList = new ArrayList<Map<String, String>>();
List<DefaultResourceProxy> drps = habitat.getAllServices(DefaultResourceProxy.class);
for (ManagedExecutorService managedExecutorService : managedExecutorServices) {
String jndiName = managedExecutorService.getJndiName();
if (bindableResourcesHelper.resourceExists(jndiName, target)) {
ActionReport.MessagePart part = report.getTopMessagePart().addChild();
part.setMessage(jndiName);
Map<String, String> resourceNameMap = new HashMap<String, String>();
String logicalName = DefaultResourceProxy.Util.getLogicalName(drps, jndiName);
if (logicalName != null) {
resourceNameMap.put("logical-jndi-name", logicalName);
}
resourceNameMap.put("name", jndiName);
resourcesList.add(resourceNameMap);
}
}
Properties extraProperties = new Properties();
extraProperties.put("managedExecutorServices", resourcesList);
report.setExtraProperties(extraProperties);
} catch (Exception e) {
report.setMessage(localStrings.getLocalString("list.managed.executor.service.failed", "List managed executor services failed"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of org.glassfish.api.naming.DefaultResourceProxy in project Payara by payara.
the class ListManagedScheduledExecutorServices 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
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
try {
Collection<ManagedScheduledExecutorService> managedScheduledExecutorServices = domain.getResources().getResources(ManagedScheduledExecutorService.class);
List<Map<String, String>> resourcesList = new ArrayList<Map<String, String>>();
List<DefaultResourceProxy> drps = habitat.getAllServices(DefaultResourceProxy.class);
for (ManagedScheduledExecutorService managedScheduledExecutorService : managedScheduledExecutorServices) {
String jndiName = managedScheduledExecutorService.getJndiName();
if (bindableResourcesHelper.resourceExists(jndiName, target)) {
ActionReport.MessagePart part = report.getTopMessagePart().addChild();
part.setMessage(jndiName);
Map<String, String> resourceNameMap = new HashMap<String, String>();
String logicalName = DefaultResourceProxy.Util.getLogicalName(drps, jndiName);
if (logicalName != null) {
resourceNameMap.put("logical-jndi-name", logicalName);
}
resourceNameMap.put("name", jndiName);
resourcesList.add(resourceNameMap);
}
}
Properties extraProperties = new Properties();
extraProperties.put("managedScheduledExecutorServices", resourcesList);
report.setExtraProperties(extraProperties);
} catch (Exception e) {
report.setMessage(localStrings.getLocalString("list.managed.scheduled.executor.service.failed", "List managed scheduled executor services failed"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Aggregations