[Yanel-commits] rev 23197 - in public/yanel/trunk: conf src/build src/core/java/org/wyona/yanel/core src/core/java/org/wyona/yanel/core/map src/test

josias at wyona.com josias at wyona.com
Thu Mar 8 18:06:40 CET 2007


Author: josias
Date: 2007-03-08 18:06:38 +0100 (Thu, 08 Mar 2007)
New Revision: 23197

Added:
   public/yanel/trunk/conf/resource-types.xml
   public/yanel/trunk/src/build/resource2resourcetypereg.xsl
Modified:
   public/yanel/trunk/conf/yanel.xml
   public/yanel/trunk/src/build/build.xml
   public/yanel/trunk/src/build/yanel2properties.xsl
   public/yanel/trunk/src/build/yanel2resources.xsl
   public/yanel/trunk/src/core/java/org/wyona/yanel/core/ResourceTypeRegistry.java
   public/yanel/trunk/src/core/java/org/wyona/yanel/core/map/RealmConfiguration.java
   public/yanel/trunk/src/test/build.xml
   public/yanel/trunk/src/test/test-resources.xsl
Log:
change yanel.properties file to yanel.xml. see bug #5212, thanks to simon

Added: public/yanel/trunk/conf/resource-types.xml
===================================================================
--- public/yanel/trunk/conf/resource-types.xml	2007-03-08 15:10:24 UTC (rev 23196)
+++ public/yanel/trunk/conf/resource-types.xml	2007-03-08 17:06:38 UTC (rev 23197)
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+
+<!-- NOTE: compile is true by default -->
+<resource-types xmlns="http://www.wyona.org/yanel/1.0">
+  <!-- HEADSUP: Make sure to add the trailing slash (/) in the @src attribute! -->
+  <resource-type src="../src/resources/file/"                        compile="true"/>
+  <resource-type src="../src/resources/directory/"                   compile="true"/>
+<!--
+  <resource-type src="../src/resources/tape/"                        compile="true"/>
+-->
+  <resource-type src="../src/resources/add-realm/"                  compile="true"/>
+  <resource-type src="../src/resources/odt/"                         compile="true"/>
+  <resource-type src="../src/resources/xml/"                         compile="true"/>
+  <resource-type src="../src/realms/welcome-admin/yanel/resources/show-realms/"                 compile="true"/>
+  <resource-type src="../src/realms/welcome-admin/yanel/resources/update-webapp/"                 compile="true"/>
+<!--
+  <resource-type src="../src/resources/invoice/"                     compile="true"/>
+-->
+  <resource-type src="../src/resources/testing-control/"             compile="true"/>
+  <resource-type src="../src/resources/testing-times/"               compile="true"/>
+  <resource-type src="../src/contributions/resources/atom/"          compile="true"/>
+  <resource-type src="../src/contributions/resources/atom-entry/"    compile="true"/>
+  <resource-type src="../src/contributions/resources/contact-form/"  compile="true"/>
+  <resource-type src="../src/contributions/resources/wiki/"          compile="true"/>
+  <resource-type src="../src/contributions/resources/zip/"           compile="true"/>
+  <resource-type src="../src/contributions/resources/calendar/"      compile="true"/>
+  <resource-type src="../src/contributions/resources/resource-creator/"      compile="true"/>
+<!--
+  <resource-type src="../src/resources/websearch/"                   compile="true"/>
+-->
+  <resource-type src="../src/contributions/resources/nutch/"         compile="true"/>
+  <resource-type src="../src/contributions/resources/davcollection/" compile="true"/>
+  <resource-type src="../src/contributions/resources/pdf/"           compile="true"/>
+
+  <resource-type src="../src/contributions/resources/yanel-user/"    compile="true"/> 
+
+</resource-types>
\ No newline at end of file


Property changes on: public/yanel/trunk/conf/resource-types.xml
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: public/yanel/trunk/conf/yanel.xml
===================================================================
--- public/yanel/trunk/conf/yanel.xml	2007-03-08 15:10:24 UTC (rev 23196)
+++ public/yanel/trunk/conf/yanel.xml	2007-03-08 17:06:38 UTC (rev 23197)
@@ -1,44 +1,11 @@
 <?xml version="1.0"?>
 
 <yanel xmlns="http://www.wyona.org/yanel/1.0">
