Search in sources :

Example 6 with ServiceConfiguration

use of org.apache.openejb.assembler.classic.util.ServiceConfiguration in project tomee by apache.

the class RESTService method deployApplication.

private void deployApplication(final AppInfo appInfo, final String contextRoot, final Map<String, EJBRestServiceInfo> restEjbs, final ClassLoader classLoader, final Collection<Injection> injections, final WebBeansContext owbCtx, final Context context, final Collection<Object> additionalProviders, final Collection<IdPropertiesInfo> pojoConfigurations, final Application application, final String prefix) {
    // get configuration
    Properties configuration;
    if (InternalApplication.class.equals(application.getClass())) {
        final Application original = InternalApplication.class.cast(application).getOriginal();
        if (original == null) {
            configuration = PojoUtil.findConfiguration(pojoConfigurations, "jaxrs-application");
        } else {
            configuration = PojoUtil.findConfiguration(pojoConfigurations, original.getClass().getName());
        }
    } else {
        configuration = PojoUtil.findConfiguration(pojoConfigurations, application.getClass().getName());
    }
    if (configuration == null) {
        // try a constant (common in half of cases)
        configuration = PojoUtil.findConfiguration(pojoConfigurations, "jaxrs-application");
    }
    if (configuration != null) {
        LOGGER.info("Registered JAX-RS Configuration: " + configuration);
    }
    final String base = getAddress(contextRoot);
    final String nopath;
    if (base.endsWith("/") && prefix.startsWith("/")) {
        nopath = base + prefix.substring(1);
    } else {
        nopath = base + prefix;
    }
    final RsHttpListener listener = createHttpListener();
    final String host = findHost(contextRoot, appInfo.webApps);
    final RsRegistry.AddressInfo address = rsRegistry.createRsHttpListener(appInfo.appId, contextRoot, listener, classLoader, nopath.substring(NOPATH_PREFIX.length() - 1), host, auth, realm);
    services.add(new DeployedService(address.complete, contextRoot, application.getClass().getName(), appInfo.appId));
    // app config
    listener.deployApplication(// app config
    application, // app config
    address.complete.substring(0, address.complete.length() - wildcard.length()), // app config
    nopath.substring(NOPATH_PREFIX.length(), nopath.length() - wildcard.length()), // app config
    additionalProviders, // app config
    restEjbs, // injection/webapp context
    classLoader, // injection/webapp context
    injections, // injection/webapp context
    context, // injection/webapp context
    owbCtx, // deployment config
    new ServiceConfiguration(configuration, appInfo.services));
}
Also used : ServiceConfiguration(org.apache.openejb.assembler.classic.util.ServiceConfiguration) Properties(java.util.Properties) Application(javax.ws.rs.core.Application)

Example 7 with ServiceConfiguration

use of org.apache.openejb.assembler.classic.util.ServiceConfiguration 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());
            manager.setDaemon(true);
            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

ServiceConfiguration (org.apache.openejb.assembler.classic.util.ServiceConfiguration)7 BeanContext (org.apache.openejb.BeanContext)4 MalformedURLException (java.net.MalformedURLException)3 Application (javax.ws.rs.core.Application)3 IdPropertiesInfo (org.apache.openejb.assembler.classic.IdPropertiesInfo)3 File (java.io.File)2 URL (java.net.URL)2 HashMap (java.util.HashMap)2 Properties (java.util.Properties)2 TreeMap (java.util.TreeMap)2 EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)2 EnterpriseBeanInfo (org.apache.openejb.assembler.classic.EnterpriseBeanInfo)2 PortInfo (org.apache.openejb.assembler.classic.PortInfo)2 WebAppInfo (org.apache.openejb.assembler.classic.WebAppInfo)2 PortData (org.apache.openejb.core.webservices.PortData)2 HttpListener (org.apache.openejb.server.httpd.HttpListener)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1