cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@apache.org
Subject svn commit: r419326 - in /cocoon/whiteboard/example-apps/bricks-archetype/src/main: java/org/apache/cocoon/apps/bricks/persistence/hsql/HsqlProperties.java resources/META-INF/spring/cocoon-bricks-application-components.xml
Date Wed, 05 Jul 2006 20:25:43 GMT
Author: giacomo
Date: Wed Jul  5 13:25:43 2006
New Revision: 419326

URL: http://svn.apache.org/viewvc?rev=419326&view=rev
Log:
Added resolver so a more advance definition of pathes for the hsql db is possible

Modified:
    cocoon/whiteboard/example-apps/bricks-archetype/src/main/java/org/apache/cocoon/apps/bricks/persistence/hsql/HsqlProperties.java
    cocoon/whiteboard/example-apps/bricks-archetype/src/main/resources/META-INF/spring/cocoon-bricks-application-components.xml

Modified: cocoon/whiteboard/example-apps/bricks-archetype/src/main/java/org/apache/cocoon/apps/bricks/persistence/hsql/HsqlProperties.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/example-apps/bricks-archetype/src/main/java/org/apache/cocoon/apps/bricks/persistence/hsql/HsqlProperties.java?rev=419326&r1=419325&r2=419326&view=diff
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-archetype/src/main/java/org/apache/cocoon/apps/bricks/persistence/hsql/HsqlProperties.java
(original)
+++ cocoon/whiteboard/example-apps/bricks-archetype/src/main/java/org/apache/cocoon/apps/bricks/persistence/hsql/HsqlProperties.java
Wed Jul  5 13:25:43 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006 Otego AG, Switzerland
+ * Copyright 1999-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,144 +15,121 @@
  */
 package org.apache.cocoon.apps.bricks.persistence.hsql;
 
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.springframework.beans.factory.InitializingBean;
+
+import java.io.IOException;
+
+
 /**
- * This class
+ * The Properties for a Hsqldb Server
  *
- * @author <a href="mailto:info@otego.com">Otego AG, Switzerland</a>
  * @version $Id$
-  */
+ */
 public class HsqlProperties
     extends org.hsqldb.persist.HsqlProperties
