Example usage for java.lang Boolean getBoolean

List of usage examples for java.lang Boolean getBoolean

Introduction

In this page you can find the example usage for java.lang Boolean getBoolean.

Prototype

public static boolean getBoolean(String name) 

Source Link

Document

Returns true if and only if the system property named by the argument exists and is equal to, ignoring case, the string "true" .

Usage

From source file:org.wso2.carbon.apimgt.rest.api.admin.impl.ExportApiServiceImpl.java

/**
 * Export an existing Application// www .j  a v  a 2  s.c  o m
 *
 * @param appName  Search query
 * @param appOwner Owner of the Application
 * @return Zip file containing exported Application
 */
@Override
public Response exportApplicationsGet(String appName, String appOwner) {
    APIConsumer consumer;
    String exportedFilePath;
    Application applicationDetails = null;
    File exportedApplicationArchiveFile = null;
    String pathToExportDir = System.getProperty(RestApiConstants.JAVA_IO_TMPDIR) + File.separator
            + APPLICATION_EXPORT_DIR_PREFIX + UUID.randomUUID().toString(); //creates a directory in default temporary-file directory
    String username = RestApiUtil.getLoggedInUsername();
    String exportedFileName = null;
    if (StringUtils.isBlank(appName) || StringUtils.isBlank(appOwner)) {
        RestApiUtil.handleBadRequest("Application name or owner should not be empty or null.", log);
    }
    try {
        consumer = RestApiUtil.getConsumer(username);
        FileBasedApplicationImportExportManager importExportManager = new FileBasedApplicationImportExportManager(
                consumer, pathToExportDir);
        if (importExportManager.isOwnerAvailable(appOwner)) {
            applicationDetails = importExportManager.getApplicationDetails(appName, appOwner);
        }
        if (applicationDetails == null) {
            String errorMsg = "No application found with name " + appName + " owned by " + appOwner;
            log.error(errorMsg);
            return Response.status(Response.Status.NOT_FOUND).entity(errorMsg).build();
        } else if (Boolean.getBoolean(RestApiConstants.MIGRATION_MODE)) { // migration flow
            String appTenant = MultitenantUtils.getTenantDomain(applicationDetails.getSubscriber().getName());
            RestApiUtil.handleMigrationSpecificPermissionViolations(appTenant, username);
        } else if (!MultitenantUtils.getTenantDomain(applicationDetails.getSubscriber().getName())
                .equals(MultitenantUtils.getTenantDomain(username))) { // normal non-migration flow
            String errorMsg = "Cross Tenant Exports are not allowed";
            log.error(errorMsg);
            return Response.status(Response.Status.FORBIDDEN).entity(errorMsg).build();
        }
        exportedFilePath = importExportManager.exportApplication(applicationDetails,
                DEFAULT_APPLICATION_EXPORT_DIR);
        String zippedFilePath = importExportManager.createArchiveFromExportedAppArtifacts(exportedFilePath,
                pathToExportDir, DEFAULT_APPLICATION_EXPORT_DIR);
        exportedApplicationArchiveFile = new File(zippedFilePath);
        exportedFileName = exportedApplicationArchiveFile.getName();
    } catch (APIManagementException e) {
        RestApiUtil.handleInternalServerError("Error while exporting Application: " + appName, e, log);
    }
    Response.ResponseBuilder responseBuilder = Response.status(Response.Status.OK)
            .entity(exportedApplicationArchiveFile).type(MediaType.APPLICATION_OCTET_STREAM);
    responseBuilder.header("Content-Disposition", "attachment; filename=\"" + exportedFileName + "\"");
    return responseBuilder.build();
}

From source file:org.openhab.binding.onewire.internal.OneWireBinding.java

public void updated(Dictionary<String, ?> pvConfig) throws ConfigurationException {
    if (pvConfig != null) {
        //Basic config
        String lvPostOnlyChangedValues = (String) pvConfig.get("post_only_changed_values");
        if (StringUtils.isNotBlank(lvPostOnlyChangedValues)) {
            ivPostOnlyChangedValues = Boolean.getBoolean(lvPostOnlyChangedValues);
        }/*w w  w  .  j  a  v  a  2s  . c o  m*/

        //Connection config
        OneWireConnection.updated(pvConfig);
    }

    for (OneWireBindingProvider lvProvider : providers) {
        scheduleAllBindings(lvProvider);
    }

}

