当前位置: 首页>>代码示例>>Java>>正文


Java Server.stop方法代码示例

本文整理汇总了Java中org.eclipse.jetty.server.Server.stop方法的典型用法代码示例。如果您正苦于以下问题:Java Server.stop方法的具体用法?Java Server.stop怎么用?Java Server.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jetty.server.Server的用法示例。


在下文中一共展示了Server.stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: stopServer

import org.eclipse.jetty.server.Server; //导入方法依赖的package包/类
@Override
public void stopServer(final int port) {
	for (final int localPort : (-1 == port ? getAllRunningServerPorts() : singletonList(port))) {
		if (isRunning(localPort)) {
			try {
				final Server server = serverCache.getIfPresent(localPort);
				if (null != server) {
					server.stop();
					if (server.isStopped()) {
						LOGGER.info("Jetty instance has successfully stopped on '" + localPort + "'.");
						serverCache.invalidate(localPort);
					} else {
						LOGGER.warn("Unexpected behavior while shutting down Jetty on '" + localPort
								+ "'. Termination failed.");
					}
				}
			} catch (final Exception e) {
				LOGGER.error("Error while stopping Jetty server on '" + localPort + "'.", e);
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:23,代码来源:JettyManager.java

示例2: restartWebServer

import org.eclipse.jetty.server.Server; //导入方法依赖的package包/类
private static void restartWebServer(final Server server, final WebAppContext webApp) throws Exception {

        //TODO reconsider restart function
        /*
          restart doesnt help much regarding heap configuration, everything else can be configured at
          runtime. So better approach for convenient restart would be an orderly shutdown and start.
         */
        server.stop();
        LOG.info("Sent stop");
        server.join();
        LOG.info("Server joined");
        LOG.info("Starting web server");
        server.setHandler(webApp);
        server.start();
        LOG.info("Server restarted");
    }
 
开发者ID:gmuecke,项目名称:boutique-de-jus,代码行数:17,代码来源:BoutiqueDeJusWebServer.java

示例3: testGet

import org.eclipse.jetty.server.Server; //导入方法依赖的package包/类
@Test
public void testGet() throws Exception {
    Server server = createServer();
    server.start();
    WebTarget client1 = ClientBuilder.newClient().target("http://localhost:8384/Hello");
    WebTarget client2 = ClientBuilder.newClient().target("http://localhost:8384/World");
    /*
    Mono<String> get1 = fromCompletionStage(client1.request().rx().get(String.class));
    Mono<String> get2 = fromCompletionStage(client2.request().rx().get(String.class));
    List<String> result = Mono
        .from(get1)
        .concatWith(get2)
        .doOnError(ex -> ex.printStackTrace())
        .collectList()
        .block(Duration.ofMillis(1500));
    String resultSt = result.stream().collect(Collectors.joining(" "));
    org.junit.Assert.assertEquals("Hello World", resultSt);
    */
    server.stop();
}
 
开发者ID:cschneider,项目名称:reactive-components,代码行数:21,代码来源:TestRs.java

示例4: redeployApp

import org.eclipse.jetty.server.Server; //导入方法依赖的package包/类
private static void redeployApp(final Server server, final Path warFilePath) {

        try {
            server.stop();
            server.join();
            LOG.info("Server stopped");
            WebAppContext webApp = createWebApp(warFilePath);
            server.setHandler(webApp);
            server.start();
            LOG.info("Server restarted");

        } catch (Exception e) {
            throw new RuntimeException("War file could not been redeployed",e);
        }
    }
 
开发者ID:gmuecke,项目名称:boutique-de-jus,代码行数:16,代码来源:BoutiqueDeJusWebServer.java

示例5: stop

import org.eclipse.jetty.server.Server; //导入方法依赖的package包/类
public void stop() {
  if (server == null) {
    throw new RuntimeException("Server is already stopped");
  }

  LOG.info("Service terminating.");
  try {
    final Server server1 = server;
    port = -1;
    server = null;
    server1.stop();
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:16,代码来源:HttpServer.java

示例6: testLoadUrlNoRegistration

import org.eclipse.jetty.server.Server; //导入方法依赖的package包/类
@Test
@Ignore
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testLoadUrlNoRegistration() throws Exception {
    final String path = "/Felis_catus.vcf";
    String vcfUrl = UrlTestingUtils.TEST_FILE_SERVER_URL + path;
    String indexUrl = UrlTestingUtils.TEST_FILE_SERVER_URL + "/Felis_catus.idx";

    Server server = UrlTestingUtils.getFileServer(context);
    try {
        server.start();

        TrackQuery vcfTrackQuery = new TrackQuery();
        vcfTrackQuery.setChromosomeId(testChromosome.getId());
        vcfTrackQuery.setStartIndex(1);
        vcfTrackQuery.setEndIndex(TEST_END_INDEX);
        vcfTrackQuery.setScaleFactor(1D);

        Track<Variation> variationTrack = Query2TrackConverter.convertToTrack(vcfTrackQuery);

        Track<Variation> trackResult = vcfManager.loadVariations(variationTrack, vcfUrl, indexUrl,
                                                                 null, true, true);
        Assert.assertFalse(trackResult.getBlocks().isEmpty());

        Variation var = vcfManager.getNextOrPreviousVariation(trackResult.getBlocks().get(3).getEndIndex(), null,
                                              null, testChromosome.getId(), true, vcfUrl, indexUrl);
        Assert.assertNotNull(var);
        Assert.assertEquals(var.getStartIndex(), trackResult.getBlocks().get(4).getStartIndex());
        Assert.assertEquals(var.getEndIndex(), trackResult.getBlocks().get(4).getEndIndex());
    } finally {
        server.stop();
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:34,代码来源:VcfManagerTest.java

示例7: testLoadExtendedSummaryUrl

import org.eclipse.jetty.server.Server; //导入方法依赖的package包/类
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testLoadExtendedSummaryUrl()
    throws Exception {
    final String path = "/Felis_catus.vcf";
    String vcfUrl = UrlTestingUtils.TEST_FILE_SERVER_URL + path;
    String indexUrl = UrlTestingUtils.TEST_FILE_SERVER_URL + "/Felis_catus.idx";

    Resource resource = context.getResource("classpath:templates/genes_sorted.gtf");

    FeatureIndexedFileRegistrationRequest request = new FeatureIndexedFileRegistrationRequest();
    request.setReferenceId(referenceId);
    request.setPath(resource.getFile().getAbsolutePath());

    GeneFile geneFile = gffManager.registerGeneFile(request);
    Assert.assertNotNull(geneFile);
    Assert.assertNotNull(geneFile.getId());

    referenceGenomeManager.updateReferenceGeneFileId(testReference.getId(), geneFile.getId());

    Server server = UrlTestingUtils.getFileServer(context);
    try {
        server.start();
        final VariationQuery query = new VariationQuery();
        query.setPosition(GENE_POSTION);
        query.setChromosomeId(testChromosome.getId());
        Variation variation = vcfManager.loadVariation(query, vcfUrl, indexUrl);

        Assert.assertFalse(variation.getInfo().isEmpty());
        Assert.assertFalse(variation.getInfo().isEmpty());
        Assert.assertNotNull(variation.getGeneNames());
        Assert.assertFalse(variation.getGeneNames().isEmpty());
    } finally {
        server.stop();
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:37,代码来源:VcfManagerTest.java

示例8: testRegisterUrl

import org.eclipse.jetty.server.Server; //导入方法依赖的package包/类
@Test
@Ignore
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testRegisterUrl() throws Exception {
    final String path = "/genes_sorted.gtf";
    String fileUrl = UrlTestingUtils.TEST_FILE_SERVER_URL + path;
    String indexUrl = UrlTestingUtils.TEST_FILE_SERVER_URL + "/genes_sorted.gtf.tbi";

    Server server = UrlTestingUtils.getFileServer(context);
    try {
        server.start();

        FeatureIndexedFileRegistrationRequest request = new FeatureIndexedFileRegistrationRequest();
        request.setReferenceId(referenceId);
        request.setPath(fileUrl);
        request.setIndexPath(indexUrl);
        request.setType(BiologicalDataItemResourceType.URL);
        request.setIndexType(BiologicalDataItemResourceType.URL);

        GeneFile geneFile = gffManager.registerGeneFile(request);
        Assert.assertNotNull(geneFile);
        Assert.assertNotNull(geneFile.getId());

        Track<Wig> histogram = new Track<>();
        histogram.setId(geneFile.getId());
        histogram.setChromosome(testChromosome);
        histogram.setScaleFactor(1.0);

        gffManager.loadHistogram(histogram);
        Assert.assertTrue(histogram.getBlocks().isEmpty());
    } finally {
        server.stop();
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:35,代码来源:GffManagerTest.java

示例9: testRegisterUrl

import org.eclipse.jetty.server.Server; //导入方法依赖的package包/类
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testRegisterUrl() throws Exception {
    String bedUrl = UrlTestingUtils.TEST_FILE_SERVER_URL + "/genes_sorted.bed";
    String indexUrl = UrlTestingUtils.TEST_FILE_SERVER_URL + "/genes_sorted.bed.tbi";

    Server server = UrlTestingUtils.getFileServer(context);
    try {
        server.start();

        IndexedFileRegistrationRequest request = new IndexedFileRegistrationRequest();
        request.setPath(bedUrl);
        request.setType(BiologicalDataItemResourceType.URL);
        request.setIndexType(BiologicalDataItemResourceType.URL);
        request.setIndexPath(indexUrl);
        request.setReferenceId(referenceId);

        BedFile bedFile = bedManager.registerBed(request);
        Assert.assertNotNull(bedFile);

        bedFile = bedFileManager.loadBedFile(bedFile.getId());
        Assert.assertNotNull(bedFile.getId());
        Assert.assertNotNull(bedFile.getBioDataItemId());
        Assert.assertNotNull(bedFile.getIndex());
        Assert.assertFalse(bedFile.getPath().isEmpty());
        Assert.assertFalse(bedFile.getIndex().getPath().isEmpty());

        testLoadBedRecords(bedFile);
    } finally {
        server.stop();
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:33,代码来源:BedManagerTest.java

示例10: testUrlNotRegistered

import org.eclipse.jetty.server.Server; //导入方法依赖的package包/类
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testUrlNotRegistered() throws Exception {
    String bedUrl = UrlTestingUtils.TEST_FILE_SERVER_URL + "/genes_sorted.bed";
    String indexUrl = UrlTestingUtils.TEST_FILE_SERVER_URL + "/genes_sorted.bed.tbi";

    Server server = UrlTestingUtils.getFileServer(context);
    try {
        server.start();

        Track<BedRecord> track = new Track<>();
        track.setScaleFactor(FULL_QUERY_SCALE_FACTOR);
        track.setStartIndex(1);
        track.setEndIndex(TEST_END_INDEX);
        track.setChromosome(testChromosome);

        track = bedManager.loadFeatures(track, bedUrl, indexUrl);
        Assert.assertFalse(track.getBlocks().isEmpty());
        track.getBlocks().stream().forEach(b -> {
            if (b.getThickStart() != null) {
                Assert.assertEquals(b.getStartIndex(), b.getThickStart());
            }
            if (b.getThickEnd() != null) {
                Assert.assertEquals(b.getEndIndex(), b.getThickEnd());
            }
        });
    } finally {
        server.stop();
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:31,代码来源:BedManagerTest.java

示例11: testUrlNotRegistered

import org.eclipse.jetty.server.Server; //导入方法依赖的package包/类
@Test
@Ignore
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testUrlNotRegistered() throws Exception {
    final String path = "/Felis_catus.vcf";
    String vcfUrl = UrlTestingUtils.TEST_FILE_SERVER_URL + path;
    String indexUrl = UrlTestingUtils.TEST_FILE_SERVER_URL + "/Felis_catus.idx";

    Server server = UrlTestingUtils.getFileServer(context);
    try {
        server.start();

        TrackQuery vcfTrackQuery = new TrackQuery();
        vcfTrackQuery.setChromosomeId(testChromosome.getId());
        vcfTrackQuery.setStartIndex(1);
        vcfTrackQuery.setEndIndex(TEST_END_INDEX);
        vcfTrackQuery.setScaleFactor(1D);

        ResultActions actions = mvc()
            .perform(post(URL_LOAD_VARIATIONS).content(getObjectMapper().writeValueAsString(vcfTrackQuery))
                         .param("fileUrl", vcfUrl).param("indexUrl", indexUrl)
                         .contentType(EXPECTED_CONTENT_TYPE))
            .andExpect(status().isOk())
            .andExpect(content().contentType(EXPECTED_CONTENT_TYPE))
            .andExpect(jsonPath(JPATH_PAYLOAD).exists())
            .andExpect(jsonPath(JPATH_STATUS).value(ResultStatus.OK.name()));
        actions.andDo(MockMvcResultHandlers.print());

        ResponseResult<Track<Variation>> vcfRes = getObjectMapper()
            .readValue(actions.andReturn().getResponse().getContentAsByteArray(),
                       getTypeFactory().constructParametrizedType(ResponseResult.class, ResponseResult.class,
                                              getTypeFactory().constructParametrizedType(Track.class, Track.class,
                                                                                         Variation.class)));

        Assert.assertFalse(vcfRes.getPayload().getBlocks().isEmpty());
    } finally {
        server.stop();
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:40,代码来源:VcfControllerTest.java

示例12: saveLoadGeneByUrl

import org.eclipse.jetty.server.Server; //导入方法依赖的package包/类
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void saveLoadGeneByUrl() throws Exception {
    String geneUrl = UrlTestingUtils.TEST_FILE_SERVER_URL + "/genes_sorted.gtf";
    String indexUrl = UrlTestingUtils.TEST_FILE_SERVER_URL + "/genes_sorted.gtf.tbi";
    Server server = UrlTestingUtils.getFileServer(context);

    try {
        server.start();

        // Load a track by fileId
        TrackQuery trackQuery = initTrackQuery(1L);
        trackQuery.setId(null);
        ResultActions actions = mvc().perform(post(String.format(URL_LOAD_GENES, testReference.getId()))
                .content(getObjectMapper().writeValueAsString(trackQuery))
                .param("fileUrl", geneUrl)
                .param("indexUrl", indexUrl)
                .contentType(EXPECTED_CONTENT_TYPE))
                .andExpect(status().isOk())
                .andExpect(content().contentType(EXPECTED_CONTENT_TYPE))
                .andExpect(jsonPath(JPATH_PAYLOAD).exists())
                .andExpect(jsonPath(JPATH_STATUS).value(ResultStatus.OK.name()));
        actions.andDo(MockMvcResultHandlers.print());

        ResponseResult<Track<GeneHighLevel>> geneRes = getObjectMapper()
                .readValue(actions.andReturn().getResponse().getContentAsByteArray(),
                        getTypeFactory().constructParametrizedType(ResponseResult.class, ResponseResult.class,
                                getTypeFactory().constructParametrizedType(Track.class, Track.class,
                                        GeneHighLevel.class)));

        Assert.assertFalse(geneRes.getPayload().getBlocks().isEmpty());
    } finally {
        server.stop();
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:36,代码来源:GeneControllerTest.java

示例13: testServlet

import org.eclipse.jetty.server.Server; //导入方法依赖的package包/类
@Test
public void testServlet() throws Exception {
    Server server = createServer();
    server.start();
    WebTarget client = ClientBuilder.newClient().target("http://localhost:8384/Hello");
    String result = client.request().get(String.class);
    Assert.assertEquals("/Hello", result);
    server.stop();
}
 
开发者ID:cschneider,项目名称:reactive-components,代码行数:10,代码来源:TestServlet.java

示例14: main

import org.eclipse.jetty.server.Server; //导入方法依赖的package包/类
public static void main(final String[] args) {
  InetSocketAddress _inetSocketAddress = new InetSocketAddress("localhost", 8080);
  final Server server = new Server(_inetSocketAddress);
  WebAppContext _webAppContext = new WebAppContext();
  final Procedure1<WebAppContext> _function = (WebAppContext it) -> {
    it.setResourceBase("WebRoot");
    it.setWelcomeFiles(new String[] { "index.html" });
    it.setContextPath("/");
    AnnotationConfiguration _annotationConfiguration = new AnnotationConfiguration();
    WebXmlConfiguration _webXmlConfiguration = new WebXmlConfiguration();
    WebInfConfiguration _webInfConfiguration = new WebInfConfiguration();
    MetaInfConfiguration _metaInfConfiguration = new MetaInfConfiguration();
    it.setConfigurations(new Configuration[] { _annotationConfiguration, _webXmlConfiguration, _webInfConfiguration, _metaInfConfiguration });
    it.setAttribute(WebInfConfiguration.CONTAINER_JAR_PATTERN, ".*/com\\.hribol\\.bromium\\.dsl\\.web/.*,.*\\.jar");
    it.setInitParameter("org.mortbay.jetty.servlet.Default.useFileMappedBuffer", "false");
  };
  WebAppContext _doubleArrow = ObjectExtensions.<WebAppContext>operator_doubleArrow(_webAppContext, _function);
  server.setHandler(_doubleArrow);
  String _name = ServerLauncher.class.getName();
  final Slf4jLog log = new Slf4jLog(_name);
  try {
    server.start();
    URI _uRI = server.getURI();
    String _plus = ("Server started " + _uRI);
    String _plus_1 = (_plus + "...");
    log.info(_plus_1);
    final Runnable _function_1 = () -> {
      try {
        log.info("Press enter to stop the server...");
        final int key = System.in.read();
        if ((key != (-1))) {
          server.stop();
        } else {
          log.warn("Console input is not available. In order to stop the server, you need to cancel process manually.");
        }
      } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
      }
    };
    new Thread(_function_1).start();
    server.join();
  } catch (final Throwable _t) {
    if (_t instanceof Exception) {
      final Exception exception = (Exception)_t;
      log.warn(exception.getMessage());
      System.exit(1);
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
}
 
开发者ID:hristo-vrigazov,项目名称:bromium,代码行数:52,代码来源:ServerLauncher.java

示例15: main

import org.eclipse.jetty.server.Server; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    int timeout = (int) Duration.ONE_HOUR.getMilliseconds();

    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(8080);
    server.addConnector(connector);

    Resource keystore = Resource.newClassPathResource("/keystore");
    if (keystore != null && keystore.exists()) {
        // if a keystore for a SSL certificate is available, start a SSL
        // connector on port 8443.
        // By default, the quickstart comes with a Apache Wicket Quickstart
        // Certificate that expires about half way september 2021. Do not
        // use this certificate anywhere important as the passwords are
        // available in the source.

        connector.setConfidentialPort(8443);

        SslContextFactory factory = new SslContextFactory();
        factory.setKeyStoreResource(keystore);
        factory.setKeyStorePassword("wicket");
        factory.setTrustStoreResource(keystore);
        factory.setKeyManagerPassword("wicket");
        SslSocketConnector sslConnector = new SslSocketConnector(factory);
        sslConnector.setMaxIdleTime(timeout);
        sslConnector.setPort(8443);
        sslConnector.setAcceptors(4);
        server.addConnector(sslConnector);

        System.out.println("SSL access to the quickstart has been enabled on port 8443");
        System.out.println("You can access the application using SSL on https://localhost:8443");
        System.out.println();
    }

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/main/webapp");

    // START JMX SERVER
    // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
    // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
    // server.getContainer().addEventListener(mBeanContainer);
    // mBeanContainer.start();

    server.setHandler(bb);

    try {
        System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
        server.start();
        System.in.read();
        System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
 
开发者ID:sparsick,项目名称:ansible-docker-talk,代码行数:65,代码来源:Start.java


注:本文中的org.eclipse.jetty.server.Server.stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。