Author: dblevins
Date: Tue Jun 17 16:28:01 2008
New Revision: 668874

URL: http://svn.apache.org/viewvc?rev=668874&view=rev
Log:
Write the cmp mappings when openejb.descriptors.output is set to true

Modified:
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/OutputGeneratedDescriptors.java

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/OutputGeneratedDescriptors.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/OutputGeneratedDescriptors.java?rev=668874&r1=668873&r2=668874&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/OutputGeneratedDescriptors.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/OutputGeneratedDescriptors.java
 Tue Jun 17 16:28:01 2008
@@ -20,6 +20,8 @@
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.jee.EjbJar;
 import org.apache.openejb.jee.JaxbJavaee;
+import org.apache.openejb.jee.jpa.JpaJaxbUtil;
+import org.apache.openejb.jee.jpa.EntityMappings;
 import org.apache.openejb.jee.oejb3.JaxbOpenejbJar3;
 import org.apache.openejb.jee.oejb3.OpenejbJar;
 import org.apache.openejb.util.LogCategory;
@@ -29,10 +31,8 @@
 import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.IOException;
 
-/**
- * @version $Rev$ $Date$
- */
 public class OutputGeneratedDescriptors implements DynamicDeployer {
     private static final Logger logger = 
Logger.getInstance(LogCategory.OPENEJB_STARTUP_CONFIG, 
"org.apache.openejb.util.resources");
     private static final String OUTPUT_DESCRIPTORS = 
"openejb.descriptors.output";
@@ -40,6 +40,11 @@
     public AppModule deploy(AppModule appModule) throws OpenEJBException {
         boolean output = SystemInstance.get().getProperty(OUTPUT_DESCRIPTORS, 
"false").equalsIgnoreCase("true");
 
+        if (output && appModule.getCmpMappings() != null){
+
+            writeGenratedCmpMappings(appModule);
+        }
+
         for (EjbModule ejbModule : appModule.getEjbModules()) {
 
             output = 
ejbModule.getOpenejbJar().getProperties().getProperty(OUTPUT_DESCRIPTORS, 
output+"").equalsIgnoreCase("true");
@@ -58,6 +63,22 @@
         return appModule;
     }
 
+    private void writeGenratedCmpMappings(AppModule appModule) {
+        try {
+            File tempFile = File.createTempFile("openejb-cmp-generated-orm-", 
".xml");
+            FileOutputStream fout = new FileOutputStream(tempFile);
+            BufferedOutputStream out = new BufferedOutputStream(fout);
+
+            try {
+                JpaJaxbUtil.marshal(EntityMappings.class, 
appModule.getCmpMappings(), out);
+            } catch (JAXBException e) {
+            } finally{
+                out.close();
+            }
+        } catch (IOException e) {
+        }
+    }
+
     private void writeOpenejbJar(EjbModule ejbModule) {
         try {
             OpenejbJar openejbJar = ejbModule.getOpenejbJar();


Reply via email to