1 package com.bull.eclipse.jonas.actions.ejb; 2 3 import java.io.File ; 4 import java.util.Enumeration ; 5 import java.util.Hashtable ; 6 import java.util.Vector ; 7 8 import org.eclipse.core.resources.IResource; 9 import org.eclipse.jdt.core.IPackageFragment; 10 11 import com.bull.eclipse.jonas.JonasLauncherPlugin; 12 import com.bull.eclipse.jonas.JonasProject; 13 import com.bull.eclipse.jonas.actions.JonasPackageAbstractActionDelegate; 14 import com.bull.eclipse.jonas.utils.AntUtils; 15 import com.bull.eclipse.jonas.utils.EjbManagement; 16 import com.bull.eclipse.jonas.utils.UpdatePropsFile; 17 import com.bull.eclipse.jonas.utils.xml.FileXmlUtils; 18 import com.bull.eclipse.jonas.utils.xml.UpdateXmlFile; 19 import com.bull.eclipse.jonas.utils.xml.XMLUtils; 20 import com.bull.eclipse.newbean.FacadeEJBGenerate; 21 import com.bull.eclipse.newbean.EntityDescValue; 22 import com.bull.eclipse.newbean.NewFacadeValue; 23 24 25 26 public class BuildFacadeEjbActionDelegate extends JonasPackageAbstractActionDelegate 27 { 28 29 public boolean doActionOn(IPackageFragment pack) throws Exception { 30 if (pack.containsJavaResources()) 32 throw new Exception ("You must execute this function on a deployment unit !"); 33 34 JonasProject jp = (JonasProject)pack.getJavaProject().getProject().getNature(JonasLauncherPlugin.NATURE_ID); 35 UpdatePropsFile.updatePropsProject(jp); 36 37 String projDir = jp.getProject().getLocation().toOSString(); 38 String packName = pack.getPath().removeFirstSegments(1).toOSString(); 39 File ejb_standard_xml = new File (projDir , pack.getPath().removeFirstSegments(1).append("ejb-jar.xml").toOSString()); 40 File ejb_jonas_xml = new File (projDir , pack.getPath().removeFirstSegments(1).append("jonas-ejb-jar.xml").toOSString()); 41 if ((!ejb_standard_xml.exists()) || (!ejb_jonas_xml.exists())) 42 throw new Exception ("The deployment unit must be create by the middlegen functionnality"); 43 44 Hashtable hashtable = FileXmlUtils.getAllNameAndPackageEJBEntity(ejb_standard_xml); 45 Enumeration nameEnum = hashtable.keys(); 46 Enumeration packageNameEnum = hashtable.elements(); 47 File tempFile = new File (jp.getProject().getLocation().append("temp").toOSString()); 48 if (!tempFile.exists()) 49 tempFile.mkdirs(); 50 while (nameEnum.hasMoreElements()) { 51 String packageName = (String ) packageNameEnum.nextElement(); 52 String name = (String ) nameEnum.nextElement(); 53 FacadeEJBGenerate feg = new FacadeEJBGenerate(jp); 54 NewFacadeValue nfv = new NewFacadeValue(); 55 nfv.setBeanName(name); 56 nfv.setPackageName(packageName); 57 EntityDescValue napv = new EntityDescValue(); 58 napv.setBeanName(name); 59 napv.setPackageName(packageName); 60 Vector vecValue = new Vector (); 61 vecValue.add(napv); 62 vecValue = AggregateFacadeEjbActionDelegate.getMethods(vecValue,pack.getJavaProject(),jp); 63 nfv.setVecValue(vecValue); 64 feg.runNewFacade(nfv); 65 UpdateXmlFile.updateEjbStandardXmlFile(ejb_standard_xml, new File (tempFile, "facadeNode.xml")); 67 UpdateXmlFile.updateEjbJOnASXmlFile(ejb_jonas_xml, new File (tempFile, "JOnASFacadeNode.xml")); 68 69 } 70 71 72 jp.getProject().refreshLocal( IResource.DEPTH_INFINITE, null ); 73 74 75 76 return false; 77 } 78 79 } 80 81 | Popular Tags |