Example usage for java.util Properties containsKey

List of usage examples for java.util Properties containsKey

Introduction

In this page you can find the example usage for java.util Properties containsKey.

Prototype

@Override
    public boolean containsKey(Object key) 

Source Link

Usage

From source file:com.ganji.cateye.flume.kestrel.KestrelRpcClient.java

License:asdf

@Override
protected void configure(Properties properties) throws FlumeException {
    if (isActive()) {
        throw new FlumeException("Attempting to re-configured an already configured client!");
    }/*ww  w . j  a  v a 2 s. c o  m*/
    stateLock.lock();
    try {
        this.sinkName = properties.getProperty(ScribeSinkConsts.CONFIG_SINK_NAME, "sink-" + hashCode());

        List<HostInfo> hosts = HostInfo.getHostInfoList(properties);
        if (hosts.size() > 0) {
            HostInfo host = hosts.get(0);
            hostname = host.getHostName();
            port = host.getPortNumber();
        } else {
            hostname = properties.getProperty(KestrelSinkConsts.CONFIG_HOSTNAME,
                    KestrelSinkConsts.DEFAULT_HOSTNAME);
            port = Integer.parseInt(properties.getProperty(KestrelSinkConsts.CONFIG_PORT,
                    KestrelSinkConsts.CONFIG_PORT_DEFAULT));
        }
        batchSize = Integer.parseInt(properties.getProperty(RpcClientConfigurationConstants.CONFIG_BATCH_SIZE,
                RpcClientConfigurationConstants.DEFAULT_BATCH_SIZE.toString()));
        requestTimeout = Long
                .parseLong(properties.getProperty(RpcClientConfigurationConstants.CONFIG_REQUEST_TIMEOUT,
                        String.valueOf(RpcClientConfigurationConstants.DEFAULT_REQUEST_TIMEOUT_MILLIS)));
        if (requestTimeout < 1000) {
            logger.warn(
                    String.format("[%s] Request timeout specified less than 1s. Using default value instead.",
                            this.sinkName));
            requestTimeout = RpcClientConfigurationConstants.DEFAULT_REQUEST_TIMEOUT_MILLIS;
        }
        connectionPoolSize = Integer
                .parseInt(properties.getProperty(RpcClientConfigurationConstants.CONFIG_CONNECTION_POOL_SIZE,
                        String.valueOf(RpcClientConfigurationConstants.DEFAULT_CONNECTION_POOL_SIZE)));
        if (connectionPoolSize < 1) {
            logger.warn(String.format(
                    "[%s] Connection Pool Size specified is less than 1. Using default value instead.",
                    this.sinkName));
            connectionPoolSize = RpcClientConfigurationConstants.DEFAULT_CONNECTION_POOL_SIZE;
        }
        connectionManager = new ConnectionPoolManager(connectionPoolSize);

        // serialization
        String serializerName = properties.getProperty(KestrelSinkConsts.CONFIG_SERIALIZER,
                KestrelSinkConsts.DEFAULT_SERIALIZER);
        if (serializerName.equalsIgnoreCase(KestrelSinkConsts.DEFAULT_SERIALIZER)) {
            serializer = new PlainMessageSerializer();
        } else if (serializerName.equalsIgnoreCase("scribe")) {
            serializer = new ScribeSerializer();
        } else {
            try {
                serializer = (MessageSerializer) Class.forName(serializerName).newInstance();
            } catch (Exception ex) {
                throw new RuntimeException(String.format("[%s] invalid serializer specified", this.sinkName),
                        ex);
            }
        }
        Context context = new Context();
        context.put(SinkConsts.CONFIG_CATEGORY_HEADER,
                properties.containsKey(SinkConsts.CONFIG_CATEGORY_HEADER)
                        ? properties.getProperty(SinkConsts.CONFIG_CATEGORY_HEADER)
                        : SinkConsts.DEFAULT_CATEGORY_HEADER);
        serializer.configure(context);
        // routes
        String rs = properties.getProperty(KestrelSinkConsts.CONFIG_ROUTES, "");
        if (StringUtils.isEmpty(rs))
            throw new FlumeException(
                    String.format("[%s] routes of KestrelRpcClient not configed", this.sinkName));
        String[] arrRoute = rs.split(RouteConfig.SPLITTER);
        for (String route : arrRoute) {
            if (route.isEmpty())
                continue;
            String prefix = KestrelSinkConsts.CONFIG_ROUTE_PREFIX + route;
            routes.add(properties.getProperty(prefix + KestrelSinkConsts.CONFIG_ROUTE_CATEGORY),
                    properties.getProperty(prefix + KestrelSinkConsts.CONFIG_ROUTE_QUEUE));
        }

        connState = State.READY;
    } catch (Throwable ex) {
        // Failed to configure, kill the client.
        connState = State.DEAD;
        if (ex instanceof Error) {
            throw (Error) ex;
        } else if (ex instanceof RuntimeException) {
            throw (RuntimeException) ex;
        }
        throw new FlumeException(String.format("[%s] Error while configuring RpcClient. ", this.sinkName), ex);
    } finally {
        stateLock.unlock();
    }
}

