當前位置: 首頁>>代碼示例>>Java>>正文


Java MBeanContainer類代碼示例

本文整理匯總了Java中org.eclipse.jetty.jmx.MBeanContainer的典型用法代碼示例。如果您正苦於以下問題:Java MBeanContainer類的具體用法?Java MBeanContainer怎麽用?Java MBeanContainer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MBeanContainer類屬於org.eclipse.jetty.jmx包,在下文中一共展示了MBeanContainer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: jettyEmbeddedServletContainerFactory

import org.eclipse.jetty.jmx.MBeanContainer; //導入依賴的package包/類
/**
 * Configures the embedded jetty server. The values are configured in
 * <b>application.yaml</b> file.
 *
 * @param port        jetty server port
 * @param maxThreads  thread pool min thread
 * @param minThreads  thread pool max thread
 * @param idleTimeout maximum thread idle time
 * @param jmxEnabled  true, if jetty jmx is enabled.
 * @return {@link JettyEmbeddedServletContainerFactory}
 */
@Bean
public JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory(@Value("${server.port:8443}") final int port,
                                                                                 @Value("${jetty.thread-pool.max-threads:200}") final int maxThreads,
                                                                                 @Value("${jetty.thread-pool.min-threads:8}") final int minThreads,
                                                                                 @Value("${jetty.thread-pool.idle-timeout:60000}") final int idleTimeout,
                                                                                 @Value("${jetty.jmx.enabled:true}") final boolean jmxEnabled) {
    log.info("Configuring Jetty server.");
    final JettyEmbeddedServletContainerFactory factory = new JettyEmbeddedServletContainerFactory(port);
    factory.addServerCustomizers(server -> {
        final QueuedThreadPool threadPool = server.getBean(QueuedThreadPool.class);
        threadPool.setMinThreads(minThreads);
        threadPool.setMaxThreads(maxThreads);
        threadPool.setIdleTimeout(idleTimeout);
        log.info("Server thread pool config:  " + server.getThreadPool());
        // Jetty JMX config.
        if (jmxEnabled) {
            log.info("Exposing Jetty managed beans to the JMX platform server.");
            server.addBean(new MBeanContainer(ManagementFactory.getPlatformMBeanServer()));
        }
    });
    return factory;
}
 
開發者ID:oneops,項目名稱:secrets-proxy,代碼行數:34,代碼來源:EmbeddedServerConfig.java

示例2: beforeClass

import org.eclipse.jetty.jmx.MBeanContainer; //導入依賴的package包/類
@BeforeClass
public static void beforeClass() throws Exception {
	ccowServer = new Server(serverPort);

	final CCOWContextListener c = new CCOWContextListener(commonContext, new InlinedContextAgentRepositoryModule());

	final MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
	ccowServer.addBean(mbContainer);

	final ServletContextHandler webSocketServletContextHandler = new ServletContextHandler(ccowServer, "/ws",
			ServletContextHandler.SESSIONS);
	webSocketServletContextHandler.addEventListener(c);
	WebSocketServerContainerInitializer.configureContext(webSocketServletContextHandler);

	final ServletContextHandler restServletContextHandler = new ServletContextHandler(ccowServer, "/");
	restServletContextHandler.addEventListener(c);
	restServletContextHandler.addFilter(AppGuiceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));

	 final ContextHandlerCollection contexts = new ContextHandlerCollection();
        contexts.setHandlers(new Handler[] { webSocketServletContextHandler, restServletContextHandler});
        
	ccowServer.setHandler(contexts);
	ccowServer.start();

}
 
開發者ID:jkiddo,項目名稱:ccow,代碼行數:26,代碼來源:WebSocketsTestSuite.java

示例3: init

