Package org.apache.tapestry.engine

Source Code of org.apache.tapestry.engine.DefaultPropertySource

/* $$ Clover has instrumented this file $$ */// 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.

package org.apache.tapestry.engine;

import java.util.ResourceBundle;

import javax.servlet.http.HttpServlet;

import org.apache.tapestry.request.RequestContext;
import org.apache.tapestry.spec.IApplicationSpecification;
import org.apache.tapestry.util.DelegatingPropertySource;
import org.apache.tapestry.util.PropertyHolderPropertySource;
import org.apache.tapestry.util.ResourceBundlePropertySource;
import org.apache.tapestry.util.ServletContextPropertySource;
import org.apache.tapestry.util.ServletPropertySource;
import org.apache.tapestry.util.SystemPropertiesPropertySource;

/**
*  The default property source for application configuration properties.
*  The search order this property source follows is the following:<br>
<ul>
*    <li>Application specification
*    <li>Servlet properties
*    <li>Servlet context
*    <li>Property source extension defined in the application specification
*    <li>System properties
*    <li>Factory defaults
</ul>
*
<p>If the application specification contains an extension
*  named "org.apache.tapestry.property-source" it is inserted
*  in the search path just before
*  the property source for JVM System Properties.  This is a simple
*  hook that allows application-specific methods of obtaining
*  configuration values (typically, from a database or from JMX,
*  in some way). 
@author mb
@since 3.0
@deprecated To be removed in 3.2, replaced with the <code>tapestry.ApplicationPropertySource</code>
*  service
*/
public class DefaultPropertySource implements IPropertySource
{public static com.cortexeb.tools.clover.d __CLOVER_78_0 = com.cortexeb.tools.clover.aq.getRecorder(new char[] {67,58,92,119,111,114,107,115,112,97,99,101,92,106,97,107,97,114,116,97,45,116,97,112,101,115,116,114,121,92,102,114,97,109,101,119,111,114,107,92,116,97,114,103,101,116,92,99,108,111,118,101,114,45,100,98},1096998272901L);
    /**
     *  Name of an application extension that can provide configuration properties.
     *
     *  @since 2.3
     *
     **/
    private static final String EXTENSION_PROPERTY_SOURCE_NAME =
        "org.apache.tapestry.property-source";

    private IPropertySource _degatingPropertySource;

    /**
     * Creates a new default property source for looking up application-specific
     * properties. The search order of the property source is shown in the
     * documentation of this class.
     *
     * @param context the request context for which this property source will be created
     */
    public DefaultPropertySource(RequestContext context)
    {try { __CLOVER_78_0.M[454]++;
        __CLOVER_78_0.S[1972]++;DelegatingPropertySource result = new DelegatingPropertySource();

        __CLOVER_78_0.S[1973]++;HttpServlet servlet = context.getServlet();
        __CLOVER_78_0.S[1974]++;IApplicationSpecification spec = context.getApplicationSpecification();

        __CLOVER_78_0.S[1975]++;result.addSource(new PropertyHolderPropertySource(spec));
        __CLOVER_78_0.S[1976]++;result.addSource(new ServletPropertySource(servlet.getServletConfig()));
        __CLOVER_78_0.S[1977]++;result.addSource(new ServletContextPropertySource(servlet.getServletContext()));

        __CLOVER_78_0.S[1978]++;if ((((spec.checkExtension(EXTENSION_PROPERTY_SOURCE_NAME)) && (++__CLOVER_78_0.CT[373] != 0)) || (++__CLOVER_78_0.CF[373] == 0))){
        {
            __CLOVER_78_0.S[1979]++;IPropertySource source =
                (IPropertySource) spec.getExtension(
                    EXTENSION_PROPERTY_SOURCE_NAME,
                    IPropertySource.class);

            __CLOVER_78_0.S[1980]++;result.addSource(source);
        }}

        __CLOVER_78_0.S[1981]++;result.addSource(SystemPropertiesPropertySource.getInstance());

        // Lastly, add a final source to handle "factory defaults".

        __CLOVER_78_0.S[1982]++;ResourceBundle bundle =
            ResourceBundle.getBundle("org.apache.tapestry.ConfigurationDefaults");

        __CLOVER_78_0.S[1983]++;result.addSource(new ResourceBundlePropertySource(bundle));

        __CLOVER_78_0.S[1984]++;_degatingPropertySource = result;
    } finally { }}

    /**
     * @see org.apache.tapestry.engine.IPropertySource#getPropertyValue(java.lang.String)
     */
    public String getPropertyValue(String propertyName)
    {try { __CLOVER_78_0.M[455]++;
        __CLOVER_78_0.S[1985]++;return _degatingPropertySource.getPropertyValue(propertyName);
    } finally { }}
}
TOP

Related Classes of org.apache.tapestry.engine.DefaultPropertySource

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.