From source file:com.ejisto.modules.dao.db.EmbeddedDatabaseManager.java

private void createSchema() {
    if (Boolean.getBoolean(StringConstants.INITIALIZE_DATABASE.getValue())) {
        //String name, boolean keepCounter, Serializer<K> keySerializer, Serializer<V> valueSerializer
        db.createHashMap(SETTINGS).valueSerializer(new SettingSerializer()).make();
        db.createHashMap(CONTAINERS).counterEnable().valueSerializer(new ContainerSerializer()).make();
        db.createHashMap(CUSTOM_OBJECT_FACTORIES).counterEnable()
                .valueSerializer(new CustomObjectFactorySerializer()).make();
        db.createHashMap(REGISTERED_OBJECT_FACTORIES).counterEnable()
                .valueSerializer(new RegisteredObjectFactorySerializer()).make();
        db.createHashMap(WEB_APPLICATION_DESCRIPTORS).counterEnable()
                .valueSerializer(new WebApplicationDescriptorSerializer()).make();
        db.createHashMap(RECORDED_SESSIONS).counterEnable().valueSerializer(new CollectedDataSerializer())
                .make();//from  w  w  w  .  j  ava  2 s .c om
        db.createAtomicInteger(STARTUP_COUNTER, 1);
    }
    contextPaths.addAll(db.getAll().keySet().stream().filter(k -> k.startsWith(CONTEXT_PATH_PREFIX))
            .map(EmbeddedDatabaseManager::decodeContextPath).collect(toList()));
    Atomic.Integer count = db.getAtomicInteger(STARTUP_COUNTER);
    count.incrementAndGet();
    db.commit();
}

From source file:web.kz.rhq.modules.plugins.jbossas7.ASConnection.java

/**
 * Construct an ASConnection object. The real "physical" connection is done in {@link #executeRaw(Operation)}.
 *
 * @param host Host of the DomainController or standalone server
 * @param port Port of the JSON api.//from   w w  w. j  a  v a  2  s. com
 * @param user user needed for authentication
 * @param password password needed for authentication
 */