import org.eclipse.jetty.jmx.MBeanContainer; //導入依賴的package包/類
@Override
public void init(ComponentRepository repo, LinkedHashMap<String, String> configuration) throws Exception {
  if (isActive() == false) {
    return;
  }
  
  Server server = initJettyServer(repo);
  
  // JMX
  final MBeanServer jmxServer = repo.findInstance(MBeanServer.class);
  if (jmxServer != null) {
    MBeanContainer jettyJmx = new MBeanContainer(jmxServer);
    server.getContainer().addEventListener(jettyJmx);
    server.addBean(jettyJmx);
  }
  // basic RESTful helpers
  registerJettyRestBasics(repo);
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:19,代碼來源:EmbeddedJettyComponentFactory.java

示例4: RestfulServer

import org.eclipse.jetty.jmx.MBeanContainer; //導入依賴的package包/類
public RestfulServer(boolean loopback,
    int port,
    String applicationName,
    boolean sslEnabled,
    String keyStoreAlias,
    String keyStorePassword,
    String keyStorePath,
    int maxNumberOfThreads,
    int maxQueuedRequests) {

    this.applicationName = applicationName;
    int maxThreads = maxNumberOfThreads + ACCEPTORS + SELECTORS;
    BlockingArrayQueue<Runnable> queue = new BlockingArrayQueue<>(MIN_THREADS, MIN_THREADS, maxQueuedRequests);
    this.queuedThreadPool = new QueuedThreadPool(maxThreads, MIN_THREADS, IDLE_TIMEOUT, queue);
    this.server = new Server(queuedThreadPool);
    this.handlers = new ContextHandlerCollection();

    server.addEventListener(new MBeanContainer(ManagementFactory.getPlatformMBeanServer()));
    server.setHandler(handlers);

    if (sslEnabled) {
        server.addConnector(makeSslConnector(keyStoreAlias, keyStorePassword, keyStorePath, port));
    } else {
        server.addConnector(makeConnector(loopback, port));
    }
}
 
開發者ID:jivesoftware,項目名稱:routing-bird,代碼行數:27,代碼來源:RestfulServer.java

示例5: main

import org.eclipse.jetty.jmx.MBeanContainer; //導入依賴的package包/類
public static void main( String[] args )throws Exception{
	//if there is more than 1 argument the second is the path to use
	//default is fhis-test
	String path = "/"+ ((args.length >1)?args[1]:"fhir-test");
	System.out.println("path "+path);
	
	Server server = new Server(8080);
    MBeanContainer mbContainer = new MBeanContainer(
            ManagementFactory.getPlatformMBeanServer());
    server.addBean(mbContainer);
    server.setAttribute("org.eclipse.jetty.server.Request.maxFormContentSize", -1);
    WebAppContext webapp = new WebAppContext();
    webapp.setContextPath(path);
    //first argument is which war file to use
    File warFile = new File(args[0]);
   
    webapp.setWar(warFile.getAbsolutePath());
    webapp.addAliasCheck(new AllowSymLinkAliasChecker());
    server.setHandler(webapp);
	server.start();

}
 
開發者ID:amida-tech,項目名稱:hapi-launcher,代碼行數:23,代碼來源:App.java

示例6: EmbeddableJetty

import org.eclipse.jetty.jmx.MBeanContainer; //導入依賴的package包/類
public EmbeddableJetty() {
    System.setProperty("wicket.configuration", "development");

    ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(new HttpConfiguration()));
    http.setPort(PORT);
    http.setIdleTimeout(1000 * 60 * 60);

    server.addConnector(http);

    ServletContextHandler sch = new ServletContextHandler(ServletContextHandler.SESSIONS);
    FilterHolder fh2 = new FilterHolder(WicketFilter.class);
    fh2.setInitParameter(ContextParamWebApplicationFactory.APP_CLASS_PARAM, WicketTestApplication.class.getName());
    fh2.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*");
    sch.addFilter(fh2, "/*", EnumSet.of(DispatcherType.REQUEST, DispatcherType.ERROR));

    server.setHandler(sch);

    MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
    MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
    server.addEventListener(mBeanContainer);
    server.addBean(mBeanContainer);

}
 
開發者ID:TDC-Netdesign,項目名稱:ManagedProperties,代碼行數:24,代碼來源:EmbeddableJetty.java

示例7: start

import org.eclipse.jetty.jmx.MBeanContainer; //導入依賴的package包/類
@Override
public void start() throws Exception {
    MBeanContainer mbContainer=new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
    server.addBean(mbContainer);
    org.eclipse.jetty.webapp.Configuration.ClassList classlist = org.eclipse.jetty.webapp.Configuration.ClassList.setServerDefault(server);
    classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration");

    if (server.isStopped()) {
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    server.start();
                } catch (Exception ex) {
                    // Logged by Jetty and managed by Lifecycle listener
                }
            }
        });
        t.start();
    }
}
 
開發者ID:nordpos,項目名稱:nordpos,代碼行數:22,代碼來源:ServerApp.java

示例8: getServer

import org.eclipse.jetty.jmx.MBeanContainer; //導入依賴的package包/類
public Server getServer(int port) {
    Server server = new Server(new QueuedThreadPool(
        Util.getConfig().getInt("bard.server.threads.max", 100),
        Util.getConfig().getInt("bard.server.threads.min", 10)));

    ServerConnector connector = new ServerConnector(server,
        Util.getConfig().getInt("bard.server.acceptors", -1),
        Util.getConfig().getInt("bard.server.selectors", -1));
    connector.setPort(port);
    server.setConnectors(new Connector[] {connector});

    ServletHandler handler = new ServletHandler();
    handler.addServletWithMapping(servletClass, "/*");
    server.setHandler(handler);

    // Setup JMX
    MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
    server.addEventListener(mbContainer);
    server.addBean(mbContainer);

    // Add loggers MBean to server (will be picked up by MBeanContainer above)
    server.addBean(Log.getLog());
    return server;
}
 
