use of org.glassfish.api.naming.DefaultResourceProxy in project Payara by payara.
the class ListJdbcResources 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<JdbcResource> jdbcResources = domain.getResources().getResources(JdbcResource.class);
List<Map<String, String>> resourcesList = new ArrayList<Map<String, String>>();
List<DefaultResourceProxy> drps = habitat.getAllServices(DefaultResourceProxy.class);
for (JdbcResource jdbcResource : jdbcResources) {
String jndiName = jdbcResource.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("jdbcResources", resourcesList);
report.setExtraProperties(extraProperties);
} catch (Exception e) {
report.setMessage(localStrings.getLocalString("list.jdbc.resources.failed", "List JDBC resources failed"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Aggregations