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