public ASConnection(String host, int port, String user, String password) {
    if (host == null) {
        throw new IllegalArgumentException("Management host cannot be null.");
    }
    if (port <= 0 || port > 65535) {
        throw new IllegalArgumentException("Invalid port: " + port);
    }
    this.host = host;
    this.port = port;

    try {
        url = new URL("http", host, port, MANAGEMENT);
        urlString = url.toString();
    } catch (MalformedURLException e) {
        throw new IllegalArgumentException(e.getMessage());
    }

    passwordAuthenticator = new AS7Authenticator(user, password);
    Authenticator.setDefault(passwordAuthenticator);

    // read system property "as7plugin.verbose"
    verbose = Boolean.getBoolean("as7plugin.verbose");

    mapper = new ObjectMapper();
    mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

From source file:org.eclipse.gemini.blueprint.extender.internal.activator.NamespaceHandlerActivator.java

protected void initNamespaceHandlers(BundleContext extenderBundleContext) {
    nsManager = new NamespaceManager(extenderBundleContext);

    // register listener first to make sure any bundles in INSTALLED state
    // are not lost

    // if the property is defined and true, consider bundles in STARTED/LAZY-INIT state, otherwise use RESOLVED
    boolean nsResolved = !Boolean.getBoolean("org.eclipse.gemini.blueprint.ns.bundles.started");
    nsListener = new NamespaceBundleLister(nsResolved, this);
    extenderBundleContext.addBundleListener(nsListener);

    Bundle[] previousBundles = extenderBundleContext.getBundles();

    for (Bundle bundle : previousBundles) {
        // special handling for uber bundle being restarted
        if ((nsResolved && OsgiBundleUtils.isBundleResolved(bundle))
                || (!nsResolved && OsgiBundleUtils.isBundleActive(bundle))
                || bundleId == bundle.getBundleId()) {
            maybeAddNamespaceHandlerFor(bundle, false);
        } else if (OsgiBundleUtils.isBundleLazyActivated(bundle)) {
            maybeAddNamespaceHandlerFor(bundle, true);
        }/*from w  w  w.j  a v a  2  s.  c om*/
    }

    // discovery finished, publish the resolvers/parsers in the OSGi space
    nsManager.afterPropertiesSet();
}

From source file:org.ajax4jsf.templatecompiler.elements.vcp.FCallTemplateElement.java

public FCallTemplateElement(final Node element, final CompilationContext componentBean)
        throws CompilationException {
    super(element, componentBean);

    this.useOnlyEnumeratingParaments = false;

    NamedNodeMap nnm = element.getAttributes();
    Node functionNameNode = nnm.getNamedItem(FUNCTION_NAME_ATTRIBUTE_NAME);

    if (functionNameNode != null) {
        this.functionName = functionNameNode.getNodeValue();
    } else {//from   w  w w  .j  a  va 2s  .c o  m
        throw new CompilationException("function name is not set");
    }

    Node nodeUseOnlyThisParameters = nnm.getNamedItem(USE_ONLY_THIS_PARAMETERS);
    if (nodeUseOnlyThisParameters != null) {
        this.useOnlyEnumeratingParaments = Boolean.getBoolean(nodeUseOnlyThisParameters.getNodeValue());
    } // if

    // read name of variable if need
    Node variableName = nnm.getNamedItem(VAR_ATTRIBUTE_NAME);
    if (variableName != null) {
        this.variable = variableName.getNodeValue();
    } // if

    // read name of parameters if need
    ParameterProcessor parameterProcessor = new ParameterProcessor(element, componentBean);

    this.parameters = parameterProcessor.getParameters();
    log.debug(this.parameters);

    List decodeFunctionName = null;

    decodeFunctionName = Arrays.asList(this.functionName.split(FUNCTION_DELIMITER));
    if (null == decodeFunctionName) {
        decodeFunctionName = new ArrayList();
        decodeFunctionName.add(this.functionName);
    }

    ArrayList functionNames = new ArrayList();
    String lastClassName = componentBean.getFullBaseclass();

    for (Iterator iter = decodeFunctionName.iterator(); iter.hasNext();) {
        String elementFunction = (String) iter.next();

        try {
            log.debug("Try to load class : " + lastClassName);

            Class clazz = componentBean.loadClass(lastClassName);

            if (!iter.hasNext()) {
                String method = getMethod(clazz, elementFunction);
                if (method != null) {
                    log.debug(method);
                    functionNames.add(method);
                } else {
                    log.error("Method  " + elementFunction + " not found in class : " + lastClassName);
                    throw new CompilationException();
                }

            } else {
                //
                // Probing properties !!!!
                //

                PropertyDescriptor propertyDescriptor = getPropertyDescriptor(clazz, elementFunction);

                if (propertyDescriptor != null) {
                    functionNames.add(propertyDescriptor.getReadMethod().getName() + "()");
                    log.debug("Property " + elementFunction + " mapped to function  : "
                            + propertyDescriptor.getReadMethod().getName());
                    lastClassName = propertyDescriptor.getPropertyType().getName();
                } else {
                    log.error("Property " + elementFunction + " not found in class : " + lastClassName);
                    throw new CompilationException();
                }
            }

        } catch (Throwable e) {

            log.error("Error load class : " + lastClassName + ", " + e.getLocalizedMessage());
            e.printStackTrace();
            throw new CompilationException("Error load class : " + lastClassName, e);
        }

    }

    StringBuffer tmpbuf = new StringBuffer();
    for (Iterator iter = functionNames.iterator(); iter.hasNext();) {
        String tmpElement = (String) iter.next();
        if (tmpbuf.length() != 0) {
            tmpbuf.append(".");
        }
        tmpbuf.append(tmpElement);
    }
    this.fullFunctionName = tmpbuf.toString();

}

From source file:org.apache.ojb.jdo.PersistenceManagerFactoryImpl.java

/**
 * This method returns an instance of PersistenceManagerFactory based on the properties
 * in the parameter. It is used by JDOHelper to construct an instance of PersistenceManagerFactory
 * based on user-specified properties.//  w  ww  .j  a  v  a  2 s . co  m
 * The following are standard key values for the Properties:
 * Java Data Objects1.0
 * javax.jdo.PersistenceManagerFactoryClass --> Ignored, we only have one and that is PersistenceManagerFactoryImpl
 * javax.jdo.option.Optimistic
 * javax.jdo.option.RetainValues
 * javax.jdo.option.RestoreValues
 * javax.jdo.option.IgnoreCache
 * javax.jdo.option.NontransactionalRead
 * javax.jdo.option.NontransactionalWrite
 * javax.jdo.option.Multithreaded
 *
 * javax.jdo.option.ConnectionUserName
 * javax.jdo.option.ConnectionPassword
 * javax.jdo.option.ConnectionURL
 * javax.jdo.option.ConnectionFactoryName
 * javax.jdo.option.ConnectionFactory2Name
 * @see JDOConstants
 * @param props
 * @return the PersistenceManagerFactory instance with the appropriate Properties.
 */
public static PersistenceManagerFactory getPersistenceManagerFactory(Properties props) {
    PersistenceManagerFactoryImpl retval = new PersistenceManagerFactoryImpl();
    // parse and set the properties
    // boolean props
    retval.setOptimistic(Boolean.getBoolean(props.getProperty(JDOConstants.OPTIMISTIC,
            BooleanUtils.toStringTrueFalse(retval.getOptimistic()))));
    retval.setRetainValues(Boolean.getBoolean(props.getProperty(JDOConstants.RETAIN_VALUES,
            BooleanUtils.toStringTrueFalse(retval.getRetainValues()))));
    retval.setRestoreValues(Boolean.getBoolean(props.getProperty(JDOConstants.RESTORE_VALUES,
            BooleanUtils.toStringTrueFalse(retval.getRestoreValues()))));
    retval.setIgnoreCache(Boolean.getBoolean(props.getProperty(JDOConstants.IGNORE_CACHE,
            BooleanUtils.toStringTrueFalse(retval.getIgnoreCache()))));
    retval.setNontransactionalRead(Boolean.getBoolean(props.getProperty(JDOConstants.NON_TRANSACTIONAL_READ,
            BooleanUtils.toStringTrueFalse(retval.getNontransactionalRead()))));
    retval.setMultithreaded(Boolean.getBoolean(props.getProperty(JDOConstants.MULTI_THREADED,
            BooleanUtils.toStringTrueFalse(retval.getMultithreaded()))));
    retval.setOptimistic(Boolean.getBoolean(props.getProperty(JDOConstants.OPTIMISTIC,
            BooleanUtils.toStringTrueFalse(retval.getOptimistic()))));
    retval.setOptimistic(Boolean.getBoolean(props.getProperty(JDOConstants.OPTIMISTIC,
            BooleanUtils.toStringTrueFalse(retval.getOptimistic()))));

    // string props
    retval.setConnectionUserName(
            props.getProperty(JDOConstants.CONNECTION_USER_NAME, retval.getConnectionUserName()));
    retval.setConnectionPassword(props.getProperty(JDOConstants.CONNECTION_PASSWORD, null));
    retval.setConnectionURL(props.getProperty(JDOConstants.CONNECTION_URL, retval.getConnectionURL()));
    retval.setConnectionFactoryName(
            props.getProperty(JDOConstants.CONNECTION_FACTORY_NAME, retval.getConnectionFactoryName()));
    retval.setConnectionFactory2Name(
            props.getProperty(JDOConstants.CONNECTION_FACTORY_2_NAME, retval.getConnectionFactory2Name()));
    retval.setAlias(props.getProperty(JDOConstants.ALIAS, retval.getAlias()));
    return retval;
}

From source file:org.sonar.server.charts.deprecated.PieChart.java

private void applyParams() {
    applyCommonParams();// ww  w .  j a  va2s  . c o m

    configureColors(params.get(CHART_PARAM_COLORS));
    addMeasures(params.get(CHART_PARAM_VALUES));

    // -- Plot
    PiePlot plot = (PiePlot) jfreechart.getPlot();
    plot.setOutlineVisible(isParamValueValid(params.get(CHART_PARAM_OUTLINE_VISIBLE))
            && Boolean.getBoolean(params.get(CHART_PARAM_OUTLINE_VISIBLE)));
}

From source file:test.SemanticConverter2.java

public void createJenaModel(RegisterContextRequest rcr) {

    OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
    Model entityOnt = FileManager.get().loadModel(ONT_FILE);
    ontModel.addSubModel(entityOnt);/*from ww  w .j a v  a  2s  . c  o m*/
    ontModel.setNsPrefixes(entityOnt.getNsPrefixMap());
    //        ontModel.loadImports();
    ontModel.setStrictMode(true);

    ExtendedIterator<OntProperty> iter = ontModel.listAllOntProperties();
    while (iter.hasNext()) {
        OntProperty ontProp = iter.next();
        System.out.println(ontProp.getLocalName());
    }

    OntClass entityGroup = (OntClass) ontModel.getOntClass(ONT_URL + "EntityGroup");
    OntClass entity = (OntClass) ontModel.getOntClass(ONT_URL + "Entity");
    OntClass attribute = (OntClass) ontModel.getOntClass(ONT_URL + "Attribute");
    OntClass metadata = (OntClass) ontModel.getOntClass(ONT_URL + "Metadata");
    OntClass location = (OntClass) ontModel.getOntClass(entityOnt.getNsPrefixURI("geo") + "Point");

    String ngsiValue = "";
    ngsiValue = rcr.getRegistrationId();
    Individual entityGroupIndiv = ontModel.createIndividual(ONT_URL + ngsiValue, entityGroup);
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(ONT_URL + "registrationId"),
            ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getTimestamp().toString();
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(ONT_URL + "regTimeStamp"),
            ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getDuration();
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(ONT_URL + "duration"),
            ontModel.createLiteral(ngsiValue));

    int contRegListSize = rcr.getContextRegistration().size();
    for (int i = 0; i < contRegListSize; i++) {

        rcr.getContextRegistration().get(i).getContextMetadata().size();
        for (int z = 0; z < contRegListSize; z++) {

            String regMeta = rcr.getContextRegistration().get(i).getContextMetadata().get(z).getName();
            boolean regMetaValue = Boolean.getBoolean(
                    rcr.getContextRegistration().get(i).getContextMetadata().get(z).getValue().toString());
            if (regMeta.contentEquals("linked-data") && regMetaValue) {

                int entityListSize = rcr.getContextRegistration().get(i).getEntityId().size();
                for (int j = 0; j < entityListSize; j++) {
                    ngsiValue = rcr.getContextRegistration().get(i).getEntityId().get(j).getId();
                    Individual entityInstance = ontModel.createIndividual(ONT_URL + ngsiValue, entity);
                    entityGroupIndiv.addProperty(ontModel.getProperty(ONT_URL + "hasEntity"), entityInstance);

                    int attrListSize = rcr.getContextRegistration().get(i).getContextRegistrationAttribute()
                            .size();
                    for (int k = 0; k < attrListSize; k++) {
                        ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().get(k)
                                .getName();
                        if (ngsiValue.isEmpty()) {
                            continue;
                        }
                        Individual attrInstance = ontModel.createIndividual(ONT_URL + ngsiValue, attribute);
                        entityInstance.addProperty(ontModel.getProperty(ONT_URL + "hasAttribute"),
                                attrInstance);
                        ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().get(k)
                                .getType();
                        attrInstance.setPropertyValue(ontModel.getProperty(ONT_URL + "type"),
                                ontModel.createLiteral(ngsiValue));

                        int mdListSize = rcr.getContextRegistration().get(i).getContextRegistrationAttribute()
                                .get(k).getContextMetadata().size();
                        for (int l = 0; l < mdListSize; l++) {
                            ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute()
                                    .get(k).getContextMetadata().get(l).getName();
                            Individual mdataInstance = ontModel.createIndividual(ONT_URL + ngsiValue, metadata);
                            attrInstance.addProperty(ontModel.getProperty(ONT_URL + "hasMetadata"),
                                    mdataInstance);

                            ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute()
                                    .get(k).getContextMetadata().get(l).getType();
                            mdataInstance.setPropertyValue(ontModel.getProperty(ONT_URL + "type"),
                                    ontModel.createLiteral(ngsiValue));
                            ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute()
                                    .get(k).getContextMetadata().get(l).getValue().toString();
                            mdataInstance.setPropertyValue(ontModel.getProperty(ONT_URL + "value"),
                                    ontModel.createLiteral(ngsiValue));
                        }
                    }

                }

            }

        }

    }
    //        ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getId();
    //        Individual entity1 = ontModel.createIndividual(ONT_URL + ngsiValue, entity);
    //        entityGroupIndiv.addProperty(ontModel.getProperty(ONT_URL + "hasEntity"), entity1);
    //        ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getId();
    //        entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "id"), ontModel.createLiteral(ngsiValue));        
    //        ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getType();
    //        entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));        

    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getName();
    //        Individual attribute1 = ontModel.createIndividual(ONT_URL + ngsiValue, attribute);
    //        entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "hasAttribute"), attribute1);
    //        
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getType();
    //        attribute1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    //        
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getName();
    //        Individual metadata1 = ontModel.createIndividual(ONT_URL + ngsiValue, metadata);
    //        attribute1.setPropertyValue(ontModel.getProperty(ONT_URL + "hasMetadata"), metadata1);
    //        
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getType();
    //        metadata1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getValue().toString();
    //        metadata1.setPropertyValue(ontModel.getProperty(ONT_URL + "value"), ontModel.createLiteral(ngsiValue));
    //        
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getName();
    //        Individual metadata2 = ontModel.createIndividual(ONT_URL + ngsiValue, metadata);
    //        attribute1.addProperty(ontModel.getProperty(ONT_URL + "hasMetadata"), metadata2);
    //        
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getType();
    //        metadata2.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getValue().toString();
    //        metadata2.setPropertyValue(ontModel.getProperty(ONT_URL + "value"), ontModel.createLiteral(ngsiValue));
    ontModel.write(System.out, "TURTLE");
    //        ontModel.write(System.out, "RDF/XML");
    //        ontModel.write(System.out, "JSON-LD");

}