-{
-    //~ Methods -----------------------------------------------------------------------------------------
+    implements InitializingBean {
+    
+    //~ Static fields/initializers -----------------------------------------------------------------
+
+    private static final Log LOG = LogFactory.getLog(HsqlProperties.class);
+
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    private SourceResolver sourceResolver;
+    private String database0;
+    private String database1;
+    private String database2;
+    private String database3;
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    public void afterPropertiesSet()
+        throws Exception {
+        setHsqlProp("server.database.0", database0);
+        setHsqlProp("server.database.1", database1);
+        setHsqlProp("server.database.2", database2);
+        setHsqlProp("server.database.3", database3);
+    }
+
+    public SourceResolver getResolver() {
+        return sourceResolver;
+    }
+
+    public void setDatabase0(final String path) {
+        this.database0 = path;
+    }
+
+    public void setDatabase1(final String path) {
+        this.database1 = path;
+    }
+
+    public void setDatabase2(final String path) {
+        this.database1 = path;
+    }
+
+    public void setDatabase3(final String path) {
+        this.database3 = path;
+    }
+
+    public void setDatabase4(final String path) {
+        super.setProperty("server.database.4", resolve(path));
+    }
+
+    public void setDbName0(final String name) {
+        super.setProperty("server.dbname.0", name);
+    }
+
+    public void setDbName1(final String name) {
+        super.setProperty("server.dbname.1", name);
+    }
+
+    public void setDbName2(final String name) {
+        super.setProperty("server.dbname.2", name);
+    }
+
+    public void setDbName3(final String name) {
+        super.setProperty("server.dbname.3", name);
+    }
+
+    public void setDbName4(final String name) {
+        super.setProperty("server.dbname.4", name);
+    }
+
+    public void setPort(final int port) {
+        super.setProperty("server.port", port);
+    }
+
+    public void setResolver(final SourceResolver sourceResolver) {
+        this.sourceResolver = sourceResolver;
+    }
+
+    public void setSilent(final boolean silent) {
+        super.setProperty("server.silent", silent);
+    }
+
+    public void setTrace(final boolean trace) {
+        super.setProperty("server.trace", trace);
+    }
+
+    private String resolve(final String path) {
+        try {
+            final String resolvedPath = getResolver().resolveURI(path).getURI();
+            LOG.info("Path '" + path + "' resolved to '" + resolvedPath + "'");
+
+            return resolvedPath;
+        } catch(final IOException ioex) {
+            return path;
+        }
+    }
 
-    /**
-     * The method
-     *
-     * @param path The <code>path</code>
-     */
-    public void setDatabase0( final String path )
-    {
-        super.setProperty( "server.database.0", path );
-    }
-
-    /**
-     * The method
-     *
-     * @param path The <code>path</code>
-     */
-    public void setDatabase1( final String path )
-    {
-        super.setProperty( "server.database.1", path );
-    }
-
-    /**
-     * The method
-     *
-     * @param path The <code>path</code>
-     */
-    public void setDatabase2( final String path )
-    {
-        super.setProperty( "server.database.2", path );
-    }
-
-    /**
-     * The method
-     *
-     * @param path The <code>path</code>
-     */
-    public void setDatabase3( final String path )
-    {
-        super.setProperty( "server.database.3", path );
-    }
-
-    /**
-     * The method
-     *
-     * @param path The <code>path</code>
-     */
-    public void setDatabase4( final String path )
-    {
-        super.setProperty( "server.database.4", path );
-    }
-
-    /**
-     * The method
-     *
-     * @param name The <code>name</code>
-     */
-    public void setDbName0( final String name )
-    {
-        super.setProperty( "server.dbname.0", name );
-    }
-
-    /**
-     * The method
-     *
-     * @param name The <code>name</code>
-     */
-    public void setDbName1( final String name )
-    {
-        super.setProperty( "server.dbname.1", name );
-    }
-
-    /**
-     * The method
-     *
-     * @param name The <code>name</code>
-     */
-    public void setDbName2( final String name )
-    {
-        super.setProperty( "server.dbname.2", name );
-    }
-
-    /**
-     * The method
-     *
-     * @param name The <code>name</code>
-     */
-    public void setDbName3( final String name )
-    {
-        super.setProperty( "server.dbname.3", name );
-    }
-
-    /**
-     * The method
-     *
-     * @param name The <code>name</code>
-     */
-    public void setDbName4( final String name )
-    {
-        super.setProperty( "server.dbname.4", name );
-    }
-
-    /**
-     * The method
-     *
-     * @param port The <code>port</code>
-     */
-    public void setPort( final int port )
-    {
-        super.setProperty( "server.port", port );
-    }
-
-    /**
-     * The method
-     *
-     * @param silence The <code>silence</code>
-     */
-    public void setSilent( final boolean silent )
-    {
-        super.setProperty( "server.silent", silent );
-    }
-
-    /**
-     * The method
-     *
-     * @param trace The <code>trace</code>
-     */
-    public void setTrace( final boolean trace )
-    {
-        super.setProperty( "server.trace", trace );
+    private void setHsqlProp(final String propName,
+                             final String path) {
+        if(getResolver() != null && path != null) {
+            super.setProperty(propName, resolve(path));
+        }
     }
 }

Modified: cocoon/whiteboard/example-apps/bricks-archetype/src/main/resources/META-INF/spring/cocoon-bricks-application-components.xml
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/example-apps/bricks-archetype/src/main/resources/META-INF/spring/cocoon-bricks-application-components.xml?rev=419326&r1=419325&r2=419326&view=diff
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-archetype/src/main/resources/META-INF/spring/cocoon-bricks-application-components.xml
(original)
+++ cocoon/whiteboard/example-apps/bricks-archetype/src/main/resources/META-INF/spring/cocoon-bricks-application-components.xml
Wed Jul  5 13:25:43 2006
@@ -46,10 +46,13 @@
       <value>false</value>
     </property>
     <property name="database0">
-      <value>target/bricksdb</value>
+      <value>context://WEB-INF/bricksdb</value>
     </property>
     <property name="dbName0">
       <value>bricksdb</value>
+    </property>
+    <property name="resolver">
+      <ref bean="org.apache.excalibur.source.SourceResolver"/>
     </property>
   </bean>
 



Mime
View raw message