Search in sources :

Example 6 with Options

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

the class MulticastDiscoveryAgent method init.

@Override
public void init(final Properties props) {
    final Options options = new Options(props);
    options.setLogger(new OptionsLog(LOGGER));
    host = props.getProperty("bind", host);
    loopbackMode = options.get("loopback_mode", loopbackMode);
    port = options.get("port", port);
    heartRate = options.get("heart_rate", heartRate);
    final Tracker.Builder builder = new Tracker.Builder();
    builder.setGroup(props.getProperty("group", builder.getGroup()));
    builder.setHeartRate(heartRate);
    builder.setMaxMissedHeartbeats(options.get("max_missed_heartbeats", builder.getMaxMissedHeartbeats()));
    builder.setMaxReconnectDelay(options.get("max_reconnect_delay", builder.getMaxReconnectDelay()));
    builder.setReconnectDelay(options.get("reconnect_delay", builder.getReconnectDelay()));
    builder.setExponentialBackoff(options.get("exponential_backoff", builder.getExponentialBackoff()));
    builder.setMaxReconnectAttempts(options.get("max_reconnect_attempts", builder.getMaxReconnectAttempts()));
    tracker = builder.build();
}
Also used : Options(org.apache.openejb.loader.Options) OptionsLog(org.apache.openejb.util.OptionsLog)

Example 7 with Options

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

the class MultipointDiscoveryAgent method init.

@Override
public void init(final Properties props) {
    final Options options = new Options(props);
    options.setLogger(new OptionsLog(LOGGER));
    host = props.getProperty("bind", host);
    port = options.get("port", port);
    initialServers = options.get("initialServers", initialServers);
    heartRate = options.get("heart_rate", heartRate);
    discoveryHost = options.get("discoveryHost", host);
    name = name != null ? name : options.get("discoveryName", MultipointServer.randomColor());
    reconnectDelay = options.get("reconnectDelay", new Duration("30 seconds"));
    final Set<URI> uris = new LinkedHashSet<>();
    // Connect the initial set of peer servers
    final StringTokenizer st = new StringTokenizer(initialServers, ",");
    while (st.hasMoreTokens()) {
        final String string = st.nextToken().trim();
        if (string.startsWith("conn://")) {
            final URI uri = URI.create(string);
            uris.add(uri);
        } else {
            final URI uri = URI.create("conn://" + string);
            uris.add(uri);
        }
    }
    roots = uris;
    final Tracker.Builder builder = new Tracker.Builder();
    builder.setHeartRate(heartRate);
    builder.setGroup(props.getProperty("group", builder.getGroup()));
    builder.setMaxMissedHeartbeats(options.get("max_missed_heartbeats", builder.getMaxMissedHeartbeats()));
    builder.setMaxReconnectDelay(options.get("max_reconnect_delay", builder.getMaxReconnectDelay()));
    builder.setReconnectDelay(options.get("reconnect_delay", builder.getReconnectDelay()));
    builder.setExponentialBackoff(options.get("exponential_backoff", builder.getExponentialBackoff()));
    builder.setMaxReconnectAttempts(options.get("max_reconnect_attempts", builder.getMaxReconnectAttempts()));
    builder.setDebug(debug);
    tracker = builder.build();
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Options(org.apache.openejb.loader.Options) StringTokenizer(java.util.StringTokenizer) OptionsLog(org.apache.openejb.util.OptionsLog) Duration(org.apache.openejb.util.Duration) URI(java.net.URI)

Example 8 with Options

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

the class JettyHttpServer method init.

@Override
public void init(final Properties props) throws Exception {
    final Options options = new Options(props);
    port = options.get("port", 8080);
    // Create all the Jetty objects but dont' start them
    server = new Server();
    final Connector connector = new SelectChannelConnector();
    connector.setPort(port);
    server.setConnectors(new Connector[] { connector });
    final ContextHandler context = new ContextHandler();
    context.setContextPath("/");
    final ServletContext servletContext = context.getServletContext();
    server.setHandler(context);
    final Handler handler = new AbstractHandler() {

        @Override
        public void handle(final String target, final HttpServletRequest req, final HttpServletResponse res, final int dispatch) throws IOException, ServletException {
            try {
                ((Request) req).setHandled(true);
                final HttpRequest httpRequest = new ServletRequestAdapter(req, res, servletContext);
                final HttpResponse httpResponse = new ServletResponseAdapter(res);
                JettyHttpServer.this.listener.onMessage(httpRequest, httpResponse);
            } catch (IOException | ServletException e) {
                throw e;
            } catch (Exception e) {
                throw new ServletException(e);
            }
        }
    };
    final SessionHandler sessionHandler = new SessionHandler();
    final SessionManager sessionManager = new HashSessionManager();
    sessionManager.setIdManager(new HashSessionIdManager());
    sessionHandler.setSessionManager(sessionManager);
    sessionHandler.setHandler(handler);
    context.setHandler(sessionHandler);
}
Also used : SessionHandler(org.mortbay.jetty.servlet.SessionHandler) Options(org.apache.openejb.loader.Options) Connector(org.mortbay.jetty.Connector) SelectChannelConnector(org.mortbay.jetty.nio.SelectChannelConnector) Server(org.mortbay.jetty.Server) HashSessionManager(org.mortbay.jetty.servlet.HashSessionManager) SessionManager(org.mortbay.jetty.SessionManager) HashSessionManager(org.mortbay.jetty.servlet.HashSessionManager) Request(org.mortbay.jetty.Request) HttpServletRequest(javax.servlet.http.HttpServletRequest) Handler(org.mortbay.jetty.Handler) SessionHandler(org.mortbay.jetty.servlet.SessionHandler) ContextHandler(org.mortbay.jetty.handler.ContextHandler) AbstractHandler(org.mortbay.jetty.handler.AbstractHandler) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException) HashSessionIdManager(org.mortbay.jetty.servlet.HashSessionIdManager) AbstractHandler(org.mortbay.jetty.handler.AbstractHandler) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) ServiceException(org.apache.openejb.server.ServiceException) ContextHandler(org.mortbay.jetty.handler.ContextHandler) HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletException(javax.servlet.ServletException) SelectChannelConnector(org.mortbay.jetty.nio.SelectChannelConnector) ServletContext(javax.servlet.ServletContext)