From source file:org.ejbca.externalra.gui.ExternalRaGuiConfiguration.java

private static Configuration instance() {
    if (config == null) {
        try {//  ww  w.ja v  a  2s  .  c  o  m
            // Default values build into war file, this is last prio used if no of the other sources override this
            boolean allowexternal = Boolean.getBoolean(new PropertiesConfiguration(
                    ExternalRaGuiConfiguration.class.getResource("/" + PROPERTIES_FILENAME))
                            .getString(PROPERTY_CONFIGALLOWEXTERNAL, "false"));
            config = new CompositeConfiguration();
            PropertiesConfiguration pc;
            // Only add these config sources if we allow external configuration
            if (allowexternal) {
                // Override with system properties, this is prio 1 if it exists (java -Dscep.test=foo)
                config.addConfiguration(new SystemConfiguration());
                log.info("Added system properties to configuration source (java -Dfoo.prop=bar).");
                // Override with file in "application server home directory"/conf, this is prio 2
                File f1 = new File("conf/" + PROPERTIES_FILENAME);
                pc = new PropertiesConfiguration(f1);
                pc.setReloadingStrategy(new FileChangedReloadingStrategy());
                config.addConfiguration(pc);
                log.info("Added file to configuration source: " + f1.getAbsolutePath());
                // Override with file in "/etc/ejbca/conf/extra, this is prio 3
                File f2 = new File("/etc/ejbca/conf/extra/" + PROPERTIES_FILENAME);
                pc = new PropertiesConfiguration(f2);
                pc.setReloadingStrategy(new FileChangedReloadingStrategy());
                config.addConfiguration(pc);
                log.info("Added file to configuration source: " + f2.getAbsolutePath());
            }
            // Default values build into war file, this is last prio used if no of the other sources override this
            URL url = ExternalRaGuiConfiguration.class.getResource("/" + PROPERTIES_FILENAME);
            pc = new PropertiesConfiguration(url);
            config.addConfiguration(pc);
            log.info("Added url to configuration source: " + url);
            log.info("Allow external re-configuration: " + allowexternal);
        } catch (ConfigurationException e) {
            log.error("Error intializing ExtRA Configuration: ", e);
        }
    }
    return config;
}