本文整理匯總了Java中org.glassfish.grizzly.http.server.HttpServer.shutdownNow方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpServer.shutdownNow方法的具體用法?Java HttpServer.shutdownNow怎麽用?Java HttpServer.shutdownNow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.glassfish.grizzly.http.server.HttpServer
的用法示例。
在下文中一共展示了HttpServer.shutdownNow方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
public static void main(String[] args) throws IllegalArgumentException,
NullPointerException, IOException {
HttpServer server = getServer();
Connection.init();
try {
StringBuffer sb = new StringBuffer();
sb.append("Server started\n");
sb.append("WADL at " + BASE_URI + "application.wadl\n");
sb.append("Press enter to stop the server...\n");
System.out.println(sb);
System.in.read();
} finally {
Connection.shutdown();
server.shutdownNow();
}
}
示例2: main
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
final UserRepository users = UserRepository.getInstance(true);
/* wait for shutdown ... */
HttpServer httpServer = createServer();
System.out.println(String.format(
"Jersey app started with WADL available at "
+ "%sapplication.wadl\nHit enter to stop it...",BASE_URI));
// System.out.println("Hit <return> to stop server...");
System.in.read();
httpServer.shutdownNow();
/* save state */
users.freeze();
}
示例3: main
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
/**
* Main method.
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// Start server and wait for user input to stop
final HttpServer server = startServer();
try {
server.start();
System.out.println(String.format("Jersey app started with WADL available at " + "%sapplication.wadl\n", BASE_URI));
// Wait forever (i.e. until the JVM instance is terminated externally)
Thread.currentThread().join();
} catch (Exception ioe) {
System.out.println("Error running Luzzu Communications service: " + ioe.toString());
} finally {
if(server != null && server.isStarted()) {
server.shutdownNow();
}
}
}
示例4: start
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
public void start() throws Exception {
HttpServer server = GrizzlyWebContainerFactory.create(URI.create(url));
WebappContext webapp = new WebappContext("GrizzlyContext", context);
if (servlet == null) {
servlet = DummyServlet.class;
}
if (servlet != null) {
registerServlet(webapp);
}
if (filter != null) {
registerFilter(webapp);
}
if (listener != null) {
registerListener(webapp);
}
webapp.deploy(server);
System.out.println(String.format("Jersey application started at %s\nHit enter to stop it...", url));
System.in.read();
server.shutdownNow();
}
示例5: testSimple
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
@Test
public void testSimple()
{
try
{
System.out.println("\"Hello World\" Jersey Example App");
final ResourceConfig resourceConfig = new ResourceConfig(HiApp.class);
final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, resourceConfig);
System.out.println(String.format("Application started.\nTry out %s%s\nHit enter to stop it...",
BASE_URI, ROOT_PATH));
System.in.read();
server.shutdownNow();
} catch (IOException ex)
{
Logger.getLogger(TelletsLauncher.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例6: main
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
/**
* Starts a standalone conversion server. Detailed documentation can be retrieved by invoking
* the application via the command line with the {@code -?} option.
*
* @param args The parameters for configuring this server.
*/
public static void main(String[] args) {
try {
ConverterServerBuilder builder = asBuilder(args);
HttpServer httpServer = builder.build();
Logger logger = LoggerFactory.getLogger(StandaloneServer.class);
try {
sayHello(builder, logger);
System.out.println("The documents4j server is up and running. Hit the enter key to shut it down...");
if (System.in.read() == -1) {
logger.warn("Console read terminated without receiving user input");
}
sayGoodbye(builder, logger);
} finally {
httpServer.shutdownNow();
}
System.out.println("Shut down successful. Goodbye!");
} catch (Exception e) {
LoggerFactory.getLogger(StandaloneServer.class).error("The documents4j server terminated with an unexpected error", e);
System.err.println(String.format("Error: %s", e.getMessage()));
System.err.println("Use option -? to display a list of legal commands.");
System.exit(-1);
}
}
示例7: main
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
/**
* Main method.
* @param args command line arguments
* @throws IOException Stops if I/O problem
*/
public static void main(String[] args) throws IOException {
if (Connexion.getInstance().getDbConnection() != null) {
final HttpServer server = startServer();
System.out.println(String.format("Jersey app started with WADL available at "
+ "%sapplication.wadl\nHit enter to stop it...", getBaseUri()));
System.in.read();
server.shutdownNow();
} else {
System.err.println("Unable to connect to DB");
}
}
示例8: main
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, new JerseyApplication());
System.out.println("Press any key to close");
System.in.read();
server.shutdownNow();
}
示例9: main
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
/**
* Main method.
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
String port = "8080";
if(args.length > 0 ){
port = args[0];
}
final HttpServer server = startServer(port);
System.out.println(String.format("Jersey app started with WADL available at "
+ "%sapplication.wadl\nHit enter to stop it...", uri));
System.in.read();
server.shutdownNow();
}
示例10: main
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
public static void main(String[] args) {
try {
final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, false);
// Creating a webapp context for the resources / DI container
final WebappContext webappContext = new WebappContext("Widow analyze");
webappContext.addListener(new WidowAnalyzeServletContextListener());
ServletRegistration servletRegistration = webappContext.addServlet("ServletContainer", ServletContainer.class);
servletRegistration.addMapping("/REST/*");
servletRegistration.setInitParameter("javax.ws.rs.Application",
"com.widowcrawler.analyze.startup.WidowAnalyzeResourceConfig");
final FilterRegistration registration = webappContext.addFilter("GuiceFilter", GuiceFilter.class);
registration.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), "/REST/*");
webappContext.deploy(server);
// static assets
CLStaticHttpHandler clStaticHttpHandler = new CLStaticHttpHandler(
Main.class.getClassLoader(),
"/", "/lib/", "/js/", "/css/", "/templates/");
server.getServerConfiguration().addHttpHandler(clStaticHttpHandler);
server.start();
System.out.println(String.format("Application started.\nTry out %s%s\nHit enter to stop it...",
BASE_URI, ROOT_PATH));
while(System.in.read() != 32);
server.shutdownNow();
} catch (Exception ex) {
logger.error("Error: " + ex.getMessage(), ex);
}
}
示例11: testStartup
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
@Test(timeout = TIMEOUT)
public void testStartup() throws Exception {
PortAssert.assertPortFree(port);
HttpServer httpServer = ConverterServerBuilder.builder()
.disable(MicrosoftWordBridge.class)
.disable(MicrosoftExcelBridge.class)
.enable(PseudoConverter.class)
.baseUri(String.format("http://localhost:%d", port))
.build();
PortAssert.assertPortBusy(port);
httpServer.shutdownNow();
PortAssert.assertPortFree(port);
}
示例12: startEmbeddedServer
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
static void startEmbeddedServer() throws IOException {
// Create test web application context.
WebappContext webappContext = new WebappContext("Test Context");
webappContext
.addContextInitParameter("contextClass",
"org.springframework.web.context.support.XmlWebApplicationContext");
webappContext.addContextInitParameter("contextConfigLocation",
"classpath*:spring-context.xml");
webappContext
.addListener("org.springframework.web.context.ContextLoaderListener");
// Create a servlet registration for the web application in order to wire up Spring managed collaborators to Jersey resources.
ServletRegistration servletRegistration = webappContext.addServlet(
"jersey-servlet", ServletContainer.class);
// The logging filters for server logging.
servletRegistration
.setInitParameter(
"com.sun.jersey.spi.container.ContainerResponseFilters",
"com.sun.jersey.api.container.filter.LoggingFilter");
servletRegistration.setInitParameter(
"com.sun.jersey.spi.container.ContainerRequestFilters",
"com.sun.jersey.api.container.filter.LoggingFilter");
servletRegistration.setInitParameter("javax.ws.rs.Application",
"com.test.MyDemoApplication");
servletRegistration.setInitParameter(
"com.sun.jersey.config.property.packages", "com.test");
servletRegistration.setInitParameter(
"com.sun.jersey.api.json.POJOMappingFeature", "true");
servletRegistration.addMapping("/*");
HttpServer server = new HttpServer();
NetworkListener listener = new NetworkListener("grizzly2", "localhost",
3388);
server.addListener(listener);
webappContext.deploy(server);
try {
server.start();
System.out.println("Press enter to stop the server...");
System.in.read();
} finally {
server.shutdownNow();
}
}
示例13: loadMasterList
import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
@Test
public void loadMasterList() {
System.setProperty(CONFIG_PATH, CONFIG_DIR);
System.setProperty(DDS_CONFIG_FILE_ARGNAME, DEFAULT_DDS_FILE);
// Initialize the Spring context to load our dependencies.
SpringContext sc = SpringContext.getInstance();
ApplicationContext context = sc.initContext("src/test/resources/config/AgoleManifestReaderTest.xml");
AgoleManifestReader reader = (AgoleManifestReader) context.getBean("agoleManifestReader");
reader.setTarget("http://localhost:8401/www/master.xml");
HttpServer server = GrizzlyHttpServerFactory.createHttpServer(URI.create("http://localhost:8401"));
StaticHttpHandler staticHttpHandler = new StaticHttpHandler("src/test/resources/config/www/");
server.getServerConfiguration().addHttpHandler(staticHttpHandler, "/www");
try {
server.start();
// Retrieve a copy of the centralized master topology list.
TopologyManifest master = reader.getManifest();
assertTrue(master != null);
System.out.println("Master id: " + master.getId() + ", version=" + master.getVersion());
// Test to see if the Netherlight entry is present.
assertTrue(master.getTopologyURL("urn:ogf:network:netherlight.net:2013:topology:a-gole:testbed") != null);
// We should not see a change in version.
master = reader.getManifestIfModified();
assertTrue(master == null);
}
catch (IOException | NotFoundException | JAXBException ex) {
System.err.println("Failed to load master topology list from: " + reader.getTarget());
ex.printStackTrace();
fail();
}
finally {
server.shutdownNow();
}
}