geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r677037 - in /geronimo/components/jaspi/trunk/geronimo-jaspi: ./ src/main/java/org/apache/geronimo/components/jaspi/model/ src/main/java/sxc/ src/main/java/sxc/org/ src/main/java/sxc/org/apache/ src/main/java/sxc/org/apache/geronimo/ src/ma...
Date Tue, 15 Jul 2008 21:00:59 GMT
Author: djencks
Date: Tue Jul 15 14:00:58 2008
New Revision: 677037

URL: http://svn.apache.org/viewvc?rev=677037&view=rev
Log:
use sxc with hand-tweaked JAXB classes

Added:
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/sxc/
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/sxc/org/
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/sxc/org/apache/
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/sxc/org/apache/geronimo/
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/sxc/org/apache/geronimo/components/
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/sxc/org/apache/geronimo/components/jaspi/
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/sxc/org/apache/geronimo/components/jaspi/model/
Modified:
    geronimo/components/jaspi/trunk/geronimo-jaspi/pom.xml
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ConfigProviderMapAdapter.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/JaspiXmlUtil.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/StringMapAdapter.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/java/org/apache/geronimo/components/jaspi/model/JaxbTest.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/resources/test-jaspi.xml

Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/pom.xml?rev=677037&r1=677036&r2=677037&view=diff
==============================================================================
--- geronimo/components/jaspi/trunk/geronimo-jaspi/pom.xml (original)
+++ geronimo/components/jaspi/trunk/geronimo-jaspi/pom.xml Tue Jul 15 14:00:58 2008
@@ -165,6 +165,7 @@
             <groupId>com.envoisolutions.sxc</groupId>
             <artifactId>sxc-jaxb</artifactId>
         </dependency>
+
         <dependency>
             <groupId>org.codehaus.woodstox</groupId>
             <artifactId>wstx-asl</artifactId>
@@ -197,8 +198,6 @@
             <scope>test</scope>
         </dependency>
 
-
-
     </dependencies>
     <build>
         <pluginManagement>
@@ -243,25 +242,25 @@
         </pluginManagement>
 
         <plugins>
-            <!--
-                     <plugin>
-                      <groupId>com.envoisolutions.sxc</groupId>
-                      <artifactId>sxc-jaxb-maven-plugin</artifactId>
-                      <version>0.8-SNAPSHOT</version>
-                      <executions>
-                        <execution>
-                          <configuration>
-                            <classes>
-                              <class>org.apache.geronimo.components.jaspi</class>
-                            </classes>
-                          </configuration>
-                          <goals>
-                            <goal>generate</goal>
-                          </goals>
-                      </execution>
-                    </executions>
-                  </plugin>
-            -->
+
+            <!--<plugin>-->
+                <!--<groupId>com.envoisolutions.sxc</groupId>-->
+                <!--<artifactId>sxc-jaxb-maven-plugin</artifactId>-->
+                <!--<version>0.8-SNAPSHOT</version>-->
+                <!--<executions>-->
+                    <!--<execution>-->
+                        <!--<configuration>-->
+                            <!--<classes>-->
+                                <!--<class>org.apache.geronimo.components.jaspi.model</class>-->
+                            <!--</classes>-->
+                        <!--</configuration>-->
+                        <!--<goals>-->
+                            <!--<goal>generate</goal>-->
+                        <!--</goals>-->
+                    <!--</execution>-->
+                <!--</executions>-->
+            <!--</plugin>-->
+
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-enforcer-plugin</artifactId>

Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ConfigProviderMapAdapter.java
URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ConfigProviderMapAdapter.java?rev=677037&r1=677036&r2=677037&view=diff
==============================================================================
--- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ConfigProviderMapAdapter.java
(original)
+++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ConfigProviderMapAdapter.java
Tue Jul 15 14:00:58 2008
@@ -20,20 +20,20 @@
 
 package org.apache.geronimo.components.jaspi.model;
 
