Search in sources :

Example 6 with CounterRepository

use of org.apache.cxf.management.counters.CounterRepository in project tomee by apache.

the class CxfUtil method configureBus.

public static void configureBus() {
    if (USER_COUNT.incrementAndGet() > 1) {
        return;
    }
    final SystemInstance systemInstance = SystemInstance.get();
    final Bus bus = getBus();
    // ensure cxf classes are loaded from container to avoid conflicts with app
    if ("true".equalsIgnoreCase(systemInstance.getProperty("openejb.cxf.CxfContainerClassLoader", "true"))) {
        bus.setExtension(new CxfContainerClassLoader(), ClassLoader.class);
    }
    // activate jmx, by default isEnabled() == false in InstrumentationManagerImpl
    final boolean hasMonitoring = hasMonitoring(systemInstance);
    if (hasMonitoring || "true".equalsIgnoreCase(systemInstance.getProperty("openejb.cxf.jmx", "true"))) {
        final InstrumentationManager mgr = bus.getExtension(InstrumentationManager.class);
        if (InstrumentationManagerImpl.class.isInstance(mgr)) {
            // just to keep everything consistent
            bus.setExtension(LocalMBeanServer.get(), MBeanServer.class);
            final InstrumentationManagerImpl manager = InstrumentationManagerImpl.class.cast(mgr);
            manager.setEnabled(true);
            manager.setServer(LocalMBeanServer.get());
            try {
                // avoid to bother our nice logs
                LogUtils.getL7dLogger(InstrumentationManagerImpl.class).setLevel(Level.WARNING);
            } catch (final Throwable th) {
            // no-op
            }
            // failed when bus was constructed or even if passed we switch the MBeanServer
            manager.init();
        }
    }
    if (hasMonitoring) {
        new CounterRepository().setBus(bus);
    }
    final ServiceConfiguration configuration = new ServiceConfiguration(systemInstance.getProperties(), systemInstance.getComponent(OpenEjbConfiguration.class).facilities.services);
    final Collection<ServiceInfo> serviceInfos = configuration.getAvailableServices();
    Properties properties = configuration.getProperties();
    if (properties == null) {
        properties = new Properties();
    }
    final String featuresIds = properties.getProperty(BUS_PREFIX + FEATURES);
    if (featuresIds != null) {
        final List<Feature> features = createFeatures(serviceInfos, featuresIds);
        if (features != null) {
            features.addAll(bus.getFeatures());
            bus.setFeatures(features);
        }
    }
    final Properties busProperties = ServiceInfos.serviceProperties(serviceInfos, properties.getProperty(BUS_PREFIX + ENDPOINT_PROPERTIES));
    if (busProperties != null) {
        bus.getProperties().putAll(PropertiesHelper.map(busProperties));
    }
    configureInterceptors(bus, BUS_PREFIX, serviceInfos, configuration.getProperties());
    systemInstance.getProperties().setProperty(BUS_CONFIGURED_FLAG, "true");
    systemInstance.fireEvent(new BusCreated(bus));
}
Also used : Bus(org.apache.cxf.Bus) CounterRepository(org.apache.cxf.management.counters.CounterRepository) InstrumentationManager(org.apache.cxf.management.InstrumentationManager) Properties(java.util.Properties) BusCreated(org.apache.openejb.server.cxf.transport.event.BusCreated) Feature(org.apache.cxf.feature.Feature) AbstractFeature(org.apache.cxf.feature.AbstractFeature) OpenEjbConfiguration(org.apache.openejb.assembler.classic.OpenEjbConfiguration) ServiceInfo(org.apache.openejb.assembler.classic.ServiceInfo) InstrumentationManagerImpl(org.apache.cxf.management.jmx.InstrumentationManagerImpl) ServiceConfiguration(org.apache.openejb.assembler.classic.util.ServiceConfiguration) SystemInstance(org.apache.openejb.loader.SystemInstance)

Aggregations

CounterRepository (org.apache.cxf.management.counters.CounterRepository)6 Bus (org.apache.cxf.Bus)5 ObjectName (javax.management.ObjectName)3 InstrumentationManager (org.apache.cxf.management.InstrumentationManager)2 InstrumentationManagerImpl (org.apache.cxf.management.jmx.InstrumentationManagerImpl)2 Test (org.junit.Test)2 Properties (java.util.Properties)1 MBeanServer (javax.management.MBeanServer)1 Endpoint (javax.xml.ws.Endpoint)1 AbstractFeature (org.apache.cxf.feature.AbstractFeature)1 Feature (org.apache.cxf.feature.Feature)1 Counter (org.apache.cxf.management.counters.Counter)1 ResponseTimeMessageInInterceptor (org.apache.cxf.management.interceptor.ResponseTimeMessageInInterceptor)1 ResponseTimeMessageInvokerInterceptor (org.apache.cxf.management.interceptor.ResponseTimeMessageInvokerInterceptor)1 ResponseTimeMessageOutInterceptor (org.apache.cxf.management.interceptor.ResponseTimeMessageOutInterceptor)1 Greeter (org.apache.hello_world_soap_http.Greeter)1 SOAPService (org.apache.hello_world_soap_http.SOAPService)1 OpenEjbConfiguration (org.apache.openejb.assembler.classic.OpenEjbConfiguration)1 ServiceInfo (org.apache.openejb.assembler.classic.ServiceInfo)1 ServiceConfiguration (org.apache.openejb.assembler.classic.util.ServiceConfiguration)1