-
-<!-- NOTE: compile is true by default -->
-<resources>
-  <!-- HEADSUP: Make sure to add the trailing slash (/) in the @src attribute! -->
-  <resource src="../src/resources/file/"                        compile="true"/>
-  <resource src="../src/resources/directory/"                   compile="true"/>
-<!--
-  <resource src="../src/resources/tape/"                        compile="true"/>
--->
-  <resource src="../src/resources/add-realm/"                  compile="true"/>
-  <resource src="../src/resources/odt/"                         compile="true"/>
-  <resource src="../src/resources/xml/"                         compile="true"/>
-  <resource src="../src/realms/welcome-admin/yanel/resources/show-realms/"                 compile="true"/>
-  <resource src="../src/realms/welcome-admin/yanel/resources/update-webapp/"                 compile="true"/>
-<!--
-  <resource src="../src/resources/invoice/"                     compile="true"/>
--->
-  <resource src="../src/resources/testing-control/"             compile="true"/>
-  <resource src="../src/resources/testing-times/"               compile="true"/>
-  <resource src="../src/contributions/resources/atom/"          compile="true"/>
-  <resource src="../src/contributions/resources/atom-entry/"    compile="true"/>
-  <resource src="../src/contributions/resources/contact-form/"  compile="true"/>
-  <resource src="../src/contributions/resources/wiki/"          compile="true"/>
-  <resource src="../src/contributions/resources/zip/"           compile="true"/>
-  <resource src="../src/contributions/resources/calendar/"      compile="true"/>
-  <resource src="../src/contributions/resources/resource-creator/"      compile="true"/>
-<!--
-  <resource src="../src/resources/websearch/"                   compile="true"/>
--->
-  <resource src="../src/contributions/resources/nutch/"         compile="true"/>
-  <resource src="../src/contributions/resources/davcollection/" compile="true"/>
-  <resource src="../src/contributions/resources/pdf/"           compile="true"/>
-
-  <resource src="../src/contributions/resources/yanel-user/"    compile="true"/> 
-
-</resources>
-
-# Realms configuration
-<realms-config src="realms.xml"/>
-
+  
+  <!-- # Realms configuration -->
+  <realms-config src="realms.xml"/>
+  
+  <!-- # ResourceTypes configuration -->
+  <resource-types-config src="resource-types.xml"/>
+  
 </yanel>

Modified: public/yanel/trunk/src/build/build.xml
===================================================================
--- public/yanel/trunk/src/build/build.xml	2007-03-08 15:10:24 UTC (rev 23196)
+++ public/yanel/trunk/src/build/build.xml	2007-03-08 17:06:38 UTC (rev 23197)
@@ -193,6 +193,7 @@
 
     <copy file="${yanel.home.dir}/conf/yanel.xml" tofile="${yanel.home.dir}/${local.config.dir}/local.yanel.xml" overwrite="false"/>
     <copy file="${yanel.home.dir}/conf/realms.xml" tofile="${yanel.home.dir}/${local.config.dir}/local.realms.xml" overwrite="false"/>
+    <copy file="${yanel.home.dir}/conf/resource-types.xml" tofile="${yanel.home.dir}/${local.config.dir}/local.resource-types.xml" overwrite="false"/>
     <copy file="${yanel.home.dir}/conf/log4j.properties" tofile="${yanel.home.dir}/${local.config.dir}/local.log4j.properties" overwrite="false"/>
 
     <echo>Customize the ${local.config.dir}/local.* files and run build.sh OR run build.sh first and then customize the config files within build/webapps/yanel/WEB-INF/classes</echo>
@@ -383,11 +384,12 @@
     <copy file="${yanel.home.dir}/conf/spring-yanel-config.xml" todir="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes" overwrite="false"/>
     <copy file="${yanel.home.dir}/conf/realms.xml" todir="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes" overwrite="false"/>
     <copy file="${yanel.home.dir}/conf/log4j.properties" todir="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes" overwrite="false"/>
-    <!-- Create yanel.properties -->
+    <!-- Create yanel.xml -->
     <condition property="local.yanel.config.exists">
       <available file="${yanel.home.dir}/${local.config.dir}/local.yanel.xml" type="file"/>
     </condition>
     <antcall target="generate-yanel-properties"/>
+    <antcall target="generate-resource-types-regisitry"/>
 
 
     <!-- Overwrite default by local properties -->
@@ -395,17 +397,22 @@
     <copy file="${yanel.home.dir}/${local.config.dir}/local.log4j.properties" tofile="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes/log4j.properties" overwrite="true" failonerror="false"/>
     <copy file="${yanel.home.dir}/${local.config.dir}/local.realms.xml" tofile="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes/realms.xml" overwrite="true" failonerror="false"/>
     <antcall target="patch-with-local-yanel-config"/>
+    <antcall target="patch-with-local-resource-types-regisitry"/>
 
 
     <!-- Patch properties ... -->
 
-    <replace file="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes/yanel.properties" value="${yanel.home.dir.forward.slashes}">
+    <replace file="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes/yanel.xml" value="${yanel.home.dir.forward.slashes}">
       <replacetoken>..</replacetoken>
     </replace>
 
     <replace file="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes/realms.xml" value="${yanel.home.dir.forward.slashes}/src/realms">
       <replacetoken>../src/realms</replacetoken>
     </replace>
