1 17 package org.apache.servicemix.maven.plugin.jbi; 18 19 import org.apache.servicemix.jbi.framework.AdminCommandsServiceMBean; 20 import org.apache.servicemix.jbi.management.task.JbiTask; 21 22 public class IsDeployedTask extends JbiTask { 23 24 private static final String JBI_SHARED_LIBRARY = "jbi-shared-library"; 25 26 private static final String JBI_COMPONENT = "jbi-component"; 27 28 private static final String JBI_SERVICE_ASSEMBLY = "jbi-service-assembly"; 29 30 private boolean deployed = false; 31 32 private String type; 33 34 private String name; 35 36 public boolean isDeployed() { 37 return deployed; 38 } 39 40 public void setDeployed(boolean deployed) { 41 this.deployed = deployed; 42 } 43 44 protected void doExecute(AdminCommandsServiceMBean acs) throws Exception { 45 if (JBI_SHARED_LIBRARY.equals(type)) { 46 String result = acs.listSharedLibraries(null, name); 47 setDeployed(isResultContaining(result, "shared-library", name)); 48 } else if (JBI_SERVICE_ASSEMBLY.equals(type)) { 49 String result = acs.listServiceAssemblies(null, null, name); 50 setDeployed(result.contains("<service-assembly-info name='" + name 51 + "'")); 52 } 53 if (JBI_COMPONENT.equals(type)) { 54 String result = acs.listComponents(false, false, false, null, null, 55 null); 56 if (isResultContaining(result, "service-engine", name) 57 || isResultContaining(result, "binding-component", name)) { 58 setDeployed(true); 59 } 60 } 61 } 62 63 private boolean isResultContaining(String result, String type, String name) { 64 String componentLine = "<component-info type='" + type + "' name='" 65 + name + "'"; 66 return result.contains(componentLine); 67 } 68 69 public void setType(String type) { 70 this.type = type; 71 } 72 73 public void setName(String name) { 74 this.name = name; 75 } 76 77 } 78 | Popular Tags |