From source file:com.alfaariss.oa.OAContextListener.java

/**
 * Starts the engine before all servlets are initialized.
 * /*w  ww .  j a v a  2 s .c o m*/
 * Searches for the properties needed for the configuration in:
 * <code>[Servlet context dir]/WEB-INF/[PROPERTIES_FILENAME]</code>
 * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
 */
@Override
public void contextInitialized(ServletContextEvent oServletContextEvent) {
    Properties pConfig = new Properties();
    try {
        _logger.info("Starting Asimba");

        Package pCurrent = OAContextListener.class.getPackage();

        String sSpecVersion = pCurrent.getSpecificationVersion();
        if (sSpecVersion != null)
            _logger.info("Specification-Version: " + sSpecVersion);

        String sImplVersion = pCurrent.getImplementationVersion();
        if (sImplVersion != null)
            _logger.info("Implementation-Version: " + sImplVersion);

        ServletContext oServletContext = oServletContextEvent.getServletContext();

        Enumeration enumContextAttribs = oServletContext.getInitParameterNames();
        while (enumContextAttribs.hasMoreElements()) {
            String sName = (String) enumContextAttribs.nextElement();
            pConfig.put(sName, oServletContext.getInitParameter(sName));
        }

        if (pConfig.size() > 0) {
            _logger.info("Using configuration items found in servlet context: " + pConfig);
        }

        // Add MountingPoint to PathTranslator
        PathTranslator.getInstance().addKey(MP_WEBAPP_ROOT, oServletContext.getRealPath(""));

        // Try to see whether there is a system property with the location of the properties file:
        String sPropertiesFilename = System.getProperty(PROPERTIES_FILENAME_PROPERTY);
        if (null != sPropertiesFilename && !"".equals(sPropertiesFilename)) {
            File fConfig = new File(sPropertiesFilename);
            if (fConfig.exists()) {
                _logger.info("Reading Asimba properties from " + fConfig.getAbsolutePath());
                pConfig.putAll(getProperties(fConfig));
            }
        }

        String sWebInf = oServletContext.getRealPath("WEB-INF");
        if (sWebInf != null) {
            _logger.info("Cannot find path in ServletContext for WEB-INF");
            StringBuffer sbConfigFile = new StringBuffer(sWebInf);
            if (!sbConfigFile.toString().endsWith(File.separator))
                sbConfigFile.append(File.separator);
            sbConfigFile.append(PROPERTIES_FILENAME);

            File fConfig = new File(sbConfigFile.toString());
            if (fConfig.exists()) {
                _logger.info("Updating configuration items with the items in file: " + fConfig.toString());
                pConfig.putAll(getProperties(fConfig));
            } else {
                _logger.info("No optional configuration properties (" + PROPERTIES_FILENAME
                        + ") file found at: " + fConfig.toString());
            }
        }
        //Search for PROPERTIES_FILENAME file in servlet context classloader classpath 
        //it looks first at this location: ./<context>/web-inf/classes/[PROPERTIES_FILENAME]
        //if previous location didn't contain PROPERTIES_FILENAME then checking: 
        //./tomcat/common/classes/PROPERTIES_FILENAME
        URL urlProperties = oServletContext.getClass().getClassLoader().getResource(PROPERTIES_FILENAME);
        if (urlProperties != null) {
            String sProperties = urlProperties.getFile();
            _logger.debug("Found '" + PROPERTIES_FILENAME + "' file in classpath: " + sProperties);
            File fProperties = new File(sProperties);
            if (fProperties != null && fProperties.exists()) {
                _logger.info("Updating configuration items with the items in file: "
                        + fProperties.getAbsolutePath());
                pConfig.putAll(getProperties(fProperties));
            } else
                _logger.info("Could not resolve: " + fProperties.getAbsolutePath());
        } else
            _logger.info("No optional '" + PROPERTIES_FILENAME
                    + "' configuration file found in servlet context classpath");

        if (!pConfig.containsKey("configuration.handler.filename")) {
            StringBuffer sbOAConfigFile = new StringBuffer(sWebInf);
            if (!sbOAConfigFile.toString().endsWith(File.separator))
                sbOAConfigFile.append(File.separator);
            sbOAConfigFile.append("conf");
            sbOAConfigFile.append(File.separator);
            sbOAConfigFile.append("asimba.xml");
            File fOAConfig = new File(sbOAConfigFile.toString());
            if (fOAConfig.exists()) {
                pConfig.put("configuration.handler.filename", sbOAConfigFile.toString());
                _logger.info(
                        "Setting 'configuration.handler.filename' configuration property with configuration file found at: "
                                + fOAConfig.toString());
            }
        }

        _oEngineLauncher.start(pConfig);

        _logger.info("Started Engine with OAContextListener");
    } catch (Exception e) {
        _logger.error("Can't start Engine with OAContextListener", e);

        _logger.debug("try stopping the server");
        _oEngineLauncher.stop();
    }

}

