本文整理汇总了Java中com.sun.grizzly.http.SelectorThread类的典型用法代码示例。如果您正苦于以下问题:Java SelectorThread类的具体用法?Java SelectorThread怎么用?Java SelectorThread使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SelectorThread类属于com.sun.grizzly.http包,在下文中一共展示了SelectorThread类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runServer
import com.sun.grizzly.http.SelectorThread; //导入依赖的package包/类
private static void runServer(RefAppConfigurator configurator) throws IOException, InterruptedException {
URI baseUri = UriBuilder.fromUri("http://localhost/").port(configurator.getServerPort()).build();
Map<String, String> params = new HashMap<String, String>();
params.put("com.sun.jersey.config.property.packages", "com.comcast.xfinity.sirius.refapplication.endpoints");
SelectorThread thread = GrizzlyWebContainerFactory.create(baseUri, params);
System.out.println();
System.out.println("Server fired up, using akka over TCP. Akka address for this server:");
System.out.println(configurator.getAkkaPath());
System.out.println("Hit ctrl-c to quit.");
try {
while (true) {
// put the local thread to sleep, let grizzly do its thing
Thread.sleep(1000L);
}
} finally {
thread.stopEndpoint();
}
}
示例2: main
import com.sun.grizzly.http.SelectorThread; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
// TODO(markf): Eventually we'll figure out how to appropriately start and stop the server when
// it's run in a production environment. For now, just kill the process
CmdLineParser cmdLineParser = new CmdLineParser(commandLineOptions);
try {
cmdLineParser.parseArgument(args);
} catch (CmdLineException e) {
LOG.severe(e.getMessage());
cmdLineParser.printUsage(System.err);
System.exit(1);
}
// Now that the command line options have been processed, we can create the buildExecutor.
buildExecutor = new NonQueuingExecutor(commandLineOptions.maxSimultaneousBuilds);
int port = commandLineOptions.port;
SelectorThread threadSelector = GrizzlyServerFactory.create("http://localhost:" + port + "/");
String hostAddress = InetAddress.getLocalHost().getHostAddress();
LOG.info("App Inventor Build Server - Version: " + GitBuildId.getVersion());
LOG.info("App Inventor Build Server - Git Fingerprint: " + GitBuildId.getFingerprint());
LOG.info("Running at: http://" + hostAddress + ":" + port + "/buildserver");
if (commandLineOptions.maxSimultaneousBuilds == 0) {
LOG.info("Maximum simultanous builds = unlimited!");
} else {
LOG.info("Maximum simultanous builds = " + commandLineOptions.maxSimultaneousBuilds);
}
LOG.info("Visit: http://" + hostAddress + ":" + port +
"/buildserver/health for server health");
LOG.info("Visit: http://" + hostAddress + ":" + port +
"/buildserver/vars for server values");
LOG.info("Server running");
}
示例3: startServer
import com.sun.grizzly.http.SelectorThread; //导入依赖的package包/类
protected static SelectorThread startServer() throws IOException {
final Map<String, String> initParams = new HashMap<String, String>();
initParams.put("com.sun.jersey.config.property.packages",
"com.melon");
System.out.println("Starting grizzly...");
SelectorThread threadSelector = GrizzlyWebContainerFactory.create(BASE_URI, initParams);
return threadSelector;
}
示例4: main
import com.sun.grizzly.http.SelectorThread; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
SelectorThread threadSelector = startServer();
System.out.println(String.format("Jersey app started with WADL available at "
+ "%sapplication.wadl\nHit enter to stop it...",
BASE_URI));
System.in.read();
threadSelector.stopEndpoint();
}
示例5: getSelectorThread
import com.sun.grizzly.http.SelectorThread; //导入依赖的package包/类
public static SelectorThread getSelectorThread(Class<?> applicationConfigClass,
String testServerUri, int testServerPort,
String testContextPath, String testServletPath, String[] springContextFiles, boolean enableJPA)
throws IllegalArgumentException, IOException {
final URI baseUri = UriBuilder.fromUri(testServerUri).port(testServerPort).build();
final ServletAdapter adapter = initRestTestServletAdapter(applicationConfigClass, testServerPort,
testContextPath, testServletPath, enableJPA);
adapter.addContextParameter(ContextLoader.CONFIG_LOCATION_PARAM,
StringUtils.arrayToCommaDelimitedString(springContextFiles));
return GrizzlyServerFactory.create(baseUri, adapter);
}
示例6: startWebServices
import com.sun.grizzly.http.SelectorThread; //导入依赖的package包/类
public static void startWebServices(final String baseUri) throws IOException, IllegalArgumentException {
final Map<String, String> initParams = new HashMap<String, String>();
initParams.put("com.sun.jersey.config.property.packages", "org.caboclo.webservices");
System.out.println("Starting backup server on " + baseUri);
SelectorThread threadSelector = GrizzlyWebContainerFactory.create(baseUri, initParams);
System.in.read();
threadSelector.stopEndpoint();
System.exit(0);
}
示例7: main
import com.sun.grizzly.http.SelectorThread; //导入依赖的package包/类
/**
* Main method.
*
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
final SelectorThread server = startServer();
System.out.println(String.format(
"Jersey app started with WADL available at "
+ "%sapplication.wadl\nHit enter to stop it...",
BASE_URI));
System.in.read();
server.stopEndpoint();
}
示例8: startServer
import com.sun.grizzly.http.SelectorThread; //导入依赖的package包/类
private static SelectorThread startServer()
throws IllegalArgumentException, IOException {
// TODO Auto-generated method stub
Map<String, String> initParams = new HashMap<String, String>();
initParams.put("com.sun.jersey.config.property.packages",
"course.cloud.computing.rest");
SelectorThread factory = GrizzlyWebContainerFactory.create(BASE_URI, initParams);
return factory;
}
示例9: setup
import com.sun.grizzly.http.SelectorThread; //导入依赖的package包/类
@Before
public void setup() {
sslConfig = mock(SSLConfig.class);
adapter = mock(Adapter.class);
springComponentProviderFactory = mock(SpringComponentProviderFactory.class);
ResourceConfig resourceConfig = mock(ResourceConfig.class);
selectorThread = mock(SelectorThread.class);
webServer = mock(GrizzlyWebServer.class);
when(webServer.getSelectorThread()).thenReturn(selectorThread);
PowerMockito.mockStatic(ContainerFactory.class);
when(ContainerFactory.createContainer(eq(Adapter.class), eq(resourceConfig), isA(SpringComponentProviderFactory.class))).thenReturn(adapter);
pisssHttpsServer = new PisssHttpsServer() {
@Override
protected GrizzlyWebServer newGrizzlyWebServer(String path) {
assertThat(path, equalTo("https://localhost:8883/"));
return webServer;
}
@Override
protected SSLConfig newSSLConfig() {
return sslConfig;
}
@Override
protected SpringComponentProviderFactory newSpringComponentProviderFactory() {
return springComponentProviderFactory;
}
};
pisssHttpsServer.setKeyStoreLocation(keystoreLocation);
pisssHttpsServer.setPassword(keystorePassword);
pisssHttpsServer.setResourceConfig(resourceConfig);
}
示例10: execute
import com.sun.grizzly.http.SelectorThread; //导入依赖的package包/类
public SelectorThread execute() throws IOException {
final Map<String, String> initParams = new HashMap<String, String>();
initParams.put("com.sun.jersey.config.property.packages",
"org.apache.zookeeper.server.jersey.resources");
System.out.println("Starting grizzly...");
SelectorThread threadSelector =
GrizzlyWebContainerFactory.create(baseUri, initParams);
return threadSelector;
}
示例11: closeSelectorThread
import com.sun.grizzly.http.SelectorThread; //导入依赖的package包/类
public static void closeSelectorThread(SelectorThread selectorThread) {
selectorThread.stopEndpoint();
}
示例12: main
import com.sun.grizzly.http.SelectorThread; //导入依赖的package包/类
public static void main(String[] args) {
// static content is linked from here
GrizzlyWebServer server = new GrizzlyWebServer(8010);
//For very slow response extractors:
SelectorThread st = server.getSelectorThread();
st.setTransactionTimeout(700000);
//create UI resources
ServletAdapter ui = new ServletAdapter();
ui.addInitParameter(
"javax.ws.rs.Application",
"fr.eurecom.hotspots.web.hypertext.RegisterUI");
ui.setServletInstance(new ServletContainer());
// REST resources
ServletAdapter api = new ServletAdapter();
api.addInitParameter(
"javax.ws.rs.Application",
"fr.eurecom.hotspots.web.api.RegisterAPI");
api.setContextPath("/api");
api.setServletInstance(new ServletContainer());
// static content adapter
ServletAdapter staticContent = new ServletAdapter("ui");
staticContent.setContextPath("/");
staticContent.setHandleStaticResources(true);
// register all above defined adapters
server.addGrizzlyAdapter(api, new String[] {"/api"});
server.addGrizzlyAdapter(staticContent, new String[] {"/"});
// let's Grizzly run
try {
server.start();
} catch (IOException e) {
e.printStackTrace();
}
}