cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r190156 - in /cocoon/trunk/src/java/org/apache/cocoon: components/source/CocoonSourceResolver.java core/Core.java sitemap/Sitemap.java
Date Sat, 11 Jun 2005 17:48:37 GMT
Author: cziegeler
Date: Sat Jun 11 10:48:36 2005
New Revision: 190156

URL: http://svn.apache.org/viewcvs?rev=190156&view=rev
Log:
Add accessor for per sitemap information (not much for now, but we can improve it)

Added:
    cocoon/trunk/src/java/org/apache/cocoon/sitemap/Sitemap.java   (with props)
Modified:
    cocoon/trunk/src/java/org/apache/cocoon/components/source/CocoonSourceResolver.java
    cocoon/trunk/src/java/org/apache/cocoon/core/Core.java

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/source/CocoonSourceResolver.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/source/CocoonSourceResolver.java?rev=190156&r1=190155&r2=190156&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/source/CocoonSourceResolver.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/source/CocoonSourceResolver.java Sat
Jun 11 10:48:36 2005
@@ -39,6 +39,7 @@
 import org.apache.cocoon.environment.SourceResolver;
 import org.apache.cocoon.environment.internal.EnvironmentHelper;
 import org.apache.cocoon.sitemap.ComponentLocator;
+import org.apache.cocoon.sitemap.Sitemap;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceException;
 import org.apache.excalibur.source.SourceFactory;
@@ -220,7 +221,11 @@
      * Get the component locator.
      */
     protected ComponentLocator getComponentLocator() {
-        ComponentLocator l = this.core.getSitemapComponentLocator();
+        ComponentLocator l = null;
+        final Sitemap sitemap = this.core.getCurrentSitemap();
+        if ( sitemap != null ) {
+            l = sitemap.getComponentLocator();
+        }
         if ( l == null ) {
             l = new ComponentLocatorWrapper(this.manager);
         }

Modified: cocoon/trunk/src/java/org/apache/cocoon/core/Core.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/Core.java?rev=190156&r1=190155&r2=190156&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/core/Core.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/core/Core.java Sat Jun 11 10:48:36 2005
@@ -27,10 +27,12 @@
 import org.apache.avalon.framework.context.ContextException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.Constants;
+import org.apache.cocoon.Processor;
 import org.apache.cocoon.components.ContextHelper;
 import org.apache.cocoon.core.container.ComponentLocatorWrapper;
 import org.apache.cocoon.environment.internal.EnvironmentHelper;
 import org.apache.cocoon.sitemap.ComponentLocator;
+import org.apache.cocoon.sitemap.Sitemap;
 import org.apache.commons.lang.NotImplementedException;
 
 /**
@@ -183,19 +185,42 @@
     }
     
     /**
-     * Return the locator of the current sitemap.
-     * @return The current locator or null if no request is currently processed
+     * Return the current sitemap.
+     * @return The current sitemap or null if no request is currently processed
      */
-    public ComponentLocator getSitemapComponentLocator() {
-        final ServiceManager m = EnvironmentHelper.getSitemapServiceManager();
-        ComponentLocator l = null;
-        if ( m != null ) {
-            if ( !(m instanceof ComponentLocator) ) {
-                l = new ComponentLocatorWrapper(m);
-            } else {
-                l = (ComponentLocator)m;
+    public Sitemap getCurrentSitemap() {
+        Processor p = EnvironmentHelper.getCurrentProcessor();
+        if ( p != null ) {
+            return SITEMAP;            
+        }
+        return null;
+    }
+
+    private final static Sitemap SITEMAP = new SitemapImpl();
+
+    public final static class SitemapImpl implements Sitemap {
+
+        /**
+         * @see org.apache.cocoon.sitemap.Sitemap#getComponentLocator()
+         */
+        public ComponentLocator getComponentLocator() {
+            final ServiceManager m = EnvironmentHelper.getSitemapServiceManager();
+            ComponentLocator l = null;
+            if ( m != null ) {
+                if ( !(m instanceof ComponentLocator) ) {
+                    l = new ComponentLocatorWrapper(m);
+                } else {
+                    l = (ComponentLocator)m;
+                }
             }
+            return l;
+        }
+
+        /**
+         * @see org.apache.cocoon.sitemap.Sitemap#getCurrentProcessor()
+         */
+        public Processor getCurrentProcessor() {
+            return EnvironmentHelper.getCurrentProcessor();
         }
-        return l;
     }
 }

Added: cocoon/trunk/src/java/org/apache/cocoon/sitemap/Sitemap.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/sitemap/Sitemap.java?rev=190156&view=auto
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/sitemap/Sitemap.java (added)
+++ cocoon/trunk/src/java/org/apache/cocoon/sitemap/Sitemap.java Sat Jun 11 10:48:36 2005
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005 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.cocoon.sitemap;
+
+import org.apache.cocoon.Processor;
+
+/**
+ * TODO WORK IN PROGRESS!!
+ * TODO Add Interpreter(s)
+ *
+ * This interface describes the current sitemap. The current sitemap is available using
+ * {@link org.apache.cocoon.core.Core#getCurrentSitemap()}.
+ *
+ * @since 2.2
+ * @version $Id$
+ */
+public interface Sitemap {
+
+    /**
+     * Return the locator of the current sitemap.
+     * @return The current locator.
+     */
+    ComponentLocator getComponentLocator();
+
+    /**
+     * Return the current processor
+     */
+    Processor getCurrentProcessor();
+
+}

Propchange: cocoon/trunk/src/java/org/apache/cocoon/sitemap/Sitemap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/src/java/org/apache/cocoon/sitemap/Sitemap.java
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message