【发布时间】:2015-12-01 15:45:53
【问题描述】:
我有以下课程:
package com.crawler.c_api.rest;
import com.crawler.c_api.provider.ResponseCorsFilter;
import java.util.logging.Logger;
import org.glassfish.jersey.filter.LoggingFilter;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.ServerProperties;
public class ApplicationResource extends ResourceConfig {
private static final Logger LOGGER = null;
public ServiceXYZ pipeline;
public ApplicationResource() {
System.out.println("iansdiansdasdasds");
// Register resources and providers using package-scanning.
packages("com.crawler.c_api");
// Register my custom provider - not needed if it's in my.package.
register(ResponseCorsFilter.class);
pipeline=new ServiceXYZ();
//Register stanford
/*Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
pipeline = new StanfordCoreNLP(props);*/
// Register an instance of LoggingFilter.
register(new LoggingFilter(LOGGER, true));
// Enable Tracing support.
property(ServerProperties.TRACING, "ALL");
}
}
我想让变量管道在整个应用程序中持续存在,这样我就可以初始化服务一次并在每个其他类中使用它。
我该怎么做?
【问题讨论】:
标签: java rest jersey jersey-2.0