本文整理汇总了Java中org.glassfish.jersey.servlet.ServletProperties类的典型用法代码示例。如果您正苦于以下问题:Java ServletProperties类的具体用法?Java ServletProperties怎么用?Java ServletProperties使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServletProperties类属于org.glassfish.jersey.servlet包,在下文中一共展示了ServletProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.glassfish.jersey.servlet.ServletProperties; //导入依赖的package包/类
@Override
public void run(Environment environment) {
ServiceLocatorUtilities.bind(serviceLocator, new EnvBinder(application, environment));
LifecycleEnvironment lifecycle = environment.lifecycle();
AdminEnvironment admin = environment.admin();
listServices(HealthCheck.class).forEach(healthCheck -> {
String name = healthCheck.getClass().getSimpleName();
environment.healthChecks().register(name, healthCheck);
});
listServices(Managed.class).forEach(lifecycle::manage);
listServices(LifeCycle.class).forEach(lifecycle::manage);
listServices(LifeCycle.Listener.class).forEach(lifecycle::addLifeCycleListener);
listServices(ServerLifecycleListener.class).forEach(lifecycle::addServerLifecycleListener);
listServices(Task.class).forEach(admin::addTask);
environment.jersey().register(HK2LifecycleListener.class);
//Set service locator as parent for Jersey's service locator
environment.getApplicationContext().setAttribute(ServletProperties.SERVICE_LOCATOR, serviceLocator);
environment.getAdminContext().setAttribute(ServletProperties.SERVICE_LOCATOR, serviceLocator);
serviceLocator.inject(application);
}
示例2: configureBaseApplication
import org.glassfish.jersey.servlet.ServletProperties; //导入依赖的package包/类
@Override
public void configureBaseApplication(Configurable<?> config, Map<String, String> metricTags) {
// Would call this but it registers additional, unwanted exception mappers
// super.configureBaseApplication(config, metricTags);
// Instead, just copy+paste the desired parts from Application.configureBaseApplication() here:
ObjectMapper jsonMapper = getJsonMapper();
new SchemaMapper().registerToObjectMapper(jsonMapper);
JacksonMessageBodyProvider jsonProvider = new JacksonMessageBodyProvider(jsonMapper);
config.register(jsonProvider);
config.register(JsonParseExceptionMapper.class);
// Don't want to buffer rows when streaming JSON in a request to the query resource
config.property(ServerProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, 0);
if (enableQuickstartPage) {
config.property(ServletProperties.FILTER_STATIC_CONTENT_REGEX, "^/quickstart\\.html$");
}
}
示例3: registerResources
import org.glassfish.jersey.servlet.ServletProperties; //导入依赖的package包/类
public void registerResources(ServletContextHandler handler) {
ServletHolder jerseyServlet = new ServletHolder(ServletContainer.class);
jerseyServlet.setInitParameter(ServerProperties.PROVIDER_PACKAGES, getClass().getPackage().getName());
jerseyServlet.setInitParameter(
ServletProperties.JAXRS_APPLICATION_CLASS,
DisconnectedResourceConfig.class.getName()
);
handler.addServlet(jerseyServlet, SECURITY_RESOURCES);
AuthenticationResourceHandler authenticationResourceHandler =
new AuthenticationResourceHandler(getAuthentication(), false);
handler.setAttribute(DISCONNECTED_SSO_AUTHENTICATION_HANDLER_ATTR, authenticationResourceHandler);
handler.setAttribute(DISCONNECTED_SSO_SERVICE_ATTR, getSsoService());
ServletHolder login = new ServletHolder(new DisconnectedLoginServlet((DisconnectedSSOService) getSsoService()));
handler.addServlet(login, DisconnectedLoginServlet.URL_PATH);
ServletHolder logout = new ServletHolder(new DisconnectedLogoutServlet((DisconnectedSSOService) getSsoService()));
handler.addServlet(logout, DisconnectedLogoutServlet.URL_PATH);
}
示例4: provideJersey
import org.glassfish.jersey.servlet.ServletProperties; //导入依赖的package包/类
@Provides(type = Type.SET)
ContextConfigurator provideJersey() {
return new ContextConfigurator() {
@Override
public void init(ServletContextHandler context) {
// REST API that requires authentication
ServletHolder protectedRest = new ServletHolder(new ServletContainer());
protectedRest.setInitParameter(
ServerProperties.PROVIDER_PACKAGES, SWAGGER_PACKAGE + "," +
RestAPI.class.getPackage().getName()
);
protectedRest.setInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS, RestAPIResourceConfig.class.getName());
context.addServlet(protectedRest, "/rest/*");
// REST API that it does not require authentication
ServletHolder publicRest = new ServletHolder(new ServletContainer());
publicRest.setInitParameter(ServerProperties.PROVIDER_PACKAGES, PublicRestAPI.class.getPackage().getName());
publicRest.setInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS, RestAPIResourceConfig.class.getName());
context.addServlet(publicRest, "/public-rest/*");
}
};
}
示例5: JerseyConfig
import org.glassfish.jersey.servlet.ServletProperties; //导入依赖的package包/类
/**
* In constructor we can define Jersey Resources & Other Components
*/
public JerseyConfig() {
/*
* Jersey will automatically register class with @provider, @Component by scanning
* these packages + nested packages
*/
packages("in.geekmj.resource", "in.geekmj.config");
/* CustomTypeParamterConsumeResource auto scanned and register */
//register(CustomTypeParamterConsumeResource.class);
register(MatrixUriResource.class);
register(RequestCookiesResource.class);
register(RequestHeaderResource.class);
register(RequestParameterResource.class);
register(EmployeeResource.class);
register(HumansResource.class);
register(HelloWorldResource.class);
property(ServletProperties.FILTER_FORWARD_ON_404, true);
register(MultiPartFeature.class);
register(JsonPayloadResource.class);
}
示例6: HttpConfiguration
import org.glassfish.jersey.servlet.ServletProperties; //导入依赖的package包/类
public HttpConfiguration(@NonNull List<HttpModule> httpModules) {
register(HostPreMatchingRequestFilter.class);
register(WebApplicationExceptionMapper.class);
property(ServletProperties.FILTER_STATIC_CONTENT_REGEX, "/(robots.txt|(assets|webjars)/.*)");
property(ServerProperties.WADL_FEATURE_DISABLE, true);
httpModules.forEach(module -> module.initialize(this));
}
示例7: jerseyApplicationConfig
import org.glassfish.jersey.servlet.ServletProperties; //导入依赖的package包/类
@Bean
public ResourceConfig jerseyApplicationConfig() {
ResourceConfig resourceConfig = new ResourceConfig();
if (configurationProperties.isForwardOn404()) {
resourceConfig.property(ServletProperties.FILTER_FORWARD_ON_404, true);
}
return resourceConfig;
}
示例8: jerseyServlet
import org.glassfish.jersey.servlet.ServletProperties; //导入依赖的package包/类
@Bean
public ServletRegistrationBean jerseyServlet() {
ServletRegistrationBean registration = new ServletRegistrationBean(new ServletContainer(), "/rest/*");
// our rest resources will be available in the path /rest/*
registration.addInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS, JerseyConfig.class.getName());
return registration;
}
示例9: jerseyFilterRegistration
import org.glassfish.jersey.servlet.ServletProperties; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(name = "jerseyFilterRegistration")
@ConditionalOnProperty(prefix = "spring.jersey", name = "type", havingValue = "filter")
public FilterRegistrationBean jerseyFilterRegistration() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(new ServletContainer(this.config));
registration.setUrlPatterns(Arrays.asList(this.path));
registration.setOrder(this.jersey.getFilter().getOrder());
registration.addInitParameter(ServletProperties.FILTER_CONTEXT_PATH,
stripPattern(this.path));
addInitParameters(registration);
registration.setName("jerseyFilter");
registration.setDispatcherTypes(EnumSet.allOf(DispatcherType.class));
return registration;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:16,代码来源:JerseyAutoConfiguration.java
示例10: JerseyConfig
import org.glassfish.jersey.servlet.ServletProperties; //导入依赖的package包/类
public JerseyConfig() {
registerProviders();
registerFilters();
registerControllers();
register(MultiPartFeature.class);
property(ServletProperties.FILTER_STATIC_CONTENT_REGEX, "/_mockenize/admin.*");
}
示例11: onStart
import org.glassfish.jersey.servlet.ServletProperties; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void onStart() {
super.onStart();
final URI baseUri = UriBuilder
.fromUri(configContext().config().jersey().baseUri())
.build();
server = createServer(baseUri);
ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
servletContextHandler.getServletContext().setAttribute(ServletProperties.SERVICE_LOCATOR, serviceLocator());
servletContextHandler.setContextPath(baseUri.getPath());
ServletHolder jerseyServletHolder = new ServletHolder(new ServletContainer(resourceConfig()));
jerseyServletHolder.setInitOrder(0);
servletContextHandler.addServlet(jerseyServletHolder, "/*");
server.setHandler(servletContextHandler);
wrapChecked(
() -> {
server.start();
return null;
},
"Jersey/Jetty server failed to start");
if (configContext().config().jersey().joinServerThread()) {
try {
server.join();
} catch (InterruptedException e) {
LOGGER.info("Jersey/Jetty server interrupted", e);
}
}
}
示例12: MotdApplication
import org.glassfish.jersey.servlet.ServletProperties; //导入依赖的package包/类
public MotdApplication() {
// scan com.gluonhq package for jax-rs classes
packages(true, "com.gluonhq");
// everything inside /webjars should not be handled by the jax-rs application
property(ServletProperties.FILTER_STATIC_CONTENT_REGEX, "/webjars/.*");
// use freemarker for web templating
register(FreemarkerMvcFeature.class);
property(FreemarkerMvcFeature.TEMPLATE_BASE_PATH, "freemarker");
}
示例13: setup
import org.glassfish.jersey.servlet.ServletProperties; //导入依赖的package包/类
public void setup() throws Exception {
singletons.add(new InternalExceptionMapper());
test = new JerseyTest() {
@Override
protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
return new InMemoryTestContainerFactory();
}
@Override
protected DeploymentContext configureDeployment() {
final DropwizardResourceConfig resourceConfig = new DropwizardResourceConfig();
for (Object singleton : singletons) {
resourceConfig.register(singleton);
}
ServletDeploymentContext deploymentContext = ServletDeploymentContext.builder(resourceConfig)
.initParam(ServletProperties.JAXRS_APPLICATION_CLASS, DropwizardResourceConfig.class.getName())
.build();
return deploymentContext;
}
@Override
protected void configureClient(ClientConfig config) {
JacksonJsonProvider jsonProvider = new JacksonJsonProvider();
jsonProvider.setMapper(Jackson.newObjectMapper());
config.register(jsonProvider);
}
};
test.setUp();
}
示例14: getResourceConfig
import org.glassfish.jersey.servlet.ServletProperties; //导入依赖的package包/类
private ResourceConfig getResourceConfig(Application application) {
ResourceConfig resourceConfig = ResourceConfig.forApplication(application);
resourceConfig.register(JacksonFeature.class);
resourceConfig.register(RolesAllowedDynamicFeature.class);
applicationCustomizers.forEach(c -> c.customize(resourceConfig));
Map<String, Object> props = new HashMap<>(resourceConfig.getProperties());
props.put(ServletProperties.FILTER_FORWARD_ON_404, "true");
resourceConfig.setProperties(props);
return resourceConfig;
}
示例15: jerseyServlet
import org.glassfish.jersey.servlet.ServletProperties; //导入依赖的package包/类
@Bean
public ServletRegistrationBean jerseyServlet() throws ServletException {
ServletContainer servlet = new ServletContainer();
ServletRegistrationBean registration = new ServletRegistrationBean(servlet, "/server/*");
registration.addInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS, JerseyConfig.class.getName());
return registration;
}