Package org.apache.stratum.configuration

Examples of org.apache.stratum.configuration.Configuration


     * Called the first time the Service is used.
     */
    public void init()
    throws InitializationException {
        int cacheInitialSize = DEFAULT_INITIAL_CACHE_SIZE;
        Configuration conf = getConfiguration();
        if (conf != null) {
            try {
                cacheInitialSize = conf.getInt(INITIAL_CACHE_SIZE, DEFAULT_INITIAL_CACHE_SIZE);
                if (cacheInitialSize <= 0) {
                    throw new IllegalArgumentException(INITIAL_CACHE_SIZE + " must be >0");
                }
                cacheCheckFrequency = conf.getLong(CACHE_CHECK_FREQUENCY, DEFAULT_CACHE_CHECK_FREQUENCY);
                if (cacheCheckFrequency <= 0) {
                    throw new IllegalArgumentException(CACHE_CHECK_FREQUENCY + " must be >0");
                }
            }
            catch (Exception x) {
View Full Code Here


     * This method sets up the template cache.
     */
    private void initJsp() throws Exception
    {
        ServletContext context = TurbineServlet.getServletContext();
        Configuration config = getConfiguration();

        /*
         * Use the turbine template service to translate
         * the template paths.
         */
        templatePaths = TurbineTemplate.translateTemplatePaths(
        config.getStringArray("templates"));

        /*
         * Set relative paths from config.
         * Needed for javax.servlet.RequestDispatcher
         */
        relativeTemplatePaths = config.getStringArray("templates");

        /*
         * Make sure that the relative paths begin with /
         */
        for (int i = 0; i < relativeTemplatePaths.length; i++)
        {
            if (!relativeTemplatePaths[i].startsWith("/"))
            {
                relativeTemplatePaths[i] = "/" + relativeTemplatePaths[i];
            }
        }

        bufferSize = config.getInt("buffer.size", 8192);

        /*
         * Register with the template service.
         */
        registerConfiguration("jsp");
View Full Code Here

            DEFAULT_COOKIE_PARSER
        };
        configurations.put(DEFAULT_CONFIG,def.clone());

        // Check other configurations.
        Configuration conf = getConfiguration();
        if (conf != null)
        {
            String key,value;
            String[] config;
            String[] plist = new String[]
            {
                RUN_DATA,
                PARAMETER_PARSER,
                COOKIE_PARSER
            };
            for (Iterator i = conf.getKeys(); i.hasNext();)
            {
                key = (String) i.next();
                value = conf.getString(key);
                for (int j = 0; j < plist.length; j++)
                {
                    if (key.endsWith(plist[j]) &&
                        (key.length() > (plist[j].length() + 1)))
                    {
View Full Code Here

     * @exception IOException, if there was an I/O problem.
     */
    public static void setPropertiesFileName(String propertiesFileName)
        throws TurbineException
    {
        Configuration mappings = (Configuration) new BaseConfiguration();

        mappings.setProperty(ResourceService.SERVICE_NAME,
            TurbineResourceService.class.getName());

        TurbineServices services = (TurbineServices) TurbineServices.getInstance();
        services.initMapping(mappings);
        services.initServices(new TurbineConfig(".", propertiesFileName), true);
View Full Code Here

     * @exception TurbineException, if there was an I/O problem.
     */
    public static void setProperties(Properties properties)
        throws TurbineException
    {
        Configuration mappings = (Configuration) new BaseConfiguration();

        mappings.setProperty(ResourceService.SERVICE_NAME,
            TurbineResourceService.class.getName());

        TurbineServices services = (TurbineServices) TurbineServices.getInstance();
        services.initMapping(mappings);
        services.initServices(properties, true);
View Full Code Here

     *
     * @param props A Properties object.
     */
    private void init(Properties props)
    {
        Configuration configuration = ConfigurationConverter
                .getConfiguration(props);
        init(configuration);
    }
View Full Code Here

     * @param prefix the common name prefix
     * @return A ResourceService providing the subset of configuration.
     */
    public ResourceService getResources(String prefix)
    {
        Configuration config = getConfiguration().subset(prefix);

        if (config == null)
        {
            return null;
        }
View Full Code Here

     * @param prefix the common name prefix
     * @return A Configuration providing the subset of configuration.
     */
    public Configuration getConfiguration(String prefix)
    {
        Configuration config = getConfiguration().subset(prefix);

        if (config == null)
        {
            return null;
        }
View Full Code Here

     *
     * @throws InitializationException if initialization fails.
     */
    public void init() throws InitializationException
    {
        Configuration conf = getConfiguration();
        if (conf != null)
        {
            Vector loaders = conf.getVector(CLASS_LOADERS);
            if (loaders != null)
            {
                for (int i = 0; i < loaders.size(); i++)
                {
                    try
                    {
                        classLoaders.add(
                            loadClass((String) loaders.get(i)).newInstance());
                    }
                    catch (Exception x)
                    {
                        throw new InitializationException(
                            "No such class loader '" +
                                (String) loaders.get(i) +
                                    "' for TurbinbeFactoryService",x);
                    }
                }
            }

            String key,factory;
            for (Iterator i = conf.getKeys(OBJECT_FACTORY); i.hasNext();)
            {
                key = (String) i.next();
                factory = conf.getString(key);

                /*
                 * Store the factory to the table as a string and
                 * instantiate it by using the service when needed.
                 */
 
View Full Code Here

     * Initializes the service.
     */
    public void init()
    {
        dbMaps = (Map)new HashMap();
        Configuration configuration = getConfiguration();

        // Get the value for the default map, but if there
        // isn't a value than fall back to the standard
        // "default" value.
        defaultMap = configuration.getString(DEFAULT_MAP, DEFAULT);

        // indicate that the service initialized correctly
        setInit(true);
    }
View Full Code Here

TOP

Related Classes of org.apache.stratum.configuration.Configuration

Copyright © 2018 www.massapicom. 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.