public void init()

in jbatch/src/main/java/org/apache/batchee/container/services/ServicesManager.java [125:191]


    public void init(final Properties props) {
        // Use double-checked locking with volatile.
        if (!isInited) {
            synchronized (isInitedLock) {
                if (!isInited) {
                    batchRuntimeConfig = new Properties();

                    batchRuntimeConfig.putAll(SERVICE_IMPL_CLASS_NAMES); // defaults

                    loader = Thread.currentThread().getContextClassLoader();

                    // file in the classloader
                    final InputStream batchServicesListInputStream = loader.getResourceAsStream(SERVICES_CONFIGURATION_FILE);
                    if (batchServicesListInputStream != null) {
                        try {
                            batchRuntimeConfig.load(batchServicesListInputStream);
                        } catch (final Exception e) {
                            LOGGER.config("Error loading " + SERVICES_CONFIGURATION_FILE + " Exception=" + e.toString());
                        } finally {
                            try {
                                batchServicesListInputStream.close();
                            } catch (final IOException e) {
                                // no-op
                            }
                        }
                    }

                    // API overriding
                    if (props != null) {
                        batchRuntimeConfig.putAll(props);
                    }

                    // JVM instance overriding
                    batchRuntimeConfig.putAll(System.getProperties());

                    logServices = Boolean.parseBoolean(batchRuntimeConfig.getProperty("batchee.service-manager.log", "false"));

                    if (Boolean.parseBoolean(batchRuntimeConfig.getProperty("org.apache.batchee.jmx", "true"))) {
                        try {
                            final MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
                            final String app = batchRuntimeConfig.getProperty("org.apache.batchee.jmx.application", "");
                            if (app.isEmpty()) {
                                jmxName = new ObjectName(BatchEEMBean.DEFAULT_OBJECT_NAME);
                            } else {
                                jmxName = new ObjectName(BatchEEMBean.DEFAULT_OBJECT_NAME + ",application=" + app);
                            }

                            if (!platformMBeanServer.isRegistered(jmxName)) {
                                platformMBeanServer.registerMBean(
                                        new BatchEE(
                                                makeLoaderAware(BatchEEMBean.class, new Class<?>[]{ BatchEEMBean.class },
                                                        BatchEEMBeanImpl.INSTANCE)),
                                        jmxName);
                            } else {
                                jmxName = null;
                                LOGGER.warning("You didn't specify org.apache.batchee.jmx.application and JMX is already registered, skipping");
                            }
                        } catch (final Exception e) {
                            throw new IllegalStateException(e);
                        }
                    }

                    isInited = Boolean.TRUE;
                }
            }
        }
    }