+
+    <replace file="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes/resource-types.xml" value="${yanel.home.dir.forward.slashes}/src">
+      <replacetoken>../src</replacetoken>
+    </replace>
     
     <copy file="${yanel.home.dir}/src/build/install.rdf" todir="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes" overwrite="true"/>
     <replace file="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes/install.rdf" value="${yanel.version}-r${yanel.revision}">
@@ -434,7 +441,7 @@
     </condition>
     <antcall target="generate-javadoc"/>
 
-    <ant antfile="${yanel.home.dir}/build/resources.xml" target="copy-resources-dependencies"/>
+    <ant antfile="${yanel.home.dir}/build/resource-types.xml" target="copy-resources-dependencies"/>
   </target>
 
   <target name="war" description="Build war file" depends="init, webapp">
@@ -786,21 +793,21 @@
   </target>
 
   <target name="generate-resources-build-from-default" description="Generate resources build from default config" depends="init" unless="local.yanel.config.exists">
-    <xslt in="${yanel.home.dir}/conf/yanel.xml" out="../../build/resources.xml" style="yanel2resources.xsl" force="false">
+    <xslt in="${yanel.home.dir}/conf/resource-types.xml" out="../../build/resource-types.xml" style="yanel2resources.xsl" force="false">
       <param name="servlet.context.prefix" expression="${servlet.context.prefix}"/>
       <param name="yanel.source.version" expression="${yanel.version}-r${yanel.revision}"/>
     </xslt>
   </target>
 
   <target name="generate-resources-build-from-local" description="Generate resources build from local config" depends="init" if="local.yanel.config.exists">
-    <xslt in="${yanel.home.dir}/${local.config.dir}/local.yanel.xml" out="../../build/resources.xml" style="yanel2resources.xsl" force="true">
+    <xslt in="${yanel.home.dir}/${local.config.dir}/local.resource-types.xml" out="../../build/resource-types.xml" style="yanel2resources.xsl" force="true">
       <param name="servlet.context.prefix" expression="${servlet.context.prefix}"/>
       <param name="yanel.source.version" expression="${yanel.version}-r${yanel.revision}"/>
     </xslt>
   </target>
 
   <target name="build-resources" description="Build resources" depends="generate-resources-build">
-    <ant antfile="${yanel.home.dir}/build/resources.xml" target="build-resources"/>
+    <ant antfile="${yanel.home.dir}/build/resource-types.xml" target="build-resources"/>
   </target>
 
   <target name="deploy-resources" description="Deploy resources" depends="generate-resources-build">
@@ -811,24 +818,44 @@
       </fileset>
     </copy>
     
-    <ant antfile="${yanel.home.dir}/build/resources.xml" target="deploy-resources"/>
+    <ant antfile="${yanel.home.dir}/build/resource-types.xml" target="deploy-resources"/>
   </target>
 
   <target name="clean-resources" description="Clean resources" depends="generate-resources-build">
-    <ant antfile="${yanel.home.dir}/build/resources.xml" target="clean-resources"/>
+    <ant antfile="${yanel.home.dir}/build/resource-types.xml" target="clean-resources"/>
   </target>
 
   <target name="generate-yanel-properties" unless="local.yanel.config.exists">
-    <xslt in="${yanel.home.dir}/conf/yanel.xml" out="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes/yanel.properties" style="yanel2properties.xsl" force="false">
+    <xslt in="${yanel.home.dir}/conf/yanel.xml" out="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes/yanel.xml" style="yanel2properties.xsl" force="false">
       <param name="servlet.context.prefix" expression="${servlet.context.prefix}"/>
+      <param name="yanel.revision" expression="${yanel.revision}"/>
+      <param name="yanel.version" expression="${yanel.version}"/>
     </xslt>
   </target>
 
   <target name="patch-with-local-yanel-config" if="local.yanel.config.exists">
-    <xslt in="${yanel.home.dir}/${local.config.dir}/local.yanel.xml" out="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes/yanel.properties" style="yanel2properties.xsl" force="true">
+    <xslt in="${yanel.home.dir}/${local.config.dir}/local.yanel.xml" out="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes/yanel.xml" style="yanel2properties.xsl" force="true">
       <param name="servlet.context.prefix" expression="${servlet.context.prefix}"/>
+      <param name="yanel.revision" expression="${yanel.revision}"/>
+      <param name="yanel.version" expression="${yanel.version}"/>
     </xslt>
   </target>
