本文整理汇总了Java中io.dropwizard.jetty.MutableServletContextHandler类的典型用法代码示例。如果您正苦于以下问题:Java MutableServletContextHandler类的具体用法?Java MutableServletContextHandler怎么用?Java MutableServletContextHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MutableServletContextHandler类属于io.dropwizard.jetty包,在下文中一共展示了MutableServletContextHandler类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getPort
import io.dropwizard.jetty.MutableServletContextHandler; //导入依赖的package包/类
public int getPort(Environment environment) {
int defaultPort = 9090;
MutableServletContextHandler h = environment.getApplicationContext();
if (h == null) {
return defaultPort;
}
Server s = h.getServer();
if (s == null) {
return defaultPort;
}
Connector[] c = s.getConnectors();
if (c != null && c.length > 0) {
AbstractNetworkConnector anc = (AbstractNetworkConnector) c[0];
if (anc != null) {
return anc.getLocalPort();
}
}
return defaultPort;
}
开发者ID:karamelchef,项目名称:karamel,代码行数:20,代码来源:KaramelServiceApplication.java
示例2: start
import io.dropwizard.jetty.MutableServletContextHandler; //导入依赖的package包/类
@Override
public void start() throws Exception {
for (MutableServletContextHandler environment : listeners.keySet()) {
final SessionHandler sessionHandler = environment.getSessionHandler();
if (sessionHandler == null) {
final String msg = String.format(
"Can't register session listeners for %s because sessions support is not enabled: %s",
environment.getDisplayName().toLowerCase(),
Joiner.on(',').join(listeners.get(environment).stream()
.map(it -> FeatureUtils.getInstanceClass(it).getSimpleName())
.collect(Collectors.toList())));
if (failWithoutSession) {
throw new IllegalStateException(msg);
} else {
logger.warn(msg);
}
} else {
listeners.get(environment).forEach(sessionHandler::addEventListener);
}
}
}
开发者ID:xvik,项目名称:dropwizard-guicey,代码行数:22,代码来源:SessionListenersSupport.java
示例3: run
import io.dropwizard.jetty.MutableServletContextHandler; //导入依赖的package包/类
@Override
public void run(Environment environment) {
MutableServletContextHandler applicationContext = environment.getApplicationContext();
FilterHolder filterHolder = applicationContext
.addFilter(CrossOriginFilter.class, "/*", EnumSet.allOf(DispatcherType.class));
filterHolder.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*");
filterHolder.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "X-Requested-With,Content-Type,Accept,Origin");
filterHolder.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET,HEAD");
filterHolder.setInitParameter(CrossOriginFilter.ALLOW_CREDENTIALS_PARAM, "false");
}
开发者ID:openregister,项目名称:openregister-java,代码行数:12,代码来源:CorsBundle.java
示例4: initialize
import io.dropwizard.jetty.MutableServletContextHandler; //导入依赖的package包/类
public WebsocketContainer initialize(WebsocketConfiguration configuration,
MutableServletContextHandler contextHandler) {
try {
return new WebsocketContainer(configuration, WebSocketServerContainerInitializer.configureContext(contextHandler));
} catch (Exception e) {
throw new IllegalStateException("Could not initialize contexthandler to enable Websockets", e);
}
}
开发者ID:TomCools,项目名称:dropwizard-websocket-jee7-bundle,代码行数:9,代码来源:WebsocketContainerInitializer.java
示例5: configureContext
import io.dropwizard.jetty.MutableServletContextHandler; //导入依赖的package包/类
public static ServerContainer configureContext(final MutableServletContextHandler context, final MetricRegistry metrics) throws ServletException {
WebSocketUpgradeFilter filter = WebSocketUpgradeFilter.configureContext(context);
NativeWebSocketConfiguration wsConfig = filter.getConfiguration();
ServerContainer wsContainer = new ServerContainer(wsConfig, context.getServer().getThreadPool());
EventDriverFactory edf = wsConfig.getFactory().getEventDriverFactory();
edf.clearImplementations();
edf.addImplementation(new InstJsrServerEndpointImpl(metrics));
edf.addImplementation(new InstJsrServerExtendsEndpointImpl(metrics));
context.addBean(wsContainer);
context.setAttribute(javax.websocket.server.ServerContainer.class.getName(), wsContainer);
context.setAttribute(WebSocketUpgradeFilter.class.getName(), filter);
return wsContainer;
}
开发者ID:LivePersonInc,项目名称:dropwizard-websockets,代码行数:16,代码来源:InstWebSocketServerContainerInitializer.java
示例6: configure
import io.dropwizard.jetty.MutableServletContextHandler; //导入依赖的package包/类
private void configure(final MutableServletContextHandler environment, final EventListener listener,
final boolean context, final boolean session) {
if (session) {
support.add(environment, listener);
}
if (context) {
environment.addEventListener(listener);
}
}
开发者ID:xvik,项目名称:dropwizard-guicey,代码行数:10,代码来源:WebListenerInstaller.java
示例7: init
import io.dropwizard.jetty.MutableServletContextHandler; //导入依赖的package包/类
@Before
public void init() {
when(containerInitializer.initialize(any(WebsocketConfiguration.class), any(MutableServletContextHandler.class))).thenReturn(container);
when(endpointRegistration.getRegisteredEndpoints()).thenReturn(endpoints);
}
开发者ID:TomCools,项目名称:dropwizard-websocket-jee7-bundle,代码行数:6,代码来源:WebsocketHandlerTest.java
示例8: getApplicationContext
import io.dropwizard.jetty.MutableServletContextHandler; //导入依赖的package包/类
public MutableServletContextHandler getApplicationContext() {
return this.environment.getApplicationContext();
}
开发者ID:rvs-fluid-it,项目名称:microservice-bundle,代码行数:4,代码来源:µsEnvironment.java
示例9: getAdminContext
import io.dropwizard.jetty.MutableServletContextHandler; //导入依赖的package包/类
public MutableServletContextHandler getAdminContext() {
return this.environment.getAdminContext();
}
开发者ID:rvs-fluid-it,项目名称:microservice-bundle,代码行数:4,代码来源:µsEnvironment.java
示例10: createAppServlet
import io.dropwizard.jetty.MutableServletContextHandler; //导入依赖的package包/类
@Override
protected Handler createAppServlet(Server server,
JerseyEnvironment jersey,
ObjectMapper objectMapper,
Validator validator,
MutableServletContextHandler handler,
@Nullable Servlet jerseyContainer,
MetricRegistry metricRegistry) {
if (jerseyContainer != null) {
jersey.register(new LoggingExceptionMapper<Throwable>() {
@Override
public Response toResponse(Throwable exception) {
final int status;
final StatusEntity statusEntity;
if (exception instanceof WebApplicationException) {
final Response response = ((WebApplicationException) exception).getResponse();
if (response.getStatusInfo().getFamily().equals(Response.Status.Family.SERVER_ERROR)) {
logException(exception);
}
status = response.getStatus();
statusEntity = new StatusEntity(status, new StatusMessage(µService.WEB_APPLICATION_ERROR, exception.getLocalizedMessage()));
} else {
final long id = logException(exception);
status = Response.Status.INTERNAL_SERVER_ERROR.getStatusCode();
StatusMessage message = new StatusMessage(StatusMessage.Type.ERROR, String.format("%016x", id), µService.INTERNAL_SERVER_ERROR, formatErrorMessage(id, exception), null);
statusEntity = new StatusEntity(status, message);
}
return Response.status(status)
.type(MediaType.APPLICATION_JSON_TYPE)
.entity(statusEntity)
.build();
}
});
jersey.register(new ConstraintViolationExceptionMapper());
jersey.register(new JsonProcessingExceptionMapper());
jersey.register(new EarlyEofExceptionMapper());
}
Handler appServlet = super.createAppServlet(server, jersey, objectMapper, validator, handler, jerseyContainer, metricRegistry);
return appServlet;
}
开发者ID:rvs-fluid-it,项目名称:microservice-bundle,代码行数:43,代码来源:µServiceFactory.java
示例11: add
import io.dropwizard.jetty.MutableServletContextHandler; //导入依赖的package包/类
public void add(final MutableServletContextHandler environment, final EventListener listener) {
listeners.put(environment, listener);
}
开发者ID:xvik,项目名称:dropwizard-guicey,代码行数:4,代码来源:SessionListenersSupport.java
示例12: nameContext
import io.dropwizard.jetty.MutableServletContextHandler; //导入依赖的package包/类
private void nameContext(final MutableServletContextHandler context, final String name) {
if (context.getDisplayName() == null) {
context.setDisplayName(name);
}
}
开发者ID:xvik,项目名称:dropwizard-guicey,代码行数:6,代码来源:WebInstallersBundle.java
示例13: setupJettySession
import io.dropwizard.jetty.MutableServletContextHandler; //导入依赖的package包/类
/**
* Override if needed, but prefer to exploit
* {@link Pac4jFactory#setSessionEnabled(boolean)} first.
*
* @param environment
* the dropwizard {@link Environment}
* @since 1.1.0
*/
protected void setupJettySession(Environment environment) {
MutableServletContextHandler contextHandler = environment
.getApplicationContext();
if (contextHandler.getSessionHandler() == null) {
contextHandler.setSessionHandler(new SessionHandler());
}
}
开发者ID:pac4j,项目名称:dropwizard-pac4j,代码行数:16,代码来源:Pac4jBundle.java
注:本文中的io.dropwizard.jetty.MutableServletContextHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论