1 17 package org.apache.servicemix.bpe; 18 19 import java.io.File ; 20 21 import org.apache.servicemix.common.BaseLifeCycle; 22 import org.apache.servicemix.common.ServiceUnit; 23 import org.springframework.core.io.Resource; 24 25 32 public class BPESpringComponent extends BPEComponent { 33 34 private String name; 35 private Resource bpelResource; 36 37 40 protected BaseLifeCycle createLifeCycle() { 41 return new LifeCycle(); 42 } 43 44 public class LifeCycle extends BPELifeCycle { 45 46 protected ServiceUnit su; 47 48 public LifeCycle() { 49 super(BPESpringComponent.this); 50 } 51 52 55 protected void doInit() throws Exception { 56 super.doInit(); 57 if (bpelResource == null) { 58 throw new IllegalArgumentException ("bpelResource must be configured"); 59 } 60 File bpelFile = bpelResource.getFile(); 61 String fileName = bpelFile.getName(); 62 if (!fileName.endsWith(".bpel")) { 63 throw new IllegalArgumentException ("bpelResource must resolve to a .bpel file"); 64 } 65 if (name == null) { 66 name = fileName.substring(0, fileName.length() - 5); 67 } 68 su = new BPEDeployer(BPESpringComponent.this).deploy(name, bpelFile.getParent()); 69 getRegistry().registerServiceUnit(su); 70 } 71 72 75 protected void doStart() throws Exception { 76 super.doStart(); 77 su.start(); 78 } 79 80 83 protected void doStop() throws Exception { 84 su.stop(); 85 super.doStop(); 86 } 87 88 91 protected void doShutDown() throws Exception { 92 su.shutDown(); 93 super.doShutDown(); 94 } 95 } 96 97 100 public Resource getBpelResource() { 101 return bpelResource; 102 } 103 104 107 public void setBpelResource(Resource bpelResource) { 108 this.bpelResource = bpelResource; 109 } 110 111 114 public String getName() { 115 return name; 116 } 117 118 121 public void setName(String name) { 122 this.name = name; 123 } 124 125 } 126 | Popular Tags |