tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-tapestry/framework/src/test/org/apache/tapestry/junit TestComponentMessages.java
Date Tue, 08 Feb 2005 16:00:51 GMT
hlship      2005/02/08 08:00:50

  Modified:    framework/src/java/org/apache/tapestry/services
                        ComponentPropertySource.java Infrastructure.java
               framework/src/java/org/apache/tapestry/services/impl
                        InfrastructureImpl.java
                        ComponentMessagesSourceImpl.java
                        ImplStrings.properties TemplateSourceImpl.java
                        ComponentPropertySourceImpl.java ImplMessages.java
               framework/src/java/org/apache/tapestry/resolver
                        PageSpecificationResolverImpl.java
               framework/src/descriptor/META-INF tapestry.parse.xml
                        hivemodule.xml tapestry.page.xml tapestry.props.xml
               framework/src/java/org/apache/tapestry Tapestry.java
               framework/src/test/org/apache/tapestry/junit
                        TestComponentMessages.java
  Removed:     framework/src/java/org/apache/tapestry/engine
                        DefaultComponentPropertySource.java
                        DefaultNamespacePropertySource.java
  Log:
  Change ComponentPropertySource to allow lookups of namespace properties.
  
  Revision  Changes    Path
  1.2       +27 -1     jakarta-tapestry/framework/src/java/org/apache/tapestry/services/ComponentPropertySource.java
  
  Index: ComponentPropertySource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/services/ComponentPropertySource.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ComponentPropertySource.java	8 Feb 2005 15:18:08 -0000	1.1
  +++ ComponentPropertySource.java	8 Feb 2005 16:00:50 -0000	1.2
  @@ -17,9 +17,14 @@
   import java.util.Locale;
   
   import org.apache.tapestry.IComponent;
  +import org.apache.tapestry.INamespace;
   
   /**
  - * Enapsulates the logic for searching for component meta-data.
  + * Enapsulates the logic for searching for component meta-data. Deployed as service
  + * tapestry.props.ComponentPropertySource.
  + * <p>
  + * TODO: Adjust name, since it now provides access to namespace properties as well as component
  + * properties.
    * 
    * @author Howard M. Lewis Ship
    * @since 3.1
  @@ -51,4 +56,25 @@
        */
       public String getLocalizedComponentProperty(IComponent component, Locale locale,
               String propertyName);
  +
  +    /**
  +     * Returns the property value for a particular named meta-data property of the namespace.
The
  +     * search order is:
  +     * <ul>
  +     * <li>The library or application specification for the namespace.</li>
  +     * <li>The chain of global property sources.</li>
  +     * </ul>
  +     * 
  +     * @return the value of the given key, or null if not found.
  +     */
  +
  +    public String getNamespaceProperty(INamespace namespace, String propertyName);
  +
  +    /**
  +     * As with {@link #getLocalizedComponentProperty(IComponent, Locale, String)}, but
with a
  +     * {@link INamespace}.
  +     */
  +
  +    public String getLocalizedNamespaceProperty(INamespace namespace, Locale locale,
  +            String propertyName);
   }
  \ No newline at end of file
  
  
  
  1.17      +7 -0      jakarta-tapestry/framework/src/java/org/apache/tapestry/services/Infrastructure.java
  
  Index: Infrastructure.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/services/Infrastructure.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Infrastructure.java	8 Feb 2005 15:18:08 -0000	1.16
  +++ Infrastructure.java	8 Feb 2005 16:00:50 -0000	1.17
  @@ -187,4 +187,11 @@
        */
       
       public Resource getContextRoot();
  +    
  +    /**
  +     * Returns an object used to access component meta-data properties.
  +     * 
  +     */
  +    
  +    public ComponentPropertySource getComponentPropertySource();
   }
  \ No newline at end of file
  
  
  
  1.17      +13 -0     jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/InfrastructureImpl.java
  
  Index: InfrastructureImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/InfrastructureImpl.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- InfrastructureImpl.java	8 Feb 2005 15:18:08 -0000	1.16
  +++ InfrastructureImpl.java	8 Feb 2005 16:00:50 -0000	1.17
  @@ -27,6 +27,7 @@
   import org.apache.tapestry.engine.ISpecificationSource;
   import org.apache.tapestry.engine.state.ApplicationStateManager;
   import org.apache.tapestry.services.ComponentMessagesSource;
  +import org.apache.tapestry.services.ComponentPropertySource;
   import org.apache.tapestry.services.DataSqueezer;
   import org.apache.tapestry.services.Infrastructure;
   import org.apache.tapestry.services.LinkFactory;
  @@ -91,6 +92,8 @@
   
       private String _applicationId;
   
  +    private ComponentPropertySource _componentPropertySource;
  +
       public IScriptSource getScriptSource()
       {
           return _scriptSource;
  @@ -316,4 +319,14 @@
       {
           _globalPropertySource = globalPropertySource;
       }
  +
  +    public ComponentPropertySource getComponentPropertySource()
  +    {
  +        return _componentPropertySource;
  +    }
  +
  +    public void setComponentPropertySource(ComponentPropertySource componentPropertySource)
  +    {
  +        _componentPropertySource = componentPropertySource;
  +    }
   }
  \ No newline at end of file
  
  
  
  1.10      +4 -13     jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/ComponentMessagesSourceImpl.java
  
  Index: ComponentMessagesSourceImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/ComponentMessagesSourceImpl.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ComponentMessagesSourceImpl.java	8 Feb 2005 15:18:08 -0000	1.9
  +++ ComponentMessagesSourceImpl.java	8 Feb 2005 16:00:50 -0000	1.10
  @@ -34,8 +34,6 @@
   import org.apache.hivemind.util.LocalizedNameGenerator;
   import org.apache.tapestry.IComponent;
   import org.apache.tapestry.INamespace;
  -import org.apache.tapestry.engine.DefaultNamespacePropertySource;
  -import org.apache.tapestry.engine.IPropertySource;
   import org.apache.tapestry.event.ResetEventListener;
   import org.apache.tapestry.services.ComponentMessagesSource;
   import org.apache.tapestry.services.ComponentPropertySource;
  @@ -68,8 +66,6 @@
   
       private Map _componentCache = new HashMap();
   
  -    private IPropertySource _globalPropertySource;
  -
       private ComponentPropertySource _componentPropertySource;
   
       /**
  @@ -338,15 +334,10 @@
   
       private String getNamespaceMessagesEncoding(INamespace namespace, Locale locale)
       {
  -        IPropertySource source = new DefaultNamespacePropertySource(namespace,
  -                _globalPropertySource, locale);
  -
  -        return source.getPropertyValue(MESSAGES_ENCODING_PROPERTY_NAME);
  -    }
  -
  -    public void setGlobalPropertySource(IPropertySource source)
  -    {
  -        _globalPropertySource = source;
  +        return _componentPropertySource.getLocalizedNamespaceProperty(
  +                namespace,
  +                locale,
  +                MESSAGES_ENCODING_PROPERTY_NAME);
       }
   
       public void setComponentPropertySource(ComponentPropertySource componentPropertySource)
  
  
  
  1.9       +2 -1      jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/ImplStrings.properties
  
  Index: ImplStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/ImplStrings.properties,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ImplStrings.properties	8 Feb 2005 15:18:08 -0000	1.8
  +++ ImplStrings.properties	8 Feb 2005 16:00:50 -0000	1.9
  @@ -47,4 +47,5 @@
   template-parameter-name=template parameter {0}
   template-tag-parameter-name=implicit template tag parameter
   
  -component-property-source-description=<PropertySource for {0}>
  \ No newline at end of file
  +component-property-source-description=<PropertySource for {0}>
  +namespace-property-source-description=<PropertySource for namespace {0}>
  \ No newline at end of file
  
  
  
  1.8       +16 -33    jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/TemplateSourceImpl.java
  
  Index: TemplateSourceImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/TemplateSourceImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TemplateSourceImpl.java	29 Jan 2005 16:45:14 -0000	1.7
  +++ TemplateSourceImpl.java	8 Feb 2005 16:00:50 -0000	1.8
  @@ -24,20 +24,14 @@
   import java.util.Locale;
   import java.util.Map;
   
  -import javax.servlet.ServletContext;
  -import javax.servlet.http.HttpServletRequest;
  -
   import org.apache.commons.logging.Log;
   import org.apache.hivemind.ApplicationRuntimeException;
   import org.apache.hivemind.Resource;
  -import org.apache.hivemind.util.ContextResource;
   import org.apache.tapestry.IAsset;
   import org.apache.tapestry.IComponent;
   import org.apache.tapestry.IPage;
   import org.apache.tapestry.IRequestCycle;
   import org.apache.tapestry.Tapestry;
  -import org.apache.tapestry.engine.DefaultComponentPropertySource;
  -import org.apache.tapestry.engine.IPropertySource;
   import org.apache.tapestry.engine.ITemplateSourceDelegate;
   import org.apache.tapestry.event.ResetEventListener;
   import org.apache.tapestry.parse.ComponentTemplate;
  @@ -47,6 +41,7 @@
   import org.apache.tapestry.parse.TemplateParser;
   import org.apache.tapestry.parse.TemplateToken;
   import org.apache.tapestry.resolver.ComponentSpecificationResolver;
  +import org.apache.tapestry.services.ComponentPropertySource;
   import org.apache.tapestry.services.TemplateSource;
   import org.apache.tapestry.spec.IComponentSpecification;
   import org.apache.tapestry.util.MultiKey;
  @@ -92,12 +87,11 @@
   
       /** @since 3.1 */
   
  -    private IPropertySource _applicationPropertySource;
  -
  +    private ComponentSpecificationResolver _componentSpecificationResolver;
   
       /** @since 3.1 */
   
  -    private ComponentSpecificationResolver _componentSpecificationResolver;
  +    private ComponentPropertySource _componentPropertySource;
   
       /**
        * Clears the template cache. This is used during debugging.
  @@ -210,7 +204,7 @@
           // specification was Bar.page. We would then search for /Bar.page. Confusing? Yes.
           // In 3.1, we are more reliant on the page name, which may include a folder prefix
(i.e.,
           // "admin/EditUser", so when we search it is based on the page name and not the
  -        // specification resource file name. We would search for Foo.html.  Moral of the
  +        // specification resource file name. We would search for Foo.html. Moral of the
           // story is to use the page name for the page specifiation and the template.
   
           String templateBaseName = page.getPageName() + "." + templateExtension;
  @@ -449,27 +443,17 @@
   
       private String getTemplateExtension(IComponent component)
       {
  -        String extension = component.getSpecification().getProperty(
  -                Tapestry.TEMPLATE_EXTENSION_PROPERTY);
  -
  -        if (extension != null)
  -            return extension;
  -
  -        extension = component.getNamespace().getSpecification().getProperty(
  +        return _componentPropertySource.getComponentProperty(
  +                component,
                   Tapestry.TEMPLATE_EXTENSION_PROPERTY);
  -
  -        if (extension != null)
  -            return extension;
  -
  -        return Tapestry.DEFAULT_TEMPLATE_EXTENSION;
       }
   
       private String getTemplateEncoding(IComponent component, Locale locale)
       {
  -        IPropertySource source = new DefaultComponentPropertySource(component,
  -                _applicationPropertySource, locale);
  -
  -        return source.getPropertyValue(TEMPLATE_ENCODING_PROPERTY_NAME);
  +        return _componentPropertySource.getLocalizedComponentProperty(
  +                component,
  +                locale,
  +                TEMPLATE_ENCODING_PROPERTY_NAME);
       }
   
       /** @since 3.1 */
  @@ -481,13 +465,6 @@
   
       /** @since 3.1 */
   
  -    public void setApplicationPropertySource(IPropertySource source)
  -    {
  -        _applicationPropertySource = source;
  -    }
  -
  -    /** @since 3.1 */
  -
       public void setLog(Log log)
       {
           _log = log;
  @@ -512,4 +489,10 @@
       {
           _contextRoot = contextRoot;
       }
  +
  +    /** @since 3.1 */
  +    public void setComponentPropertySource(ComponentPropertySource componentPropertySource)
  +    {
  +        _componentPropertySource = componentPropertySource;
  +    }
   }
  \ No newline at end of file
  
  
  
  1.2       +66 -4     jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/ComponentPropertySourceImpl.java
  
  Index: ComponentPropertySourceImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/ComponentPropertySourceImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ComponentPropertySourceImpl.java	8 Feb 2005 15:18:08 -0000	1.1
  +++ ComponentPropertySourceImpl.java	8 Feb 2005 16:00:50 -0000	1.2
  @@ -23,6 +23,7 @@
   import org.apache.hivemind.Resource;
   import org.apache.hivemind.lib.chain.ChainBuilder;
   import org.apache.tapestry.IComponent;
  +import org.apache.tapestry.INamespace;
   import org.apache.tapestry.engine.IPropertySource;
   import org.apache.tapestry.event.ResetEventListener;
   import org.apache.tapestry.services.ComponentPropertySource;
  @@ -45,10 +46,31 @@
   
       private Map _localizedComponentSources = new HashMap();
   
  +    private Map _namespaceSources = new HashMap();
  +
  +    private Map _localizedNamespaceSources = new HashMap();
  +
       public synchronized void resetEventDidOccur()
       {
           _componentSources.clear();
           _localizedComponentSources.clear();
  +        _namespaceSources.clear();
  +        _localizedNamespaceSources.clear();
  +    }
  +
  +    private synchronized IPropertySource getSourceForNamespace(INamespace namespace)
  +    {
  +        Resource key = namespace.getSpecificationLocation();
  +
  +        IPropertySource result = (IPropertySource) _namespaceSources.get(key);
  +
  +        if (result == null)
  +        {
  +            result = createSourceForNamespace(namespace);
  +            _namespaceSources.put(key, result);
  +        }
  +
  +        return result;
       }
   
       private synchronized IPropertySource getSourceForComponent(IComponent component)
  @@ -70,17 +92,34 @@
       {
           Resource key = component.getSpecification().getSpecificationLocation();
   
  -        LocalizedPropertySource result = (LocalizedPropertySource) _componentSources.get(key);
  +        LocalizedPropertySource result = (LocalizedPropertySource) _localizedComponentSources
  +                .get(key);
   
           if (result == null)
           {
               result = new LocalizedPropertySource(getSourceForComponent(component));
   
  -            _componentSources.put(key, result);
  +            _localizedComponentSources.put(key, result);
           }
   
           return result;
  +    }
  +
  +    private synchronized LocalizedPropertySource getLocalizedSourceForNamespace(INamespace
namespace)
  +    {
  +        Resource key = namespace.getSpecificationLocation();
   
  +        LocalizedPropertySource result = (LocalizedPropertySource) _localizedNamespaceSources
  +                .get(key);
  +
  +        if (result == null)
  +        {
  +            result = new LocalizedPropertySource(getSourceForNamespace(namespace));
  +
  +            _localizedNamespaceSources.put(key, result);
  +        }
  +
  +        return result;
       }
   
       private IPropertySource createSourceForComponent(IComponent component)
  @@ -90,8 +129,7 @@
           List sources = new ArrayList();
   
           sources.add(new PropertyHolderPropertySource(specification));
  -        sources.add(new PropertyHolderPropertySource(component.getNamespace().getSpecification()));
  -        sources.add(_globalProperties);
  +        sources.add(getSourceForNamespace(component.getNamespace()));
   
           return (IPropertySource) _chainBuilder.buildImplementation(
                   IPropertySource.class,
  @@ -99,6 +137,19 @@
                   ImplMessages.componentPropertySourceDescription(specification));
       }
   
  +    private IPropertySource createSourceForNamespace(INamespace namespace)
  +    {
  +        List sources = new ArrayList();
  +
  +        sources.add(new PropertyHolderPropertySource(namespace.getSpecification()));
  +        sources.add(_globalProperties);
  +
  +        return (IPropertySource) _chainBuilder.buildImplementation(
  +                IPropertySource.class,
  +                sources,
  +                ImplMessages.namespacePropertySourceDescription(namespace));
  +    }
  +
       public String getComponentProperty(IComponent component, String propertyName)
       {
           return getSourceForComponent(component).getPropertyValue(propertyName);
  @@ -110,6 +161,17 @@
           return getLocalizedSourceForComponent(component).getPropertyValue(propertyName,
locale);
       }
   
  +    public String getNamespaceProperty(INamespace namespace, String propertyName)
  +    {
  +        return getSourceForNamespace(namespace).getPropertyValue(propertyName);
  +    }
  +
  +    public String getLocalizedNamespaceProperty(INamespace namespace, Locale locale,
  +            String propertyName)
  +    {
  +        return getLocalizedSourceForNamespace(namespace).getPropertyValue(propertyName,
locale);
  +    }
  +
       public void setChainBuilder(ChainBuilder chainBuilder)
       {
           _chainBuilder = chainBuilder;
  
  
  
  1.10      +7 -0      jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/ImplMessages.java
  
  Index: ImplMessages.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/ImplMessages.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ImplMessages.java	8 Feb 2005 15:18:08 -0000	1.9
  +++ ImplMessages.java	8 Feb 2005 16:00:50 -0000	1.10
  @@ -26,6 +26,7 @@
   import org.apache.hivemind.Resource;
   import org.apache.hivemind.impl.MessageFormatter;
   import org.apache.tapestry.IComponent;
  +import org.apache.tapestry.INamespace;
   import org.apache.tapestry.engine.IEngineService;
   import org.apache.tapestry.services.Infrastructure;
   import org.apache.tapestry.spec.IComponentSpecification;
  @@ -205,4 +206,10 @@
           return _formatter.format("component-property-source-description", spec
                   .getSpecificationLocation());
       }
  +
  +    public static String namespacePropertySourceDescription(INamespace namespace)
  +    {
  +        return _formatter
  +                .format("namespace-property-source-description", namespace.getExtendedId());
  +    }
   }
  \ No newline at end of file
  
  
  
  1.5       +68 -62    jakarta-tapestry/framework/src/java/org/apache/tapestry/resolver/PageSpecificationResolverImpl.java
  
  Index: PageSpecificationResolverImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/resolver/PageSpecificationResolverImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PageSpecificationResolverImpl.java	29 Jan 2005 16:45:14 -0000	1.4
  +++ PageSpecificationResolverImpl.java	8 Feb 2005 16:00:50 -0000	1.5
  @@ -20,45 +20,44 @@
   import org.apache.tapestry.INamespace;
   import org.apache.tapestry.IRequestCycle;
   import org.apache.tapestry.Tapestry;
  +import org.apache.tapestry.services.ComponentPropertySource;
   import org.apache.tapestry.spec.ComponentSpecification;
   import org.apache.tapestry.spec.IComponentSpecification;
   
   /**
  - *  Performs the tricky work of resolving a page name to a page specification.
  - *  The search for pages in the application namespace is the most complicated,
  - *  since Tapestry searches for pages that aren't explicitly defined in the
  - *  application specification.  The search, based on the <i>simple-name</i>
  - *  of the page, goes as follows:
  + * Performs the tricky work of resolving a page name to a page specification. The search
for pages
  + * in the application namespace is the most complicated, since Tapestry searches for pages
that
  + * aren't explicitly defined in the application specification. The search, based on the
  + * <i>simple-name </i> of the page, goes as follows:
  + * <ul>
  + * <li>As declared in the application specification
  + * <li><i>simple-name </i>.page in the same folder as the application
specification
  + * <li><i>simple-name </i> page in the WEB-INF/ <i>servlet-name
</i> directory of the context root
  + * <li><i>simple-name </i>.page in WEB-INF
  + * <li><i>simple-name </i>.page in the application root (within the context
root)
  + * <li><i>simple-name </i>.html as a template in the application root,
for which an implicit
  + * specification is generated
  + * <li>By searching the framework namespace
  + * <li>By invoking
  + * {@link org.apache.tapestry.resolver.ISpecificationResolverDelegate#findPageSpecification(IRequestCycle,
INamespace, String)}
  + * </ul>
  + * <p>
  + * Pages in a component library are searched for in a more abbreviated fashion:
  + * <ul>
  + * <li>As declared in the library specification
  + * <li><i>simple-name </i>.page in the same folder as the library specification
  + * <li>By searching the framework namespace
  + * <li>By invoking
  + * {@link org.apache.tapestry.resolver.ISpecificationResolverDelegate#findPageSpecification(IRequestCycle,
INamespace, String)}
  + * </ul>
    * 
  - *  <ul>
  - *  <li>As declared in the application specification
  - *  <li><i>simple-name</i>.page in the same folder as the application
specification
  - *  <li><i>simple-name</i> page in the WEB-INF/<i>servlet-name</i>
directory of the context root
  - *  <li><i>simple-name</i>.page in WEB-INF
  - *  <li><i>simple-name</i>.page in the application root (within the context
root)
  - *  <li><i>simple-name</i>.html as a template in the application root,

  - *      for which an implicit specification is generated
  - *  <li>By searching the framework namespace
  - *  <li>By invoking {@link org.apache.tapestry.resolver.ISpecificationResolverDelegate#findPageSpecification(IRequestCycle,
INamespace, String)}
  - *  </ul>
  - * 
  - *  <p>Pages in a component library are searched for in a more abbreviated fashion:
  - *  <ul>
  - *  <li>As declared in the library specification
  - *  <li><i>simple-name</i>.page in the same folder as the library specification
  - *  <li>By searching the framework namespace
  - *  <li>By invoking {@link org.apache.tapestry.resolver.ISpecificationResolverDelegate#findPageSpecification(IRequestCycle,
INamespace, String)}
  - *  </ul>
  - *
  - *  @see org.apache.tapestry.engine.IPageSource
  - *  @author Howard Lewis Ship
  - *  @since 3.0
  - *
  + * @see org.apache.tapestry.engine.IPageSource
  + * @author Howard Lewis Ship
  + * @since 3.0
    */
   
  -public class PageSpecificationResolverImpl
  -    extends AbstractSpecificationResolver
  -    implements PageSpecificationResolver
  +public class PageSpecificationResolverImpl extends AbstractSpecificationResolver implements
  +        PageSpecificationResolver
   {
       /** set by container */
       private Log _log;
  @@ -66,12 +65,16 @@
       /** Set by resolve() */
       private String _simpleName;
   
  -    /** @since 3.1 **/
  +    /** @since 3.1 * */
       private INamespace _applicationNamespace;
   
  -    /** @since 3.1 **/
  +    /** @since 3.1 * */
       private INamespace _frameworkNamespace;
   
  +    /** @since 3.1 */
  +
  +    private ComponentPropertySource _componentPropertySource;
  +
       public void initializeService()
       {
           _applicationNamespace = getSpecificationSource().getApplicationNamespace();
  @@ -88,11 +91,11 @@
       }
   
       /**
  -     *  Resolve the name (which may have a library id prefix) to a namespace
  -     *  (see {@link #getNamespace()}) and a specification (see {@link #getSpecification()}).
  -     * 
  -     *  @throws ApplicationRuntimeException if the name cannot be resolved
  +     * Resolve the name (which may have a library id prefix) to a namespace (see
  +     * {@link #getNamespace()}) and a specification (see {@link #getSpecification()}).
        * 
  +     * @throws ApplicationRuntimeException
  +     *             if the name cannot be resolved
        */
   
       public void resolve(IRequestCycle cycle, String prefixedName)
  @@ -133,8 +136,9 @@
           searchForPage(cycle);
   
           if (getSpecification() == null)
  -            throw new ApplicationRuntimeException(
  -                ResolverMessages.noSuchPage(_simpleName, namespace));
  +            throw new ApplicationRuntimeException(ResolverMessages.noSuchPage(
  +                    _simpleName,
  +                    namespace));
       }
   
       public String getSimplePageName()
  @@ -174,12 +178,12 @@
               if (found(getContextRoot().getRelativeResource(expectedName)))
                   return;
   
  -            // The wierd one ... where we see if there's a template in the application
