Example usage for java.util Properties stringPropertyNames

List of usage examples for java.util Properties stringPropertyNames

Introduction

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

Prototype

public Set<String> stringPropertyNames() 

Source Link

Document

Returns an unmodifiable set of keys from this property list where the key and its corresponding value are strings, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list.

Usage

From source file:net.lunikon.rethul.service.FileService.java

/**
 * Reloads the master file. New keys are added. If a key value changes, the
 * corresponding translations are marked as pending. Keys that have dropped
 * from the master file are deleted in all translations.
 * //from ww  w.jav  a2 s  .co m
 * @param file
 *            The file.
 * @return an array containing the number of affected keys/strings. [0] new
 *         keys added, [1] changed master values, [2] strings marked as
 *         pending, [3] keys removed, [4] strings deleted
 */
public Object[] reloadMaster(File file) {
    // load properties
    Properties props = new Properties();
    try {
        FileInputStream is = new FileInputStream(FileStatus.getLanguageFilePath(file, null));
        props.load(is);
        is.close();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    // load existing master strings from database and add them to a map
    List<LocalizedString> strings = stringsDAO.loadMasterStrings(file);
    Map<String, LocalizedString> existing = new HashMap<String, LocalizedString>(strings.size());
    for (LocalizedString ls : strings)
        existing.put(ls.getKey(), ls);

    // an array containing some counters that will be returned as the result
    Object[] results = new Object[5];

    // run through properties
    int added = 0, changed = 0;
    Set<String> pending = new HashSet<String>();
    for (String key : props.stringPropertyNames()) {
        // does key exist yet?
        LocalizedString value = existing.get(key);
        String masterValue = props.getProperty(key);
        if (value != null) {
            if (!value.getTranslation().equals(masterValue)) {
                // mark key as pending
                pending.add(key);
                changed++;

                // update master
                value.setTranslation(masterValue);
                stringsDAO.update(value);
            }
        } else {
            // create new key
            value = new LocalizedString(file, key, masterValue);
            stringsDAO.save(value);
            added++;
        }

        // remove from existing list
        existing.remove(key);
    }
    results[0] = added;
    results[1] = changed;

    // mark all strings that changed in master as pending for other locales
    results[2] = stringsDAO.markPending(file, pending);

    // delete strings that have dropped from the master
    results[3] = existing.size();
    results[4] = stringsDAO.deleteKeys(file, existing.keySet());

    return results;
}

From source file:datafu.hourglass.jobs.AbstractJob.java

/**
 * Creates Hadoop configuration using the provided properties.
 * /* w w w  .  j  av a2s  . c o  m*/
 * @param props
 * @return
 */
private void updateConfigurationFromProps(Properties props) {
    Configuration config = getConf();

    if (config == null) {
        config = new Configuration();
    }

    // to enable unit tests to inject configuration  
    if (props.containsKey("test.conf")) {
        try {
            byte[] decoded = Base64.decodeBase64(props.getProperty("test.conf"));
            ByteArrayInputStream byteInput = new ByteArrayInputStream(decoded);
            DataInputStream inputStream = new DataInputStream(byteInput);
            config.readFields(inputStream);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    } else {
        for (String key : props.stringPropertyNames()) {
            String newKey = key;
            String value = props.getProperty(key);

            if (key.toLowerCase().startsWith(HADOOP_PREFIX)) {
                newKey = key.substring(HADOOP_PREFIX.length());
                config.set(newKey, value);
            }
        }
    }
}

From source file:com.dilmus.dilshad.scabi.core.DCompute.java

public DCompute input(Properties propertyInput) {
    Dson dson = new Dson();
    Set<String> st = propertyInput.stringPropertyNames();
    for (String s : st) {
        dson = dson.add(s, propertyInput.getProperty(s));
    }/*from   w  w w .  jav a 2s  . c  om*/
    m_jsonStrInput = dson.toString();
    return this;
}

From source file:com.heliosapm.streams.collector.ds.pool.impls.JMXClientPoolBuilder.java

/**
 * Creates a new JMXClientPoolBuilder//from   w  w w  .j av a 2s .  co m
 * @param config The configuration properties
 */
public JMXClientPoolBuilder(final Properties config) {
    final String jmxUrl = config.getProperty(JMX_URL_KEY, "").trim();
    if (jmxUrl.isEmpty())
        throw new IllegalArgumentException("The passed JMXServiceURL was null or empty");
    try {
        url = new JMXServiceURL(jmxUrl);
    } catch (Exception ex) {
        throw new IllegalArgumentException("The passed JMXServiceURL was invalid", ex);
    }
    final String user = config.getProperty(JMX_USER_KEY, "").trim();
    final String password = config.getProperty(JMX_PW_KEY, "").trim();
    if (!user.isEmpty() && !password.isEmpty()) {
        credentials = new String[] { user, password };
        env.put(JMXConnector.CREDENTIALS, credentials);
    } else {
        credentials = null;
    }
    if (config.size() > 1) {
        for (final String key : config.stringPropertyNames()) {
            final String _key = key.trim();
            if (_key.startsWith(JMX_ENVMAP_PREFIX)) {
                final String _envKey = _key.replace(JMX_ENVMAP_PREFIX, "");
                if (_envKey.isEmpty())
                    continue;
                final String _rawValue = config.getProperty(key, "").trim();
                if (_rawValue.isEmpty())
                    continue;
                final Object _convertedValue = StringHelper.convertTyped(_rawValue);
                env.put(_envKey, _convertedValue);
            }
        }
    }
}

From source file:org.apache.geode.management.internal.cli.commands.GfshCommandJUnitTest.java

@Test
public void testAddGemFireSystemPropertiesToCommandLine() {
    final List<String> commandLine = new ArrayList<>();
    assertTrue(commandLine.isEmpty());/*w  ww. ja v  a  2  s  .  c  om*/
    StartMemberUtils.addGemFireSystemProperties(commandLine, new Properties());
    assertTrue(commandLine.isEmpty());

    final Properties gemfireProperties = new Properties();
    gemfireProperties.setProperty(LOCATORS, "localhost[11235]");
    gemfireProperties.setProperty(LOG_LEVEL, "config");
    gemfireProperties.setProperty(LOG_FILE, org.apache.commons.lang.StringUtils.EMPTY);
    gemfireProperties.setProperty(MCAST_PORT, "0");
    gemfireProperties.setProperty(NAME, "machine");
    StartMemberUtils.addGemFireSystemProperties(commandLine, gemfireProperties);

    assertFalse(commandLine.isEmpty());
    assertEquals(4, commandLine.size());

    for (final String propertyName : gemfireProperties.stringPropertyNames()) {
        final String propertyValue = gemfireProperties.getProperty(propertyName);
        if (org.apache.commons.lang.StringUtils.isBlank(propertyValue)) {
            for (final String systemProperty : commandLine) {
                assertFalse(systemProperty.startsWith(
                        "-D" + DistributionConfig.GEMFIRE_PREFIX + "".concat(propertyName).concat("=")));
            }
        } else {
            assertTrue(commandLine.contains("-D" + DistributionConfig.GEMFIRE_PREFIX
                    + "".concat(propertyName).concat("=").concat(propertyValue)));
        }
    }
}

From source file:org.dataconservancy.packaging.apt.AutomatedPackageTool.java

private LinkedHashMap<String, List<String>> createPackageMetadata() {
    Properties props = new Properties();
    if (packageMetadataFile != null) {
        if (!packageMetadataFile.exists()) {
            throw new PackageToolException(PackagingToolReturnInfo.CMD_LINE_FILE_NOT_FOUND_EXCEPTION);
        }//www  . ja va2 s .  c om
        try (InputStream fileStream = new FileInputStream(packageMetadataFile)) {
            props.load(fileStream);
        } catch (FileNotFoundException e) {
            throw new PackageToolException(PackagingToolReturnInfo.CMD_LINE_FILE_NOT_FOUND_EXCEPTION, e);
        } catch (IOException e) {
            log.error(e.getMessage());
            throw new PackageToolException(PackagingToolReturnInfo.CMD_LINE_FILE_NOT_FOUND_EXCEPTION);
        }
    }
    LinkedHashMap<String, List<String>> metadata = new LinkedHashMap<>();

    List<String> valueList;
    for (String key : props.stringPropertyNames()) {
        valueList = Arrays.asList(props.getProperty(key).trim().split("\\s*,\\s*"));
        metadata.put(key, valueList);
    }

    return metadata;
}

From source file:jdao.JDAO.java

public static void adjustPropertiesForEnvParameters(Properties properties) {
    for (String key : properties.stringPropertyNames()) {
        String property = properties.getProperty(key);
        int ofs = 0;
        while ((ofs = property.indexOf("$(", ofs)) > 0) {
            int efs = property.indexOf(')', ofs);
            String lookupKey = property.substring(ofs + 2, efs);
            String lookupProp = System.getProperty(lookupKey, "$(" + lookupKey + ")");
            property = property.substring(0, ofs) + lookupProp + property.substring(efs + 1);
            ofs++;/*from w  ww.  j ava2 s. c o  m*/
            properties.setProperty(key, property);
        }
    }
}

From source file:org.apache.tomee.embedded.Configuration.java

public void loadFromProperties(final Properties config) {
    // filtering properties with system properties or themself
    final StrSubstitutor strSubstitutor = new StrSubstitutor(new StrLookup<String>() {
        @Override/*from ww  w  . j a v  a2 s. c om*/
        public String lookup(final String key) {
            final String property = System.getProperty(key);
            return property == null ? config.getProperty(key) : null;
        }
    });
    for (final String key : config.stringPropertyNames()) {
        final String val = config.getProperty(key);
        if (val == null || val.trim().isEmpty()) {
            continue;
        }
        final String newVal = strSubstitutor.replace(config.getProperty(key));
        if (!val.equals(newVal)) {
            config.setProperty(key, newVal);
        }
    }

    final String http = config.getProperty("http");
    if (http != null) {
        setHttpPort(Integer.parseInt(http));
    }
    final String https = config.getProperty("https");
    if (https != null) {
        setHttpsPort(Integer.parseInt(https));
    }
    final String stop = config.getProperty("stop");
    if (stop != null) {
        setStopPort(Integer.parseInt(stop));
    }
    final String host = config.getProperty("host");
    if (host != null) {
        setHost(host);
    }
    final String dir = config.getProperty("dir");
    if (dir != null) {
        setDir(dir);
    }
    final String serverXml = config.getProperty("serverXml");
    if (serverXml != null) {
        setServerXml(serverXml);
    }
    final String keepServerXmlAsThis = config.getProperty("keepServerXmlAsThis");
    if (keepServerXmlAsThis != null) {
        setKeepServerXmlAsThis(Boolean.parseBoolean(keepServerXmlAsThis));
    }
    final String quickSession = config.getProperty("quickSession");
    if (quickSession != null) {
        setQuickSession(Boolean.parseBoolean(quickSession));
    }
    final String skipHttp = config.getProperty("skipHttp");
    if (skipHttp != null) {
        setSkipHttp(Boolean.parseBoolean(skipHttp));
    }
    final String ssl = config.getProperty("ssl");
    if (ssl != null) {
        setSsl(Boolean.parseBoolean(ssl));
    }
    final String http2 = config.getProperty("http2");
    if (http2 != null) {
        setHttp2(Boolean.parseBoolean(http2));
    }
    final String deleteBaseOnStartup = config.getProperty("deleteBaseOnStartup");
    if (deleteBaseOnStartup != null) {
        setDeleteBaseOnStartup(Boolean.parseBoolean(deleteBaseOnStartup));
    }
    final String webResourceCached = config.getProperty("webResourceCached");
    if (webResourceCached != null) {
        setWebResourceCached(Boolean.parseBoolean(webResourceCached));
    }
    final String withEjbRemote = config.getProperty("withEjbRemote");
    if (withEjbRemote != null) {
        setWithEjbRemote(Boolean.parseBoolean(withEjbRemote));
    }
    final String deployOpenEjbApp = config.getProperty("deployOpenEjbApp");
    if (deployOpenEjbApp != null) {
        setDeployOpenEjbApp(Boolean.parseBoolean(deployOpenEjbApp));
    }
    final String keystoreFile = config.getProperty("keystoreFile");
    if (keystoreFile != null) {
        setKeystoreFile(keystoreFile);
    }
    final String keystorePass = config.getProperty("keystorePass");
    if (keystorePass != null) {
        setKeystorePass(keystorePass);
    }
    final String keystoreType = config.getProperty("keystoreType");
    if (keystoreType != null) {
        setKeystoreType(keystoreType);
    }
    final String clientAuth = config.getProperty("clientAuth");
    if (clientAuth != null) {
        setClientAuth(clientAuth);
    }
    final String keyAlias = config.getProperty("keyAlias");
    if (keyAlias != null) {
        setKeyAlias(keyAlias);
    }
    final String sslProtocol = config.getProperty("sslProtocol");
    if (sslProtocol != null) {
        setSslProtocol(sslProtocol);
    }
    final String webXml = config.getProperty("webXml");
    if (webXml != null) {
        setWebXml(webXml);
    }
    final String tempDir = config.getProperty("tempDir");
    if (tempDir != null) {
        setTempDir(tempDir);
    }
    final String customWebResources = config.getProperty("customWebResources");
    if (customWebResources != null) {
        setCustomWebResources(customWebResources);
    }
    final String classesFilterType = config.getProperty("classesFilter");
    if (classesFilterType != null) {
        try {
            setClassesFilter(Filter.class.cast(
                    Thread.currentThread().getContextClassLoader().loadClass(classesFilterType).newInstance()));
        } catch (final InstantiationException | IllegalAccessException | ClassNotFoundException e) {
            throw new IllegalArgumentException(e);
        }
    }
    final String conf = config.getProperty("conf");
    if (conf != null) {
        setConf(conf);
    }
    for (final String prop : config.stringPropertyNames()) {
        if (prop.startsWith("properties.")) {
            property(prop.substring("properties.".length()), config.getProperty(prop));
        } else if (prop.startsWith("users.")) {
            user(prop.substring("users.".length()), config.getProperty(prop));
        } else if (prop.startsWith("roles.")) {
            role(prop.substring("roles.".length()), config.getProperty(prop));
        } else if (prop.startsWith("connector.")) { // created in container
            property(prop, config.getProperty(prop));
        } else if (prop.equals("realm")) {
            final ObjectRecipe recipe = new ObjectRecipe(config.getProperty(prop));
            for (final String realmConfig : config.stringPropertyNames()) {
                if (realmConfig.startsWith("realm.")) {
                    recipe.setProperty(realmConfig.substring("realm.".length()),
                            config.getProperty(realmConfig));
                }
            }
            setRealm(Realm.class.cast(recipe.create()));
        } else if (prop.equals("login")) {
            final ObjectRecipe recipe = new ObjectRecipe(LoginConfigBuilder.class.getName());
            for (final String nestedConfig : config.stringPropertyNames()) {
                if (nestedConfig.startsWith("login.")) {
                    recipe.setProperty(nestedConfig.substring("login.".length()),
                            config.getProperty(nestedConfig));
                }
            }
            loginConfig(LoginConfigBuilder.class.cast(recipe.create()));
        } else if (prop.equals("securityConstraint")) {
            final ObjectRecipe recipe = new ObjectRecipe(SecurityConstaintBuilder.class.getName());
            for (final String nestedConfig : config.stringPropertyNames()) {
                if (nestedConfig.startsWith("securityConstraint.")) {
                    recipe.setProperty(nestedConfig.substring("securityConstraint.".length()),
                            config.getProperty(nestedConfig));
                }
            }
            securityConstaint(SecurityConstaintBuilder.class.cast(recipe.create()));
        } else if (prop.equals("configurationCustomizer.")) {
            final String next = prop.substring("configurationCustomizer.".length());
            if (next.contains(".")) {
                continue;
            }
            final ObjectRecipe recipe = new ObjectRecipe(properties.getProperty(prop + ".class"));
            for (final String nestedConfig : config.stringPropertyNames()) {
                if (nestedConfig.startsWith(prop) && !prop.endsWith(".class")) {
                    recipe.setProperty(nestedConfig.substring(prop.length() + 1 /*dot*/),
                            config.getProperty(nestedConfig));
                }
            }
            addCustomizer(ConfigurationCustomizer.class.cast(recipe.create()));
        }
    }
}

From source file:com.aliyun.odps.mapred.bridge.streaming.PipeMapRed.java

public void configure(JobConf job) {
    try {/*  w ww .  j a v  a  2  s .c  o  m*/

        String argv = getPipeCommand(job);
        if (argv == null) {
            throw new RuntimeException("streaming pipe cmd is null");
        }

        joinDelay_ = job.getLong("stream.joindelay.milli", 0);

        job_ = new BridgeJobConf(job);

        mapInputWriterClass_ = job_.getClass("stream.map.input.writer.class", TextInputWriter.class,
                InputWriter.class);
        mapOutputReaderClass_ = job_.getClass("stream.map.output.reader.class", TextOutputReader.class,
                OutputReader.class);
        reduceInputWriterClass_ = job_.getClass("stream.reduce.input.writer.class", TextInputWriter.class,
                InputWriter.class);
        reduceOutputReaderClass_ = job_.getClass("stream.reduce.output.reader.class", TextOutputReader.class,
                OutputReader.class);
        nonZeroExitIsFailure_ = job_.getBoolean("stream.non.zero.exit.is.failure", true);

        doPipe_ = getDoPipe();
        if (!doPipe_) {
            return;
        }

        setStreamJobDetails(job);

        String[] argvSplit = splitArgs(argv);
        String prog = argvSplit[0];
        //File currentDir = new File(".").getAbsoluteFile();
        //if (new File(prog).isAbsolute()) {
        //  // we don't own it. Hope it is executable
        //} else {
        //  FileUtil.chmod(new File(currentDir, prog).toString(), "a+x");
        //}

        // 
        // argvSplit[0]:
        // An absolute path should be a preexisting valid path on all TaskTrackers
        // A relative path is converted into an absolute pathname by looking
        // up the PATH env variable. If it still fails, look it up in the
        // tasktracker's local working directory
        //
        //if (!new File(argvSplit[0]).isAbsolute()) {
        //  PathFinder finder = new PathFinder("PATH");
        //  finder.prependPathComponent(currentDir.toString());
        //  File f = finder.getAbsolutePath(argvSplit[0]);
        //  if (f != null) {
        //    argvSplit[0] = f.getAbsolutePath();
        //  }
        //  f = null;
        //}
        LOG.info("PipeMapRed exec " + Arrays.asList(argvSplit));
        Properties childEnv = new Properties();
        addJobConfToEnvironment(job_, childEnv);
        addEnvironment(childEnv, job_.get("stream.addenvironment"));
        // add TMPDIR environment variable with the value of java.io.tmpdir
        // FIXME
        envPut(childEnv, "TMPDIR", System.getProperty("java.io.tmpdir"));
        envPut(childEnv, "TABLE_RESOURCE_READER", "../table_resource_reader");

        final Map<String, String> envMap = new HashMap<String, String>();
        for (String key : childEnv.stringPropertyNames()) {
            envMap.put(key, childEnv.getProperty(key));
        }
        // Start the process
        sim = StreamSecurityHelper.startChildProcess(argvSplit, envMap);

        clientOut_ = new DataOutputStream(new BufferedOutputStream(sim.getOutputStream(), BUFFER_SIZE));
        clientIn_ = new DataInputStream(new BufferedInputStream(sim.getInputStream(), BUFFER_SIZE));
        clientErr_ = new DataInputStream(new BufferedInputStream(sim.getErrorStream()));
        startTime_ = System.currentTimeMillis();

    } catch (IOException e) {
        LOG.error("configuration exception", e);
        throw new RuntimeException("configuration exception", e);
        //} catch (InterruptedException e)  {
        //  LOG.error("configuration exception", e);
        //  throw new RuntimeException("configuration exception", e);
    }
}

From source file:io.github.arven.flare.boot.TomcatContainer.java

public void start() throws Exception {
    if (base == null || !base.exists()) {
        setup(configuration);//from ww  w  . j  ava  2 s . c  o m
    }

    final Properties props = configuration.getProperties();

    if (props != null) {
        StrSubstitutor substitutor = null;
        for (final String s : props.stringPropertyNames()) {
            final String v = props.getProperty(s);
            if (v != null && v.contains("${")) {
                if (substitutor == null) {
                    final Map<String, String> placeHolders = new HashMap<String, String>();
                    placeHolders.put("tomee.embedded.http", Integer.toString(configuration.getHttpPort()));
                    placeHolders.put("tomee.embedded.https", Integer.toString(configuration.getHttpsPort()));
                    placeHolders.put("tomee.embedded.stop", Integer.toString(configuration.getStopPort()));
                    substitutor = new StrSubstitutor(placeHolders);
                }
                props.put(s, substitutor.replace(v));
            }
        }

        // inherit from system props
        final Properties properties = new Properties(System.getProperties());
        properties.putAll(configuration.getProperties());
        Logger.configure(properties);
    } else {
        Logger.configure();
    }

    final File conf = new File(base, "conf");
    final File webapps = new File(base, "webapps");

    final String catalinaBase = base.getAbsolutePath();

    // set the env before calling anoything on tomcat or Catalina!!
    System.setProperty("catalina.base", catalinaBase);
    System.setProperty("openejb.deployments.classpath", "false");
    System.setProperty("catalina.home", catalinaBase);
    System.setProperty("catalina.base", catalinaBase);
    System.setProperty("openejb.home", catalinaBase);
    System.setProperty("openejb.base", catalinaBase);
    System.setProperty("openejb.servicemanager.enabled", "false");

    copyFileTo(conf, "catalina.policy");
    copyTemplateTo(conf, "catalina.properties");
    copyFileTo(conf, "context.xml");
    copyFileTo(conf, "openejb.xml");
    copyFileTo(conf, "tomcat-users.xml");
    copyFileTo(conf, "web.xml");

    final boolean initialized;
    if (configuration.hasServerXml()) {
        final File file = new File(conf, "server.xml");
        final FileOutputStream fos = new FileOutputStream(file);
        try {
            IO.copy(configuration.getServerXmlFile(), fos);
        } finally {
            IO.close(fos);
        }

        // respect config (host/port) of the Configuration
        final QuickServerXmlParser ports = QuickServerXmlParser.parse(file);
        if (configuration.isKeepServerXmlAsThis()) {
            // force ports to be able to stop the server and get @ArquillianResource
            configuration.setHttpPort(Integer.parseInt(ports.http()));
            configuration.setStopPort(Integer.parseInt(ports.stop()));
        } else {
            final Map<String, String> replacements = new HashMap<String, String>();
            replacements.put(ports.http(), String.valueOf(configuration.getHttpPort()));
            replacements.put(ports.https(), String.valueOf(configuration.getHttpsPort()));
            replacements.put(ports.stop(), String.valueOf(configuration.getStopPort()));
            IO.copy(IO.slurp(new ReplaceStringsInputStream(IO.read(file), replacements)).getBytes(), file);
        }

        tomcat.server(createServer(file.getAbsolutePath()));
        initialized = true;
    } else {
        copyFileTo(conf, "server.xml");
        initialized = false;
    }

    if (props != null && !props.isEmpty()) {
        final FileWriter systemProperties = new FileWriter(new File(conf, "system.properties"));
        try {
            props.store(systemProperties, "");
        } finally {
            IO.close(systemProperties);
        }
    }

    // Need to use JULI so log messages from the tests are visible
    // using openejb logging conf in embedded mode
    /* if we use our config (Logger.configure()) don't override it
    copyFileTo(conf, "logging.properties");
    System.setProperty("java.util.logging.manager", "org.apache.juli.ClassLoaderLogManager");
    final File logging = new File(conf, "logging.properties");
    if (logging.exists()) {
    System.setProperty("java.util.logging.config.file", logging.getAbsolutePath());
    }
    */

    // Trigger loading of catalina.properties
    CatalinaProperties.getProperty("foo");

    tomcat.setBaseDir(base.getAbsolutePath());
    tomcat.setHostname(configuration.getHost());
    if (!initialized) {
        tomcat.getHost().setAppBase(webapps.getAbsolutePath());
        tomcat.getEngine().setDefaultHost(configuration.getHost());
        tomcat.setHostname(configuration.getHost());
    }

    if (tomcat.getRawConnector() == null && !configuration.isSkipHttp()) {
        final Connector connector = new Connector(Http11Protocol.class.getName());
        connector.setPort(configuration.getHttpPort());
        connector.setAttribute("connectionTimeout", "3000");
        tomcat.getService().addConnector(connector);
        tomcat.setConnector(connector);
    }

    // create https connector
    if (configuration.isSsl()) {
        final Connector httpsConnector = new Connector(Http11Protocol.class.getName());
        httpsConnector.setPort(configuration.getHttpsPort());
        httpsConnector.setSecure(true);
        httpsConnector.setProperty("SSLEnabled", "true");
        httpsConnector.setProperty("sslProtocol", configuration.getSslProtocol());

        if (configuration.getKeystoreFile() != null) {
            httpsConnector.setAttribute("keystoreFile", configuration.getKeystoreFile());
        }
        if (configuration.getKeystorePass() != null) {
            httpsConnector.setAttribute("keystorePass", configuration.getKeystorePass());
        }
        httpsConnector.setAttribute("keystoreType", configuration.getKeystoreType());
        httpsConnector.setAttribute("clientAuth", configuration.getClientAuth());
        httpsConnector.setAttribute("keyAlias", configuration.getKeyAlias());

        tomcat.getService().addConnector(httpsConnector);

        if (configuration.isSkipHttp()) {
            tomcat.setConnector(httpsConnector);
        }
    }

    // Bootstrap Tomcat
    Logger.getInstance(LogCategory.OPENEJB_STARTUP, TomcatContainer.class)
            .info("Starting TomEE from: " + base.getAbsolutePath()); // create it after Logger is configured

    if (configuration.getUsers() != null) {
        for (final Map.Entry<String, String> user : configuration.getUsers().entrySet()) {
            tomcat.addUser(user.getKey(), user.getValue());
        }
    }
    if (configuration.getRoles() != null) {
        for (final Map.Entry<String, String> user : configuration.getRoles().entrySet()) {
            for (final String role : user.getValue().split(" *, *")) {
                tomcat.addRole(user.getKey(), role);
            }
        }
    }
    if (!initialized) {
        tomcat.init();
    }
    tomcat.start();

    // Bootstrap OpenEJB
    final Properties properties = new Properties();
    properties.setProperty("openejb.deployments.classpath", "false");
    properties.setProperty("openejb.loader", "tomcat-system");
    properties.setProperty("openejb.home", catalinaBase);
    properties.setProperty("openejb.base", catalinaBase);
    properties.setProperty("openejb.servicemanager.enabled", "false");
    if (configuration.getProperties() != null) {
        properties.putAll(configuration.getProperties());
    }
    if (properties.getProperty("openejb.system.apps") == null) { // will make startup faster and it is rarely useful for embedded case
        properties.setProperty("openejb.system.apps", "false");
    }
    if (configuration.isQuickSession()) {
        properties.put("openejb.session.manager", QuickSessionManager.class.getName());
    }

    try {
        final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        final Properties tomcatServerInfo = IO.readProperties(
                classLoader.getResourceAsStream("org/apache/catalina/util/ServerInfo.properties"),
                new Properties());

        String serverNumber = tomcatServerInfo.getProperty("server.number");
        if (serverNumber == null) {
            // Tomcat5 only has server.info
            final String serverInfo = tomcatServerInfo.getProperty("server.info");
            if (serverInfo != null) {
                final int slash = serverInfo.indexOf('/');
                serverNumber = serverInfo.substring(slash + 1);
            }
        }
        if (serverNumber != null) {
            System.setProperty("tomcat.version", serverNumber);
        }

        final String serverBuilt = tomcatServerInfo.getProperty("server.built");
        if (serverBuilt != null) {
            System.setProperty("tomcat.built", serverBuilt);
        }
    } catch (final Throwable e) {
        // no-op
    }

    final TomcatLoader loader = new TomcatLoader();
    loader.initDefaults(properties);

    // need to add properties after having initialized defaults
    // to properties passed to SystemInstance otherwise we loose some of them
    final Properties initProps = new Properties();
    initProps.putAll(System.getProperties());
    initProps.putAll(properties);
    if (SystemInstance.isInitialized()) {
        SystemInstance.get().getProperties().putAll(initProps);
    } else {
        SystemInstance.init(initProps);
    }
    SystemInstance.get().setComponent(StandardServer.class, (StandardServer) tomcat.getServer());
    SystemInstance.get().setComponent(Server.class, tomcat.getServer()); // needed again cause of init()

    loader.initialize(properties);

    assembler = SystemInstance.get().getComponent(Assembler.class);
    configurationFactory = new ConfigurationFactory();
}