From source file:com.marklogic.client.impl.JerseyServices.java

private void connect(String host, int port, String database, String user, String password,
        Authentication authenType, SSLContext context, X509HostnameVerifier verifier) {
    if (logger.isDebugEnabled())
        logger.debug("Connecting to {} at {} as {}", new Object[] { host, port, user });

    if (host == null)
        throw new IllegalArgumentException("No host provided");

    if (authenType == null) {
        if (context != null) {
            authenType = Authentication.BASIC;
        }//  w  w w  .j a  v a 2 s. c  om
    }

    if (authenType != null) {
        if (user == null)
            throw new IllegalArgumentException("No user provided");
        if (password == null)
            throw new IllegalArgumentException("No password provided");
    }

    if (connection != null)
        connection = null;
    if (client != null) {
        client.destroy();
        client = null;
    }

    this.database = database;

    String baseUri = ((context == null) ? "http" : "https") + "://" + host + ":" + port + "/v1/";

    Properties props = System.getProperties();

    if (props.containsKey(MAX_DELAY_PROP)) {
        String maxDelayStr = props.getProperty(MAX_DELAY_PROP);
        if (maxDelayStr != null && maxDelayStr.length() > 0) {
            int max = Integer.parseInt(maxDelayStr);
            if (max > 0) {
                maxDelay = max * 1000;
            }
        }
    }
    if (props.containsKey(MIN_RETRY_PROP)) {
        String minRetryStr = props.getProperty(MIN_RETRY_PROP);
        if (minRetryStr != null && minRetryStr.length() > 0) {
            int min = Integer.parseInt(minRetryStr);
            if (min > 0) {
                minRetry = min;
            }
        }
    }

    // TODO: integrated control of HTTP Client and Jersey Client logging
    if (!props.containsKey("org.apache.commons.logging.Log")) {
        System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
    }
    if (!props.containsKey("org.apache.commons.logging.simplelog.log.org.apache.http")) {
        System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http", "warn");
    }
    if (!props.containsKey("org.apache.commons.logging.simplelog.log.org.apache.http.wire")) {
        System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.wire", "warn");
    }

    Scheme scheme = null;
    if (context == null) {
        SchemeSocketFactory socketFactory = PlainSocketFactory.getSocketFactory();
        scheme = new Scheme("http", port, socketFactory);
    } else {
        SSLSocketFactory socketFactory = new SSLSocketFactory(context, verifier);
        scheme = new Scheme("https", port, socketFactory);
    }
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(scheme);

    int maxRouteConnections = 100;
    int maxTotalConnections = 2 * maxRouteConnections;

    /*
     * 4.2 PoolingClientConnectionManager connMgr = new
     * PoolingClientConnectionManager(schemeRegistry);
     * connMgr.setMaxTotal(maxTotalConnections);
     * connMgr.setDefaultMaxPerRoute(maxRouteConnections);
     * connMgr.setMaxPerRoute( new HttpRoute(new HttpHost(baseUri)),
     *     maxRouteConnections);
     */
    // start 4.1
    ThreadSafeClientConnManager connMgr = new ThreadSafeClientConnManager(schemeRegistry);
    connMgr.setMaxTotal(maxTotalConnections);
    connMgr.setDefaultMaxPerRoute(maxRouteConnections);
    connMgr.setMaxForRoute(new HttpRoute(new HttpHost(baseUri)), maxRouteConnections);
    // end 4.1

    // CredentialsProvider credentialsProvider = new
    // BasicCredentialsProvider();
    // credentialsProvider.setCredentials(new AuthScope(host, port),
    // new UsernamePasswordCredentials(user, password));

    HttpParams httpParams = new BasicHttpParams();

    if (authenType != null) {
        List<String> authpref = new ArrayList<String>();

        if (authenType == Authentication.BASIC)
            authpref.add(AuthPolicy.BASIC);
        else if (authenType == Authentication.DIGEST)
            authpref.add(AuthPolicy.DIGEST);
        else
            throw new MarkLogicInternalException(
                    "Internal error - unknown authentication type: " + authenType.name());

        httpParams.setParameter(AuthPNames.PROXY_AUTH_PREF, authpref);
    }

    httpParams.setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);

    HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1);

    // HttpConnectionParams.setStaleCheckingEnabled(httpParams, false);

    // long-term alternative to isFirstRequest alive
    // HttpProtocolParams.setUseExpectContinue(httpParams, false);
    // httpParams.setIntParameter(CoreProtocolPNames.WAIT_FOR_CONTINUE, 1000);

    DefaultApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
    Map<String, Object> configProps = config.getProperties();
    configProps.put(ApacheHttpClient4Config.PROPERTY_PREEMPTIVE_BASIC_AUTHENTICATION, false);
    configProps.put(ApacheHttpClient4Config.PROPERTY_DISABLE_COOKIES, true);
    configProps.put(ApacheHttpClient4Config.PROPERTY_CONNECTION_MANAGER, connMgr);
    // ignored?
    configProps.put(ApacheHttpClient4Config.PROPERTY_FOLLOW_REDIRECTS, false);
    // configProps.put(ApacheHttpClient4Config.PROPERTY_CREDENTIALS_PROVIDER,
    // credentialsProvider);
    configProps.put(ApacheHttpClient4Config.PROPERTY_HTTP_PARAMS, httpParams);
    // switches from buffered to streamed in Jersey Client
    configProps.put(ApacheHttpClient4Config.PROPERTY_CHUNKED_ENCODING_SIZE, 32 * 1024);

    client = ApacheHttpClient4.create(config);

    // System.setProperty("javax.net.debug", "all"); // all or ssl

    if (authenType == null) {
        checkFirstRequest = false;
    } else if (authenType == Authentication.BASIC) {
        checkFirstRequest = false;

        client.addFilter(new HTTPBasicAuthFilter(user, password));
    } else if (authenType == Authentication.DIGEST) {
        checkFirstRequest = true;

        // workaround for JerseyClient bug 1445
        client.addFilter(new DigestChallengeFilter());

        client.addFilter(new HTTPDigestAuthFilter(user, password));
    } else {
        throw new MarkLogicInternalException(
                "Internal error - unknown authentication type: " + authenType.name());
    }

    // client.addFilter(new LoggingFilter(System.err));

    connection = client.resource(baseUri);
}

