本文整理汇总了Java中org.glassfish.jersey.server.ResourceConfig.packages方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceConfig.packages方法的具体用法?Java ResourceConfig.packages怎么用?Java ResourceConfig.packages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.glassfish.jersey.server.ResourceConfig
的用法示例。
在下文中一共展示了ResourceConfig.packages方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initApi
import org.glassfish.jersey.server.ResourceConfig; //导入方法依赖的package包/类
private void initApi() {
ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
servletHandler.setContextPath("/api");
servletHandler.getSessionHandler().setSessionManager(sessionManager);
servletHandler.addServlet(new ServletHolder(new AsyncSocketServlet()), "/socket");
ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig.registerClasses(JacksonFeature.class, ObjectMapperProvider.class, ResourceErrorHandler.class);
resourceConfig.registerClasses(SecurityRequestFilter.class, CorsResponseFilter.class);
resourceConfig.packages(ServerResource.class.getPackage().getName());
servletHandler.addServlet(new ServletHolder(new ServletContainer(resourceConfig)), "/*");
handlers.addHandler(servletHandler);
}
示例2: configure
import org.glassfish.jersey.server.ResourceConfig; //导入方法依赖的package包/类
@Override
protected Application configure() {
enable(TestProperties.LOG_TRAFFIC);
enable(TestProperties.DUMP_ENTITY);
ResourceConfig config = new ResourceConfig();
FastJsonProvider fastJsonProvider = new FastJsonProvider();
FastJsonConfig fastJsonConfig = new FastJsonConfig();
fastJsonConfig.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect, SerializerFeature.BrowserSecure);
fastJsonProvider.setFastJsonConfig(fastJsonConfig);
config.register(fastJsonProvider);
config.packages("com.alibaba.json.bvt.issue_1300");
return config;
}
示例3: configure
import org.glassfish.jersey.server.ResourceConfig; //导入方法依赖的package包/类
@Override
protected Application configure() {
enable(TestProperties.LOG_TRAFFIC);
enable(TestProperties.DUMP_ENTITY);
ResourceConfig config = new ResourceConfig();
//config.register(new FastJsonFeature()).register(FastJsonProvider.class);
config.register(new FastJsonFeature()).register(new FastJsonProvider().setPretty(true));
config.packages("com.alibaba.fastjson");
return config;
}
示例4: configure
import org.glassfish.jersey.server.ResourceConfig; //导入方法依赖的package包/类
@Override
protected Application configure() {
enable(TestProperties.LOG_TRAFFIC);
enable(TestProperties.DUMP_ENTITY);
ResourceConfig config = new ResourceConfig();
config.register(FastJsonProvider.class);
config.packages("com.alibaba.json.bvt.issue_1300");
return config;
}
示例5: configure
import org.glassfish.jersey.server.ResourceConfig; //导入方法依赖的package包/类
@Override
protected Application configure() {
enable(TestProperties.LOG_TRAFFIC);
enable(TestProperties.DUMP_ENTITY);
ResourceConfig config = new ResourceConfig();
config.register(FastJsonResolver.class);
config.register(FastJsonFeature.class);
config.packages("com.alibaba.json.bvt.issue_1300");
return config;
}
示例6: startRestServer
import org.glassfish.jersey.server.ResourceConfig; //导入方法依赖的package包/类
public static HttpServer startRestServer() {
BeanConfig beanConfig = new BeanConfig();
beanConfig.setVersion("1.0.0");
beanConfig.setTitle("SlideBar REST Interface");
beanConfig.setResourcePackage(RootResource.class.getPackage().getName());
beanConfig.setSchemes(new String[] { "http" });
beanConfig.setHost("localhost:5055");
beanConfig.setScan(true);
final ResourceConfig rc = new ResourceConfig();
rc.packages(RootResource.class.getPackage().getName());
rc.register(LoggingFeature.class);
rc.register(JacksonFeature.class);
rc.register(ApiListingResource.class);
rc.register(SwaggerSerializers.class);
rc.property(ServerProperties.WADL_FEATURE_DISABLE, true);
Logger l = Logger.getLogger("org.glassfish.grizzly.http.server.HttpHandler");
l.setLevel(Level.FINE);
l.setUseParentHandlers(false);
ConsoleHandler ch = new ConsoleHandler();
ch.setLevel(Level.ALL);
l.addHandler(ch);
try {
return GrizzlyHttpServerFactory.createHttpServer(new URI("http://localhost:5055"), rc);
} catch (URISyntaxException e) {
e.printStackTrace();
return null;
}
}
示例7: start
import org.glassfish.jersey.server.ResourceConfig; //导入方法依赖的package包/类
public void start() {
Server server = new Server(new InetSocketAddress(config.getHostname(), config.getPort()));
ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig.packages(RESOURCE_PACKAGES_TO_SCAN);
registerMetrics(resourceConfig);
ServletContainer servletContainer = new ServletContainer(resourceConfig);
ServletHolder servletHolder = new ServletHolder(servletContainer);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
context.addServlet(servletHolder, API_PREFIX);
registerMetricsServlets(context);
server.setHandler(context);
ServerContainer wscontainer;
try {
wscontainer = WebSocketServerContainerInitializer.configureContext(context);
wscontainer.addEndpoint(EventSocket.class);
} catch (ServletException | DeploymentException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
server.start();
server.join();
} catch (Exception e) {
// TODO
e.printStackTrace();
}
}
示例8: runOnSeparateThread
import org.glassfish.jersey.server.ResourceConfig; //导入方法依赖的package包/类
public void runOnSeparateThread() throws Exception {
for (String resource: resourcesToBeExtractedInDirectory) {
InputStream resourceAsStream = this.getClass().getResourceAsStream("/" + resource);
File outputFile = Paths.get(baseOutputDirectory.getAbsolutePath(), resource).toFile();
FileOutputStream fileOutputStream = FileUtils.openOutputStream(outputFile);
IOUtils.copy(resourceAsStream, fileOutputStream);
}
ResourceConfig config = new ResourceConfig();
config.packages("com.hribol.bromium.demo.app");
ServletHolder servlet = new ServletHolder(new ServletContainer(config));
server = new Server(0);
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setResourceBase(baseOutputDirectory.getAbsolutePath());
resourceHandler.setDirectoriesListed(true);
resourceHandler.setWelcomeFiles(resourcesToBeExtractedInDirectory);
ServletContextHandler context = new ServletContextHandler(server, "/*");
context.addServlet(servlet, "/*");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] {
resourceHandler,
context
});
server.setHandler(handlers);
server.start();
this.port = ((ServerConnector) server.getConnectors()[0]).getLocalPort();
logger.info("Server started on port " + port);
new Thread(() -> {
try {
server.join();
} catch (InterruptedException e) {
logger.info("Interrupted!", e);
}
}).start();
}