You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ri...@apache.org on 2005/07/15 01:26:30 UTC
svn commit: r219136 - in /incubator/beehive/trunk/netui/src:
core/org/apache/beehive/netui/core/
core/org/apache/beehive/netui/core/factory/
core/org/apache/beehive/netui/core/urltemplates/
pageflow/org/apache/beehive/netui/pageflow/ tags-html/org/apac...
Author: rich
Date: Thu Jul 14 16:26:29 2005
New Revision: 219136
URL: http://svn.apache.org/viewcvs?rev=219136&view=rev
Log:
This is a contribution from Carlin Rogers to address http://issues.apache.org/jira/browse/BEEHIVE-835 : Make improvements to the support for URL templating.
tests: bvt in netui (WinXP)
BB: self (linux)
Added:
incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/factory/
incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/factory/Factory.java
- copied, changed from r216014, incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/Factory.java
incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/factory/FactoryConfig.java (with props)
incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/factory/FactoryUtils.java (with props)
Removed:
incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/Factory.java
incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/FactoryConfig.java
Modified:
incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/urltemplates/URLTemplatesFactory.java
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/DefaultServletContainerAdapter.java
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBeanFactory.java
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ServletContainerAdapter.java
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlBaseTag.java
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageAnchor.java
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageButton.java
Copied: incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/factory/Factory.java (from r216014, incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/Factory.java)
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/factory/Factory.java?p2=incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/factory/Factory.java&p1=incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/Factory.java&r1=216014&r2=219136&rev=219136&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/Factory.java (original)
+++ incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/factory/Factory.java Thu Jul 14 16:26:29 2005
@@ -15,7 +15,7 @@
*
* $Header:$
*/
-package org.apache.beehive.netui.core;
+package org.apache.beehive.netui.core.factory;
import org.apache.beehive.netui.util.config.bean.CustomProperty;
import org.apache.beehive.netui.util.config.bean.PageflowFactory;
@@ -43,7 +43,7 @@
{
}
- private void init( ServletContext servletContext, FactoryConfig config )
+ void init( ServletContext servletContext, FactoryConfig config )
{
_servletContext = servletContext;
_config = config;
@@ -73,70 +73,5 @@
protected FactoryConfig getConfig()
{
return _config;
- }
-
- public static Factory getFactory( ServletContext servletContext, PageflowFactory factoryBean, Class factoryType )
- {
- if ( factoryBean == null ) return null;
-
- String className = factoryBean.getFactoryClass();
- ClassLoader cl = DiscoveryUtils.getClassLoader();
-
- try
- {
- Class actualFactoryType = cl.loadClass( className );
-
- if ( ! factoryType.isAssignableFrom( actualFactoryType ) )
- {
- _log.error( "Factory class " + actualFactoryType.getName() + " is not derived from "
- + factoryType.getName() );
- return null;
- }
-
- CustomProperty[] props = factoryBean.getCustomPropertyArray();
- FactoryConfig config = new FactoryConfig();
-
- if ( props != null )
- {
- for ( int i = 0; i < props.length; i++ )
- {
- CustomProperty prop = props[i];
- config.addCustomProperty( prop.getName(), prop.getValue() );
- }
- }
-
- return getFactory( servletContext, actualFactoryType, config );
- }
- catch ( ClassNotFoundException e )
- {
- _log.error( "Could not load factory class " + className, e );
- }
-
- return null;
- }
-
- public static Factory getFactory( ServletContext servletContext, Class factoryType, FactoryConfig config )
- {
- assert Factory.class.isAssignableFrom( factoryType ) : factoryType.getClass().getName();
-
- Factory factory = null;
-
- try
- {
- factory = ( Factory ) factoryType.newInstance();
- }
- catch ( InstantiationException e )
- {
- _log.error( "Could not instantiate a factory of type " + factoryType.getName(), e );
- }
- catch ( IllegalAccessException e )
- {
- _log.error( "Could not access the default constructor for factory of type " + factoryType.getName(), e );
- }
-
- factory.init( servletContext, config );
- factory.onCreate();
-
- return factory;
}
}
Added: incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/factory/FactoryConfig.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/factory/FactoryConfig.java?rev=219136&view=auto
==============================================================================
--- incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/factory/FactoryConfig.java (added)
+++ incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/factory/FactoryConfig.java Thu Jul 14 16:26:29 2005
@@ -0,0 +1,42 @@
+/*
+ * Copyright 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.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.core.factory;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Configuration object passed to a {@link Factory}.
+ */
+public class FactoryConfig
+ implements Serializable
+{
+ private Map/*< String, String >*/ _customProperties = null;
+
+ void addCustomProperty( String name, String value )
+ {
+ if ( _customProperties == null ) _customProperties = new HashMap();
+ _customProperties.put( name, value );
+ }
+
+ public String getCustomProperty( String name )
+ {
+ return _customProperties != null ? ( String ) _customProperties.get( name ) : null;
+ }
+}
Propchange: incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/factory/FactoryConfig.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/factory/FactoryUtils.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/factory/FactoryUtils.java?rev=219136&view=auto
==============================================================================
--- incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/factory/FactoryUtils.java (added)
+++ incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/factory/FactoryUtils.java Thu Jul 14 16:26:29 2005
@@ -0,0 +1,97 @@
+/*
+ * Copyright 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.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.core.factory;
+
+import org.apache.beehive.netui.util.config.bean.CustomProperty;
+import org.apache.beehive.netui.util.config.bean.PageflowFactory;
+import org.apache.beehive.netui.util.internal.DiscoveryUtils;
+import org.apache.beehive.netui.util.logging.Logger;
+
+import javax.servlet.ServletContext;
+
+/**
+ * Utility class for creating ServletContext-scoped factories.
+ */
+public class FactoryUtils
+{
+ private static final Logger _log = Logger.getInstance( FactoryUtils.class );
+
+ public static Factory getFactory( ServletContext servletContext, PageflowFactory factoryBean, Class factoryType )
+ {
+ if ( factoryBean == null ) return null;
+
+ String className = factoryBean.getFactoryClass();
+ ClassLoader cl = DiscoveryUtils.getClassLoader();
+
+ try
+ {
+ Class actualFactoryType = cl.loadClass( className );
+
+ if ( ! factoryType.isAssignableFrom( actualFactoryType ) )
+ {
+ _log.error( "Factory class " + actualFactoryType.getName() + " is not derived from "
+ + factoryType.getName() );
+ return null;
+ }
+
+ CustomProperty[] props = factoryBean.getCustomPropertyArray();
+ FactoryConfig config = new FactoryConfig();
+
+ if ( props != null )
+ {
+ for ( int i = 0; i < props.length; i++ )
+ {
+ CustomProperty prop = props[i];
+ config.addCustomProperty( prop.getName(), prop.getValue() );
+ }
+ }
+
+ return getFactory( servletContext, actualFactoryType, config );
+ }
+ catch ( ClassNotFoundException e )
+ {
+ _log.error( "Could not load factory class " + className, e );
+ }
+
+ return null;
+ }
+
+ public static Factory getFactory( ServletContext servletContext, Class factoryType, FactoryConfig config )
+ {
+ assert Factory.class.isAssignableFrom( factoryType ) : factoryType.getClass().getName();
+
+ try
+ {
+ Factory factory = ( Factory ) factoryType.newInstance();
+ factory.init( servletContext, config );
+ factory.onCreate();
+
+ return factory;
+ }
+ catch ( InstantiationException e )
+ {
+ _log.error( "Could not instantiate a factory of type " + factoryType.getName(), e );
+ }
+ catch ( IllegalAccessException e )
+ {
+ _log.error( "Could not access the default constructor for factory of type " + factoryType.getName(), e );
+ }
+
+ return null;
+ }
+}
Propchange: incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/factory/FactoryUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/urltemplates/URLTemplatesFactory.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/urltemplates/URLTemplatesFactory.java?rev=219136&r1=219135&r2=219136&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/urltemplates/URLTemplatesFactory.java (original)
+++ incubator/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/urltemplates/URLTemplatesFactory.java Thu Jul 14 16:26:29 2005
@@ -17,7 +17,7 @@
*/
package org.apache.beehive.netui.core.urltemplates;
-import org.apache.beehive.netui.core.Factory;
+import org.apache.beehive.netui.core.factory.Factory;
import javax.servlet.ServletContext;
import java.util.Collection;
Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/DefaultServletContainerAdapter.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/DefaultServletContainerAdapter.java?rev=219136&r1=219135&r2=219136&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/DefaultServletContainerAdapter.java (original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/DefaultServletContainerAdapter.java Thu Jul 14 16:26:29 2005
@@ -17,8 +17,8 @@
*/
package org.apache.beehive.netui.pageflow;
-import org.apache.beehive.netui.core.Factory;
-import org.apache.beehive.netui.core.FactoryConfig;
+import org.apache.beehive.netui.core.factory.Factory;
+import org.apache.beehive.netui.core.factory.FactoryConfig;
import org.apache.beehive.netui.pageflow.adapter.AdapterContext;
import org.apache.beehive.netui.pageflow.internal.PageFlowBeanContext;
import org.apache.beehive.netui.util.logging.Logger;
Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBeanFactory.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBeanFactory.java?rev=219136&r1=219135&r2=219136&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBeanFactory.java (original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBeanFactory.java Thu Jul 14 16:26:29 2005
@@ -17,7 +17,8 @@
*/
package org.apache.beehive.netui.pageflow;
-import org.apache.beehive.netui.core.Factory;
+import org.apache.beehive.netui.core.factory.Factory;
+import org.apache.beehive.netui.core.factory.FactoryUtils;
import org.apache.beehive.netui.pageflow.internal.InternalConstants;
import org.apache.beehive.netui.pageflow.internal.InternalUtils;
import org.apache.beehive.netui.pageflow.internal.AnnotationReader;
@@ -63,7 +64,7 @@
if ( factoriesBean != null )
{
PageflowFactory fcFactoryBean = factoriesBean.getFacesBackingBeanFactory();
- factory = ( FacesBackingBeanFactory ) getFactory( servletContext, fcFactoryBean, FacesBackingBeanFactory.class );
+ factory = ( FacesBackingBeanFactory ) FactoryUtils.getFactory( servletContext, fcFactoryBean, FacesBackingBeanFactory.class );
}
if ( factory == null ) factory = new FacesBackingBeanFactory();
Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java?rev=219136&r1=219135&r2=219136&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java (original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java Thu Jul 14 16:26:29 2005
@@ -17,7 +17,8 @@
*/
package org.apache.beehive.netui.pageflow;
-import org.apache.beehive.netui.core.Factory;
+import org.apache.beehive.netui.core.factory.Factory;
+import org.apache.beehive.netui.core.factory.FactoryUtils;
import org.apache.beehive.netui.util.logging.Logger;
import org.apache.beehive.netui.util.config.ConfigUtil;
import org.apache.beehive.netui.util.config.bean.PageflowConfig;
@@ -75,7 +76,7 @@
if ( factoriesBean != null )
{
PageflowFactory fcFactoryBean = factoriesBean.getFlowcontrollerFactory();
- factory = ( FlowControllerFactory ) getFactory( servletContext, fcFactoryBean, FlowControllerFactory.class );
+ factory = ( FlowControllerFactory ) FactoryUtils.getFactory( servletContext, fcFactoryBean, FlowControllerFactory.class );
}
if ( factory == null ) factory = new FlowControllerFactory();
Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ServletContainerAdapter.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ServletContainerAdapter.java?rev=219136&r1=219135&r2=219136&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ServletContainerAdapter.java (original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ServletContainerAdapter.java Thu Jul 14 16:26:29 2005
@@ -17,8 +17,8 @@
*/
package org.apache.beehive.netui.pageflow;
-import org.apache.beehive.netui.core.Factory;
-import org.apache.beehive.netui.core.FactoryConfig;
+import org.apache.beehive.netui.core.factory.Factory;
+import org.apache.beehive.netui.core.factory.FactoryConfig;
import org.apache.beehive.netui.pageflow.adapter.Adapter;
import javax.servlet.http.HttpServletRequest;
Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlBaseTag.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlBaseTag.java?rev=219136&r1=219135&r2=219136&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlBaseTag.java (original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlBaseTag.java Thu Jul 14 16:26:29 2005
@@ -530,29 +530,4 @@
{
super.localRelease();
}
-
- /**
- * This method will take any absolute URL that doesn't contain the scheme part and append
- * the context path. In other words, if the URL starts with '/' and the context path isn't
- * present it will be added.
- * @param url The url to be added.
- * @return a url with the context path if the url begins with '/' otherwise the unchanged url.
- */
- protected String qualifyUrlToContext(String url)
- {
- /*
- // This has been removed because we are not supporting this within the tags. Question: should we?
- if (url != null && url.length() > 0) {
- if (url.charAt(0) == '/') {
- HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
- String ctxtPath = request.getContextPath();
- if (!url.startsWith(ctxtPath)) {
- url = ctxtPath + url;
- return url;
- }
- }
- }
- */
- return url;
- }
}
Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageAnchor.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageAnchor.java?rev=219136&r1=219135&r2=219136&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageAnchor.java (original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageAnchor.java Thu Jul 14 16:26:29 2005
@@ -425,7 +425,7 @@
if (_rolloverImage != null) {
try {
String uri = PageFlowTagUtils.rewriteResourceURL(pageContext, _rolloverImage, null, null);
- _rolloverImage = response.encodeURL(qualifyUrlToContext(uri));
+ _rolloverImage = response.encodeURL(uri);
}
catch (URISyntaxException e) {
// report the error...
Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageButton.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageButton.java?rev=219136&r1=219135&r2=219136&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageButton.java (original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageButton.java Thu Jul 14 16:26:29 2005
@@ -321,7 +321,7 @@
try {
String uri = PageFlowTagUtils.rewriteResourceURL(pageContext, _rolloverImage, null, null);
- _rolloverImage = response.encodeURL(qualifyUrlToContext(uri));
+ _rolloverImage = response.encodeURL(uri);
}
catch (URISyntaxException e) {
// report the error...