geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke...@apache.org
Subject svn commit: r1134164 - in /geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment: AbstractWebModuleBuilder.java utils/WebAppXmlAttributeBuilder.java
Date Fri, 10 Jun 2011 01:18:17 GMT
Author: kevan
Date: Fri Jun 10 01:18:17 2011
New Revision: 1134164

URL: http://svn.apache.org/viewvc?rev=1134164&view=rev
Log:
GERONIMO-6002 allow gbean xml attributes to be overridden in config.xml

Modified:
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/utils/WebAppXmlAttributeBuilder.java

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java?rev=1134164&r1=1134163&r2=1134164&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
Fri Jun 10 01:18:17 2011
@@ -17,6 +17,7 @@
 
 package org.apache.geronimo.web25.deployment;
 
+import java.beans.PropertyEditorManager;
 import java.io.File;
 import java.io.IOException;
 import java.io.StringWriter;
@@ -91,6 +92,7 @@ import org.apache.geronimo.security.jasp
 import org.apache.geronimo.security.jaspi.ServerAuthModuleGBean;
 import org.apache.geronimo.web.info.WebAppInfo;
 import org.apache.geronimo.web.security.SpecSecurityBuilder;
+import org.apache.geronimo.web25.deployment.utils.WebAppXmlAttributeBuilder;
 import org.apache.geronimo.web25.deployment.merge.MergeHelper;
 import org.apache.geronimo.web25.deployment.security.AuthenticationWrapper;
 import org.apache.geronimo.xbeans.geronimo.j2ee.GerSecurityDocument;
@@ -121,6 +123,10 @@ import org.xml.sax.SAXException;
 public abstract class AbstractWebModuleBuilder implements ModuleBuilder {
     private static final Logger log = LoggerFactory.getLogger(AbstractWebModuleBuilder.class);
     
+    static {
+        PropertyEditorManager.registerEditor(WebAppInfo.class, WebAppXmlAttributeBuilder.class);
+    }
+
     //are we combining all web apps into one bundle in an ear?
     //TODO eliminate this
     protected static final boolean COMBINED_BUNDLE = true;

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/utils/WebAppXmlAttributeBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/utils/WebAppXmlAttributeBuilder.java?rev=1134164&r1=1134163&r2=1134164&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/utils/WebAppXmlAttributeBuilder.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/utils/WebAppXmlAttributeBuilder.java
Fri Jun 10 01:18:17 2011
@@ -20,31 +20,41 @@
 
 package org.apache.geronimo.web25.deployment.utils;
 
+import java.beans.PropertyEditorSupport;
+import java.io.StringReader;
+import java.io.StringWriter;
+
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.ValidationEvent;
 import javax.xml.bind.ValidationEventHandler;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
 
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.common.propertyeditor.PropertyEditorException;
 import org.apache.geronimo.deployment.service.XmlAttributeBuilder;
 import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.web.info.WebAppInfo;
 import org.apache.geronimo.web25.deployment.DefaultWebAppInfoFactory;
 import org.apache.geronimo.web25.deployment.WebAppInfoBuilder;
 import org.apache.openejb.jee.JAXBContextFactory;
 import org.apache.openejb.jee.WebApp;
 import org.apache.xmlbeans.XmlObject;
 import org.osgi.framework.Bundle;
+import org.xml.sax.InputSource;
 
 /**
  * @version $Rev:$ $Date:$
  */
 
 @GBean(j2eeType = "XmlAttributeBuilder")
-public class WebAppXmlAttributeBuilder implements XmlAttributeBuilder {
+public class WebAppXmlAttributeBuilder extends PropertyEditorSupport implements XmlAttributeBuilder
{
 
     @Override
     public String getNamespace() {
@@ -85,4 +95,40 @@ public class WebAppXmlAttributeBuilder i
         }
     }
 
-}
+    //TODO figure out how to turn WebAppInfo back into xml
+//    public String getAsText() {
+//        try {
+//            WebAppInfo webAppInfo = (WebAppInfo) getValue();
+//            StringWriter sw = new StringWriter();
+//            JAXBContext ctx = JAXBContextFactory.newInstance(WebApp.class);
+//            Marshaller marshaller = ctx.createMarshaller();
+//            marshaller.marshal(webAppInfo, sw);
+//            return sw.toString();
+//        } catch (JAXBException e) {
+//            throw new RuntimeException("parsing problem", e);
+//        }
+//    }
+
+    public void setAsText(String text) {
+        try {
+            JAXBContext ctx = JAXBContextFactory.newInstance(WebApp.class);
+            Unmarshaller unmarshaller = ctx.createUnmarshaller();
+            unmarshaller.setEventHandler(new ValidationEventHandler(){
+                public boolean handleEvent(ValidationEvent validationEvent) {
+                    return false;
+                }
+            });
+
+
+            JAXBElement<WebApp> element = unmarshaller.unmarshal(new StreamSource(new
StringReader(text)), WebApp.class);
+            WebAppInfo webAppInfo = new WebAppInfoBuilder(element.getValue(), new DefaultWebAppInfoFactory()).build();
+            setValue(webAppInfo);
+        } catch (JAXBException e) {
+            throw new RuntimeException("parsing problem", e);
+        } catch (DeploymentException e) {
+            throw new RuntimeException("conversion problem", e);
+        }
+    }
+
+
+}
\ No newline at end of file



Mime
View raw message