in core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsService.java [291:368]
public String listComponents(boolean excludeSEs, boolean excludeBCs, boolean excludePojos, String requiredState,
String sharedLibraryName, String serviceAssemblyName) throws Exception {
// validate requiredState
if (requiredState != null && requiredState.length() > 0
&& !LifeCycleMBean.UNKNOWN.equalsIgnoreCase(requiredState)
&& !LifeCycleMBean.SHUTDOWN.equalsIgnoreCase(requiredState)
&& !LifeCycleMBean.STOPPED.equalsIgnoreCase(requiredState)
&& !LifeCycleMBean.STARTED.equalsIgnoreCase(requiredState)) {
throw ManagementSupport.failure("listComponents", "Required state '" + requiredState + "' is not a valid state.");
}
// Get components
Collection connectors = container.getRegistry().getComponents();
List<ComponentMBeanImpl> components = new ArrayList<ComponentMBeanImpl>();
for (Iterator iter = connectors.iterator(); iter.hasNext();) {
ComponentMBeanImpl component = (ComponentMBeanImpl) iter.next();
// Skip SEs if needed
if (excludeSEs && component.isService()) {
continue;
}
// Skip BCs if needed
if (excludeBCs && component.isBinding()) {
continue;
}
// Skip Pojos if needed
if (excludePojos && component.isPojo()) {
continue;
}
// Check status
if (requiredState != null && requiredState.length() > 0 && !requiredState.equalsIgnoreCase(component.getCurrentState())) {
continue;
}
// Check shared library
// TODO: check component dependency on SL
if (sharedLibraryName != null && sharedLibraryName.length() > 0
&& !container.getInstallationService().containsSharedLibrary(sharedLibraryName)) {
continue;
}
// Check deployed service assembly
// TODO: check SA dependency on component
if (serviceAssemblyName != null && serviceAssemblyName.length() > 0) {
String[] saNames = container.getRegistry().getDeployedServiceAssembliesForComponent(component.getName());
boolean found = false;
for (int i = 0; i < saNames.length; i++) {
if (serviceAssemblyName.equals(saNames[i])) {
found = true;
break;
}
}
if (!found) {
continue;
}
}
components.add(component);
}
StringBuffer buffer = new StringBuffer();
buffer.append("<?xml version='1.0'?>\n");
buffer.append("<component-info-list xmlns='http://java.sun.com/xml/ns/jbi/component-info-list' version='1.0'>\n");
for (Iterator<ComponentMBeanImpl> iter = components.iterator(); iter.hasNext();) {
ComponentMBeanImpl component = iter.next();
buffer.append(" <component-info");
if (!component.isBinding() && component.isService()) {
buffer.append(" type='service-engine'");
} else if (component.isBinding() && !component.isService()) {
buffer.append(" type='binding-component'");
}
buffer.append(" name='" + component.getName() + "'");
buffer.append(" state='" + component.getCurrentState() + "'>\n");
if (component.getDescription() != null) {
buffer.append(" <description>");
buffer.append(component.getDescription());
buffer.append("</description>\n");
}
buffer.append(" </component-info>\n");
}
buffer.append("</component-info-list>");
return buffer.toString();
}