root location.
  +            // The wierd one ... where we see if there's a template in the application
root
  +            // location.
   
               String templateName = _simpleName + "." + getTemplateExtension();
   
  -            Resource templateResource =
  -                getContextRoot().getRelativeResource(templateName);
  +            Resource templateResource = getContextRoot().getRelativeResource(templateName);
   
               if (templateResource.getResourceURL() != null)
               {
  @@ -196,8 +200,8 @@
   
                   setNamespace(_frameworkNamespace);
   
  -                // Note:  This implies that normal lookup rules don't work
  -                // for the framework!  Framework pages must be
  +                // Note: This implies that normal lookup rules don't work
  +                // for the framework! Framework pages must be
                   // defined in the framework library specification.
   
                   setSpecification(_frameworkNamespace.getPageSpecification(_simpleName));
  @@ -208,8 +212,10 @@
           // Not found by any normal rule, so its time to
           // consult the delegate.
   
  -        IComponentSpecification specification =
  -            getDelegate().findPageSpecification(cycle, namespace, _simpleName);
  +        IComponentSpecification specification = getDelegate().findPageSpecification(
  +                cycle,
  +                namespace,
  +                _simpleName);
   
           setSpecification(specification);
       }
  @@ -219,7 +225,7 @@
           if (_log.isDebugEnabled())
               _log.debug("Found HTML template at " + resource);
   
  -        // TODO The SpecFactory in Specification parser should be used in some way to 
  +        // TODO The SpecFactory in Specification parser should be used in some way to
           // create an IComponentSpecification!
   
           IComponentSpecification specification = new ComponentSpecification();
  @@ -252,28 +258,23 @@
           IComponentSpecification specification = getSpecification();
   
           if (_log.isDebugEnabled())
  -            _log.debug(
  -                "Installing page " + _simpleName + " into " + namespace + " as " + specification);
  +            _log.debug("Installing page " + _simpleName + " into " + namespace + " as "
  +                    + specification);
   
           namespace.installPageSpecification(_simpleName, specification);
       }
   
       /**
  -     *  If the namespace defines the template extension (as property
  -     *  {@link Tapestry#TEMPLATE_EXTENSION_PROPERTY}, then that is used, otherwise
  -     *  the default is used.
  -     * 
  +     * If the namespace defines the template extension (as property
  +     * {@link Tapestry#TEMPLATE_EXTENSION_PROPERTY}, then that is used, otherwise the default
is
  +     * used.
        */
   
       private String getTemplateExtension()
       {
  -        String extension =
  -            getNamespace().getSpecification().getProperty(Tapestry.TEMPLATE_EXTENSION_PROPERTY);
  -
  -        if (extension == null)
  -            extension = Tapestry.DEFAULT_TEMPLATE_EXTENSION;
  -
  -        return extension;
  +        return _componentPropertySource.getNamespaceProperty(
  +                getNamespace(),
  +                Tapestry.TEMPLATE_EXTENSION_PROPERTY);
       }
   
       /** @since 3.1 */
  @@ -283,4 +284,9 @@
           _log = log;
       }
   
  -}
  +    /** @since 3.1 */
  +    public void setComponentPropertySource(ComponentPropertySource componentPropertySource)
  +    {
  +        _componentPropertySource = componentPropertySource;
  +    }
  +}
  \ No newline at end of file
  
  
  
  1.10      +1 -2      jakarta-tapestry/framework/src/descriptor/META-INF/tapestry.parse.xml
  
  Index: tapestry.parse.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/descriptor/META-INF/tapestry.parse.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- tapestry.parse.xml	31 Jan 2005 05:36:22 -0000	1.9
  +++ tapestry.parse.xml	8 Feb 2005 16:00:50 -0000	1.10
  @@ -75,11 +75,10 @@
       <invoke-factory>
         <construct class="org.apache.tapestry.services.impl.TemplateSourceImpl">
           <set-service property="parser" service-id="TemplateParser"/>
  -        <set-object property="applicationPropertySource" 
  -                       value="infrastructure:applicationPropertySource"/>
           <set-service property="delegate" service-id="TemplateSourceDelegate"/>
           <set-object property="contextRoot" value="infrastructure:contextRoot"/>
           <set-service property="componentSpecificationResolver" service-id="tapestry.page.ComponentSpecificationResolver"/>
  +        <set-object property="componentPropertySource"  value="infrastructure:componentPropertySource"/>
           <event-listener service-id="tapestry.ResetEventCoordinator"/>
         </construct>
       </invoke-factory>
  
  
  
  1.22      +2 -2      jakarta-tapestry/framework/src/descriptor/META-INF/hivemodule.xml
  
  Index: hivemodule.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/descriptor/META-INF/hivemodule.xml,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- hivemodule.xml	8 Feb 2005 15:18:08 -0000	1.21
  +++ hivemodule.xml	8 Feb 2005 16:00:50 -0000	1.22
  @@ -76,6 +76,7 @@
           <set-service property="applicationStateManager" service-id="tapestry.state.ApplicationStateManager"/>
           <set-service property="request" service-id="tapestry.globals.HttpServletRequest"/>
           <set-service property="response" service-id="tapestry.globals.HttpServletResponse"/>
  +        <set-service property="componentPropertySource" service-id="tapestry.props.ComponentPropertySource"/>
           <set-object property="applicationId" value="service-property:tapestry.globals.ApplicationGlobals:servletName"/>
           <set-object property="context" value="service-property:tapestry.globals.ApplicationGlobals:context"/>
         </construct>
  @@ -141,8 +142,7 @@
       <invoke-factory>
         <construct class="org.apache.tapestry.services.impl.ComponentMessagesSourceImpl">
           <event-listener service-id="ResetEventCoordinator"/>
  -        <set-object property="globalPropertySource" value="infrastructure:globalPropertySource"/>
  -        <set-service property="componentPropertySource" service-id="tapestry.props.ComponentPropertySource"/>
  +        <set-object property="componentPropertySource" value="infrastructure:componentPropertySource"/>
         </construct>
       </invoke-factory>
       
  
  
  
  1.11      +1 -0      jakarta-tapestry/framework/src/descriptor/META-INF/tapestry.page.xml
  
  Index: tapestry.page.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/descriptor/META-INF/tapestry.page.xml,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- tapestry.page.xml	29 Jan 2005 16:45:14 -0000	1.10
  +++ tapestry.page.xml	8 Feb 2005 16:00:50 -0000	1.11
  @@ -78,6 +78,7 @@
       <invoke-factory model="threaded">
         <construct class="org.apache.tapestry.resolver.PageSpecificationResolverImpl">
           <set-object property="specificationSource" value="infrastructure:specificationSource"/>
  +        <set-object property="componentPropertySource" value="infrastructure:componentPropertySource"/>
           <set-service property="delegate" service-id="SpecificationResolverDelegate"/>
           <set-object property="applicationId" value="infrastructure:applicationId"/>
           <set-object property="contextRoot" value="infrastructure:contextRoot"/>
  
  
  
  1.6       +1 -0      jakarta-tapestry/framework/src/descriptor/META-INF/tapestry.props.xml
  
  Index: tapestry.props.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/descriptor/META-INF/tapestry.props.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- tapestry.props.xml	8 Feb 2005 15:18:08 -0000	1.5
  +++ tapestry.props.xml	8 Feb 2005 16:00:50 -0000	1.6
  @@ -187,6 +187,7 @@
       <default symbol="org.apache.tapestry.output-encoding" value="UTF-8"/>
       <default symbol="org.apache.tapestry.enhance.disable-abstract-method-validation"
