KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > bull > eclipse > jonas > actions > ejb > DeployEjbActionDelegate


1 package com.bull.eclipse.jonas.actions.ejb;
2
3 /*
4  * (c) Copyright Bull SA 2003.
5  * All Rights Reserved.
6  */

7
8 import java.io.File JavaDoc;
9 import java.util.Vector JavaDoc;
10
11 import org.eclipse.core.runtime.CoreException;
12 import org.eclipse.jdt.core.IPackageFragment;
13
14 import com.bull.eclipse.jonas.JonasLauncherPlugin;
15 import com.bull.eclipse.jonas.JonasProject;
16 import com.bull.eclipse.jonas.actions.JonasPackageAbstractActionDelegate;
17
18 public class DeployEjbActionDelegate extends JonasPackageAbstractActionDelegate {
19
20     public boolean doActionOn(IPackageFragment pack) throws Exception JavaDoc {
21         String JavaDoc packName = pack.getPath().removeFirstSegments(2).toOSString();
22         JonasLauncherPlugin.log("PackName = " + packName);
23         String JavaDoc jarName = null;
24         JonasProject prj = JonasProject.create(pack.getJavaProject());
25         Vector JavaDoc vec = prj.getPackageProjectFolder();
26         if (vec != null)
27             for (int i = 0; i < vec.size(); i++) {
28                 JonasLauncherPlugin.log("Element = " + vec.elementAt(i));
29                 if (vec.elementAt(i).toString().equals(packName)) {
30                     JonasLauncherPlugin.log("Element = " + vec.elementAt(i));
31                     jarName = prj.getJarEjbName().elementAt(i).toString();
32                     continue;
33                 }
34             }
35         if (jarName == null) {
36             jarName = packName.replace(File.separatorChar,'_');
37         }
38 // throw new Exception("The EJB does not exist");
39

40         deploy(jarName + ".jar");
41         return false;
42     }
43
44     static public void deploy(String JavaDoc jarName) throws CoreException {
45         JonasLauncherPlugin.log("ejbFile = " + jarName);
46         String JavaDoc[] options = {"-a",jarName};
47         JonasLauncherPlugin.getDefault().getJonasBootstrap().admin(options);
48     }
49
50 }
51
52
Popular Tags