Search in sources :

Example 21 with SystemInstance

use of org.apache.openejb.loader.SystemInstance in project tomee by apache.

the class HttpEjbServer method init.

@Override
public void init(final Properties props) throws Exception {
    name = props.getProperty("name");
    final EjbServer ejbServer = new EjbServer();
    final ServerServiceAdapter adapter = new ServerServiceAdapter(ejbServer);
    final SystemInstance systemInstance = SystemInstance.get();
    HttpListenerRegistry registry = systemInstance.getComponent(HttpListenerRegistry.class);
    if (registry == null) {
        registry = new HttpListenerRegistry();
        systemInstance.setComponent(HttpListenerRegistry.class, registry);
    }
    registry.addHttpListener(adapter, "/ejb/?.*");
    // register the http server
    systemInstance.setComponent(HttpServer.class, httpServer);
    httpServer.init(props);
    ejbServer.init(props);
}
Also used : SystemInstance(org.apache.openejb.loader.SystemInstance) EjbServer(org.apache.openejb.server.ejbd.EjbServer)

Example 22 with SystemInstance

use of org.apache.openejb.loader.SystemInstance in project tomee by apache.

the class EEFilter method init.

@Override
public void init(final FilterConfig filterConfig) throws ServletException {
    final SystemInstance si = SystemInstance.isInitialized() ? SystemInstance.get() : null;
    final Properties config = si != null ? si.getProperties() : System.getProperties();
    securityService = si != null ? si.getComponent(SecurityService.class) : null;
    active = Boolean.parseBoolean(config.getProperty("tomee.http.request.wrap", "true"));
}
Also used : SystemInstance(org.apache.openejb.loader.SystemInstance) Properties(java.util.Properties)

Example 23 with SystemInstance

use of org.apache.openejb.loader.SystemInstance in project tomee by apache.

the class TomeeJaxWsService method init.

@Override
public void init(final Properties props) throws Exception {
    // Install the Tomcat webservice registry
    final SystemInstance system = SystemInstance.get();
    TomcatWsRegistry tomcatSoapHandler = (TomcatWsRegistry) system.getComponent(WsRegistry.class);
    if (tomcatSoapHandler == null) {
        tomcatSoapHandler = new TomcatWsRegistry();
        system.setComponent(WsRegistry.class, tomcatSoapHandler);
    }
    system.addObserver(this);
}
Also used : WsRegistry(org.apache.openejb.server.webservices.WsRegistry) SystemInstance(org.apache.openejb.loader.SystemInstance)

Example 24 with SystemInstance

use of org.apache.openejb.loader.SystemInstance in project tomee by apache.

the class TomcatWebAppBuilder method isExcludedBySystemProperty.

private static boolean isExcludedBySystemProperty(final StandardContext standardContext) {
    String name = standardContext.getName();
    if (name == null) {
        name = standardContext.getPath();
        if (name == null) {
            // possible ?
            name = "";
        }
    }
    if (name.startsWith("/")) {
        name = name.substring(1);
    }
    final SystemInstance systemInstance = SystemInstance.get();
    return "true".equalsIgnoreCase(systemInstance.getProperty(name + ".tomcat-only", systemInstance.getProperty("tomcat-only", "false")));
}
Also used : SystemInstance(org.apache.openejb.loader.SystemInstance)

Example 25 with SystemInstance

use of org.apache.openejb.loader.SystemInstance 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

SystemInstance (org.apache.openejb.loader.SystemInstance)26 File (java.io.File)7 IOException (java.io.IOException)7 Properties (java.util.Properties)7 OpenEJBException (org.apache.openejb.OpenEJBException)7 MalformedURLException (java.net.MalformedURLException)5 ArrayList (java.util.ArrayList)5 URL (java.net.URL)4 NamingException (javax.naming.NamingException)4 BeanContext (org.apache.openejb.BeanContext)4 NoSuchApplicationException (org.apache.openejb.NoSuchApplicationException)4 OpenEJBRuntimeException (org.apache.openejb.OpenEJBRuntimeException)4 UndeployException (org.apache.openejb.UndeployException)4 InvalidObjectException (java.io.InvalidObjectException)3 ObjectStreamException (java.io.ObjectStreamException)3 URISyntaxException (java.net.URISyntaxException)3 ExecutionException (java.util.concurrent.ExecutionException)3 TimeoutException (java.util.concurrent.TimeoutException)3 DefinitionException (javax.enterprise.inject.spi.DefinitionException)3 DeploymentException (javax.enterprise.inject.spi.DeploymentException)3