KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > bull > eclipse > jonas > actions > persistence > PersistenceAPIActionDelegate


1 package com.bull.eclipse.jonas.actions.persistence;
2
3 import java.io.File JavaDoc;
4 import java.util.Enumeration JavaDoc;
5 import java.util.Hashtable JavaDoc;
6 import java.util.Vector JavaDoc;
7
8 import org.eclipse.core.resources.IResource;
9 import org.eclipse.jdt.core.IJavaElement;
10 import org.eclipse.jdt.core.IPackageFragment;
11 import org.eclipse.jdt.internal.core.PackageFragmentRoot;
12
13 import com.bull.eclipse.jonas.JonasLauncherPlugin;
14 import com.bull.eclipse.jonas.JonasProject;
15 import com.bull.eclipse.jonas.actions.JonasPackageAbstractActionDelegate;
16 import com.bull.eclipse.jonas.actions.JonasPackageRootAbstractActionDelegate;
17 import com.bull.eclipse.jonas.actions.ejb.AggregateFacadeEjbActionDelegate;
18 import com.bull.eclipse.jonas.actions.hibernate.PersistenceServicesValue;
19 import com.bull.eclipse.jonas.actions.persistence.utils.PersistencePackage;
20 import com.bull.eclipse.jonas.utils.AntUtils;
21 import com.bull.eclipse.jonas.utils.EjbManagement;
22 import com.bull.eclipse.jonas.utils.UpdatePropsFile;
23 import com.bull.eclipse.jonas.utils.xml.FileXmlUtils;
24 import com.bull.eclipse.jonas.utils.xml.UpdateXmlFile;
25 import com.bull.eclipse.jonas.utils.xml.XMLUtils;
26 import com.bull.eclipse.newbean.FacadeEJBGenerate;
27 import com.bull.eclipse.newbean.EntityDescValue;
28 import com.bull.eclipse.newbean.NewFacadeValue;
29 import com.bull.eclipse.persitence.EJB3ServicePersistenceGenerate;
30
31
32
33 public class PersistenceAPIActionDelegate extends JonasPackageRootAbstractActionDelegate
34 {
35
36     public boolean doActionOn(PackageFragmentRoot packageRoot) throws Exception JavaDoc {
37         // Update build.properties with JONAS_ROOT
38
if (!"persistence".equals(packageRoot.getElementName()))
39             throw new Exception JavaDoc("You must execute this function on the persistence folder !");
40         
41         JonasProject jp = (JonasProject)packageRoot.getJavaProject().getProject().getNature(JonasLauncherPlugin.NATURE_ID);
42         UpdatePropsFile.updatePropsProject(jp);
43         
44         String JavaDoc projDir = jp.getProject().getLocation().toOSString();
45         String JavaDoc packName = packageRoot.getPath().removeFirstSegments(1).toOSString();
46
47         String JavaDoc packagePersistence = PersistencePackage.getPersistencePackage(packageRoot.getChildren());
48         PersistenceValue psv = new PersistenceValue();
49         psv.setPersistencePackage(packagePersistence);
50         psv.setPersistenceName("EntityManager");
51         psv.setQueryInterfaceName("Query");
52         
53         
54         EJB3ServicePersistenceGenerate espg = new EJB3ServicePersistenceGenerate(jp);
55         espg.generateServicePersistence(psv);
56         
57         jp.getProject().refreshLocal( IResource.DEPTH_INFINITE, null );
58         
59         
60         
61         return false;
62     }
63
64 }
65
66
Popular Tags