1 package org.objectweb.petals.binding.axis2; 2 3 import java.io.File ; 4 import java.io.FileOutputStream ; 5 import java.io.IOException ; 6 import java.util.Properties ; 7 8 import javax.jbi.JBIException; 9 import javax.jbi.component.InstallationContext; 10 11 import org.objectweb.petals.component.common.SimpleBootstrap; 12 import org.objectweb.petals.tools.jbicommon.util.XMLUtil; 13 import org.w3c.dom.DocumentFragment ; 14 import org.w3c.dom.Node ; 15 16 public class Axis2Bootstrap extends SimpleBootstrap { 17 18 InstallationContext installContext = null; 19 20 25 @Override 26 public void init(InstallationContext installContext) throws JBIException { 27 this.installContext = installContext; 28 } 29 30 35 @Override 36 public void cleanUp() throws JBIException { 37 installContext = null; 38 } 39 40 45 @Override 46 public void onInstall() throws JBIException { 47 48 copyAxisConfFiles(); 50 51 String htmlPort = retrieveHttpServerPort(); 53 54 if (htmlPort == null) { 55 htmlPort = "8080"; 56 } 57 58 Properties p = new Properties (); 60 p.put("axis2.server.port", htmlPort); 61 62 File propertieFile = new File (installContext.getInstallRoot() 63 + File.separator + "axis2.properties"); 64 try { 65 FileOutputStream fos = new FileOutputStream (propertieFile); 66 p.store(fos, "html port used to start the axis2 http server"); 67 } catch (IOException e) { 68 throw new JBIException(e); 69 } 70 } 71 72 77 @Override 78 public void onUninstall() throws JBIException { 79 } 80 81 85 protected void copyAxisConfFiles() { 86 File installPath = new File (installContext.getInstallRoot()); 87 88 File modules = new File (installPath, "modules"); 89 File services = new File (installPath, "services"); 90 91 modules.mkdirs(); 92 services.mkdirs(); 93 94 96 File [] metaInfFiles = new File (installPath, "META-INF").listFiles(); 97 for (File file : metaInfFiles) { 98 if (file.getName().endsWith(".mar")) { 99 file.renameTo(new File (modules, file.getName())); 100 } 101 if (file.getName().equals("axis2.xml")) { 102 file.renameTo(new File (installPath, file.getName())); 103 } 104 } 105 } 106 107 116 protected String retrieveHttpServerPort() { 117 String result = null; 118 DocumentFragment ext = installContext 119 .getInstallationDescriptorExtension(); 120 Node httpPort = ext.getFirstChild(); 121 if (httpPort != null && httpPort.getNodeName().contains("http")) { 122 result = XMLUtil.getTextContent(httpPort); 123 } 124 return result; 125 } 126 127 } 128 | Popular Tags |