+
+  <target name="generate-resource-types-regisitry" unless="local.yanel.config.exists">
+    <xslt in="${yanel.home.dir}/conf/resource-types.xml" out="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes/resource-types.xml" style="resource2resourcetypereg.xsl" force="false">
+      <param name="servlet.context.prefix" expression="${servlet.context.prefix}"/>
+      <param name="yanel.revision" expression="${yanel.revision}"/>
+      <param name="yanel.version" expression="${yanel.version}"/>
+    </xslt>
+  </target>
+
+  <target name="patch-with-local-resource-types-regisitry" if="local.yanel.config.exists">
+    <xslt in="${yanel.home.dir}/${local.config.dir}/local.resource-types.xml" out="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes/resource-types.xml" style="resource2resourcetypereg.xsl" force="true">
+      <param name="servlet.context.prefix" expression="${servlet.context.prefix}"/>
+      <param name="yanel.revision" expression="${yanel.revision}"/>
+      <param name="yanel.version" expression="${yanel.version}"/>
+    </xslt>
+  </target>
   
   <target name="test" description="Run tests">
     <ant dir="../test" target="test" inheritall="false"/>

Added: public/yanel/trunk/src/build/resource2resourcetypereg.xsl
===================================================================
--- public/yanel/trunk/src/build/resource2resourcetypereg.xsl	2007-03-08 15:10:24 UTC (rev 23196)
+++ public/yanel/trunk/src/build/resource2resourcetypereg.xsl	2007-03-08 17:06:38 UTC (rev 23197)
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:yanel="http://www.wyona.org/yanel/1.0" 
+  xmlns="http://www.wyona.org/yanel/1.0"
+  >
+  
+  <xsl:output method="xml" indent="yes"/>
+  
+  <xsl:param name="servlet.context.prefix" select="'NULL'"/>
+  
+  <xsl:template match="/">
+    <xsl:apply-templates/>
+  </xsl:template>
+  
+  <xsl:template match="@src">
+    <xsl:attribute name="src"><xsl:value-of select="."/>resource.xml</xsl:attribute>
+  </xsl:template>
+
+  <xsl:template match="@*|node()" priority="-1">
+    <xsl:copy>
+      <xsl:apply-templates select="@*|node()"/>
+    </xsl:copy>
+  </xsl:template>
+</xsl:stylesheet>


Property changes on: public/yanel/trunk/src/build/resource2resourcetypereg.xsl
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: public/yanel/trunk/src/build/yanel2properties.xsl
===================================================================
--- public/yanel/trunk/src/build/yanel2properties.xsl	2007-03-08 15:10:24 UTC (rev 23196)
+++ public/yanel/trunk/src/build/yanel2properties.xsl	2007-03-08 17:06:38 UTC (rev 23197)
@@ -1,57 +1,23 @@
 <?xml version="1.0"?>
-
-<xsl:stylesheet version="1.0"
+<xsl:stylesheet version="1.0" 
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-  xmlns:yanel="http://www.wyona.org/yanel/1.0"
->
+  xmlns:yanel="http://www.wyona.org/yanel/1.0" 
+  xmlns="http://www.wyona.org/yanel/1.0"
+  >
+  
+  <xsl:output method="xml" indent="yes"/>
+  
+  <xsl:param name="servlet.context.prefix" select="'NULL'"/>
+  <xsl:param name="yanel.revision" select="'NULL'"/>
+  <xsl:param name="yanel.version" select="'NULL'"/>
+  
+  <xsl:template match="/">
+    <yanel>
+      <xsl:comment> NOTE: This file has been generated automatically from conf/yanel.xml!</xsl:comment>
+      <version version="{$yanel.version}" revision="{$yanel.revision}"/>
+      <xsl:copy-of select="/yanel:yanel/yanel:realms-config"/>
+      <xsl:copy-of select="/yanel:yanel/yanel:resource-types-config"/>
+    </yanel>
+  </xsl:template>
 
-<xsl:output method="text" indent="yes"/>
-
-<xsl:param name="servlet.context.prefix" select="'NULL'"/>
-
-<xsl:template match="/">
-# NOTE: This file has been generated automatically from conf/yanel.xml!
-
-# Version
-version=1.0-dev-r21728
-
-# Registered resources
-resources=<xsl:for-each select="/yanel:yanel/yanel:resources/yanel:resource"><xsl:value-of select="@src"/>resource.xml<xsl:if test="position() != last()">,</xsl:if></xsl:for-each>
-
-<xsl:apply-templates select="/yanel:yanel/yanel:reverse-proxy"/>
-
-<xsl:apply-templates select="/yanel:yanel/yanel:realms-config"/>
-</xsl:template>
-
-<xsl:template match="yanel:reverse-proxy">
-
-
-# Reverse Proxy Configuration
-<xsl:apply-templates select="yanel:host-name"/>
-<xsl:apply-templates select="yanel:port"/>
-<xsl:apply-templates select="yanel:prefix"/>
-</xsl:template>
-
-
-
-<xsl:template match="yanel:host-name">
-proxy-host-name=<xsl:value-of select="."/>
-</xsl:template>
-
-<xsl:template match="yanel:port">
-proxy-port=<xsl:value-of select="."/>
-</xsl:template>
-
-<xsl:template match="yanel:prefix">
-proxy-prefix=<xsl:value-of select="."/>
-</xsl:template>
-
-
-<xsl:template match="yanel:realms-config">
-
-
-# Realms configuration
-realms-config=<xsl:value-of select="@src"/>
-</xsl:template>
-
 </xsl:stylesheet>