-import java.util.Map;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
-import java.util.ArrayList;
+import java.util.Map;
 
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 
 import org.apache.geronimo.components.jaspi.ClassLoaderLookup;
 
 /**
- * @version $Rev:$ $Date:$
+ * @version $Rev$ $Date$
  */
 public class ConfigProviderMapAdapter extends XmlAdapter<ConfigProviderType[], Map<String,
ConfigProviderType>> {
-
+    public static ClassLoaderLookup staticClassLoaderLookup;
     private final ClassLoaderLookup classLoaderLookup;
 
     public ConfigProviderMapAdapter(ClassLoaderLookup classLoaderLookup) {
@@ -41,33 +41,41 @@
     }
 
     public ConfigProviderMapAdapter() {
-        ClassLoader testLoader = Thread.currentThread().getContextClassLoader();
-        final ClassLoader cl = testLoader == null? ConfigProviderMapAdapter.class.getClassLoader():
testLoader;
-        classLoaderLookup = new ClassLoaderLookup() {
-
-            public ClassLoader getClassLoader(String name) {
-                return cl;
-            }
-        };
+        if (staticClassLoaderLookup != null) {
+            this.classLoaderLookup = staticClassLoaderLookup;
+        } else {
+            ClassLoader testLoader = Thread.currentThread().getContextClassLoader();
+            final ClassLoader cl = testLoader == null ? ConfigProviderMapAdapter.class.getClassLoader()
: testLoader;
+            classLoaderLookup = new ClassLoaderLookup() {
+
+                public ClassLoader getClassLoader(String name) {
+                    return cl;
+                }
+            };
+        }
     }
 
     public Map<String, ConfigProviderType> unmarshal(ConfigProviderType[] configProviderTypes)
throws Exception {
         Map<String, ConfigProviderType> map = new HashMap<String, ConfigProviderType>();
-        for (ConfigProviderType configProviderType: configProviderTypes) {
-            String key = configProviderType.getRegistrationKey();
-            map.put(key, configProviderType);
-            configProviderType.createAuthConfigProvider(classLoaderLookup);
+        if (configProviderTypes != null) {
+            for (ConfigProviderType configProviderType : configProviderTypes) {
+                if (configProviderType != null) {
+                    String key = configProviderType.getRegistrationKey();
+                    map.put(key, configProviderType);
+                    configProviderType.createAuthConfigProvider(classLoaderLookup);
+                }
+            }
         }
         return map;
     }
 
     public ConfigProviderType[] marshal(Map<String, ConfigProviderType> stringConfigProviderTypeMap)
throws Exception {
         List<ConfigProviderType> list = new ArrayList<ConfigProviderType>();
-        for (ConfigProviderType configProviderType: stringConfigProviderTypeMap.values())
{
+        for (ConfigProviderType configProviderType : stringConfigProviderTypeMap.values())
{
             if (configProviderType.isPersistent()) {
                 list.add(configProviderType);
             }
         }
-        return list.toArray(new ConfigProviderType[stringConfigProviderTypeMap.size()]);
+        return list.toArray(new ConfigProviderType[list.size()]);
     }
 }

Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/JaspiXmlUtil.java
URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/JaspiXmlUtil.java?rev=677037&r1=677036&r2=677037&view=diff
==============================================================================
--- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/JaspiXmlUtil.java
(original)
+++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/JaspiXmlUtil.java
Tue Jul 15 14:00:58 2008
@@ -23,6 +23,7 @@
 import java.io.Writer;
 import java.io.Reader;
 import java.io.IOException;
+import java.util.Collections;
 
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamException;
@@ -47,7 +48,9 @@
 
     static {
         try {
-            JASPI_CONTEXT = JAXBContext.newInstance(JaspiType.class);
+//            JASPI_CONTEXT = JAXBContext.newInstance(JaspiType.class);
+            JASPI_CONTEXT = com.envoisolutions.sxc.jaxb.JAXBContextImpl.newInstance(new Class[]
{JaspiType.class}, Collections.singletonMap("com.envoisolutions.sxc.generate", "false"));
+
         } catch (JAXBException e) {
             throw new RuntimeException("Could not create jaxb contexts for plugin types",
e);
         }

Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/StringMapAdapter.java
URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/StringMapAdapter.java?rev=677037&r1=677036&r2=677037&view=diff
==============================================================================
--- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/StringMapAdapter.java
(original)
+++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/StringMapAdapter.java
Tue Jul 15 14:00:58 2008
@@ -29,10 +29,13 @@
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 
 /**
- * @version $Rev:$ $Date:$
+ * @version $Rev$ $Date$
  */
 public class StringMapAdapter extends XmlAdapter<String, Map<String, String>>
{
     public Map<String, String> unmarshal(String s) throws Exception {
+        if (s == null) {
+            return null;
+        }
         Properties properties = new Properties();
         ByteArrayInputStream in = new ByteArrayInputStream(s.getBytes());
         properties.load(in);
@@ -44,6 +47,9 @@
     }
 
     public String marshal(Map<String, String> map) throws Exception {
+        if (map == null) {
+            return "";
+        }
         Properties properties = new Properties();
         properties.putAll(map);
         ByteArrayOutputStream out = new ByteArrayOutputStream();

Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/java/org/apache/geronimo/components/jaspi/model/JaxbTest.java
URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/java/org/apache/geronimo/components/jaspi/model/JaxbTest.java?rev=677037&r1=677036&r2=677037&view=diff
==============================================================================
--- geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/java/org/apache/geronimo/components/jaspi/model/JaxbTest.java
(original)
+++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/java/org/apache/geronimo/components/jaspi/model/JaxbTest.java
Tue Jul 15 14:00:58 2008
@@ -24,6 +24,11 @@
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
+import java.io.File;
+import java.io.Writer;
+import java.io.FileWriter;
+import java.io.FileReader;
+import java.net.URL;
 
 import javax.xml.bind.JAXBException;
 import javax.xml.parsers.ParserConfigurationException;
@@ -43,11 +48,17 @@
     @Test
     public void testLoad() throws Exception {
         String file = "test-jaspi.xml";
-        JaspiType rbac = loadRbac(file);
-        
+        JaspiType jaspi1 = loadJaspi(file);
+        if (jaspi1.getConfigProvider().size() != 1) throw new Exception("expected 1 configprovider,
not this: " + jaspi1.getConfigProvider());
+        URL url = getClass().getClassLoader().getResource("test-jaspi.xml");
+        File newFile = new File(new File(url.getPath()).getParentFile(), "test-jaspi-2.xml");
+        Writer writer = new FileWriter(newFile);
+        JaspiXmlUtil.writeJaspi(jaspi1, writer);
+        JaspiType jaspi2 = JaspiXmlUtil.loadJaspi(new FileReader(newFile));
+        if (jaspi2.getConfigProvider().size() != 1) throw new Exception("expected 1 configprovider,
not this: " + jaspi2.getConfigProvider());
     }
 
-    private JaspiType loadRbac(String file) throws ParserConfigurationException, IOException,
SAXException, JAXBException, XMLStreamException {
+    private JaspiType loadJaspi(String file) throws ParserConfigurationException, IOException,
SAXException, JAXBException, XMLStreamException {
         InputStream in = getClass().getClassLoader().getResourceAsStream(file);
         Reader reader = new InputStreamReader(in);
         JaspiType rbac = JaspiXmlUtil.loadJaspi(reader);

Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/resources/test-jaspi.xml
URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/resources/test-jaspi.xml?rev=677037&r1=677036&r2=677037&view=diff
==============================================================================
--- geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/resources/test-jaspi.xml (original)
+++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/resources/test-jaspi.xml Tue Jul
15 14:00:58 2008
@@ -24,7 +24,7 @@
         <description>description</description>
         <className>org.apache.geronimo.components.jaspi.providers.DummyProvider</className>
         <properties>foo=bar</properties>
-        <persistent>false</persistent>
+        <persistent>true</persistent>
     </configProvider>
 
 </jaspi>
\ No newline at end of file



Mime
View raw message