開發者ID:wb14123,項目名稱:bard,代碼行數:25,代碼來源:BardServer.java

示例9: main

import org.eclipse.jetty.jmx.MBeanContainer; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
  if (args.length < 2) {
    System.out.println("Required arguments: <local_ip:port> <rtmp_host:port>");
    return;
  }
  String localAddress = StringUtils.substringBefore(args[0], ":");
  int localPort = Integer.parseInt(StringUtils.substringAfter(args[0], ":"));
  String remoteHost = StringUtils.substringBefore(args[1], ":");
  int remotePort = Integer.parseInt(StringUtils.substringAfter(args[1], ":"));
  System.out.println("Starting RTMPT proxy " + localAddress + ":" + localPort + " -> " + remoteHost + ":"
                     + remotePort);
  Server server = new Server(new InetSocketAddress(localAddress, localPort));
  MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
  server.getContainer().addEventListener(mbContainer);
  server.addBean(mbContainer);
  ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
  context.setContextPath("/");
  server.setHandler(context);

  RtmptServlet.remoteHost = remoteHost;
  RtmptServlet.remotePort = remotePort;
  context.addServlet(new ServletHolder(new RtmptServlet()), "/*");
  server.start();
  server.join();

}
 
開發者ID:lindenbaum,項目名稱:rtmpt-proxy,代碼行數:27,代碼來源:RtmptProxy.java

示例10: customizeJetty

import org.eclipse.jetty.jmx.MBeanContainer; //導入依賴的package包/類
@Override
void customizeJetty(JettyEmbeddedServletContainerFactory container) {
    container.addServerCustomizers(server -> {
        MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
        server.addEventListener(mbContainer);
        server.addBean(mbContainer);
    });
}
 
開發者ID:amvnetworks,項目名稱:amv-access-api-poc,代碼行數:9,代碼來源:JettyJmxCustomizer.java

示例11: compose

import org.eclipse.jetty.jmx.MBeanContainer; //導入依賴的package包/類
public static void compose(Server server) {
    //Servlets + Guice
    ServletContextHandler servletContextHandler = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS);
    servletContextHandler.addFilter(GuiceFilter.class, "/*", EnumSet.allOf(DispatcherType.class));
    servletContextHandler.addServlet(DefaultServlet.class, "/");

    //JMX stuff...
    MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
    server.addEventListener(mbContainer);
    server.addBean(mbContainer);
    server.addBean(Log.getLog());
}
 
開發者ID:Sixt,項目名稱:ja-micro,代碼行數:13,代碼來源:JettyComposer.java

示例12: main

import org.eclipse.jetty.jmx.MBeanContainer; //導入依賴的package包/類
public static void main(final String[] args) throws Exception {

		// This test server exposes the CCOW ContextManager according to the
		// HTTP Web bindings and exposes the ContextParticipant notification
		// part through Websockets.

		// Connect to the server at
		// ws://host:serverPort/ws/ContextManager/{unique-client-id}

		// All invocations on ContextParticipants that the ContextManager does
		// according to the HTTP Web bindings spec will also be done to the
		// Websocket client (see ccow.cma.IContextParticipant for procedures
		// that are invoked). As
		// ContextParticipant.ContextChangedPending return values the
		// connected Websocket client will have a max of 5 seconds to respond
		// accordingly.

		server = new Server(2116);
		final CCOWContextListener servletContextListener = new CCOWContextListener();

		final MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
		server.addBean(mbContainer);

		final ServletContextHandler webSocketServletContextHandler = new ServletContextHandler(server, "/ws",
				ServletContextHandler.SESSIONS);
		webSocketServletContextHandler.addEventListener(servletContextListener);
		WebSocketServerContainerInitializer.configureContext(webSocketServletContextHandler);

		final ServletContextHandler restServletContextHandler = new ServletContextHandler(server, "/");
		restServletContextHandler.addEventListener(servletContextListener);
		restServletContextHandler.addFilter(AppGuiceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));

		final ContextHandlerCollection contexts = new ContextHandlerCollection();
		contexts.setHandlers(new Handler[] { webSocketServletContextHandler, restServletContextHandler });
		
		server.setHandler(contexts);
		server.start();
		server.join();
	}
 
開發者ID:jkiddo,項目名稱:ccow,代碼行數:40,代碼來源:EmbeddedJettyInstance.java

