Author: thorsten Date: Tue May 12 13:28:09 2009 New Revision: 773885 URL: http://svn.apache.org/viewvc?rev=773885&view=rev Log: FOR-1164 - The 'lm' preffix is harcoded, make it configurable Reporter/due-to: Javier Puerto
Thanks Javier. Modified: forrest/trunk/main/java/org/apache/forrest/locationmap/source/impl/LocationmapSourceFactory.java forrest/trunk/whiteboard/cocoon-2.2-blocks/locationmap/src/main/java/org/apache/forrest/locationmap/source/impl/LocationmapSourceFactory.java Modified: forrest/trunk/main/java/org/apache/forrest/locationmap/source/impl/LocationmapSourceFactory.java URL: http://svn.apache.org/viewvc/forrest/trunk/main/java/org/apache/forrest/locationmap/source/impl/LocationmapSourceFactory.java?rev=773885&r1=773884&r2=773885&view=diff ============================================================================== --- forrest/trunk/main/java/org/apache/forrest/locationmap/source/impl/LocationmapSourceFactory.java (original) +++ forrest/trunk/main/java/org/apache/forrest/locationmap/source/impl/LocationmapSourceFactory.java Tue May 12 13:28:09 2009 @@ -20,6 +20,8 @@ import java.net.MalformedURLException; import java.util.Map; +import org.apache.avalon.framework.configuration.Configurable; +import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.context.Context; import org.apache.avalon.framework.context.ContextException; @@ -37,18 +39,12 @@ import org.apache.excalibur.source.SourceException; import org.apache.excalibur.source.SourceFactory; -/** - * A <code>Source</code> that takes its content from the - * locationmap module. - * <p>The URI syntax is "lm//:<location>", - * where the location is any given String that - * will be match by the locationmap module. - */ public class LocationmapSourceFactory extends AbstractLogEnabled implements - Serviceable, SourceFactory, ThreadSafe, Contextualizable { + Serviceable, SourceFactory, ThreadSafe, Contextualizable, Configurable{ protected ServiceManager m_manager; private Context context; + private String prefix; public static final String LM_PREFIX = "lm"; public static final String LM_SOURCE_SCHEME =LM_PREFIX+ ":"; @@ -106,4 +102,17 @@ this.m_manager = manager; } + /* FOR-1164 + * We can configure like: + <source-factories> + <component-instance class="org.apache.forrest.locationmap.source.impl.LocationmapSourceFactory" + name="lmx" prefix="lmx"/> + </source-factories> + And call the other instance of Locationmap with uris like this "lmx://*" + * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration) + */ + public void configure(Configuration configuration) + throws ConfigurationException { + prefix = configuration.getAttribute("prefix", LM_PREFIX); + } } Modified: forrest/trunk/whiteboard/cocoon-2.2-blocks/locationmap/src/main/java/org/apache/forrest/locationmap/source/impl/LocationmapSourceFactory.java URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/cocoon-2.2-blocks/locationmap/src/main/java/org/apache/forrest/locationmap/source/impl/LocationmapSourceFactory.java?rev=773885&r1=773884&r2=773885&view=diff ============================================================================== --- forrest/trunk/whiteboard/cocoon-2.2-blocks/locationmap/src/main/java/org/apache/forrest/locationmap/source/impl/LocationmapSourceFactory.java (original) +++ forrest/trunk/whiteboard/cocoon-2.2-blocks/locationmap/src/main/java/org/apache/forrest/locationmap/source/impl/LocationmapSourceFactory.java Tue May 12 13:28:09 2009 @@ -20,6 +20,8 @@ import java.net.MalformedURLException; import java.util.Map; +import org.apache.avalon.framework.configuration.Configurable; +import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.context.Context; import org.apache.avalon.framework.context.ContextException; @@ -38,10 +40,11 @@ import org.apache.excalibur.source.SourceFactory; public class LocationmapSourceFactory extends AbstractLogEnabled implements - Serviceable, SourceFactory, ThreadSafe, Contextualizable { + Serviceable, SourceFactory, ThreadSafe, Contextualizable, Configurable{ protected ServiceManager m_manager; private Context context; + private String prefix; public static final String LM_PREFIX = "lm"; public static final String LM_SOURCE_SCHEME =LM_PREFIX+ ":"; @@ -99,4 +102,17 @@ this.m_manager = manager; } + /* FOR-1164 + * We can configure like: + <source-factories> + <component-instance class="org.apache.forrest.locationmap.source.impl.LocationmapSourceFactory" + name="lmx" prefix="lmx"/> + </source-factories> + And call the other instance of Locationmap with uris like this "lmx://*" + * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration) + */ + public void configure(Configuration configuration) + throws ConfigurationException { + prefix = configuration.getAttribute("prefix", LM_PREFIX); + } }