/* (non-Javadoc)
@see com.ibm.jbatch.container.services.impl.AbstractPersistenceManagerImpl#init(com.ibm.jbatch.container.IBatchConfig)
423886
@Override
	public void init(IBatchConfig batchConfig) throws BatchContainerServiceException {

		logger.config("Entering CLASSNAME.init(), batchConfig =" + batchConfig);

		this.batchConfig = batchConfig;

		schema = batchConfig.getDatabaseConfigurationBean().getSchema();

		if (!batchConfig.isJ2seMode()) {

			dataSource = batchConfig.getDatabaseConfigurationBean().getDataSource();

			if (dataSource != null) {

				logger.config("DataSource obtained from DB config bean = " + dataSource);

			} else {

				jndiName = batchConfig.getDatabaseConfigurationBean().getJndiName();

				logger.config("JNDI name = " + jndiName);

				if (jndiName == null || jndiName.equals("")) {
					throw new BatchContainerServiceException("JNDI name is not defined, which was the last way to initialize a DataSource.");
				}

				try {
					Context ctx = new InitialContext();
					dataSource = (DataSource) ctx.lookup(jndiName);

				} catch (NamingException e) {
					logger.severe("Lookup failed for JNDI name: " + jndiName + 
							".  One cause of this could be that the batch runtime is incorrectly configured to EE mode when it should be in SE mode.");
					throw new BatchContainerServiceException(e);
				}
			}

		} else {
			driver = batchConfig.getDatabaseConfigurationBean().getJdbcDriver();
			url = batchConfig.getDatabaseConfigurationBean().getJdbcUrl();
			userId = batchConfig.getDatabaseConfigurationBean().getDbUser();
			pwd = batchConfig.getDatabaseConfigurationBean().getDbPassword();

			logger.config("driver: " + driver + ", url: " + url);
		}

		try {
			// only auto-create on Derby
			if(isDerby()) {	
				if(!isSchemaValid()) {
					createSchema();
				}
				checkAllTables();
			}
		} catch (SQLException e) {
			logger.severe(e.getLocalizedMessage());
			throw new BatchContainerServiceException(e);
		}

		logger.config("Exiting CLASSNAME.init()");
	}
220953
@Override
    public void init(FilterConfig filterConfig) throws ServletException {
        LOG.info("AtlasAuthenticationFilter initialization started");
        final FilterConfig globalConf = filterConfig;
        final Map<String, String> params = new HashMap<>();
        try {
            configuration = ApplicationProperties.get();
        } catch (Exception e) {
            throw new ServletException(e);
        }

        if (configuration != null) {
            headerProperties = ConfigurationConverter.getProperties(configuration.subset("atlas.headers"));
        }

        FilterConfig filterConfig1 = new FilterConfig() {
            @Override
            public ServletContext getServletContext() {
                if (globalConf != null) {
                    return globalConf.getServletContext();
                } else {
                    return nullContext;
                }
            }

            @SuppressWarnings("unchecked")
            @Override
            public Enumeration<String> getInitParameterNames() {
                return new IteratorEnumeration(params.keySet().iterator());
            }

            @Override
            public String getInitParameter(String param) {
                return params.get(param);
            }

            @Override
            public String getFilterName() {
                return "AtlasAuthenticationFilter";
            }
        };

        super.init(filterConfig1);

        optionsServlet = new HttpServlet() {
        };
        optionsServlet.init();
    }
776587
@Override
	public void init(Config config, TaskContext context) throws Exception {
		String yarnConfHome = config.get(SamzaConfigFactory.YARN_CONF_HOME_KEY);
		if (yarnConfHome != null && yarnConfHome.length() > 0) // if the property is set , otherwise, assume we are running in
            													// local mode and ignore this
			SystemsUtils.setHadoopConfigHome(yarnConfHome);
		
		String filename = config.get(SamzaConfigFactory.FILE_KEY);
		String filesystem = config.get(SamzaConfigFactory.FILESYSTEM_KEY);
		this.setName(config.get(SamzaConfigFactory.JOB_NAME_KEY));
		SerializationProxy wrapper = (SerializationProxy) SystemsUtils.deserializeObjectFromFileAndKey(filesystem, filename, this.getName());
		this.setProcessor(wrapper.processor);
		this.outputStreams = wrapper.outputStreams;
		
		// Init Processor and Streams
		this.getProcessor().onCreate(0);
		for (SamzaStream stream:this.outputStreams) {
			stream.onCreate();
		}
		
	}
1220304
@Override
	public void setInitializationData(IConfigurationElement configElem, String propertyName,
			Object data) throws CoreException {

		final String sourceMethod = "setInitializationData"; //$NON-NLS-1$
		boolean isTraceLogging = log.isLoggable(Level.FINER);
		if (isTraceLogging) {
			log.entering(sourceClass, sourceMethod, new Object[]{configElem, propertyName, data});
		}
		contributingBundle = Platform.getBundle(configElem.getNamespaceIdentifier());
		if (contributingBundle.getState() != Bundle.ACTIVE) {
			try {
				contributingBundle.start();
			} catch (BundleException e) {
				throw new CoreException(
						new Status(Status.ERROR, configElem.getNamespaceIdentifier(),
								e.getMessage(), e)
						);
			}
		}


		Map<String, String> configMap = new HashMap<String, String>();
		configMap = getConfigMap(configElem);
		initParams = getConfigInitParams(configElem);
		singletonExtensions = new HashMap<String, Object>();

		try {
			BundleContext bundleContext = Activator.getBundleContext();
			platformServices = new PlatformServicesImpl(contributingBundle);
			name = getAggregatorName(configMap);

			// Make sure there isn't already an instance of the aggregator registered for the current name
			if (getPlatformServices().getServiceReferences(
					IAggregator.class.getName(),
					"(name=" + getName() + ")") != null) { //$NON-NLS-1$ //$NON-NLS-2$
				throw new IllegalStateException("Name already registered - " + name); //$NON-NLS-1$
			}
			registerLayerListener();
			executorsServiceTracker = getExecutorsServiceTracker(bundleContext);
			variableResolverServiceTracker = getVariableResolverServiceTracker(bundleContext);
			initExtensions(configElem);
			initOptions(initParams);
			IConfig config = newConfig();
			initWorkingDirectory(configMap, config); // this must be after initOptions
			primeCache(config);
			super.initialize(config);

		} catch (Exception e) {
			throw new CoreException(
					new Status(Status.ERROR, configElem.getNamespaceIdentifier(),
							e.getMessage(), e)
					);
		}

		if (isTraceLogging) {
			log.exiting(sourceClass, sourceMethod);
		}
	}
1277619
public static synchronized void init(LogProviderConfig config) {
        if (config == null)
            throw new NullPointerException("LogProviderConfig must not be null");

        if (loggingConfig.get().compareAndSet(null, config)) {
            // Only initialize Tr once -- all subsequent changes go through update
            // The synchronization of this method is gratuitous (just makes us feel better), 
            // it is called while the system is single threaded at startup. 

            // config.getTrDelegate() must not return null -- it should either
            // return a dummy/disabled delegate, or throw an exception so that startup
            // does not proceed.
            final TrService tr = config.getTrDelegate();
            if (tr == null)
                throw new NullPointerException("LogProviderConfig must provide a TrService delegate");
            Callable<TrService> result = new Callable<TrService>() {
                @Override
                public TrService call() throws Exception {
                    return tr;
                }
            };
            delegate = StaticValue.mutateStaticValue(delegate, result);
            delegate.get().init(config);

            // Validate and propagate the initial trace specification 
            setTraceSpec(config.getTraceString());

            // Set class that we want the LogManager to instantiate when someone
            // calls getLogger: This logger interacts only with the Tr/FFDC API: 
            // it is not dependent on the implementation of the underlying delegate
            WsLogManager.setWsLogger(com.ibm.ws.logging.internal.WsLogger.class);
        }
    }
51390
@Override
    protected void initialize(boolean reactivate) throws RemoteException, InvocationTargetException {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled()) {
            Tr.entry(tc, "initialize");
        }

        BeanMetaData bmd = home.beanMetaData;
        ivCallbackKind = bmd.ivCallbackKind;

        state = PRE_CREATE; // d159152

        CallbackContextHelper contextHelper = new CallbackContextHelper(this); // d630940
        try {
            // Disallow setRollbackOnly until create is done.
            allowRollbackOnly = false;

            // Set the BeanId for this MDB. Just like we do for SLSB,
            // we use the BeanId for the home bean so that the same ID
            // is used for all MDB instances. Note the ivStatelessId is
            // for the home bean, which is implemented as a SLSB.
            if (home != null) {
                setId(home.ivStatelessId); // d140003.12
            }

            // Note that the local transaction surrounds injection methods and
            // PostConstruct lifecycle callbacks.
            contextHelper.begin(CallbackContextHelper.Tx.CompatLTC,
                                CallbackContextHelper.Contexts.CallbackBean); // d630940

            InterceptorMetaData imd = bmd.ivInterceptorMetaData;
            createInterceptorsAndInstance(contextHelper);

            // Now set the MessageDrivenContext and/or do the dependency injection.
            // Note that dependency injection must occur while in PRE_CREATE state.
            injectInstance(ivManagedObject, ivEjbInstance, this);

            //---------------------------------------------------------
            // Now that the MessageDrivenContext is set and/or dependencies
            // injection has occured, change state to CREATING state to allow
            // additional methods to be called by the ejbCreate or
            // PostConstruct interceptor methods (e.g. getEJBObject).
            //---------------------------------------------------------
            setState(CREATING); //d399469.2

            // Determine of life cycle callback to make if any.
            if (ivCallbackKind == CallbackKind.MessageDrivenBean) {
                Method m = bmd.ivEjbCreateMethod; //d453778
                if (m != null) //d453778
                {
                    // This is a 2.x MDB that has a ejbCreate method in it.
                    try {
                        if (isTraceOn && // d527372
                            TEBeanLifeCycleInfo.isTraceEnabled()) {
                            TEBeanLifeCycleInfo.traceEJBCallEntry("ejbCreate");
                        }
                        m.invoke(ivEjbInstance, new Object[] {});
                    } catch (InvocationTargetException itex) {
                        //FFDCFilter.processException(itex, CLASS_NAME + ".MessageDrivenBeanO", "96", this);

                        // All exceptions returned through a reflect method call
                        // are wrapped... making it difficult to debug a problem
                        // since InovcationTargetException does not print the root
                        // exception. Unwrap the 'target' exception so that the
                        // client will see it as the cause of the
                        // CreateFailureException.                        d534353.1
                        Throwable targetEx = itex.getCause();
                        if (targetEx == null)
                            targetEx = itex;

                        // MDB 2.x is allowed to throw application exceptions as well as
                        // javax.ejb.CreateException. Continue to wrap with a CreateFailureException
                        // to ensure no behavior change with prior releases.
                        if (isTraceOn && tc.isDebugEnabled()) {
                            Tr.debug(tc, "MDB ejbCreate failure", targetEx);
                        }
                        throw new CreateFailureException(targetEx);
                    } catch (Throwable ex) {
                        //FFDCFilter.processException(ex, CLASS_NAME + ".MessageDrivenBeanO", "96", this);

                        // MDB 2.x is allowed to throw application exceptions as well as
                        // javax.ejb.CreateException. Continue to wrap with a CreateFailureException
                        // to ensure no behavior change with prior releases.
                        if (isTraceOn && tc.isDebugEnabled()) {
                            Tr.debug(tc, "MDB ejbCreate failure", ex);
                        }
                        throw new CreateFailureException(ex);
                    } finally {
                        if (isTraceOn && // d527372
                            TEBeanLifeCycleInfo.isTraceEnabled()) {
                            TEBeanLifeCycleInfo.traceEJBCallExit("ejbCreate");
                        }
                    }
                }
            } else if (ivCallbackKind == CallbackKind.InvocationContext) {
                // This is a MDB 3 that may have one or more PostConstruct interceptors
                // methods. Invoke PostContruct interceptors if there is atleast 1
                // PostConstruct interceptor.
                try {
                    if (imd != null) // d402681
                    {
                        InterceptorProxy[] proxies = imd.ivPostConstructInterceptors;
                        if (proxies != null) {
                            if (isTraceOn && // d527372
                                TEBeanLifeCycleInfo.isTraceEnabled()) {
                                TEBeanLifeCycleInfo.traceEJBCallEntry("PostConstruct");
                            }
                            InvocationContextImpl<?> inv = getInvocationContext();
                            inv.doLifeCycle(proxies, bmd._moduleMetaData); //d450431, F743-14982
                        }
                    }
                } catch (Throwable t) {
                    //FFDCFilter.processException(t, CLASS_NAME + ".MessageDrivenBeanO", "281", this);

                    // PostConstruct interceptors are allowed to throw system runtime exceptions,
                    // but NOT application exceptions. Therefore, wrap the caught Throwable
                    // in a javax.ejb.EJBException so that it gets handled as an unchecked
                    // exception.
                    if (isTraceOn && tc.isDebugEnabled()) {
                        Tr.debug(tc, "MDB PostConstruct failure", t);
                    }
                    throw ExceptionUtil.EJBException("MDB PostConstruct failure", t);
                } finally {
                    if (isTraceOn && // d527372
                        TEBeanLifeCycleInfo.isTraceEnabled() &&
                        imd != null &&
                        imd.ivPostConstructInterceptors != null) {
                        TEBeanLifeCycleInfo.traceEJBCallExit("PostConstruct");
                    }
                }
            } // d367572.1 end

            //---------------------------------------------------------
            // Now that create has completed, allow setRollbackOnly to
            // be called on the SessionContext and change state to the
            // POOLED state to indicate the MDB is in the method-ready
            // pool state and message listener methods are now allowed to be
            // invoked on this MDB.
            //---------------------------------------------------------
            allowRollbackOnly = true;
            setState(POOLED);
        } finally // d399469
        {
            contextHelper.complete(true);
        }

        if (isTraceOn && tc.isEntryEnabled()) {
            Tr.exit(tc, "initialize");
        }
    }
686018
public static synchronized void init(HpelTraceServiceConfig config) {
        if (config == null)
            throw new NullPointerException("LogProviderConfig must not be null");

        loggingConfig.compareAndSet(null, config);
    }
1144069
@SuppressWarnings("unchecked")
    public void init(ServletConfig config) throws ServletException
    {
        super.init(config);
        // Move init params to my properties
        Enumeration<String> paramNames = this.getInitParameterNames();
        while (paramNames.hasMoreElements())
        {
            String paramName = paramNames.nextElement();
            this.setProperty(paramName, this.getInitParameter(paramName));
        }
        if (Boolean.TRUE.toString().equalsIgnoreCase(this.getInitParameter(LOG_PARAM)))
            logger = Logger.getLogger(PROPERTY_PREFIX);
    }
1169741
public void init(ServletConfig config)
        throws ServletException
    {
        super.init(config);

        try {
            if (_service == null) {
                String className = getInitParameter("service-class");
                Class<?> serviceClass = null;

                if (className != null) {
                    ClassLoader loader = Thread.currentThread().getContextClassLoader();

                    if (loader != null)
                        serviceClass = Class.forName(className, false, loader);
                    else
                        serviceClass = Class.forName(className);
                }
                else {
                    if (getClass().equals(BurlapServlet.class))
                        throw new ServletException("server must extend BurlapServlet");

                    serviceClass = getClass();
                }

                _service = serviceClass.newInstance();

                if (_service instanceof BurlapServlet)
                    ((BurlapServlet) _service).setService(this);
                if (_service instanceof Service)
                    ((Service) _service).init(getServletConfig());
                else if (_service instanceof Servlet)
                    ((Servlet) _service).init(getServletConfig());
            }

            if (_apiClass == null) {
                String className = getInitParameter("api-class");

                if (className != null) {
                    ClassLoader loader = Thread.currentThread().getContextClassLoader();

                    if (loader != null)
                        _apiClass = Class.forName(className, false, loader);
                    else
                        _apiClass = Class.forName(className);
                }
                else
                    _apiClass = _service.getClass();
            }

            _skeleton = new BurlapSkeleton(_service, _apiClass);
        } catch (ServletException e) {
            throw e;
        } catch (Exception e) {
            throw new ServletException(e);
        }
    }
492751
@Override
    public void init() throws InitializationException {
        engine = Engine.createCachingEngine();
        JMTEDateRendrer dateRendrer = new JMTEDateRendrer();
        dateRendrer.setDateFormat(dateFormat);
        engine.registerRenderer(Date.class, dateRendrer);
    }
150522
@SuppressWarnings("unchecked")
  public void init(PlayerConfig config) throws InitializationFailedException {
    this.config = config;
    String sourceClassName = config.get(SOURCE_CLASS_CONFIG_KEY);
    if (sourceClassName == null) {
      System.out.println("Missing required property in config: " + SOURCE_CLASS_CONFIG_KEY);
    }
    try {
      sourceClass = (Class<? extends Source>) Class.forName(sourceClassName);
    } catch (ClassNotFoundException e) {
      LOG.fatal("Instantiating source factory failed, " + SOURCE_CLASS_CONFIG_KEY + ": " + sourceClassName, e);
      System.exit(0);
    }
  }
375840
@Override
  public void init(PlayerConfig config) throws InitializationFailedException {
    super.init(config);
    String bulkSize = config.get(ES_BATCH_SIZE_KEY);
    if (bulkSize != null && !"".equals(bulkSize.trim())) {
      this.bulkSize = Integer.parseInt(bulkSize);
    }
    events = new ArrayList<SimpleDataEvent>();
  }
261339
public static void init(Map configProperties){
		if(configProperties != null && configProperties.size() > 0){
			ElasticSearchPropertiesFilePlugin.configProperties = configProperties;
			initType = 1;
		}
	}
1292598
protected void init(CollectorConfiguration config) {
        for (String btxn : config.getTransactions().keySet()) {
            TransactionConfig btc = config.getTransactions().get(btxn);
            init(btxn, btc);
        }

        onlyNamedTransactions = new Boolean(config.getProperty(
                "HAWKULAR_APM_COLLECTOR_ONLYNAMED", Boolean.FALSE.toString()));
    }
198045
private synchronized void init(AlluxioConfiguration alluxioConf) {
    mJobMasterInquireClient = MasterInquireClient.Factory.createForJobMaster(alluxioConf);
    mJobMasterClientPool =
        new JobMasterClientPool(JobMasterClientContext
            .newBuilder(ClientContext.create(alluxioConf)).build());
  }
16897
@Override
    public void init(FilterConfig filterConfig) throws ServletException {
        super.init(filterConfig);

        int reloadTime = readInt(filterConfig.getInitParameter(INIT_PARAM_RELOAD_TIME), 0);

        this.resetTime = readInt(filterConfig.getInitParameter(INIT_PARAM_RESET_TIME), resetTime);
        this.cacheKeyFormat = readString(filterConfig.getInitParameter(INIT_PARAM_CAHE_KEY_FORMAT), DEFAULT_CACHE_KEY_FORMAT);

        lastResetTime = new Date().getTime();

        CacheConfig<String, CachedResponse> cacheConfig = new CacheConfig<>();

        String providerValue = readString(filterConfig.getInitParameter(INIT_PARAM_CACHE_PROVIDER), null);

        if (providerValue != null)
            cacheConfig.setProvider(CacheConfig.CacheProvider.valueOf(providerValue.toUpperCase()));

        String cacheHost = filterConfig.getInitParameter(INIT_PARAM_CACHE_HOST);
        cacheConfig.setHostname(cacheHost);
        int cachePort = readInt(filterConfig.getInitParameter(INIT_PARAM_CACHE_PORT), 0);
        cacheConfig.setPortNumber(cachePort);

        if (!CacheFactory.isCacheProvider(cache, cacheConfig.getProvider())) {
            try {
                cache = CacheFactory.getCache(cacheConfig);
            } catch (Exception ex) {
                LOGGER.debug("Failed to initialize Cache Config: {}. Falling back to default Cache Service.", cacheConfig);
                cache = CacheFactory.<String, CachedResponse>getDefaultCache();
            }
        }

        LOGGER.debug("Cache Filter initialized with: " +
                        "{}:{},\n" +
                        "{}:{},\n" +
                        "{}:{},\n" +
                        "{}:{},\n" +
                        "{}:{}",
                INIT_PARAM_CACHE_PROVIDER, providerValue,
                INIT_PARAM_CACHE_HOST, cacheHost,
                INIT_PARAM_CACHE_PORT, String.valueOf(cachePort),
                INIT_PARAM_RELOAD_TIME, String.valueOf(reloadTime),
                INIT_PARAM_RESET_TIME, String.valueOf(resetTime));
    }
134961
@Override
    public void internalInitialize(BeanDeployerEnvironment environment) {
        super.internalInitialize(environment);
        checkEJBTypeAllowed();
        checkConflictingRoles();
        checkObserverMethods();
        checkScopeAllowed();
    }