001: /*
002: * $Header: /export/home/cvsroot/MyPersonalizerRepository/MyPersonalizer/Subsystems/Kernel/Sources/es/udc/mypersonalizer/kernel/config/KernelConfigManager.java,v 1.1.1.1 2004/03/25 12:08:38 fbellas Exp $
003: * $Revision: 1.1.1.1 $
004: * $Date: 2004/03/25 12:08:38 $
005: *
006: * =============================================================================
007: *
008: * Copyright (c) 2003, The MyPersonalizer Development Group
009: * (http://www.tic.udc.es/~fbellas/mypersonalizer/index.html) at
010: * University Of A Coruna
011: * All rights reserved.
012: *
013: * Redistribution and use in source and binary forms, with or without
014: * modification, are permitted provided that the following conditions are met:
015: *
016: * - Redistributions of source code must retain the above copyright notice,
017: * this list of conditions and the following disclaimer.
018: *
019: * - Redistributions in binary form must reproduce the above copyright notice,
020: * this list of conditions and the following disclaimer in the documentation
021: * and/or other materials provided with the distribution.
022: *
023: * - Neither the name of the University Of A Coruna nor the names of its
024: * contributors may be used to endorse or promote products derived from
025: * this software without specific prior written permission.
026: *
027: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
028: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
029: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
030: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
031: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
032: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
033: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
034: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
035: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
036: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
037: * POSSIBILITY OF SUCH DAMAGE.
038: *
039: */
040:
041: package es.udc.mypersonalizer.kernel.config;
042:
043: import es.udc.mypersonalizer.kernel.util.config.ConfigurationManager;
044: import es.udc.mypersonalizer.kernel.util.exceptions.InternalErrorException;
045: import es.udc.mypersonalizer.kernel.util.xml.LocalEntityResolver;
046:
047: /**
048: * This class manages the configuration for the Kernel subsystem. When
049: * requested, asks the {@link ConfigurationManager} for the right
050: * configuration (the one suited for the Kernel Subsystem) and returns it as a
051: * {@link KernelConfig} object.
052: *
053: * @author Daniel Fernandez
054: * @since 1.0
055: */
056: public class KernelConfigManager {
057:
058: /**
059: * Stores the name of the Kernel configuration file. It is set to
060: * <code>myper-kernel-config</code>, being
061: * <code>myper-kernel-config.xml</code> the
062: * name of the correspondent XML file.
063: */
064: private static final String CONFIG_NAME = "myper-kernel-config";
065:
066: /**
067: * The XML PUBLIC ID that identifies the Kernel configuration. Set to
068: * <code>-//MyPersonalizer//DTD MyPersonalizer Kernel Configuration
069: * 1.0//EN</code>.
070: */
071: private static String PUBLIC_ID = "-//MyPersonalizer//DTD MyPersonalizer Kernel Configuration 1.0//EN";
072:
073: /**
074: * The name of the DTD file against which the XML configuration file
075: * is validated.
076: * Set to <code>myper-kernel-config_1_0.dtd</code>.
077: */
078: private static String FILE_NAME = "myper-kernel-config_1_0.dtd";
079:
080: /**
081: * {@link LocalEntityResolver} object which will help the parsers find
082: * the DTD in the subsystem distribution.
083: */
084: private static LocalEntityResolver ENTITY_RESOLVER = null;
085:
086: /*
087: * Creates the local entity resolver to allow XML files to be validated
088: * against local DTD files.
089: */
090: static {
091: ENTITY_RESOLVER = new LocalEntityResolver(PUBLIC_ID, FILE_NAME);
092: }
093:
094: /**
095: * Creates a new instance of KernelConfigManager.
096: */
097: private KernelConfigManager() {
098: }
099:
100: /**
101: * Returns the Kernel subsystem configuration in a {@link KernelConfig}
102: * object.
103: *
104: * @throws InternalErrorException If any error shows up, for instance,
105: * a parsing error.
106: * @return a KernelConfig object containing the subsystem configuration.
107: */
108: public static KernelConfig getConfig()
109: throws InternalErrorException {
110: return (KernelConfig) ConfigurationManager.getConfiguration(
111: CONFIG_NAME, ENTITY_RESOLVER);
112: }
113:
114: }
|