Modified: public/yanel/trunk/src/build/yanel2resources.xsl
===================================================================
--- public/yanel/trunk/src/build/yanel2resources.xsl	2007-03-08 15:10:24 UTC (rev 23196)
+++ public/yanel/trunk/src/build/yanel2resources.xsl	2007-03-08 17:06:38 UTC (rev 23197)
@@ -25,7 +25,7 @@
   </target>
 
   <target name="build-resources" description="Build resources" depends="init">
-<xsl:for-each select="/yanel:yanel/yanel:resources/yanel:resource">
+<xsl:for-each select="/yanel:resource-types/yanel:resource-type">
   <xsl:choose>
     <xsl:when test="@compile='false'">
       <echo>INFO: Do not compile: <xsl:value-of select="@src"/></echo>
@@ -49,7 +49,7 @@
   </target>
 
   <target name="deploy-resources" description="Deploy resources" depends="init">
-<xsl:for-each select="/yanel:yanel/yanel:resources/yanel:resource">
+<xsl:for-each select="/yanel:resource-types/yanel:resource-type">
     <xsl:choose>
       <xsl:when test="starts-with(@src, '/')">
     <copy todir="${{build.dir}}/webapps/{$servlet.context.prefix}/WEB-INF/lib">
@@ -66,7 +66,7 @@
   </target>
 
   <target name="clean-resources" description="Clean resources" depends="init">
-<xsl:for-each select="/yanel:yanel/yanel:resources/yanel:resource">
+<xsl:for-each select="/yanel:resource-types/yanel:resource-type">
   <xsl:choose>
     <xsl:when test="@compile='false'">
       <echo>INFO: Do not clean: <xsl:value-of select="@src"/>build</echo>
@@ -87,7 +87,7 @@
   </target>
 
   <target name="copy-resources-dependencies" description="Copy dependencies of resources" depends="init">
-<xsl:for-each select="/yanel:yanel/yanel:resources/yanel:resource">
+<xsl:for-each select="/yanel:resource-types/yanel:resource-type">
     <xsl:choose>
       <xsl:when test="starts-with(@src, '/')">
     <ant inheritAll="false" antfile="{@src}/build.xml" target="copy-dependencies">

Modified: public/yanel/trunk/src/core/java/org/wyona/yanel/core/ResourceTypeRegistry.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/core/ResourceTypeRegistry.java	2007-03-08 15:10:24 UTC (rev 23196)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/core/ResourceTypeRegistry.java	2007-03-08 17:06:38 UTC (rev 23197)
@@ -22,13 +22,17 @@
 import java.lang.InstantiationException;
 import java.net.URL;
 import java.net.URLDecoder;
+import java.util.LinkedHashMap;
 import java.util.Properties;
 
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
 import org.apache.log4j.Category;
 
 import org.wyona.commons.io.FileUtil;
 import org.wyona.yanel.core.map.Map;
 import org.wyona.yanel.core.map.Realm;
