geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgenen...@apache.org
Subject svn commit: r470543 - in /geronimo/sandbox/gcache: ./ server/src/main/java/org/apache/geronimo/gcache/dd/ server/src/main/java/org/apache/geronimo/gcache/util/ server/src/test/java/org/apache/geronimo/gcache/dd/
Date Thu, 02 Nov 2006 22:06:29 GMT
Author: jgenender
Date: Thu Nov  2 14:06:28 2006
New Revision: 470543

URL: http://svn.apache.org/viewvc?view=rev&rev=470543
Log:
Fix xml to allow for property substitution before processing

Modified:
    geronimo/sandbox/gcache/pom.xml
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/ConfigBuilder.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/JaxbGcacheConfigFactory.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/StringUtil.java
    geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/dd/ConfigBuilderTest.java

Modified: geronimo/sandbox/gcache/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/pom.xml?view=diff&rev=470543&r1=470542&r2=470543
==============================================================================
--- geronimo/sandbox/gcache/pom.xml (original)
+++ geronimo/sandbox/gcache/pom.xml Thu Nov  2 14:06:28 2006
@@ -18,187 +18,186 @@
 
     <modules>
         <!--module>openwire</module-->
-        <module>client</module>
-        <module>server</module>
-    </modules>
-
-    <properties>
-        <gcacheVersion>1.0-SNAPSHOT</gcacheVersion>
-    </properties>
-
-    <dependencyManagement>
-        <dependencies>
-            <dependency>
-                <groupId>org.apache.geronimo.gcache</groupId>
-                <artifactId>gcache-server</artifactId>
-                <version>${gcacheVersion}</version>
-            </dependency>
-
-            <dependency>
-                <groupId>org.apache.geronimo.gcache</groupId>
-                <artifactId>gcache-client</artifactId>
-                <version>${gcacheVersion}</version>
-            </dependency>
-            
-            <dependency>
-                <groupId>org.apache.geronimo.gcache</groupId>
-                <artifactId>openwire</artifactId>
-                <version>${gcacheVersion}</version>
-            </dependency>
-
-            <dependency>
-                <groupId>backport-util-concurrent</groupId>
-                <artifactId>backport-util-concurrent</artifactId>
-                <version>2.2</version>
-            </dependency>
-
-            <dependency>
-                <groupId>commons-logging</groupId>
-                <artifactId>commons-logging</artifactId>
-                <version>1.0.4</version>
-            </dependency>
-
-            <dependency>
-                <groupId>log4j</groupId>
-                <artifactId>log4j</artifactId>
-                <version>1.2.8</version>
-            </dependency>
-
-            <dependency>
-                <groupId>org.testng</groupId>
-                <artifactId>testng</artifactId>
-                <classifier>jdk15</classifier>
-                <version>5.1</version>
-                <scope>test</scope>
-            </dependency>
-
-            <dependency>
-                <groupId>net.sf.ehcache</groupId>
-                <artifactId>ehcache</artifactId>
-                <version>1.2.3</version>
-            </dependency>
-
-            <dependency>
-                <groupId>org.apache.mina</groupId>
-                <artifactId>mina-core</artifactId>
-                <version>1.0.0</version>
-            </dependency>
-
-            <dependency>
-                <groupId>org.slf4j</groupId>
-                <artifactId>slf4j-simple</artifactId>
-                <version>1.0</version>
-                <scope>provided</scope>
-            </dependency>
-
-        </dependencies>
-    </dependencyManagement>
-
-    <distributionManagement>
-
-        <repository>
-            <id>apache-releases</id>
-            <name>Apache Release Distribution Repository</name>
-            <url>scp://people.apache.org/www/people.apache.org/repo/m2-ibiblio-rsync-repository</url>
-        </repository>
-
-        <snapshotRepository>
-            <id>apache-snapshots</id>
-            <name>Apache Snapshot Repository</name>
-            <url>scp://people.apache.org/www/people.apache.org/repo/m2-snapshot-repository</url>
-        </snapshotRepository>
-
-        <site>
-            <id>gcache-website</id>
-            <url>scp://people.apache.org/www/geronimo.apache.org/maven/gcache</url>
-        </site>
-
-    </distributionManagement>
-
-    <build>
-        <pluginManagement>
-            <plugins>
-                <plugin>
-                    <groupId>org.codehaus.mojo</groupId>
-                    <artifactId>xmlbeans-maven-plugin</artifactId>
-                    <version>2.0.1-SNAPSHOT</version>
-
-                    <executions>
-                        <execution>
-                            <goals>
-                                <goal>xmlbeans</goal>
-                            </goals>
-                        </execution>
-                    </executions>
-
-                    <configuration>
-                        <schemaDirectory>
-                            ${pom.basedir}/src/main/schema
-                        </schemaDirectory>
-                        <xmlConfigs>
-                            <xmlConfig implementation="java.io.File">
-                                ${pom.basedir}/src/main/schema/xmlconfig.xml
-                            </xmlConfig>
-                        </xmlConfigs>
-                        <download>true</download>
-                        <quiet>false</quiet>
-                    </configuration>
-                </plugin>
-                <plugin>
-                    <artifactId>maven-compiler-plugin</artifactId>
-                    <configuration>
-                        <source>1.5</source>
-                        <target>1.5</target>
-                    </configuration>
-                </plugin>
-                <!--
-                NOTE: Using custom maven-surefire-plugin that supports TestNG:
-                      
-                      http://testng.org/doc/maven.html
-                -->
-                <plugin>
-                    <groupId>org.apache.maven.plugins</groupId>
-                    <artifactId>maven-surefire-plugin</artifactId>
-                    <version>2.8-SNAPSHOT</version>
-                </plugin>
-            </plugins>
-        </pluginManagement>
-    </build>
-
-    <!--
-    NOTE: This is the repository where maven-surefire-plugin:2.8-SNAPSHOT comes from.
-    -->
-    <pluginRepositories>
-        <pluginRepository>
-            <id>tapestry.javaforge</id>
-            <url>http://howardlewisship.com/repository</url>
-        </pluginRepository>
-        <pluginRepository>
-            <releases>
-                <enabled>false</enabled>
-            </releases>
-            <id>snapshots</id>
-            <name>Maven Snapshot Development Repository</name>
-            <url>http://snapshots.maven.codehaus.org/maven2</url>
-        </pluginRepository>
-    </pluginRepositories>
-
-    <repositories>
-        <repository>
-            <id>apache-m2-snapshot-repo</id>
-            <url>http://people.apache.org/repo/m2-snapshot-repository</url>
-            <name>Apache Maven Snapshots Repository</name>
-            <layout>default</layout>
-            <snapshots>
-                <enabled>true</enabled>
-                <updatePolicy>daily</updatePolicy>
-                <checksumPolicy>ignore</checksumPolicy>
-            </snapshots>
-            <releases>
-                <enabled>true</enabled>
-            </releases>
-        </repository>
-    </repositories>
+    <module>client</module>
+    <module>server</module>
+</modules>
+
+<properties>
+    <gcacheVersion>1.0-SNAPSHOT</gcacheVersion>
+</properties>
+
+<dependencyManagement>
+    <dependencies>
+
+        <dependency>
+            <groupId>com.sun.xml.bind</groupId>
+            <artifactId>jaxb-impl</artifactId>
+            <version>2.0.3</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.gcache</groupId>
+            <artifactId>gcache-server</artifactId>
+            <version>${gcacheVersion}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.gcache</groupId>
+            <artifactId>gcache-client</artifactId>
+            <version>${gcacheVersion}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.gcache</groupId>
+            <artifactId>openwire</artifactId>
+            <version>${gcacheVersion}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>backport-util-concurrent</groupId>
+            <artifactId>backport-util-concurrent</artifactId>
+            <version>2.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>1.0.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.xml.bind</groupId>
+            <artifactId>jaxb-api</artifactId>
+            <version>2.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.8</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+            <classifier>jdk15</classifier>
+            <version>5.1</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>net.sf.ehcache</groupId>
+            <artifactId>ehcache</artifactId>
+            <version>1.2.3</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.mina</groupId>
+            <artifactId>mina-core</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <version>1.0</version>
+            <scope>provided</scope>
+        </dependency>
+
+    </dependencies>
+</dependencyManagement>
+
+<distributionManagement>
+
+    <repository>
+        <id>apache-releases</id>
+        <name>Apache Release Distribution Repository</name>
+        <url>scp://people.apache.org/www/people.apache.org/repo/m2-ibiblio-rsync-repository</url>
+    </repository>
+
+    <snapshotRepository>
+        <id>apache-snapshots</id>
+        <name>Apache Snapshot Repository</name>
+        <url>scp://people.apache.org/www/people.apache.org/repo/m2-snapshot-repository</url>
+    </snapshotRepository>
+
+    <site>
+        <id>gcache-website</id>
+        <url>scp://people.apache.org/www/geronimo.apache.org/maven/gcache</url>
+    </site>
+
+</distributionManagement>
+
+<build>
+    <pluginManagement>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>jaxb2-maven-plugin</artifactId>
+                <version>1.1-SNAPSHOT</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>xjc</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                </configuration>
+            </plugin>
+            <!--
+            NOTE: Using custom maven-surefire-plugin that supports TestNG:
+
+            http://testng.org/doc/maven.html
+            -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.8-SNAPSHOT</version>
+            </plugin>
+        </plugins>
+    </pluginManagement>
+</build>
+
+<!--
+NOTE: This is the repository where maven-surefire-plugin:2.8-SNAPSHOT comes from.
+-->
+<pluginRepositories>
+    <pluginRepository>
+        <id>tapestry.javaforge</id>
+        <url>http://howardlewisship.com/repository</url>
+    </pluginRepository>
+    <pluginRepository>
+        <releases>
+            <enabled>false</enabled>
+        </releases>
+        <id>snapshots</id>
+        <name>Maven Snapshot Development Repository</name>
+        <url>http://snapshots.maven.codehaus.org/maven2</url>
+    </pluginRepository>
+</pluginRepositories>
+
+<repositories>
+    <repository>
+        <id>apache-m2-snapshot-repo</id>
+        <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+        <name>Apache Maven Snapshots Repository</name>
+        <layout>default</layout>
+        <snapshots>
+            <enabled>true</enabled>
+            <updatePolicy>daily</updatePolicy>
+            <checksumPolicy>ignore</checksumPolicy>
+        </snapshots>
+        <releases>
+            <enabled>true</enabled>
+        </releases>
+    </repository>
+</repositories>
 
 
 </project>

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/ConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/ConfigBuilder.java?view=diff&rev=470543&r1=470542&r2=470543
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/ConfigBuilder.java
(original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/ConfigBuilder.java
Thu Nov  2 14:06:28 2006
@@ -101,8 +101,7 @@
             if (diskStore != null) {
                 String path = diskStore.getPath();
                 diskConfig = new DiskStoreConfiguration();
-                diskConfig.setPath(StringUtil
-                        .parseAndReplaceSystemProperty(path));
+                diskConfig.setPath(path);
             }
             
             //Read the default cache

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/JaxbGcacheConfigFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/JaxbGcacheConfigFactory.java?view=diff&rev=470543&r1=470542&r2=470543
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/JaxbGcacheConfigFactory.java
(original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/dd/JaxbGcacheConfigFactory.java
Thu Nov  2 14:06:28 2006
@@ -17,8 +17,12 @@
  */
 package org.apache.geronimo.gcache.dd;
 
-import java.io.InputStream;
-import java.net.URL;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLFilterImpl;
+import org.apache.geronimo.gcache.util.StringUtil;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Unmarshaller;
@@ -26,28 +30,37 @@
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 import javax.xml.transform.sax.SAXSource;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLFilterImpl;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.BufferedReader;
+import java.io.StringReader;
+import java.net.URL;
 
 public class JaxbGcacheConfigFactory {
 
     public static final String SCHEMA = "http://geronimo.apache.org/xml/ns/gcache-1.0";
 
-    public static GcacheConfig getConfig(URL url) throws Exception{
+    public static GcacheConfig getConfig(URL url) throws Exception {
         InputStream gcacheDescriptor = null;
 
         try {
 
             gcacheDescriptor = url.openStream();
 
+            //First read the file into memory to convert properties before processing
+            BufferedReader in = new BufferedReader(new InputStreamReader(gcacheDescriptor));
+            String inputLine;
+
+            StringBuffer inFile = new StringBuffer();
+            while ((inputLine = in.readLine()) != null)
+                inFile.append(inputLine);
+            in.close();
+            StringUtil.parseAndReplaceSystemProperty(inFile);
+
             JAXBContext jc = JAXBContext.newInstance(GcacheConfig.class);
             Unmarshaller u = jc.createUnmarshaller();
             UnmarshallerHandler uh = u.getUnmarshallerHandler();
-            
+
             // create a new XML parser
             SAXParserFactory factory = SAXParserFactory.newInstance();
             factory.setNamespaceAware(true);
@@ -62,9 +75,8 @@
             // Be sure the filter has the JAXB content handler set (or it wont
             // work)
             xmlFilter.setContentHandler(uh);
-            SAXSource source = new SAXSource(xmlFilter, new InputSource(
-                    gcacheDescriptor));
-            
+            SAXSource source = new SAXSource(xmlFilter, new InputSource(new StringReader(inFile.toString())
));
+
             return (GcacheConfig) u.unmarshal(source);
 
         } finally {
@@ -82,7 +94,7 @@
 
         @Override
         public void startElement(String arg0, String arg1, String arg2,
-                Attributes arg3) throws SAXException {
+                                 Attributes arg3) throws SAXException {
             super.startElement(SCHEMA, arg1, arg2, arg3);
         }
     }

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/StringUtil.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/StringUtil.java?view=diff&rev=470543&r1=470542&r2=470543
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/StringUtil.java
(original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/StringUtil.java
Thu Nov  2 14:06:28 2006
@@ -21,9 +21,14 @@
     
     private static final String DEFAULT_PLACEHOLDER_PREFIX = "${";
     private static final String DEFAULT_PLACEHOLDER_SUFFIX = "}";
-    
+
     public static String parseAndReplaceSystemProperty(String str) {
         StringBuffer buf = new StringBuffer(str);
+        parseAndReplaceSystemProperty(buf);
+        return buf.toString();
+    }
+
+    public static void parseAndReplaceSystemProperty(StringBuffer buf) {
 
         int start = buf.indexOf(DEFAULT_PLACEHOLDER_PREFIX);
         while (start != -1) {
@@ -42,7 +47,6 @@
             }
         }
         
-        return buf.toString();
     }
 
 }

Modified: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/dd/ConfigBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/dd/ConfigBuilderTest.java?view=diff&rev=470543&r1=470542&r2=470543
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/dd/ConfigBuilderTest.java
(original)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/dd/ConfigBuilderTest.java
Thu Nov  2 14:06:28 2006
@@ -25,39 +25,42 @@
 import org.testng.annotations.Test;
 
 public class ConfigBuilderTest {
-    
+
     @Test
-    public void testConfigBuilder() throws Exception{
-       ConfigBuilder cb = new ConfigBuilder();
-       
-       //Pull the configuration
-       GcacheConfiguration config = cb.getConfig(null);
-       
-       //Server and Transport Settings
-       assert config.getServerName().equals("gcache");
-       assert config.getTransportUri().getHost().equals("default");
-       assert config.getTransportUri().getScheme().equals("tcp");
-       
-       //Check for cache configs
-       Configuration ehcacheConfig = config.getEhcacheConfig();
-       assert ehcacheConfig != null;
-       
-       Map configs = ehcacheConfig.getCacheConfigurations();
-       assert configs.containsKey("Test");
-       assert configs.containsKey("Test2");
-       
-       //Test cache detail info
-       CacheConfiguration cacheConfig = (CacheConfiguration) configs.get("Test");
-       assert 60 == cacheConfig.getDiskExpiryThreadIntervalSeconds();
-       assert 1800 == cacheConfig.getTimeToIdleSeconds();
-       assert cacheConfig.getMemoryStoreEvictionPolicy().toString().equals("LRU");
-       assert 0 == cacheConfig.getTimeToLiveSeconds();
-       
-       CacheConfiguration defaultConfig = ehcacheConfig.getDefaultCacheConfiguration();
-       assert 120 == defaultConfig.getDiskExpiryThreadIntervalSeconds();
-       assert 120 == defaultConfig.getTimeToIdleSeconds();
-       assert defaultConfig.getMemoryStoreEvictionPolicy().toString().equals("LRU");
-       assert 120 == defaultConfig.getTimeToLiveSeconds();
+    public void testConfigBuilder() throws Exception {
+        ConfigBuilder cb = new ConfigBuilder();
+
+        //Pull the configuration
+        GcacheConfiguration config = cb.getConfig(null);
+
+        //Server and Transport Settings
+        assert config.getServerName().equals("gcache");
+        assert config.getTransportUri().getHost().equals("default");
+        assert config.getTransportUri().getScheme().equals("tcp");
+        assert config.getDiscoveryUri().getHost().equals("default");
+        assert config.getDiscoveryUri().getScheme().equals("multicast");
+
+        //Check for cache configs
+        Configuration ehcacheConfig = config.getEhcacheConfig();
+        assert ehcacheConfig != null;
+
+        Map configs = ehcacheConfig.getCacheConfigurations();
+        assert configs.containsKey("Test");
+        assert configs.containsKey("Test2");
+
+        //Test cache detail info
+        CacheConfiguration cacheConfig = (CacheConfiguration) configs.get("Test");
+        assert 60 == cacheConfig.getDiskExpiryThreadIntervalSeconds();
+        assert 1800 == cacheConfig.getTimeToIdleSeconds();
+        assert cacheConfig.getMemoryStoreEvictionPolicy().toString().equals("LRU");
+        assert 0 == cacheConfig.getTimeToLiveSeconds();
+
+        //Test a default cache was configured
+        CacheConfiguration defaultConfig = ehcacheConfig.getDefaultCacheConfiguration();
+        assert 120 == defaultConfig.getDiskExpiryThreadIntervalSeconds();
+        assert 120 == defaultConfig.getTimeToIdleSeconds();
+        assert defaultConfig.getMemoryStoreEvictionPolicy().toString().equals("LRU");
+        assert 120 == defaultConfig.getTimeToLiveSeconds();
     }
 
 }



Mime
View raw message