From source file:org.apache.geode.internal.cache.GemFireCacheImpl.java

/*****
 * Request the shared configuration from the locator(s) which have the Cluster config service
 * running//from w  w  w .  j  a  v  a 2s .com
 */
public ConfigurationResponse requestSharedConfiguration() {
    final DistributionConfig config = this.system.getConfig();

    if (!(dm instanceof DistributionManager))
        return null;

    // do nothing if this vm is/has locator or this is a client
    if (((DistributionManager) dm).getDMType() == DistributionManager.LOCATOR_DM_TYPE || isClient
            || Locator.getLocator() != null)
        return null;

    // can't simply return null if server is not using shared configuration, since we need to find
    // out
    // if the locator is running in secure mode or not, if yes, then we need to throw an exception
    // if server is not using cluster config

    Map<InternalDistributedMember, Collection<String>> scl = this.getDistributionManager()
            .getAllHostedLocatorsWithSharedConfiguration();

    // If there are no locators with Shared configuration, that means the system has been started
    // without shared configuration
    // then do not make requests to the locators
    if (scl.isEmpty()) {
        logger.info(LocalizedMessage
                .create(LocalizedStrings.GemFireCache_NO_LOCATORS_FOUND_WITH_SHARED_CONFIGURATION));
        return null;
    }

    ConfigurationResponse response = null;
    List<String> locatorConnectionStrings = getSharedConfigLocatorConnectionStringList();

    try {
        response = ClusterConfigurationLoader.requestConfigurationFromLocators(system.getConfig(),
                locatorConnectionStrings);

        // log the configuration received from the locator
        logger.info(LocalizedMessage
                .create(LocalizedStrings.GemFireCache_RECEIVED_SHARED_CONFIGURATION_FROM_LOCATORS));
        logger.info(response.describeConfig());

        Configuration clusterConfig = response.getRequestedConfiguration()
                .get(ClusterConfigurationService.CLUSTER_CONFIG);
        Properties clusterSecProperties = (clusterConfig == null) ? new Properties()
                : clusterConfig.getGemfireProperties();

        // If not using shared configuration, return null or throw an exception is locator is secured
        if (!config.getUseSharedConfiguration()) {
            if (clusterSecProperties.containsKey(ConfigurationProperties.SECURITY_MANAGER)) {
                throw new GemFireConfigException(
                        LocalizedStrings.GEMFIRE_CACHE_SECURITY_MISCONFIGURATION_2.toLocalizedString());
            } else {
                logger.info(
                        LocalizedMessage.create(LocalizedStrings.GemFireCache_NOT_USING_SHARED_CONFIGURATION));
                return null;
            }
        }

        Properties serverSecProperties = config.getSecurityProps();
        // check for possible mis-configuration
        if (isMisConfigured(clusterSecProperties, serverSecProperties, ConfigurationProperties.SECURITY_MANAGER)
                || isMisConfigured(clusterSecProperties, serverSecProperties,
                        ConfigurationProperties.SECURITY_POST_PROCESSOR)) {
            throw new GemFireConfigException(
                    LocalizedStrings.GEMFIRE_CACHE_SECURITY_MISCONFIGURATION.toLocalizedString());
        }
        return response;

    } catch (ClusterConfigurationNotAvailableException e) {
        throw new GemFireConfigException(
                LocalizedStrings.GemFireCache_SHARED_CONFIGURATION_NOT_AVAILABLE.toLocalizedString(), e);
    } catch (UnknownHostException e) {
        throw new GemFireConfigException(e.getLocalizedMessage(), e);
    }
}