Example 9 with Options

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

the class MulticastPulseAgent method init.

@Override
public void init(final Properties p) throws Exception {
    final Options o = new Options(p);
    o.setLogger(new OptionsLog(LOG));
    this.ignore.add("localhost");
    this.ignore.add("::1");
    this.ignore.add("127.0.0.1");
    try {
        final String[] ignoreList = o.get("ignore", "").split(",");
        for (final String s : ignoreList) {
            if (null != s && s.trim().length() > 0) {
                this.ignore.add(s.trim().toLowerCase());
            }
        }
    } catch (final Exception e) {
        LOG.warning("Invalid ignore parameter. Should be a lowercase single host or comma seperated list of hosts to ignore like: ignore=host1,host2,ipv4,ipv6");
    }
    this.multicast = o.get("bind", this.multicast);
    this.port = o.get("port", this.port);
    this.group = o.get("group", this.group);
    final InetAddress ia = InetAddress.getByName(this.multicast);
    this.address = new InetSocketAddress(ia, this.port);
    this.buildPacket();
}
Also used : Options(org.apache.openejb.loader.Options) InetSocketAddress(java.net.InetSocketAddress) OptionsLog(org.apache.openejb.util.OptionsLog) InetAddress(java.net.InetAddress) SocketException(java.net.SocketException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) ServiceException(org.apache.openejb.server.ServiceException)

Example 10 with Options

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

the class Assembler method init.

@Override
public void init(final Properties props) throws OpenEJBException {
    this.props = new Properties(props);
    final Options options = new Options(props, SystemInstance.get().getOptions());
    final String className = options.get("openejb.configurator", "org.apache.openejb.config.ConfigurationFactory");
    if ("org.apache.openejb.config.ConfigurationFactory".equals(className)) {
        // no need to use reflection
        configFactory = new ConfigurationFactory();
    } else {
        configFactory = (OpenEjbConfigurationFactory) toolkit.newInstance(className);
    }
    configFactory.init(props);
    SystemInstance.get().setComponent(OpenEjbConfigurationFactory.class, configFactory);
}
Also used : Options(org.apache.openejb.loader.Options) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) SuperProperties(org.apache.openejb.util.SuperProperties) Properties(java.util.Properties)

Aggregations

Options (org.apache.openejb.loader.Options)21 IOException (java.io.IOException)7 OpenEJBException (org.apache.openejb.OpenEJBException)5 Properties (java.util.Properties)4 NamingException (javax.naming.NamingException)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 ArrayList (java.util.ArrayList)3 TimeoutException (java.util.concurrent.TimeoutException)3 MBeanServer (javax.management.MBeanServer)3 MalformedObjectNameException (javax.management.MalformedObjectNameException)3 ObjectName (javax.management.ObjectName)3 ApplicationException (org.apache.openejb.ApplicationException)3 SystemException (org.apache.openejb.SystemException)3 OptionsLog (org.apache.openejb.util.OptionsLog)3 URL (java.net.URL)2 RemoteException (java.rmi.RemoteException)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 AttributeNotFoundException (javax.management.AttributeNotFoundException)2 InstanceNotFoundException (javax.management.InstanceNotFoundException)2