value="false"/>
       <default symbol="org.apache.tapestry.default-page-class" value="org.apache.tapestry.html.BasePage"/>
  +    <default symbol="org.apache.tapestry.template-extension" value="html"/>    
     </contribution>    
     
     <!-- This may nedd to be converted into an IPropertySource and injected into the ApplicationPropertySources
  
  
  
  1.15      +0 -8      jakarta-tapestry/framework/src/java/org/apache/tapestry/Tapestry.java
  
  Index: Tapestry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/Tapestry.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Tapestry.java	6 Jan 2005 02:17:12 -0000	1.14
  +++ Tapestry.java	8 Feb 2005 16:00:50 -0000	1.15
  @@ -166,14 +166,6 @@
       public static final String TEMPLATE_EXTENSION_PROPERTY = "org.apache.tapestry.template-extension";
   
       /**
  -     * The default extension for templates, "html".
  -     * 
  -     * @since 3.0
  -     */
  -
  -    public static final String DEFAULT_TEMPLATE_EXTENSION = "html";
  -
  -    /**
        * The name of an {@link org.apache.tapestry.IRequestCycle}attribute in which the currently
        * rendering {@link org.apache.tapestry.components.ILinkComponent}is stored. Link components
do
        * not nest.
  
  
  
  1.9       +11 -1     jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/TestComponentMessages.java
  
  Index: TestComponentMessages.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/TestComponentMessages.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TestComponentMessages.java	8 Feb 2005 15:18:08 -0000	1.8
  +++ TestComponentMessages.java	8 Feb 2005 16:00:50 -0000	1.9
  @@ -65,6 +65,17 @@
           {
               return null;
           }
  +
  +        public String getNamespaceProperty(INamespace namespace, String propertyName)
  +        {
  +            return null;
  +        }
  +
  +        public String getLocalizedNamespaceProperty(INamespace namespace, Locale locale,
  +                String propertyName)
  +        {
  +            return null;
  +        }
       }
   
       private void check(Messages messages, String key, String expected)
  @@ -125,7 +136,6 @@
       private Messages createMessages(String location, Locale locale)
       {
           ComponentMessagesSourceImpl source = new ComponentMessagesSourceImpl();
  -        source.setGlobalPropertySource(new NullPropertySource());
           source.setComponentPropertySource(new NullComponentPropertySource());
   
           IComponentSpecification spec = newSpec(location);
  
  
  

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


Mime
View raw message