KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > bull > eclipse > jonas > actions > ws > CreateWSActionDelegate


1 package com.bull.eclipse.jonas.actions.ws;
2
3 import java.io.File JavaDoc;
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 JavaDoc {
23         // Update build.properties with JONAS_ROOT
24

25         JonasProject jp = (JonasProject)pack.getJavaProject().getProject().getNature(JonasLauncherPlugin.NATURE_ID);
26         String JavaDoc projDir =
27             pack
28                 .getJavaProject()
29                 .getProject()
30                 .getParent()
31                 .getLocation()
32                 .toOSString();
33         String JavaDoc packName = pack.getPath().removeFirstSegments(2).toOSString();
34         updateProjectWithAxisConfig(jp);
35         File JavaDoc serverConfigFile =
36             new File JavaDoc(
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 JavaDoc(TemplateDirUtil.getTemplateDir() + File.separator + "ws" + File.separator + "server-config.wsdd"), new File JavaDoc(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 JavaDoc packName) {
56         CreateDeployWSDD usc = new CreateDeployWSDD(jp);
57         String JavaDoc ejbName = EjbManagement.getEjbName(packName,jp);
58         JonasLauncherPlugin.log("Xml File = " + jp.getSrcEJBDirFolder().getLocation().append(packName).append("jonas-" + ejbName + ".xml"));
59         File JavaDoc jonasXmlFile = new File JavaDoc(jp.getSrcEJBDirFolder().getLocation().append(packName).append("jonas-" + ejbName + ".xml").toOSString());
60         File JavaDoc standardXmlFile = new File JavaDoc(jp.getSrcEJBDirFolder().getLocation().append(packName).append(ejbName + ".xml").toOSString());
61         if (!jonasXmlFile.exists())
62             return false;
63         String JavaDoc jndiName = FileXmlUtils.getValueForNode(jonasXmlFile,"jndi-name");
64         String JavaDoc homeClass = FileXmlUtils.getValueForNode(standardXmlFile,"home");
65         String JavaDoc remoteClass = FileXmlUtils.getValueForNode(standardXmlFile,"remote");
66         String JavaDoc homeLocalClass = FileXmlUtils.getValueForNode(standardXmlFile,"local-home");
67         String JavaDoc 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 JavaDoc packName, String JavaDoc jarName) {
74         UpdateXmlFile.updateServerConfigXmlFile(packName,jp, jarName);
75         return false;
76     }
77
78 }
79
80
Popular Tags