1 package com.bull.eclipse.jonas.actions.ws; 2 3 import java.io.File ; 4 5 import org.eclipse.core.resources.IResource; 6 import org.eclipse.jdt.core.IPackageFragment; 7 8 import com.bull.eclipse.jonas.JonasLauncherPlugin; 9 import com.bull.eclipse.jonas.JonasProject; 10 import com.bull.eclipse.jonas.actions.JonasPackageAbstractActionDelegate; 11 import com.bull.eclipse.jonas.utils.EjbManagement; 12 import com.bull.eclipse.jonas.utils.FileUtil; 13 import com.bull.eclipse.jonas.utils.TemplateDirUtil; 14 import com.bull.eclipse.jonas.utils.xml.FileXmlUtils; 15 import com.bull.eclipse.jonas.utils.xml.UpdateXmlFile; 16 17 18 19 public class CreateWSActionDelegate extends JonasPackageAbstractActionDelegate 20 { 21 22 public boolean doActionOn(IPackageFragment pack) throws Exception { 23 25 JonasProject jp = (JonasProject)pack.getJavaProject().getProject().getNature(JonasLauncherPlugin.NATURE_ID); 26 String projDir = 27 pack 28 .getJavaProject() 29 .getProject() 30 .getParent() 31 .getLocation() 32 .toOSString(); 33 String packName = pack.getPath().removeFirstSegments(2).toOSString(); 34 updateProjectWithAxisConfig(jp); 35 File serverConfigFile = 36 new File ( 37 jp 38 .getWebInfFolder() 39 .getLocation() 40 .append("server-config.wsdd") 41 .toOSString()); 42 createDeployWSDD(jp, packName); 43 if (!serverConfigFile.exists()) 44 FileUtil.copy(new File (TemplateDirUtil.getTemplateDir() + File.separator + "ws" + File.separator + "server-config.wsdd"), new File (jp.getWebInfFolder().getLocation().append("server-config.wsdd").toOSString())); 45 updateServerConfig(jp, packName, EjbManagement.getEjbName(packName,jp)); 46 jp.getProject().refreshLocal( IResource.DEPTH_INFINITE, null ); 47 48 return false; 49 } 50 51 private void updateProjectWithAxisConfig(JonasProject jp) { 52 UpdateXmlFile.updateWebXmlFileWithAxisServlet(jp.getWebInfFolder().getLocation().append("web.xml").toFile()); 53 } 54 55 private boolean createDeployWSDD(JonasProject jp, String packName) { 56 CreateDeployWSDD usc = new CreateDeployWSDD(jp); 57 String ejbName = EjbManagement.getEjbName(packName,jp); 58 JonasLauncherPlugin.log("Xml File = " + jp.getSrcEJBDirFolder().getLocation().append(packName).append("jonas-" + ejbName + ".xml")); 59 File jonasXmlFile = new File (jp.getSrcEJBDirFolder().getLocation().append(packName).append("jonas-" + ejbName + ".xml").toOSString()); 60 File standardXmlFile = new File (jp.getSrcEJBDirFolder().getLocation().append(packName).append(ejbName + ".xml").toOSString()); 61 if (!jonasXmlFile.exists()) 62 return false; 63 String jndiName = FileXmlUtils.getValueForNode(jonasXmlFile,"jndi-name"); 64 String homeClass = FileXmlUtils.getValueForNode(standardXmlFile,"home"); 65 String remoteClass = FileXmlUtils.getValueForNode(standardXmlFile,"remote"); 66 String homeLocalClass = FileXmlUtils.getValueForNode(standardXmlFile,"local-home"); 67 String localClass = FileXmlUtils.getValueForNode(standardXmlFile,"local"); 68 69 usc.runUpdate(ejbName + "EndPoint",jndiName,homeClass,remoteClass,homeLocalClass,localClass,packName); 70 return false; 71 } 72 73 private boolean updateServerConfig(JonasProject jp, String packName, String jarName) { 74 UpdateXmlFile.updateServerConfigXmlFile(packName,jp, jarName); 75 return false; 76 } 77 78 } 79 80 | Popular Tags |