本文整理匯總了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;
}
示例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();
}
示例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);
}
示例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));
}
}
示例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();
}
示例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);
}
示例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();
}
}
示例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;
}
示例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();
}
示例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);
});
}
示例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());
}
示例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();
}
示例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();
}
示例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);
}
}
示例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);
}