From source file:lu.fisch.unimozer.Diagram.java

private void loadFromBlueJ(String path) {
    // load files from the current directory
    String bfilename = path + System.getProperty("file.separator") + Unimozer.B_PACKAGENAME;

    File bfile = new File(bfilename);
    if (bfile.exists()) {
        Properties p = new Properties();
        try {/* w  w w.  j a  va 2  s .  co m*/
            p.load(new FileInputStream(bfilename));
            int i = 1;
            while (p.containsKey("target" + i + ".name")) {
                if (!p.getProperty("target" + i + ".type").equals("PackageTarget")) {
                    MyClass mc = new MyClass(path + System.getProperty("file.separator")
                            + p.getProperty("target" + i + ".name") + ".java", Unimozer.FILE_ENCODING);
                    mc.setPosition(new Point(Integer.valueOf(p.getProperty("target" + i + ".x")),
                            Integer.valueOf(p.getProperty("target" + i + ".y"))));
                    addClass(mc);
                }
                i++;
            }
        } catch (Exception ex) {
            MyError.display(ex);
        }
    }

    // search all other directories
    File dir = new File(path);

    String[] children = dir.list();
    if (children == null) {
        // Either dir does not exist or is not a directory
    } else {
        for (int i = 0; i < children.length; i++) {
            // Get filename of file or directory
            String ffilename = children[i];
        }
    }

    // It is also possible to filter the list of returned files.
    // This example does not return any files that start with `.'.
    FilenameFilter filter = new FilenameFilter() {
        @Override
        public boolean accept(File dir, String name) {
            return ((new File(dir.getAbsolutePath() + System.getProperty("file.separator") + name))
                    .isDirectory());
        }
    };
    children = dir.list(filter);

    for (int i = 0; i < children.length; i++) {
        //System.out.println("Loading: "+directoryName + System.getProperty("file.separator") + children[i]);
        loadFromBlueJ(path + System.getProperty("file.separator") + children[i]);
    }

}

From source file:de.innovationgate.wgpublisher.WGACore.java