+import org.wyona.yanel.core.map.RealmConfiguration;
 
 /**
  *
@@ -38,9 +42,12 @@
     private static Category log = Category.getInstance(ResourceTypeRegistry.class);
 
     public static final String DEFAULT_CONFIGURATION_FILE = "yanel.properties";
+    public static final String DEFAULT_CONFIGURATION_FILE_XML = "yanel.xml";
     public static String CONFIGURATION_FILE = DEFAULT_CONFIGURATION_FILE;
 
     private URL propertiesURL;
+    private File configFile;
+    private File resourceTypeConfigFile; 
 
     java.util.HashMap hm = new java.util.HashMap();
 
@@ -48,32 +55,99 @@
      *
      */
     public ResourceTypeRegistry() {
-        this(DEFAULT_CONFIGURATION_FILE);
+        this(DEFAULT_CONFIGURATION_FILE_XML);
     }
 
     /**
-     *
+     * 
      */
     public ResourceTypeRegistry(String configurationFile) {
         CONFIGURATION_FILE = configurationFile;
 
-        propertiesURL = ResourceTypeRegistry.class.getClassLoader().getResource(CONFIGURATION_FILE);
-        if (propertiesURL == null) {
-            log.error("No such resource: " + CONFIGURATION_FILE);
-            return;
+        if (RealmConfiguration.class.getClassLoader().getResource(CONFIGURATION_FILE) == null) {
+            CONFIGURATION_FILE = DEFAULT_CONFIGURATION_FILE;
         }
 
-        Properties props = new Properties();
+        if (ResourceTypeRegistry.class.getClassLoader().getResource(CONFIGURATION_FILE) != null) {
+
+            if (CONFIGURATION_FILE.endsWith(".xml")) {
+                configFile = new File(RealmConfiguration.class.getClassLoader()
+                        .getResource(CONFIGURATION_FILE)
+                        .getFile());
+                try {
+                    DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+                    Configuration config;
+                    config = builder.buildFromFile(configFile);
+
+                    resourceTypeConfigFile = new File(config.getChild("resource-types-config")
+                            .getAttribute("src"));
+                    if (!resourceTypeConfigFile.isAbsolute()) {
+                        resourceTypeConfigFile = FileUtil.file(configFile.getParentFile()
+                                .getAbsolutePath(), resourceTypeConfigFile.toString());
+                    }
+                    log.debug("Realms Configuration: " + resourceTypeConfigFile);
+                    readResourceTypes();
+                } catch (Exception e) {
+                    String errorMsg = "Failure while reading configuration: " + e.getMessage();
+                    log.error(errorMsg, e);
+                }
+
+
+            } else if (CONFIGURATION_FILE.endsWith("properties")) {
+                propertiesURL = ResourceTypeRegistry.class.getClassLoader()
+                        .getResource(CONFIGURATION_FILE);
+
+                Properties props = new Properties();
+                try {
+                    props.load(propertiesURL.openStream());
+                    // use URLDecoder to avoid problems when the filename contains spaces, see
+                    // http://bugzilla.wyona.com/cgi-bin/bugzilla/show_bug.cgi?id=5165
+                    File propsFile = new File(URLDecoder.decode(propertiesURL.getFile()));
+                    String separator = ",";
+                    String[] tokens = props.getProperty("resources").split(separator);
+                    for (int i = 0; i < tokens.length; i++) {
+                        File resConfigFile = new File(tokens[i]);
+                        if (!resConfigFile.isAbsolute()) {
+                            resConfigFile = FileUtil.file(propsFile.getParentFile()
+                                    .getAbsolutePath(), tokens[i]);
+                        }
+
+                        if (resConfigFile.exists()) {
+                            ResourceTypeDefinition rtd = new ResourceTypeDefinition(resConfigFile);
+                            log.debug("Universal Name: " + rtd.getResourceTypeUniversalName());
+                            log.debug("Classname: " + rtd.getResourceTypeClassname());
+                            hm.put(rtd.getResourceTypeUniversalName(), rtd);
+                        } else {
+                            log.warn("No such file or directory: " + resConfigFile);
+                        }
+                    }
+                } catch (Exception e) {
+                    log.error(e);
+                }
+            } else {
+                log.error(CONFIGURATION_FILE + "have to be either .xml or .properties");
+            }
+        } else {
+            log.error("No such config file" + CONFIGURATION_FILE);
+        }
+    }
+
+    /**
+     * 
+     */
+    public void readResourceTypes() throws ConfigurationException {
         try {
-            props.load(propertiesURL.openStream());
-            // use URLDecoder to avoid problems when the filename contains spaces, see http://bugzilla.wyona.com/cgi-bin/bugzilla/show_bug.cgi?id=5165
-            File propsFile = new File(URLDecoder.decode(propertiesURL.getFile()));
-            String separator = ",";
-            String[] tokens = props.getProperty("resources").split(separator);
-            for (int i = 0; i < tokens.length; i++) {
-                File resConfigFile = new File(tokens[i]);
+            DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+            Configuration config;
+            config = builder.buildFromFile(resourceTypeConfigFile);
+            
+            Configuration resourceTypes[] = config.getChildren("resource-type");
+            
+            for (int i = 0; i < resourceTypes.length; i++) {
+                File resConfigFile = new File(resourceTypes[i].getAttribute("src"));
                 if (!resConfigFile.isAbsolute()) {
-                    resConfigFile = FileUtil.file(propsFile.getParentFile().getAbsolutePath(), tokens[i]);
+                    resConfigFile = FileUtil.file(resourceTypeConfigFile.getParentFile()
+                            .getAbsolutePath(), resourceTypes[i].getAttribute("src"));
                 }
 
                 if (resConfigFile.exists()) {
@@ -84,12 +158,15 @@
                 } else {
                     log.warn("No such file or directory: " + resConfigFile);
                 }
-            }
+            }    
         } catch (Exception e) {
-            log.error(e);
+            String errorMsg = "Failure while reading configuration: " + e.getMessage(); 
+            log.error(errorMsg, e);
+            throw new ConfigurationException(errorMsg, e);
         }
+        
     }
-
+   
     /**
      *
      */
@@ -117,7 +194,7 @@
      * @deprecated
      */
     public Resource newResource(String universalName) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
-	ResourceTypeDefinition rtd = (ResourceTypeDefinition) hm.get(universalName);
+    ResourceTypeDefinition rtd = (ResourceTypeDefinition) hm.get(universalName);
         if (rtd != null) {
             Resource resource = (Resource) Class.forName(rtd.getResourceTypeClassname()).newInstance();
 

Modified: public/yanel/trunk/src/core/java/org/wyona/yanel/core/map/RealmConfiguration.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/core/map/RealmConfiguration.java	2007-03-08 15:10:24 UTC (rev 23196)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/core/map/RealmConfiguration.java	2007-03-08 17:06:38 UTC (rev 23197)
@@ -56,9 +56,11 @@
     private static Category log = Category.getInstance(RealmConfiguration.class);
 
     public static final String DEFAULT_CONFIGURATION_FILE = "yanel.properties";
+    public static final String DEFAULT_CONFIGURATION_FILE_XML = "yanel.xml";
     public static String CONFIGURATION_FILE = DEFAULT_CONFIGURATION_FILE;
 
     private URL propertiesURL;
+    private File configFile;
 
     private File realmsConfigFile; 
 
@@ -69,7 +71,7 @@
      *
      */
     public RealmConfiguration() throws ConfigurationException {
-        this(DEFAULT_CONFIGURATION_FILE);
+        this(DEFAULT_CONFIGURATION_FILE_XML);
     }
 
     /**
@@ -78,29 +80,67 @@
     public RealmConfiguration(String configurationFile) throws ConfigurationException {
         CONFIGURATION_FILE = configurationFile;
 
-        propertiesURL = RealmConfiguration.class.getClassLoader().getResource(CONFIGURATION_FILE);
-        if (propertiesURL == null) {
-            log.error("No such resource: " + CONFIGURATION_FILE);
-            return;
+        if (RealmConfiguration.class.getClassLoader().getResource(CONFIGURATION_FILE) == null) {
+            CONFIGURATION_FILE = DEFAULT_CONFIGURATION_FILE;
         }
 
-        Properties props = new Properties();
-        try {
-            props.load(propertiesURL.openStream());
-            // use URLDecoder to avoid problems when the filename contains spaces, see http://bugzilla.wyona.com/cgi-bin/bugzilla/show_bug.cgi?id=5165
-            File propsFile = new File(URLDecoder.decode(propertiesURL.getFile()));
+        if (RealmConfiguration.class.getClassLoader().getResource(CONFIGURATION_FILE) != null) {
+            if (CONFIGURATION_FILE.endsWith(".xml")) {
 
-            realmsConfigFile = new File(props.getProperty("realms-config"));
-            if (!realmsConfigFile.isAbsolute()) {
-                realmsConfigFile = FileUtil.file(propsFile.getParentFile().getAbsolutePath(), realmsConfigFile.toString());
+                configFile = new File(RealmConfiguration.class.getClassLoader()
+                        .getResource(CONFIGURATION_FILE)
+                        .getFile());
+                try {
+                    DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+                    Configuration config;
+                    config = builder.buildFromFile(configFile);
+
+                    realmsConfigFile = new File(config.getChild("realms-config")
+                            .getAttribute("src"));
+                } catch (Exception e) {
+                    String errorMsg = "Failure while reading configuration: " + e.getMessage();
+                    log.error(errorMsg, e);
+                    throw new ConfigurationException(errorMsg, e);
+                }
+                if (!realmsConfigFile.isAbsolute()) {
+                    realmsConfigFile = FileUtil.file(configFile.getParentFile().getAbsolutePath(),
+                            realmsConfigFile.toString());
+                }
+                log.debug("Realms Configuration: " + realmsConfigFile);
+                readRealms();
+            } else if (CONFIGURATION_FILE.endsWith("properties")) {
+                propertiesURL = RealmConfiguration.class.getClassLoader()
+                        .getResource(CONFIGURATION_FILE);
+                if (propertiesURL == null) {
+                    log.error("No such resource: " + CONFIGURATION_FILE);
+                    return;
+                }
+                Properties props = new Properties();
+                try {
+                    props.load(propertiesURL.openStream());
+                    // use URLDecoder to avoid problems when the filename contains spaces, see
+                    // http://bugzilla.wyona.com/cgi-bin/bugzilla/show_bug.cgi?id=5165
+                    File propsFile = new File(URLDecoder.decode(propertiesURL.getFile()));
+
+                    realmsConfigFile = new File(props.getProperty("realms-config"));
+                    if (!realmsConfigFile.isAbsolute()) {
+                        realmsConfigFile = FileUtil.file(propsFile.getParentFile()
+                                .getAbsolutePath(), realmsConfigFile.toString());
+                    }
+                    log.debug("Realms Configuration: " + realmsConfigFile);
+                    readRealms();
+                    // assignRepositories();
+                } catch (IOException e) {
+                    log.error(e.getMessage(), e);
+                    throw new ConfigurationException("Could not load realms configuration file: "
+                            + propertiesURL);
+                }
+            } else {
+                log.error(CONFIGURATION_FILE + "have to be either .xml or .properties");
             }
-            log.debug("Realms Configuration: " + realmsConfigFile);
-            readRealms();
-            //assignRepositories();
-        } catch (IOException e) {
-            log.error(e.getMessage(), e);
-            throw new ConfigurationException("Could not load realms configuration file: " + propertiesURL);
+            log.error("No such configuration file" + CONFIGURATION_FILE);
         }
+
     }
 
     /**
@@ -357,8 +397,8 @@
         File destRootDir;
         if (destDir != null) {
             if (!destDir.exists() || !destDir.isDirectory()) {
-            	if (!new File(destDir.getAbsolutePath()).mkdirs()) {
-            		throw new Exception("cannot create directory: " + destDir);
+                if (!new File(destDir.getAbsolutePath()).mkdirs()) {
+                    throw new Exception("cannot create directory: " + destDir);
                 }
             }
             destRootDir = new File(destDir, destRealmID);

Modified: public/yanel/trunk/src/test/build.xml
===================================================================
--- public/yanel/trunk/src/test/build.xml	2007-03-08 15:10:24 UTC (rev 23196)
+++ public/yanel/trunk/src/test/build.xml	2007-03-08 17:06:38 UTC (rev 23197)
@@ -86,11 +86,11 @@
   </target>
   
   <target name="generate-resources-test-build-from-default" depends="init" unless="local.yanel.config.exists">
-    <xslt in="${conf.dir}/yanel.xml" out="${build.dir}/test-resources.xml" style="test-resources.xsl" force="false"/>
+    <xslt in="${conf.dir}/resource-types.xml" out="${build.dir}/test-resources.xml" style="test-resources.xsl" force="false"/>
   </target>
 
   <target name="generate-resources-test-build-from-local" depends="init" if="local.yanel.config.exists">
-    <xslt in="${local.conf.dir}/local.yanel.xml" out="${build.dir}/test-resources.xml" style="test-resources.xsl" force="true"/>
+    <xslt in="${local.conf.dir}/local.resource-types.xml" out="${build.dir}/test-resources.xml" style="test-resources.xsl" force="true"/>
   </target>
   
   <target name="copy-properties">

Modified: public/yanel/trunk/src/test/test-resources.xsl
===================================================================
--- public/yanel/trunk/src/test/test-resources.xsl	2007-03-08 15:10:24 UTC (rev 23196)
+++ public/yanel/trunk/src/test/test-resources.xsl	2007-03-08 17:06:38 UTC (rev 23197)
@@ -20,20 +20,20 @@
         <javac destdir="${{junit.build.dir}}">
           <classpath refid="classpath" />
           <include name="src/test/junit/**/*.java"/>
-          <xsl:apply-templates select="/yanel:yanel/yanel:resources/yanel:resource"/>
+          <xsl:apply-templates select="/yanel:resource-types/yanel:resource-type"/>
         </javac>
         
         <javac destdir="${{htmlunit.build.dir}}">
           <classpath refid="classpath" />
           <include name="src/test/htmlunit/**/*.java"/>
-          <xsl:apply-templates select="/yanel:yanel/yanel:resources/yanel:resource"/>
+          <xsl:apply-templates select="/yanel:resource-types/yanel:resource-type"/>
         </javac>
         
       </target>
     </project>
   </xsl:template>
   
-  <xsl:template match="yanel:resource[@compile='true']">
+  <xsl:template match="yanel:resource-type[@compile='true']">
     <xsl:variable name="srcpath">
       <xsl:choose>
         <xsl:when test="starts-with(@src, '/')">
@@ -47,7 +47,7 @@
     <src path="{$srcpath}"/>
   </xsl:template>
   
-  <xsl:template match="yanel:resource[@compile='false']">
+  <xsl:template match="yanel:resource-type[@compile='false']">
   </xsl:template>
 
 </xsl:stylesheet>




More information about the Yanel-commits mailing list