Example usage for javax.persistence EntityManagerFactory equals

List of usage examples for javax.persistence EntityManagerFactory equals

Introduction

In this page you can find the example usage for javax.persistence EntityManagerFactory equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:org.ejbca.extra.caservice.ExtRACAServiceWorker.java

private void init() {

    // Read configuration properties
    // First we get it from the built in configuration in the properties file using ConfigurationHolder
    // Second we try to override this value with a value from the properties of this specific worker, configured in the GUI
    // Oh, and if no configuration exist it uses the hard coded values from the top of this file.

    String persistenceUnit = this.properties.getProperty("externalra-caservice.persistenceunit",
            "RAMessage1DS");
    log.debug("externalra-caservice.hibernateresource: " + persistenceUnit);

    String keystorePath = this.properties.getProperty("externalra-caservice.keystore.path",
            "keystore/extrakeystore.p12");
    log.debug("externalra-caservice.keystore.path: " + keystorePath);

    keystorePwd = this.properties.getProperty("externalra-caservice.keystore.pwd", "foo123");
    log.debug("externalra-caservice.keystore.pwd: " + keystorePwd);

    encryptionRequired = Boolean//from   w w  w  .ja  v a 2 s .  com
            .valueOf(this.properties.getProperty("externalra-caservice.encryption.required", "false"));
    log.debug("externalra-caservice.encryption.required: " + encryptionRequired);

    signatureRequired = Boolean
            .valueOf(this.properties.getProperty("externalra-caservice.signature.required", "false"));
    log.debug("externalra-caservice.signature.required: " + signatureRequired);

    caname = this.properties.getProperty("externalra-caservice.raissuer", "AdminCA1");
    log.debug("externalra-caservice.raissuer: " + caname);

    whiteList = this.properties.getProperty("externalra-caservice.whitelist", "");
    log.debug("externalra-caservice.whitelist: " + whiteList);

    // Initialize the JPA provider with the current persistence unit
    if (entityManagerFactories.get(persistenceUnit) == null) {
        EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory(persistenceUnit);
        EntityManagerFactory entityManagerFactoryOld = entityManagerFactories.putIfAbsent(persistenceUnit,
                entityManagerFactory);
        if (entityManagerFactoryOld != null && !entityManagerFactoryOld.equals(entityManagerFactory)) {
            entityManagerFactory.close();
        } else {
            log.info("Created new entity manager factory for persistence unit '" + persistenceUnit + "'");
        }
    }
    msgHome = new MessageHome(entityManagerFactories.get(persistenceUnit), MessageHome.MESSAGETYPE_EXTRA, true); // We manage transactions ourself for this DataSource

    try {
        serviceKeyStore = new RAKeyStore(keystorePath, keystorePwd);
    } catch (Exception e) {
        if (encryptionRequired || signatureRequired) {
            log.error("Error reading ExtRACAService keystore", e);
        } else {
            log.debug("ExtRACAService KeyStore couldn't be configured, but isn't required");
        }
    }
}