List assemblies = new ArrayList(); for (int i = 0; i < result.length; i++) { ServiceAssemblyLifeCycle sa = container.getRegistry().getServiceAssembly(result[i]);  if (state != null && state.length() > 0 && !state.equals(sa.getCurrentState())) { continue; } assemblies.add(sa); }
List assemblies = new ArrayList(); for (int i = 0; i < result.length; i++) { ServiceAssemblyLifeCycle sa = container.getRegistry() .getServiceAssembly(result[i]); if (sa != null) {  if (state != null && state.length() > 0 && !state.equals(sa.getCurrentState())) { continue; } assemblies.add(sa); } }
    public String listServiceAssemblies(String state, String componentName, String serviceAssemblyName) throws Exception {        String[] result = null;        if (null != serviceAssemblyName && serviceAssemblyName.length() > 0) {            result = new String[]{serviceAssemblyName};        } else if (null != componentName && componentName.length() > 0) {            result = container.getRegistry().getDeployedServiceAssembliesForComponent(componentName);        } else {            result = container.getRegistry().getDeployedServiceAssemblies();        }        List assemblies = new ArrayList();        for (int i = 0; i < result.length; i++) {            ServiceAssemblyLifeCycle sa = container.getRegistry().getServiceAssembly(result[i]);            // Check status            if (state != null && state.length() > 0 && !state.equals(sa.getCurrentState())) {                continue;            }            assemblies.add(sa);        }        StringBuffer buffer = new StringBuffer();        buffer.append("<?xml version='1.0'?>\n");        buffer.append("<service-assembly-info-list xmlns='http://java.sun.com/xml/ns/jbi/service-assembly-info-list' version='1.0'>\n");        for (Iterator iter = assemblies.iterator(); iter.hasNext();) {            ServiceAssemblyLifeCycle sa = (ServiceAssemblyLifeCycle) iter.next();            buffer.append("  <service-assembly-info");            buffer.append(" name='" + sa.getName() + "'");            buffer.append(" state='" + sa.getCurrentState() + "'>\n");            buffer.append("    <description>" + sa.getDescription() + "</description>\n");            ServiceUnitLifeCycle[] serviceUnitList = sa.getDeployedSUs();            for (int i = 0; i < serviceUnitList.length; i++) {                buffer.append("    <service-unit-info");                buffer.append(" name='" + serviceUnitList[i].getName() + "'");                buffer.append(" state='" + serviceUnitList[i].getCurrentState() + "'");                buffer.append(" deployed-on='" + serviceUnitList[i].getComponentName() + "'>\n");                buffer.append("      <description>" + serviceUnitList[i].getDescription() + "</description>\n");                buffer.append("    </service-unit-info>\n");            }                        buffer.append("  </service-assembly-info>\n");        }        buffer.append("</service-assembly-info-list>");        return buffer.toString();    }