Search in sources :

Example 1 with ResourceLocatorMap

use of org.candlepin.resteasy.ResourceLocatorMap in project candlepin by candlepin.

the class CandlepinContextListener method withInjector.

@Override
public void withInjector(Injector injector) {
    // Must call super.contextInitialized() before accessing injector
    insertValidationEventListeners(injector);
    ResourceLocatorMap map = injector.getInstance(ResourceLocatorMap.class);
    map.init();
    if (config.getBoolean(ConfigProperties.AMQP_INTEGRATION_ENABLED) && !config.getBoolean(ConfigProperties.SUSPEND_MODE_ENABLED)) {
        QpidQmf qmf = injector.getInstance(QpidQmf.class);
        QpidStatus status = qmf.getStatus();
        if (status != QpidStatus.CONNECTED) {
            log.error("Qpid is in status {}. Please fix Qpid configuration " + "and make sure Qpid is up and running. Candlepin will shutdown " + "now.", status);
            throw new RuntimeException("Error during Startup: Qpid is in status " + status);
        }
    }
    if (config.getBoolean(ConfigProperties.AMQP_INTEGRATION_ENABLED) && config.getBoolean(ConfigProperties.SUSPEND_MODE_ENABLED)) {
        SuspendModeTransitioner mw = injector.getInstance(SuspendModeTransitioner.class);
        mw.transitionAppropriately();
        mw.startPeriodicExecutions();
    }
    if (config.getBoolean(ACTIVEMQ_ENABLED)) {
        try {
            activeMQContextListener = injector.getInstance(ActiveMQContextListener.class);
            activeMQContextListener.contextInitialized(injector);
        } catch (Exception e) {
            log.error("Exception occurred while trying to load ActiveMQ", e);
        }
    }
    if (config.getBoolean(ConfigProperties.CACHE_JMX_STATS)) {
        MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
        ManagementService.registerMBeans(CacheManager.getInstance(), mBeanServer, true, true, true, true);
    }
    pinsetterListener = injector.getInstance(PinsetterContextListener.class);
    pinsetterListener.contextInitialized();
    loggerListener = injector.getInstance(LoggerContextListener.class);
    /**
     * Custom ModelConverter to handle our specific serialization requirements
     */
    ModelConverters.getInstance().addConverter(injector.getInstance(CandlepinSwaggerModelConverter.class));
    this.injector = injector;
}
Also used : SuspendModeTransitioner(org.candlepin.controller.SuspendModeTransitioner) ActiveMQContextListener(org.candlepin.audit.ActiveMQContextListener) LoggerContextListener(org.candlepin.logging.LoggerContextListener) QpidStatus(org.candlepin.audit.QpidQmf.QpidStatus) PinsetterContextListener(org.candlepin.pinsetter.core.PinsetterContextListener) CandlepinSwaggerModelConverter(org.candlepin.swagger.CandlepinSwaggerModelConverter) QpidQmf(org.candlepin.audit.QpidQmf) ResourceLocatorMap(org.candlepin.resteasy.ResourceLocatorMap) ConfigurationException(org.candlepin.common.config.ConfigurationException) MBeanServer(javax.management.MBeanServer)

Aggregations

MBeanServer (javax.management.MBeanServer)1 ActiveMQContextListener (org.candlepin.audit.ActiveMQContextListener)1 QpidQmf (org.candlepin.audit.QpidQmf)1 QpidStatus (org.candlepin.audit.QpidQmf.QpidStatus)1 ConfigurationException (org.candlepin.common.config.ConfigurationException)1 SuspendModeTransitioner (org.candlepin.controller.SuspendModeTransitioner)1 LoggerContextListener (org.candlepin.logging.LoggerContextListener)1 PinsetterContextListener (org.candlepin.pinsetter.core.PinsetterContextListener)1 ResourceLocatorMap (org.candlepin.resteasy.ResourceLocatorMap)1 CandlepinSwaggerModelConverter (org.candlepin.swagger.CandlepinSwaggerModelConverter)1