示例13: main

import org.eclipse.jetty.jmx.MBeanContainer; //導入依賴的package包/類
public static void main(final String[] args) throws Exception {

		// This test server exposes the CCOW ContextManager according to the
		// HTTP Web bindings and exposes the ContextParticipant notification
		// part through Websockets.

		// Connect to the server at
		// ws://host:serverPort/ws/ContextManager/{unique-client-id}

		// All invocations on ContextParticipants that the ContextManager does
		// according to the HTTP Web bindings spec will also be done to the
		// Websocket client (see ccow.cma.IContextParticipant for procedures
		// that are invoked). As
		// ContextParticipant.ContextChangedPending return values the
		// connected Websocket client will have a max of 5 seconds to respond
		// accordingly.

		final Server server = new Server(2116);
		final ContextState commonState = new ContextState();
		final CCOWContextListener servletContextListener = new CCOWContextListener(commonState);

		final MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
		server.addBean(mbContainer);

		final ServletContextHandler webSocketServletContextHandler = new ServletContextHandler(server, "/ws",
				ServletContextHandler.SESSIONS);
		webSocketServletContextHandler.addEventListener(servletContextListener);
		WebSocketServerContainerInitializer.configureContext(webSocketServletContextHandler);

		final ServletContextHandler restServletContextHandler = new ServletContextHandler(server, "/");
		restServletContextHandler.addEventListener(servletContextListener);
		restServletContextHandler.addFilter(AppGuiceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));

		final ContextHandlerCollection contexts = new ContextHandlerCollection();
		contexts.setHandlers(new Handler[] { webSocketServletContextHandler, restServletContextHandler });

		server.setHandler(contexts);
		server.start();
		server.join();
	}
 
開發者ID:jkiddo,項目名稱:ccow,代碼行數:41,代碼來源:EmbeddedJettyTester.java

示例14: enableJmx

import org.eclipse.jetty.jmx.MBeanContainer; //導入依賴的package包/類
private void enableJmx(Server server) {
    MBeanContainer containerToRegister = getMbContainer();
    if (containerToRegister != null) {
        LOG.info("Jetty JMX Extensions is enabled");
        addServerMBean(server);
        // Since we may have many Servers running, don't tie the MBeanContainer
        // to a Server lifecycle or we end up closing it while it is still in use.
        //server.addBean(mbContainer);
    }
}
 
開發者ID:nkasvosve,項目名稱:beyondj,代碼行數:11,代碼來源:JettyHttpComponent.java

示例15: run

import org.eclipse.jetty.jmx.MBeanContainer; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void run(@NonNull T configuration, @NonNull Environment environment) {
    finishBinding();
    // Bridge into Jersey's locator
    environment.jersey().register(new AbstractBinder() {
        @Override
        protected void configure() {
            bind(getLocator()).to(ServiceLocator.class).named(SERVICE_LOCATOR);
        }
    });
    // Make the service locator available to the admin context too.
    environment.getAdminContext().setAttribute(SERVICE_LOCATOR, getLocator());
    // Finish configuring HK2 when Jetty starts (after the Application.run() method)
    environment.lifecycle().addLifeCycleListener(new AbstractLifeCycleListener() {
        @Override
        public void lifeCycleStarting(LifeCycle event) {
            if (event instanceof Server) {
                finishBinding();
                ServiceLocatorUtilities.addOneConstant(getLocator(), event, null, Server.class);
                immediateController.setImmediateState(ImmediateServiceState.RUNNING);
                ((Server) event).addBean(mBeanContainer);
                ((Server) event).addBean(new ManagedMBeanContainer(mBeanContainer));
            }
        }
    });
    ServiceLocatorUtilities.bind(getLocator(), new EnvironmentBinder<>(bootstrap, configuration, environment));
    ServiceLocatorUtilities.bind(getLocator(), new HK2MetricBinder());
    ServiceLocatorUtilities.bind(getLocator(), new BundleBinder(bootstrap));
    ServiceLocatorUtilities.addOneConstant(getLocator(), mBeanContainer, null, MBeanContainer.class);
    // Register Jersey components to activate injectable dropwizard components when Jersey starts up
    environment.jersey().register(HK2BridgeFeature.class);
    environment.jersey().register(HealthCheckActivator.class);
    environment.jersey().register(MetricActivator.class);
    environment.jersey().register(LifeCycleActivator.class);
    environment.jersey().register(TaskActivator.class);
    autoBind(MBeanActivator.class);
}
 
開發者ID:baharclerode,項目名稱:dropwizard-hk2,代碼行數:39,代碼來源:HK2Bundle.java


注:本文中的org.eclipse.jetty.jmx.MBeanContainer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。