public void contextInitialized(ServletContextEvent arg0) {

    try {//  w  w w  .  java  2 s .co m
        _context = arg0.getServletContext();

        // General inits
        this.instanceActiveSince = new Date();
        arg0.getServletContext().setAttribute(ATTRIB_CORE, this);
        WGFactory.setAuthModuleFactory(new WGAAuthModuleFactory(this));
        WGFactory.setMimetypeDeterminationService(new WGAMimetypeDeterminationService());

        // Create temp dir
        File mainTempDir = new File(System.getProperty("java.io.tmpdir"));
        this.wgaTempDir = new File(mainTempDir, ".wgatemp");
        if (wgaTempDir.exists()) {
            killTempDir(wgaTempDir);
        }
        wgaTempDir.mkdir();
        WGFactory.setTempDir(wgaTempDir);
        TemporaryFile.prepareDirectory(wgaTempDir);

        // Creating logger
        initLoggingFile();
        String debug = System.getProperty(SYSPROPERTY_DEBUG);
        if (debug != null) {
            for (String target : WGUtils.deserializeCollection(debug, ",", true)) {
                Logger logger = Logger.getLogger(target);
                logger.setLevel(Level.DEBUG);
            }
        }

        // Try to retrieve build properties
        _buildSignature = "NOSIGNATURE";
        try {
            InputStream buildPropIn = _context.getResourceAsStream("/WEB-INF/wgabuild.properties");
            Properties props = new Properties();
            props.load(buildPropIn);
            if (props.containsKey("signature")) {
                _buildSignature = props.getProperty("signature");
            }
        } catch (RuntimeException e1) {
        }

        // Retrieving platform info
        String endDate = (new SimpleDateFormat("yyyy")).format(new Date());
        log.info(getReleaseString() + " (c) 2001-" + endDate + " Innovation Gate GmbH");
        try {
            this.servletPlatform = new Double(arg0.getServletContext().getMajorVersion() + "."
                    + arg0.getServletContext().getMinorVersion()).doubleValue();
            this.jspPlatform = new Double(
                    javax.servlet.jsp.JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion())
                            .doubleValue();
            log.info("On platform " + arg0.getServletContext().getServerInfo() + " (Servlet Engine "
                    + this.servletPlatform + ", JSP Engine " + this.jspPlatform + ")");
        } catch (Exception ecx) {
            log.warn("Unable to retrieve platform info. Assuming Servlet Engine 3.0, JSP Engine 2.2", ecx);
            this.servletPlatform = 3.0;
            this.jspPlatform = 2.2;
        }
        arg0.getServletContext().setAttribute(WGACore.ATTRIB_SERVLET_ENGINE, new Double(this.servletPlatform));
        arg0.getServletContext().setAttribute(WGACore.ATTRIB_JSP_ENGINE, new Double(this.jspPlatform));

        // Starting other non-servlet services
        this._deployer = new WGPDeployer(this);

        // Create the statistics object
        _usageStatistics = new WGAUsageStatistics(this);

        // Test some neccessary running conditions for WGA

        // We test for exploded WAR
        if (getServletContext().getRealPath("/") == null) {
            log.fatal(
                    "WGA is not deployed as exploded WGA archive which is absolutely mandatory! WebTML deploying and rendering will not work correctly.");
        }

        // Eventually overwrite wga configpath/datapath/permanent log sysvar with init parameter
        String initConfigPath = getServletContext().getInitParameter(SYSPROPERTY_CONFIGPATH);
        if (initConfigPath != null) {
            log.info("Using WGA config path from servlet init parameter: " + initConfigPath);
            System.setProperty(SYSPROPERTY_CONFIGPATH, initConfigPath);
        }
        String initDataPath = getServletContext().getInitParameter(SYSPROPERTY_DATAPATH);
        if (initDataPath != null) {
            log.info("Using WGA data path from servlet init parameter: " + initDataPath);
            System.setProperty(SYSPROPERTY_DATAPATH, initDataPath);
        }
        String initPermLog = getServletContext().getInitParameter(SYSPROPERTY_LOGPATH);
        if (initPermLog != null) {
            log.info("Using WGA permanent log path from servlet init parameter: " + initPermLog);
            System.setProperty(SYSPROPERTY_LOGPATH, initPermLog);
        }

        // Do startup
        fireCoreEvent(new WGACoreEvent(WGACoreEvent.TYPE_PRE_STARTUP, null, this));
        startup();
    } catch (Throwable e) {
        log.fatal("Fatal error initializing wga", e);
        e.printStackTrace();
    }

}