portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r405544 - in /portals/jetspeed-2/trunk/components/rewriter/src/java/org/apache/jetspeed/rewriter: JetspeedClasspathRewriterController.java JetspeedRewriterController.java
Date Tue, 09 May 2006 21:46:31 GMT
Author: taylor
Date: Tue May  9 14:46:29 2006
New Revision: 405544

URL: http://svn.apache.org/viewcvs?rev=405544&view=rev
Log:
request for classpath oriented mapping loader

Added:
    portals/jetspeed-2/trunk/components/rewriter/src/java/org/apache/jetspeed/rewriter/JetspeedClasspathRewriterController.java
Modified:
    portals/jetspeed-2/trunk/components/rewriter/src/java/org/apache/jetspeed/rewriter/JetspeedRewriterController.java

Added: portals/jetspeed-2/trunk/components/rewriter/src/java/org/apache/jetspeed/rewriter/JetspeedClasspathRewriterController.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/rewriter/src/java/org/apache/jetspeed/rewriter/JetspeedClasspathRewriterController.java?rev=405544&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/rewriter/src/java/org/apache/jetspeed/rewriter/JetspeedClasspathRewriterController.java
(added)
+++ portals/jetspeed-2/trunk/components/rewriter/src/java/org/apache/jetspeed/rewriter/JetspeedClasspathRewriterController.java
Tue May  9 14:46:29 2006
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2000-2004 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.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.rewriter;
+
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * RewriterServiceImpl
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
+ * @version $Id: JetspeedRewriterController.java,v 1.2 2004/03/08 00:44:40 jford
+ *          Exp $
+ */
+public class JetspeedClasspathRewriterController
+       extends JetspeedRewriterController
+       implements RewriterController
+{
+    protected final static Log log = LogFactory.getLog(JetspeedClasspathRewriterController.class);
+
+    public JetspeedClasspathRewriterController( String mappingFile ) throws RewriterException
+    {
+        super(mappingFile);
+    }
+
+    public JetspeedClasspathRewriterController( String mappingFile, List rewriterClasses,
List adaptorClasses )
+            throws RewriterException
+    {
+        super(mappingFile, rewriterClasses, adaptorClasses);
+    }
+    
+    public JetspeedClasspathRewriterController( String mappingFile, 
+            String basicRewriterClassName, String rulesetRewriterClassName, 
+            String adaptorHtmlClassName, String adaptorXmlClassName )
+    throws RewriterException
+    {
+        super(mappingFile, toClassList(basicRewriterClassName,rulesetRewriterClassName),

+              toClassList(adaptorHtmlClassName,adaptorXmlClassName));
+    }
+    
+    protected Reader getReader(String resource)
+    throws RewriterException
+    {
+        InputStream stream = this.getClass().getClassLoader().getResourceAsStream(resource);
+        if (stream != null)
+            return new InputStreamReader(stream);
+
+        throw new RewriterException("could not access rewriter classpath resource " + resource);
       
+    }
+}

Modified: portals/jetspeed-2/trunk/components/rewriter/src/java/org/apache/jetspeed/rewriter/JetspeedRewriterController.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/rewriter/src/java/org/apache/jetspeed/rewriter/JetspeedRewriterController.java?rev=405544&r1=405543&r2=405544&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/rewriter/src/java/org/apache/jetspeed/rewriter/JetspeedRewriterController.java
(original)
+++ portals/jetspeed-2/trunk/components/rewriter/src/java/org/apache/jetspeed/rewriter/JetspeedRewriterController.java
Tue May  9 14:46:29 2006
@@ -17,6 +17,8 @@
 
 import java.io.File;
 import java.io.FileReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.io.Reader;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -109,7 +111,7 @@
         this(mappingFile, toClassList(basicRewriterClassName,rulesetRewriterClassName), toClassList(adaptorHtmlClassName,adaptorXmlClassName));
     }
 
-    private static List toClassList(String classNameA, String classNameB)
+    protected static List toClassList(String classNameA, String classNameB)
     {
         try
         {
@@ -223,6 +225,24 @@
 
     }
 
+    protected Reader getReader(String resource)
+    throws RewriterException
+    {
+        File file = new File(resource);
+        if (file.exists() && file.isFile() && file.canRead())
+        {
+            try
+            {
+                return new FileReader(file);
+            }
+            catch (Exception e)
+            {
+                throw new RewriterException("could not open rewriter file " + resource, e);
+            }
+        }
+        throw new RewriterException("could not access rewriter file " + resource);
+    }
+        
     /*
      * (non-Javadoc)
      * 



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message