Java Code Examples for org.eclipse.jetty.server.Server

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project ANNIS, under directory /annis-kickstarter/src/main/java/de/hu_berlin/german/korpling/annis/kickstarter/.

Source file: MainFrame.java

  22 
vote

private void startJetty() throws Exception {
  Server jetty=new Server(8080);
  WebAppContext context=new WebAppContext("./webapp/","/annis-gui");
  context.setInitParameter("managerClassName","annis.security.TestSecurityManager");
  String webxmlOverrride=System.getProperty("annis.home") + "/conf/override-web.xml";
  context.setOverrideDescriptor(webxmlOverrride);
  jetty.setHandler(context);
  jetty.start();
}
 

Example 2

From project apjp, under directory /APJP_REMOTE_JAVA/src/main/assembly/APJP_REMOTE_JAVA_HEROKU/src/main/java/APJP/.

Source file: Main.java

  22 
vote

public static void main(String[] args) throws Exception {
  Server server=new Server(Integer.valueOf(System.getenv("PORT")));
  WebAppContext webAppContext=new WebAppContext();
  webAppContext.setContextPath("/");
  webAppContext.setDescriptor("src/main/webapp/WEB-INF/web.xml");
  webAppContext.setResourceBase("src/main/webapp/");
  webAppContext.setParentLoaderPriority(true);
  server.setHandler(webAppContext);
  server.start();
  server.join();
}
 

Example 3

From project cometd, under directory /cometd-java/cometd-java-oort/src/test/java/org/cometd/oort/.

Source file: OortMulticastConfigurerTest.java

  22 
vote

@Test public void testTwoComets() throws Exception {
  Server server1=startServer(0);
  int groupPort=server1.getConnectors()[0].getLocalPort();
  Oort oort1=startOort(server1);
  startConfigurer(oort1,groupPort);
  Server server2=startServer(0);
  Oort oort2=startOort(server2);
  startConfigurer(oort2,groupPort);
  Thread.sleep(1000);
  Assert.assertEquals(1,oort1.getKnownComets().size());
  Assert.assertEquals(1,oort2.getKnownComets().size());
}
 

Example 4

From project elasticsearch-jetty, under directory /src/main/java/com/sonian/elasticsearch/http/jetty/handler/.

Source file: JettyHttpServerTransportHandler.java

  22 
vote

@Override protected void doStart() throws Exception {
  super.doStart();
  Server server=getServer();
  if (transport == null) {
    JettyHttpServerTransport transport=(JettyHttpServerTransport)server.getAttribute(JettyHttpServerTransport.TRANSPORT_ATTRIBUTE);
    if (transport == null) {
      throw new IllegalArgumentException("Transport is not specified");
    }
    setTransport(transport);
  }
}
 

Example 5

From project hcatalog, under directory /webhcat/svr/src/main/java/org/apache/hcatalog/templeton/.

Source file: Main.java

  22 
vote

public Server runServer(int port) throws Exception {
  if (UserGroupInformation.isSecurityEnabled()) {
    UserGroupInformation.loginUserFromKeytab(conf.kerberosPrincipal(),conf.kerberosKeytab());
  }
  Server server=new Server(port);
  ServletContextHandler root=new ServletContextHandler(server,"/");
  root.addFilter(makeAuthFilter(),"/*",FilterMapping.REQUEST);
  ServletHolder h=new ServletHolder(new ServletContainer(makeJerseyConfig()));
  root.addServlet(h,"/" + SERVLET_PATH + "/*");
  addRedirects(server);
  server.start();
  return server;
}
 

Example 6

From project http-testing-harness, under directory /server-provider/src/main/java/org/sonatype/tests/http/server/jetty/impl/.

Source file: JettyServerProvider.java

  22 
vote

public Server createServer() throws URISyntaxException {
  Server s=new Server();
  Connector connector;
  if (ssl) {
    connector=sslConnector();
  }
 else {
    connector=connector();
  }
  s.setConnectors(new Connector[]{connector});
  initWebappContext(s);
  return s;
}
 

Example 7

From project https-utils, under directory /src/main/java/org/italiangrid/utils/https/.

Source file: ServerFactory.java

  22 
vote

/** 
 * Returns a new Jetty server configured to listen on the host:port passed as argument and  according to the SSL configuration options provided.
 * @param host
 * @param port
 * @param options
 * @return a {@link Server} configured as requested
 */
public static Server newServer(String host,int port,SSLOptions options){
  Server server=new Server();
  server.setSendServerVersion(false);
  server.setSendDateHeader(false);
  configureThreadPool(server);
  Connector connector=configurator.configureConnector(host,port,options);
  if (connector == null)   throw new RuntimeException("Error creating SSL connector.");
  server.setConnectors(new Connector[]{connector});
  return server;
}
 

Example 8

From project indextank-engine, under directory /embedded-api/com/flaptor/indextank/api/util/.

Source file: JettyHelper.java

  22 
vote

public static void server(int port,Handler handler) throws Exception {
  Server server=new Server(port);
  server.setHandler(handler);
  server.start();
  server.join();
}
 

Example 9

From project ivyde, under directory /doc/sample/webapp-js-repo/webapp/src/org/apache/ivyde/sample/webappjsrepo/.

Source file: HTTPServer.java

  22 
vote

public static void main(String[] args) throws Exception {
  InetSocketAddress bindAdress=new InetSocketAddress("localhost",8888);
  Server server=new Server(bindAdress);
  ResourceHandler resourceHandler=new ResourceHandler();
  resourceHandler.setBaseResource(Resource.newClassPathResource("/org/apache/ivyde/sample/webappjsrepo/"));
  server.setHandler(resourceHandler);
  server.start();
  server.join();
}
 

Example 10

From project james-hupa, under directory /client/src/main/java/org/apache/hupa/.

Source file: Launcher.java

  22 
vote

public static void main(String[] args) throws Exception {
  int port=Integer.parseInt(System.getProperty("port","8282"));
  String bindAddress=System.getProperty("host","0.0.0.0");
  InetSocketAddress a=new InetSocketAddress(bindAddress,port);
  Server server=new Server(a);
  ProtectionDomain domain=Launcher.class.getProtectionDomain();
  URL location=domain.getCodeSource().getLocation();
  WebAppContext webapp=new WebAppContext();
  webapp.setContextPath("/");
  webapp.setWar(location.toExternalForm());
  server.setHandler(webapp);
  server.start();
  server.join();
}
 

Example 11

From project jangaroo-tools, under directory /jangaroo-maven/jangaroo-maven-plugin/src/main/java/net/jangaroo/jooc/mvnplugin/test/.

Source file: JettyRunTestsMojo.java

  22 
vote

public void execute() throws MojoExecutionException {
  Server server=jettyRunTest(false);
  String url=getJettyUrl(server);
  getLog().info("Test-URL: " + url + "/"+ testsHtml.replace(File.separatorChar,'/'));
  try {
    server.join();
  }
 catch (  InterruptedException e) {
  }
  stopServerIgnoreException(server);
}
 

Example 12

From project jena-fuseki, under directory /src/main/java/org/apache/jena/fuseki/mgt/.

Source file: ManagementServer.java

  22 
vote

public static Server createManagementServer(int mgtPort){
  Fuseki.serverLog.info("Adding management functions");
  Server server=new Server();
  BlockingChannelConnector bcConnector=new BlockingChannelConnector();
  Connector connector=bcConnector;
  connector.setMaxIdleTime(0);
  connector.setPort(mgtPort);
  server.addConnector(connector);
  ServletContextHandler context=new ServletContextHandler(ServletContextHandler.SESSIONS);
  context.setErrorHandler(new FusekiErrorHandler());
  server.setHandler(context);
  addServlet(context,new MgtCmdServlet(),"/mgt");
  return server;
}
 

Example 13

From project ning-service-skeleton, under directory /base/src/test/java/com/ning/jetty/base/modules/.

Source file: TestBaseServerModule.java

  22 
vote

@Test(groups="slow") public void testJettyStartup() throws Exception {
  final ServerModuleBuilder builder=new ServerModuleBuilder();
  final ServletModule module=builder.build();
  final Server server=startServer(module);
  server.stop();
}
 

Example 14

From project springside4, under directory /examples/showcase/src/main/java/org/springside/examples/showcase/.

Source file: Main.java

  22 
vote

public static void main(String[] args) throws Exception {
  String contextPath="/showcase";
  int port=Integer.getInteger("port",8080);
  Server server=createServer(contextPath,port);
  try {
    server.start();
    server.join();
  }
 catch (  Exception e) {
    e.printStackTrace();
    System.exit(100);
  }
}
 

Example 15

From project summer, under directory /plugins/onejar/src/main/java/com/asual/summer/onejar/.

Source file: OneJarServer.java

  22 
vote

public static void main(String[] args) throws Exception {
  Server server=new Server(Integer.valueOf(System.getProperty("server.port","8080")));
  server.setHandler(new WebAppContext(getCurrentWarFile(),System.getProperty("server.contextPath","/")));
  try {
    server.start();
  }
 catch (  Exception e) {
    server.stop();
    e.printStackTrace();
    System.exit(-1);
  }
}
 

Example 16

From project tesb-rt-se, under directory /examples/camel/spring-security/war/src/test/java/.

Source file: JettyStarter.java

  22 
vote

private void run() throws Exception {
  Server server=new org.eclipse.jetty.server.Server(8080);
  WebAppContext webappcontext=new WebAppContext();
  webappcontext.setContextPath("/");
  webappcontext.setWar("src/main/webapp");
  webappcontext.setClassLoader(this.getClass().getClassLoader());
  server.setHandler(webappcontext);
  server.start();
}
 

Example 17

From project turismo, under directory /src/test/java/com/ghosthack/turismo/example/.

Source file: JettyHelper.java

  22 
vote

public static void server(int port,Handler handler) throws Exception {
  Server server=new Server(port);
  server.setHandler(handler);
  server.start();
  server.join();
}
 

Example 18

From project turmeric-monitoring, under directory /mgmt-console/src/main/java/org/ebayopensource/turmeric/monitoring/.

Source file: Main.java

  22 
vote

/** 
 * The main method.
 * @param args the arguments
 * @throws Exception the exception
 */
public static void main(String[] args) throws Exception {
  Server server=new Server(9090);
  server.setHandler(new SimpleHandler());
  server.start();
  server.join();
}
 

Example 19

From project acceleo-webapp-generator, under directory /plugins/webserver/src/org/eclipse/acceleo/tutorial/.

Source file: SimpleWebServer.java

  21 
vote

public static void main(String[] args) throws Exception {
  Server server=new Server();
  SelectChannelConnector connector=new SelectChannelConnector();
  connector.setPort(8080);
  server.addConnector(connector);
  ResourceHandler resource_handler=new ResourceHandler();
  resource_handler.setDirectoriesListed(true);
  resource_handler.setWelcomeFiles(new String[]{"index.html"});
  resource_handler.setResourceBase(".");
  HandlerList handlers=new HandlerList();
  handlers.setHandlers(new Handler[]{resource_handler,new DefaultHandler()});
  server.setHandler(handlers);
  server.start();
  server.join();
}
 

Example 20

From project aether-core, under directory /aether-connector-asynchttpclient/src/test/java/org/eclipse/aether/connector/async/.

Source file: ResumeGetTest.java

  21 
vote

@Before public void before() throws Exception {
  factory=new AsyncRepositoryConnectorFactory();
  factory.setFileProcessor(new TestFileProcessor());
  factory.setLoggerFactory(new SysoutLoggerFactory());
  session=new TestRepositorySystemSession();
  artifact=new DefaultArtifact("gid","aid","classifier","extension","version");
  server=new Server(0);
}
 

Example 21

From project airlift, under directory /event/src/test/java/io/airlift/event/client/.

Source file: TestHttpEventClient.java

  21 
vote

private Server createServer(final DummyServlet servlet) throws Exception {
  int port;
  ServerSocket socket=new ServerSocket();
  try {
    socket.bind(new InetSocketAddress(0));
    port=socket.getLocalPort();
  }
  finally {
    socket.close();
  }
  baseUri=new URI("http",null,"127.0.0.1",port,null,null,null);
  Server server=new Server();
  server.setSendServerVersion(false);
  SelectChannelConnector httpConnector;
  httpConnector=new SelectChannelConnector();
  httpConnector.setName("http");
  httpConnector.setPort(port);
  server.addConnector(httpConnector);
  ServletHolder servletHolder=new ServletHolder(servlet);
  ServletContextHandler context=new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
  context.addServlet(servletHolder,"/*");
  HandlerCollection handlers=new HandlerCollection();
  handlers.addHandler(context);
  server.setHandler(handlers);
  return server;
}
 

Example 22

From project Arecibo, under directory /util/src/main/java/com/ning/arecibo/util/.

Source file: EmbeddedJettyJerseyProvider.java

  21 
vote

@Override public Server get(){
  QueuedThreadPool threadPool=new QueuedThreadPool();
  threadPool.setMinThreads(config.getMinThreads());
  threadPool.setMaxThreads(config.getMaxThreads());
  SelectChannelConnector connector=new SelectChannelConnector();
  connector.setHost(config.getHost());
  connector.setPort(config.getPort());
  connector.setMaxIdleTime(30000);
  connector.setAcceptors(2);
  connector.setStatsOn(true);
  connector.setLowResourcesConnections(20000);
  connector.setLowResourceMaxIdleTime(5000);
  connector.setAcceptQueueSize(config.getAcceptQueueSize());
  Server server=new Server(config.getPort());
  server.setThreadPool(threadPool);
  server.setConnectors(new Connector[]{connector});
  server.setGracefulShutdown(1000);
  ServletContextHandler root=new ServletContextHandler(server,"/",ServletContextHandler.SESSIONS);
  root.setResourceBase(config.getResourceBase());
  final FilterHolder filterHolder=new FilterHolder(GuiceFilter.class);
  root.addFilter(filterHolder,"/*",EnumSet.of(DispatcherType.REQUEST,DispatcherType.ASYNC));
  final ServletHolder sh=new ServletHolder(DefaultServlet.class);
  root.addServlet(sh,"/*");
  root.addEventListener(new GuiceServletContextListener(){
    @Override protected Injector getInjector(){
      return injector;
    }
  }
);
  root.addServlet(DefaultServlet.class,"/");
  return server;
}
 

Example 23

From project arquillian-core, under directory /protocols/servlet/src/test/java/org/jboss/arquillian/protocol/servlet/.

Source file: AbstractServerBase.java

  21 
vote

@Before public void setup() throws Exception {
  server=new Server(8181);
  ServletContextHandler root=new ServletContextHandler(ServletContextHandler.SESSIONS);
  root.setContextPath("/arquillian-protocol");
  root.addServlet(ServletTestRunner.class,ServletMethodExecutor.ARQUILLIAN_SERVLET_MAPPING);
  server.setHandler(root);
  server.start();
}
 

Example 24

From project ATHENA, under directory /runner/src/main/java/org/fracturedatlas/athena/runner/.

Source file: AthenaRunner.java

  21 
vote

public static void main(String[] args) throws Exception {
  String port=System.getProperty("port");
  Server server=new Server(Integer.parseInt(port));
  ContextHandlerCollection contexts=new ContextHandlerCollection();
  String[] appNames=new String[]{"athena","payments"};
  for (  String appName : appNames) {
    WebAppContext app=new WebAppContext();
    app.setContextPath("/" + appName);
    app.setExtraClasspath("../components/shared/config/;../components/shared/lib/web-resources.jar;../components/shared/lib/util.jar;../components/shared/lib/apa.jar;../components/shared/lib/client.jar;../components/" + appName + "/config/");
    app.setWar("../components/" + appName + "/war/"+ appName+ ".war");
    app.setLogUrlOnStart(true);
    contexts.addHandler(app);
  }
  server.setHandler(contexts);
  XmlConfiguration configuration=new XmlConfiguration(new FileInputStream("../config/jetty.xml"));
  configuration.configure(server);
  server.start();
  server.start();
  System.out.println("@");
  System.out.println("@");
  System.out.println("@    Athena started on port " + port + ".  Have fun.");
  System.out.println("@");
  System.out.println("@");
  server.join();
}
 

Example 25

From project BeeQueue, under directory /src/org/beequeue/buzz/.

Source file: BuzzServer.java

  21 
vote

public void start(){
  this.server=new Server(port);
  HandlerList handlers=new HandlerList();
  handlers.setHandlers(new Handler[]{new BuzzHandler(root)});
  this.server.setHandler(handlers);
  try {
    this.server.start();
    this.server.join();
  }
 catch (  Throwable e) {
    throw new BeeException(e);
  }
}
 

Example 26

From project blogs, under directory /request-mappers/src/test/java/com/wicketinaction/.

Source file: Start.java

  21 
vote

public static void main(String[] args) throws Exception {
  Server server=new Server();
  SocketConnector connector=new SocketConnector();
  connector.setMaxIdleTime(1000 * 60 * 60);
  connector.setSoLingerTime(-1);
  connector.setPort(8080);
  server.setConnectors(new Connector[]{connector});
  WebAppContext bb=new WebAppContext();
  bb.setServer(server);
  bb.setContextPath("/");
  bb.setWar("src/main/webapp");
  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(100);
  }
}
 

Example 27

From project camel-websocket, under directory /src/main/java/org/apache/camel/component/websocket/.

Source file: WebsocketComponent.java

  21 
vote

protected Server createServer(ServletContextHandler context,String host,int port,String home){
  InetSocketAddress address=new InetSocketAddress(host,port);
  Server server=new Server(address);
  context.setContextPath("/");
  SessionManager sm=new HashSessionManager();
  SessionHandler sh=new SessionHandler(sm);
  context.setSessionHandler(sh);
  if (home != null) {
    context.setResourceBase(home);
    DefaultServlet defaultServlet=new DefaultServlet();
    ServletHolder holder=new ServletHolder(defaultServlet);
    holder.setInitParameter("useFileMappedBuffer","false");
    context.addServlet(holder,"/");
  }
  server.setHandler(context);
  return server;
}
 

Example 28

From project clutter, under directory /src/clutter/hypertoolkit/.

Source file: WebApp.java

  21 
vote

public void start(int httpPort,int ajpPort){
  Server server=new Server();
  Connector connector=new SelectChannelConnector();
  connector.setPort(httpPort);
  connector.setHost("0.0.0.0");
  server.setConnectors(new Connector[]{connector});
  ServletContextHandler contextHandler=new ServletContextHandler();
  contextHandler.setContextPath("/");
  server.setHandler(contextHandler);
  Dispatcher dispatcher=new Dispatcher<T>(app,actionResolver);
  contextHandler.addServlet(new ServletHolder(dispatcher),"/");
  server.setHandler(contextHandler);
  try {
    server.start();
    server.join();
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}
 

Example 29

From project Ebselen, under directory /ebselen-core/src/test/java/com/lazerycode/ebselen/customhandlers/.

Source file: JettyServer.java

  21 
vote

public void startJettyServer(int port) throws Exception {
  String resourceBasePath=this.getClass().getResource("/web").toExternalForm();
  jettyServer=new Server(port);
  WebAppContext webapp=new WebAppContext();
  webapp.setResourceBase(resourceBasePath);
  jettyServer.setHandler(webapp);
  jettyServer.start();
}
 

Example 30

From project ehour, under directory /eHour-standalone/src/main/java/net/rrm/ehour/.

Source file: EhourServer.java

  21 
vote

private void startServer(ServerConfig config) throws Exception {
  Server server=new Server(config.getPort());
  File jettyXmlFile=EhourHomeUtil.getFileInConfDir(config.getDefaultConfigFileName());
  FileInputStream stream=null;
  try {
    stream=new FileInputStream(jettyXmlFile);
    XmlConfiguration configuration=new XmlConfiguration(stream);
    configuration.configure(server);
    registerJndiDS(config);
    server.start();
    server.join();
  }
  finally {
    IoUtil.close(stream);
  }
}
 

Example 31

From project flatpack-java, under directory /demo-server/src/main/java/com/getperka/flatpack/demo/server/.

Source file: DemoServer.java

  21 
vote

public boolean start(int port){
  ServletHolder holder=new ServletHolder(new ServletContainer());
  holder.setInitParameter(ServletContainer.APPLICATION_CONFIG_CLASS,DemoApplication.class.getName());
  holder.setInitParameter(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS,FlatPackProvider.class.getName());
  holder.setInitParameter(ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS,FlatPackProvider.class.getName());
  ServletContextHandler context=new ServletContextHandler(null,"/");
  context.addServlet(holder,"/");
  ConstraintSecurityHandler sh=new ConstraintSecurityHandler();
  sh.setAuthenticator(new DummyAuthenticator());
  sh.setIdentityService(new DefaultIdentityService());
  context.setSecurityHandler(sh);
  Server server=new Server(port);
  server.setHandler(context);
  try {
    server.start();
    return true;
  }
 catch (  Exception e) {
    e.printStackTrace();
    return false;
  }
}
 

Example 32

From project Game_3, under directory /server/src/playn/server/.

Source file: GameServer.java

  21 
vote

public GameServer(int port){
  server=new Server(port);
  servletHandler=new ServletContextHandler(ServletContextHandler.SESSIONS);
  servletHandler.setContextPath("/rpc");
  resourceHandler=new ResourceHandler();
  resourceHandler.setDirectoriesListed(true);
  resourceHandler.setWelcomeFiles(new String[]{"index.html"});
  resourceHandler.setResourceBase("www");
  HandlerList list=new HandlerList();
  list.setHandlers(new Handler[]{resourceHandler,servletHandler,new DefaultHandler()});
  server.setHandler(list);
}
 

Example 33

From project geolatte-mapserver, under directory /src/main/java/org/geolatte/mapserver/app/.

Source file: JettyServer.java

  21 
vote

public static void start() throws Exception {
  if (server != null && !server.isStarting() && !server.isStarted()) {
    server.start();
  }
 else {
    server=new Server(8090);
    ServletContextHandler context=new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");
    server.setHandler(context);
    context.addServlet(new ServletHolder(new WMSServlet()),"/wms");
    server.start();
  }
}
 

Example 34

From project hank, under directory /src/java/com/rapleaf/hank/ui/.

Source file: WebUiServer.java

  21 
vote

void run() throws Exception {
  Server server=new Server(port);
  Package p=WebUiServer.class.getPackage();
  String pName=p.getName();
  String pPath=pName.replaceAll("\\.","/");
  final URL warUrl=getClass().getClassLoader().getResource(pPath);
  final String warUrlString=warUrl.toExternalForm();
  WebAppContext webAppContext=new WebAppContext(warUrlString,"/");
  webAppContext.setAttribute("coordinator",coordinator);
  webAppContext.setAttribute("clientCache",clientCache);
  HankApiServlet apiServlet=new HankApiServlet(coordinator);
  ServletHolder apiHolder=new ServletHolder(apiServlet);
  ServletContextHandler servletHandler=new ServletContextHandler();
  servletHandler.setContextPath("/");
  servletHandler.addServlet(apiHolder,"/api");
  new DomainController("domain",coordinator).addServlet(servletHandler);
  new DomainGroupController("domain_group",coordinator).addServlet(servletHandler);
  new RingGroupController("ring_group",coordinator).addServlet(servletHandler);
  new RingController("ring",coordinator).addServlet(servletHandler);
  new HostController("host",coordinator).addServlet(servletHandler);
  ContextHandlerCollection contexts=new ContextHandlerCollection();
  contexts.setHandlers(new Handler[]{servletHandler,webAppContext});
  server.setHandler(contexts);
  server.start();
  server.join();
}
 

Example 35

From project ihtika, under directory /Incubator/TestForUsingJetty/src/main/java/khartn/testforusingjetty/.

Source file: App.java

  21 
vote

public static void main(String[] args){
  try {
    Server server=new Server(7878);
    WebAppProvider www=new WebAppProvider();
    www.setMonitoredDirName("c:/Art/Dropbox/OpenSource/MyGIT/ihtika/Incubator/WebApplication1/dist");
    www.setScanInterval(1);
    www.setContextXmlDir("c:/Art/Dropbox/OpenSource/MyGIT/ihtika/Incubator/WebApplication1/contexts");
    www.setDefaultsDescriptor("c:/Art/Dropbox/OpenSource/MyGIT/ihtika/Incubator/WebApplication1/webdefault.xml");
    www.setExtractWars(true);
    DeploymentManager qqq=new DeploymentManager();
    ContextHandlerCollection contexts=new ContextHandlerCollection();
    qqq.setContexts(contexts);
    qqq.addAppProvider(www);
    server.addBean(qqq);
    server.start();
    server.join();
  }
 catch (  Exception ex) {
    ex.printStackTrace();
    Logger.getLogger(App.class.getName()).log(Level.SEVERE,null,ex);
  }
}
 

Example 36

From project inproctester, under directory /inproctester-jetty/src/main/java/com/thoughtworks/inproctester/jetty/.

Source file: HttpAppTester.java

  21 
vote

public HttpAppTester(String webApp,String contextPath){
  server=new Server();
  LocalConnector connector=new LocalConnector();
  context=createWebAppContext(webApp,contextPath);
  server.addBean(new ErrorHandler());
  server.setSendServerVersion(false);
  server.addConnector(connector);
  server.setHandler(context);
  localConnection=new LocalConnection(connector);
}
 

Example 37

From project interoperability-framework, under directory /interfaces/taverna/t2-webdav/src/test/java/eu/impact_project/resultsrepository/.

Source file: ServerStarter.java

  21 
vote

public static void startWebServer(int port) throws Exception {
  webServer=new Server();
  SelectChannelConnector connector=new SelectChannelConnector();
  connector.setPort(port);
  webServer.addConnector(connector);
  ResourceHandler resource_handler=new ResourceHandler();
  resource_handler.setDirectoriesListed(true);
  String serverRoot=ServerStarter.class.getResource("/").getFile();
  resource_handler.setResourceBase(serverRoot);
  HandlerList handlers=new HandlerList();
  handlers.setHandlers(new Handler[]{resource_handler,new DefaultHandler()});
  webServer.setHandler(handlers);
  webServer.start();
}
 

Example 38

From project IronCount, under directory /src/main/java/com/jointhegrid/ironcount/httpserver/.

Source file: ICHTTPServer.java

  21 
vote

public void startServer() throws Exception {
  server=new Server();
  SelectChannelConnector connector=new SelectChannelConnector();
  connector.setPort(8766);
  server.addConnector(connector);
  ResourceHandler handler=new ResourceHandler();
  handler.setDirectoriesListed(true);
  handler.setResourceBase(this.docBase);
  HandlerList handlers=new HandlerList();
  handlers.setHandlers(new Handler[]{handler,new DefaultHandler()});
  server.setHandler(handlers);
  server.start();
}
 

Example 39

From project javamagic, under directory /cometd/src/test/java/com/googlecode/tawus/cometd/examples/.

Source file: JavaClientBasedTest.java

  21 
vote

@BeforeClass public void startupServer() throws Exception {
  server=new Server(9990);
  server.setStopAtShutdown(true);
  server.setGracefulShutdown(1000);
  WebAppContext context=new WebAppContext();
  context.setContextPath("/test");
  context.setWar("src/test/webapp");
  server.setHandler(context);
  server.start();
  logger.info("Server started");
}
 

Example 40

From project jDcHub, under directory /jdchub-modules/WebManagementConsole/src/main/java/jdchub/module/.

Source file: ModuleMain.java

  21 
vote

@Override public boolean init(){
  try {
    XmlConfiguration configuration=new XmlConfiguration(getClass().getClassLoader().getResourceAsStream("jetty-config.xml"));
    server=new Server();
    configuration.configure(server);
    server.start();
  }
 catch (  Exception e) {
    e.printStackTrace();
    return false;
  }
  log.info("Module " + moduleName + " inited");
  return server.isRunning();
}
 

Example 41

From project jetty-project, under directory /archetype/jetty-archetype-assembler/src/main/resources/archetype-resources/src/main/java/.

Source file: Main.java

  21 
vote

/** 
 * @param args
 */
public static void main(String[] args) throws Exception {
  String webappDirLocation="src/main/webapp/";
  String webPort=System.getenv("PORT");
  if (webPort == null || webPort.isEmpty()) {
    webPort="8080";
  }
  Server server=new Server(Integer.valueOf(webPort));
  WebAppContext root=new WebAppContext();
  root.setContextPath("/");
  root.setDescriptor(webappDirLocation + "/WEB-INF/web.xml");
  root.setResourceBase(webappDirLocation);
  root.setParentLoaderPriority(true);
  server.setHandler(root);
  server.start();
  server.join();
}
 

Example 42

From project jibu, under directory /itest/war-itest-suite/src/main/java/org/gaixie/jibu/itest/.

Source file: JettyService.java

  21 
vote

private void startJetty(){
  try {
    this.server=new Server(8080);
    this.webapp.setContextPath("/");
    this.webapp.setWar(warpath);
    this.server.setHandler(webapp);
    this.server.start();
  }
 catch (  Exception e) {
    System.out.println("Exception while initializing Jetty.");
  }
}
 

Example 43

From project jPOS-EE, under directory /modules/jetty/src/main/java/org/jpos/q2/jetty/.

Source file: Jetty7.java

  21 
vote

@Override public void initService() throws Exception {
  server=new Server();
  FileInputStream fis=new FileInputStream(config);
  XmlConfiguration xml=new XmlConfiguration(fis);
  xml.configure(server);
}
 

Example 44

From project logback, under directory /logback-access/src/test/java/ch/qos/logback/access/jetty/.

Source file: JettyFixtureBase.java

  21 
vote

public void start() throws Exception {
  server=new Server();
  Connector connector=new SelectChannelConnector();
  connector.setPort(port);
  server.setConnectors(new Connector[]{connector});
  RequestLogHandler requestLogHandler=new RequestLogHandler();
  configureRequestLogImpl();
  requestLogHandler.setRequestLog(requestLogImpl);
  HandlerList handlers=new HandlerList();
  handlers.addHandler(requestLogHandler);
  handlers.addHandler(getRequestHandler());
  server.setHandler(handlers);
  server.start();
}
 

Example 45

From project Metamorphosis, under directory /metamorphosis-server-wrapper/src/main/java/com/taobao/metamorphosis/http/.

Source file: MetamorphosisOnJettyBroker.java

  21 
vote

public void init(MetaMorphosisBroker metaMorphosisBroker,Properties props){
  Handler handler=new MetamorphosisOnJettyProcessor(metaMorphosisBroker);
  this.props=props;
  server=new Server();
  server.setHandler(handler);
  SelectChannelConnector connector=new SelectChannelConnector();
  connector.setPort(Integer.parseInt(this.props.getProperty("serverPort","8080")));
  server.setConnectors(new Connector[]{connector});
}
 

Example 46

From project meteo, under directory /core/src/main/java/com/ning/metrics/meteo/publishers/.

Source file: ResmonPublisher.java

  21 
vote

public ResmonPublisher() throws Exception {
  Handler handler=new AbstractHandler(){
    public void handle(    String target,    HttpServletRequest request,    HttpServletResponse response,    int dispatch) throws IOException, ServletException {
    }
    /** 
 * Handle a request.
 * @param target      The target of the request - either a URI or a name.
 * @param baseRequest The original unwrapped request object.
 * @param request     The request either as the {@link org.eclipse.jetty.server.Request}object or a wrapper of that request. The  {@link org.eclipse.jetty.server.HttpConnection#getCurrentConnection()}method can be used access the Request object if required.
 * @param response    The response as the {@link org.eclipse.jetty.server.Response}object or a wrapper of that request. The  {@link org.eclipse.jetty.server.HttpConnection#getCurrentConnection()}method can be used access the Response object if required.
 * @throws java.io.IOException
 * @throws javax.servlet.ServletException
 */
    @Override public void handle(    String target,    Request baseRequest,    HttpServletRequest request,    HttpServletResponse response) throws IOException, ServletException {
      response.setContentType("text/xml; encoding=UTF-8");
      response.setStatus(HttpServletResponse.SC_OK);
      response.getWriter().println(writeResmon());
      ((Request)request).setHandled(true);
    }
  }
;
  Server server=new Server(8083);
  server.setHandler(handler);
  server.start();
}
 

Example 47

From project objectos-comuns-sitebricks, under directory /src/test/java/br/com/objectos/comuns/sitebricks/.

Source file: Jetty.java

  21 
vote

public Jetty(WebAppContext webAppContext,int port){
  this.port=port;
  this.server=new Server(port);
  webAppContext.addLifeCycleListener(new WebAppContextListener());
  this.server.setHandler(webAppContext);
}
 

Example 48

From project org.ops4j.pax.url, under directory /pax-url-aether/src/test/java/org/ops4j/pax/url/mvn/internal/.

Source file: MirrorTest.java

  21 
vote

@Before public void startHttp() throws Exception {
  server=new Server();
  SelectChannelConnector connector=new SelectChannelConnector();
  connector.setPort(8181);
  server.addConnector(connector);
  ResourceHandler resource_handler=new ResourceHandler();
  resource_handler.setDirectoriesListed(false);
  resource_handler.setWelcomeFiles(new String[]{});
  resource_handler.setResourceBase("target/test-classes/repo2");
  HandlerList handlers=new HandlerList();
  handlers.setHandlers(new Handler[]{resource_handler,new DefaultHandler()});
  server.setHandler(handlers);
  server.start();
}
 

Example 49

From project picketbox-http, under directory /src/test/java/org/picketbox/test/http/jetty/.

Source file: EmbeddedWebServerBase.java

  21 
vote

@Before public void setUp() throws Exception {
  server=new Server();
  server.setConnectors(getConnectors());
  this.establishUserApps();
  server.start();
}
 

Example 50

From project Places, under directory /service/src/main/java/org/folg/places/service/.

Source file: Main.java

  21 
vote

/** 
 * @param args
 */
public static void main(String[] args) throws Exception {
  String webappDirLocation="service/src/main/webapp/";
  String webPort=System.getenv("PORT");
  if (webPort == null || webPort.isEmpty()) {
    webPort="8080";
  }
  Server server=new Server(Integer.valueOf(webPort));
  WebAppContext root=new WebAppContext();
  root.setContextPath("/");
  root.setDescriptor(webappDirLocation + "/WEB-INF/web.xml");
  root.setResourceBase(webappDirLocation);
  root.setParentLoaderPriority(true);
  server.setHandler(root);
  server.start();
  server.join();
}
 

Example 51

From project platform_3, under directory /event/src/test/java/com/proofpoint/event/client/.

Source file: TestHttpEventClient.java

  21 
vote

private Server createServer(final DummyServlet servlet) throws Exception {
  int port;
  ServerSocket socket=new ServerSocket();
  try {
    socket.bind(new InetSocketAddress(0));
    port=socket.getLocalPort();
  }
  finally {
    socket.close();
  }
  baseUri=new URI("http",null,"127.0.0.1",port,null,null,null);
  Server server=new Server();
  server.setSendServerVersion(false);
  SelectChannelConnector httpConnector;
  httpConnector=new SelectChannelConnector();
  httpConnector.setName("http");
  httpConnector.setPort(port);
  server.addConnector(httpConnector);
  ServletHolder servletHolder=new ServletHolder(servlet);
  ServletContextHandler context=new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
  context.addServlet(servletHolder,"/*");
  HandlerCollection handlers=new HandlerCollection();
  handlers.addHandler(context);
  server.setHandler(handlers);
  return server;
}
 

Example 52

From project playn, under directory /server/src/playn/server/.

Source file: GameServer.java

  21 
vote

public GameServer(int port){
  server=new Server(port);
  servletHandler=new ServletContextHandler(ServletContextHandler.SESSIONS);
  servletHandler.setContextPath("/rpc");
  resourceHandler=new ResourceHandler();
  resourceHandler.setDirectoriesListed(true);
  resourceHandler.setWelcomeFiles(new String[]{"index.html"});
  resourceHandler.setResourceBase("www");
  HandlerList list=new HandlerList();
  list.setHandlers(new Handler[]{resourceHandler,servletHandler,new DefaultHandler()});
  server.setHandler(list);
}
 

Example 53

From project reef-example-apps, under directory /apps/web-embedded/src/main/java/org/totalgrid/reef/examples/web/embedded/.

Source file: WebEmbedded.java

  21 
vote

public static void main(String[] args) throws Exception {
  if (args.length < 2) {
    System.out.println("Usage: <broker settings> <user settings>");
    System.exit(-1);
  }
  int result=0;
  AmqpSettings amqp=new AmqpSettings(args[0]);
  UserSettings user=new UserSettings(args[1]);
  ConnectionFactory connectionFactory=ReefConnectionFactory.buildFactory(amqp,new ReefServices());
  Connection connection=null;
  try {
    connection=connectionFactory.connect();
    Client client=connection.login(user);
    Server server=new Server(8080);
    server.setHandler(new WebEmbedded(client));
    System.out.println("Starting Jetty web server...");
    server.start();
    server.join();
  }
 catch (  ReefServiceException rse) {
    System.out.println("Reef service error: " + rse.getMessage() + ". check that Reef server is running.");
    rse.printStackTrace();
    result=-1;
  }
 finally {
    if (connection != null) {
      connection.disconnect();
    }
    connectionFactory.terminate();
  }
  System.exit(result);
}
 

Example 54

From project repose, under directory /project-set/core/valve/src/main/java/com/rackspace/cloud/valve/jetty/.

Source file: ValveJettyServerBuilder.java

  21 
vote

public Server newServer(){
  Server server=new Server();
  List<Connector> connectors=new ArrayList<Connector>();
  for (  Port p : ports) {
    if ("http".equalsIgnoreCase(p.getProtocol())) {
      connectors.add(createHttpConnector(p));
    }
 else     if ("https".equalsIgnoreCase(p.getProtocol())) {
      connectors.add(createHttpsConnector(p));
    }
  }
  server.setConnectors(connectors.toArray(new Connector[connectors.size()]));
  final ServletContextHandler rootContext=buildRootContext(server);
  final FilterHolder powerFilterHolder=new FilterHolder(ValvePowerFilter.class);
  final ServletHolder valveServer=new ServletHolder(new ProxyServlet());
  rootContext.addFilter(powerFilterHolder,"/*",EnumSet.allOf(DispatcherType.class));
  rootContext.addServlet(valveServer,"/*");
  server.setHandler(rootContext);
  return server;
}
 

Example 55

From project rest-driver, under directory /rest-client-driver/src/main/java/com/github/restdriver/clientdriver/.

Source file: ClientDriver.java

  21 
vote

/** 
 * Constructor. This will find a free port, bind to it and start the server up before it returns.
 * @param handler The  {@link ClientDriverJettyHandler} to use.
 * @param port The port to listen on. Expect startup errors if this port is not free.
 */
public ClientDriver(ClientDriverJettyHandler handler,int port){
  this.port=port;
  this.handler=handler;
  jettyServer=new Server(port);
  startJetty();
}
 

Example 56

From project restfuse, under directory /com.eclipsesource.restfuse/src/com/eclipsesource/restfuse/internal/callback/.

Source file: CallbackServer.java

  21 
vote

private void configureServer(){
  server=new Server(port);
  ServletContextHandler context=new ServletContextHandler(server,"/",ServletContextHandler.SESSIONS);
  servlet=new CallbackSerlvet(resource,statement);
  context.addServlet(new ServletHolder(servlet),path);
}
 

Example 57

From project revoc, under directory /src/main/java/no/kantega/labs/revoc/agent/.

Source file: JettyStarter.java

  21 
vote

public void start(Properties props) throws Exception {
  String port=props.getProperty("port");
  if (port != null) {
    log("Using HTTP port " + port);
  }
 else {
    port="7070";
  }
  int p=0;
  try {
    p=Integer.parseInt(port);
  }
 catch (  NumberFormatException e) {
    err("Port is not a number: " + port);
    System.exit(-1);
  }
  Server server=new Server(p);
  HandlerList collection=new HandlerList();
  ServletContextHandler ctx=new ServletContextHandler();
  ctx.setContextPath("/ws");
  ctx.addServlet(RevocWebSocketServlet.class,"/ws");
  collection.addHandler(ctx);
  collection.addHandler(new WebHandler(new CompondSourceSource(new MavenProjectSourceSource(),new MavenSourceArtifactSourceSource())));
  server.setHandler(collection);
  server.start();
}
 

Example 58

From project sandbox_2, under directory /wicket15-html5-parent/wicket-html5-examples/src/test/java/org/wicketstuff/html5/.

Source file: Start.java

  21 
vote

public static void main(String[] args) throws Exception {
  Server server=new Server();
  SocketConnector connector=new SocketConnector();
  connector.setMaxIdleTime(1000 * 60 * 60);
  connector.setSoLingerTime(-1);
  connector.setPort(8080);
  server.setConnectors(new Connector[]{connector});
  WebAppContext bb=new WebAppContext();
  bb.setServer(server);
  bb.setContextPath("/");
  bb.setWar("src/main/webapp");
  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(100);
  }
}
 

Example 59

From project ServiceFramework, under directory /src/net/csdn/modules/http/.

Source file: HttpServer.java

  21 
vote

@Inject public HttpServer(Settings settings,RestController restController){
  this.restController=restController;
  server=new Server();
  SelectChannelConnector connector=new SelectChannelConnector();
  connector.setPort(settings.getAsInt("http.port",8080));
  server.addConnector(connector);
  HandlerList handlers=new HandlerList();
  handlers.setHandlers(new Handler[]{new DefaultHandler()});
  server.setHandler(handlers);
}
 

Example 60

From project Socket.IO-Java, under directory /samples/broadcast/src/main/java/com/glines/socketio/sample/broadcast/.

Source file: BroadcastServer.java

  21 
vote

/** 
 * @param args
 * @throws Exception 
 */
public static void main(String[] args) throws Exception {
  String host="localhost";
  int port=8080;
  if (args.length > 0) {
    host=args[0];
  }
  if (args.length > 1) {
    port=Integer.parseInt(args[1]);
  }
  Server server=new Server();
  SelectChannelConnector connector=new SelectChannelConnector();
  connector.setHost(host);
  connector.setPort(port);
  server.addConnector(connector);
  ServletContextHandler context=new ServletContextHandler(ServletContextHandler.SESSIONS);
  ServletHolder holder=new ServletHolder(new BroadcastSocketServlet());
  holder.setInitParameter(FlashSocketTransport.FLASHPOLICY_SERVER_HOST_KEY,host);
  holder.setInitParameter(FlashSocketTransport.FLASHPOLICY_DOMAIN_KEY,host);
  holder.setInitParameter(FlashSocketTransport.FLASHPOLICY_PORTS_KEY,"" + port);
  context.addServlet(holder,"/socket.io/*");
  server.setHandler(context);
  server.start();
}
 

Example 61

From project sonatype-aether, under directory /aether-connector-asynchttpclient/src/test/java/org/sonatype/aether/connector/async/.

Source file: ResumeGetTest.java

  21 
vote

@Before public void before() throws Exception {
  factory=new AsyncRepositoryConnectorFactory(new SysoutLogger(),new TestFileProcessor());
  session=new TestRepositorySystemSession();
  artifact=new StubArtifact("gid","aid","classifier","extension","version");
  server=new Server(0);
}
 

Example 62

From project spark_1, under directory /src/main/java/spark/webserver/.

Source file: SparkServerImpl.java

  21 
vote

@Override public void ignite(int port){
  Server server=new Server();
  SocketConnector connector=new SocketConnector();
  connector.setMaxIdleTime(1000 * 60 * 60);
  connector.setSoLingerTime(-1);
  connector.setPort(port);
  server.setConnectors(new Connector[]{connector});
  server.setHandler(handler);
  try {
    System.out.println("== " + NAME + " has ignited ...");
    System.out.println(">> Listening on 0.0.0.0:" + port);
    server.start();
synchronized (lock) {
      while (!stopped) {
        try {
          lock.wait();
        }
 catch (        Exception e) {
        }
      }
    }
    System.out.println(">>> " + NAME + " shutting down...");
    server.stop();
    server.join();
  }
 catch (  Exception e) {
    e.printStackTrace();
    System.exit(100);
  }
}
 

Example 63

From project spring-data-neo4j, under directory /spring-data-neo4j-examples/todos/src/main/java/.

Source file: Main.java

  21 
vote

public static void main(String[] args) throws Exception {
  String webappDirLocation="src/main/webapp/";
  String webPort=System.getenv("PORT");
  if (webPort == null || webPort.isEmpty()) {
    webPort="8080";
  }
  Server server=new Server(Integer.valueOf(webPort));
  WebAppContext root=new WebAppContext();
  root.setContextPath("/");
  root.setDescriptor(webappDirLocation + "/WEB-INF/web.xml");
  root.setResourceBase(webappDirLocation);
  root.setParentLoaderPriority(true);
  server.setHandler(root);
  server.start();
  server.join();
}
 

Example 64

From project streetlights, under directory /streetlights-server/src/main/java/streetlights/server/.

Source file: ResourceServer.java

  21 
vote

protected void initServerDelegate(){
  delegate=new Server();
  try {
    home=new File(RoadService.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).getParentFile().getParent();
    System.setProperty("jetty.home",home);
  }
 catch (  Exception e) {
    throw new RuntimeException("Unable to determine server home",e);
  }
}
 

Example 65

From project tapx, under directory /tapx-heroku/src/main/java/com/howardlewisship/tapx/heroku/.

Source file: JettyMain.java

  21 
vote

public void startServer() throws Exception {
  String webPort=System.getenv("PORT");
  int port=isBlank(webPort) ? 8080 : Integer.parseInt(webPort);
  Server server=new Server(port);
  WebAppContext root=new WebAppContext();
  SessionHandler sessionHandler=new SessionHandler();
  if (mongoURL != null) {
    System.out.printf("Starting Jetty server, port %d, for '%s', using MongoDB URL '%s' (session collection '%s').\n",port,webappFolder,mongoURL,sessionCollectionName);
    MongoURI mongoURI=new MongoURI(mongoURL);
    DB connectedDB=mongoURI.connectDB();
    if (mongoURI.getUsername() != null) {
      connectedDB.authenticate(mongoURI.getUsername(),mongoURI.getPassword());
    }
    DBCollection sessions=connectedDB.getCollection(sessionCollectionName);
    SessionIdManager sessionIdManager=new MongoSessionIdManager(server,sessions);
    MongoSessionManager manager=new MongoSessionManager();
    manager.setSessionIdManager(sessionIdManager);
    sessionHandler.setSessionManager(manager);
  }
 else {
    System.out.printf("Starting Jetty server, port %d, for '%s', using in-memory sessions only.\n",port,webappFolder);
    sessionHandler.setSessionManager(new HashSessionManager());
  }
  root.setSessionHandler(sessionHandler);
  root.setContextPath("/");
  root.setDescriptor(webappFolder + "/WEB-INF/web.xml");
  root.setResourceBase(webappFolder);
  root.setParentLoaderPriority(true);
  server.setHandler(root);
  server.start();
  server.join();
}
 

Example 66

From project teachus, under directory /teachus-frontend/src/test/java/dk/teachus/frontend/test/.

Source file: JettyStarter.java

  21 
vote

public static void main(String[] args) throws Exception {
  System.setProperty("wicket.configuration","development");
  Server server=new Server(8080);
  WebAppContext webAppContext=new WebAppContext("src/main/webapp","/");
  webAppContext.setConfigurationClasses(new String[]{WebInfConfiguration.class.getName(),WebXmlConfiguration.class.getName(),MetaInfConfiguration.class.getName(),FragmentConfiguration.class.getName(),EnvConfiguration.class.getName(),PlusConfiguration.class.getName(),JettyWebXmlConfiguration.class.getName()});
  webAppContext.setInitParameter("doDynamicDataImport","true");
  MysqlConnectionPoolDataSource dataSource=new MysqlConnectionPoolDataSource();
  dataSource.setUrl("jdbc:mysql://localhost/teachus");
  dataSource.setUser("root");
  dataSource.setPassword("");
  new Resource("jdbc/teachus",dataSource);
  server.setHandler(webAppContext);
  server.start();
  server.join();
}
 

Example 67

From project templeton, under directory /src/java/org/apache/hcatalog/templeton/.

Source file: Main.java

  21 
vote

public Server runServer(int port) throws Exception {
  if (UserGroupInformation.isSecurityEnabled()) {
    UserGroupInformation.loginUserFromKeytab(conf.kerberosPrincipal(),conf.kerberosKeytab());
  }
  Server server=new Server(port);
  ServletContextHandler root=new ServletContextHandler(server,"/");
  FilterHolder fHolder=makeAuthFilter();
  root.addFilter(fHolder,"/" + SERVLET_PATH + "/v1/ddl/*",FilterMapping.REQUEST);
  root.addFilter(fHolder,"/" + SERVLET_PATH + "/v1/pig/*",FilterMapping.REQUEST);
  root.addFilter(fHolder,"/" + SERVLET_PATH + "/v1/hive/*",FilterMapping.REQUEST);
  root.addFilter(fHolder,"/" + SERVLET_PATH + "/v1/queue/*",FilterMapping.REQUEST);
  root.addFilter(fHolder,"/" + SERVLET_PATH + "/v1/mapreduce/*",FilterMapping.REQUEST);
  root.addFilter(fHolder,"/" + SERVLET_PATH + "/v1/status/*",FilterMapping.REQUEST);
  root.addFilter(fHolder,"/" + SERVLET_PATH + "/v1/version/*",FilterMapping.REQUEST);
  ServletHolder h=new ServletHolder(new ServletContainer(makeJerseyConfig()));
  root.addServlet(h,"/" + SERVLET_PATH + "/*");
  addRedirects(server);
  server.start();
  return server;
}
 

Example 68

From project tycho, under directory /tycho-bundles/org.eclipse.tycho.test.utils/src/main/java/org/eclipse/tycho/test/util/.

Source file: HttpServer.java

  21 
vote

private static HttpServer doStartServer(String username,String password,int port) throws Exception {
  Server server=new Server();
  Connector connector=new SocketConnector();
  connector.setPort(port);
  server.addConnector(connector);
  ServletContextHandler context;
  if (username != null) {
    context=new ServletContextHandler(server,"/",ServletContextHandler.SESSIONS | ServletContextHandler.SECURITY);
    HashLoginService userRealm=new HashLoginService("default");
    userRealm.putUser(username,new Password(password),new String[0]);
    Constraint constraint=new Constraint(Constraint.__BASIC_AUTH,Constraint.ANY_ROLE);
    constraint.setAuthenticate(true);
    ConstraintMapping constraintMapping=new ConstraintMapping();
    constraintMapping.setPathSpec("/*");
    constraintMapping.setConstraint(constraint);
    ConstraintSecurityHandler securityHandler=(ConstraintSecurityHandler)context.getSecurityHandler();
    securityHandler.setLoginService(userRealm);
    securityHandler.setAuthMethod(Constraint.__BASIC_AUTH);
    securityHandler.setConstraintMappings(new ConstraintMapping[]{constraintMapping});
  }
 else {
    context=new ServletContextHandler(server,"/",0);
  }
  server.start();
  return new HttpServer(port,server,context);
}
 

Example 69

From project vysper, under directory /server/admin-console/src/main/java/org/apache/vysper/console/.

Source file: AdminConsole.java

  21 
vote

/** 
 * Start the admin console in an embedded web server
 * @throws Exception
 */
public void start() throws Exception {
  server=new Server(port);
  WebAppContext context=new WebAppContext();
  context.setDescriptor("src/main/resources/webapp/WEB-INF/web.xml");
  context.setResourceBase("src/main/resources/webapp");
  context.setContextPath("/");
  server.setHandler(context);
  server.start();
}
 

Example 70

From project arquillian-container-jetty, under directory /jetty-embedded-7/src/main/java/org/jboss/arquillian/container/jetty/embedded_7/.

Source file: JettyEmbeddedContainer.java

  20 
vote

public void start() throws LifecycleException {
  try {
    String configuredConfigurationClasses=containerConfig.getConfigurationClasses();
    if (configuredConfigurationClasses != null && configuredConfigurationClasses.trim().length() > 0) {
      this.configurationClasses=configuredConfigurationClasses.split(",");
    }
 else     if (containerConfig.isJettyPlus()) {
      if (VersionUtil.isGraterThenOrEqual(Server.getVersion(),"7.2")) {
        configurationClasses=JETTY_PLUS_CONFIGURATION_CLASSES;
      }
 else {
        configurationClasses=JETTY_PLUS_PRE_7_2_CONFIGURATION_CLASSES;
      }
    }
    server=new Server();
    Connector connector=new SelectChannelConnector();
    connector.setHost(containerConfig.getBindAddress());
    connector.setPort(containerConfig.getBindHttpPort());
    server.setConnectors(new Connector[]{connector});
    server.setHandler(new HandlerCollection(true));
    log.info("Starting Jetty Embedded Server " + Server.getVersion() + " [id:"+ server.hashCode()+ "]");
    server.start();
  }
 catch (  Exception e) {
    throw new LifecycleException("Could not start container",e);
  }
}
 

Example 71

From project arquillian_deprecated, under directory /containers/jetty-embedded-7/src/main/java/org/jboss/arquillian/container/jetty/embedded_7/.

Source file: JettyEmbeddedContainer.java

  20 
vote

public void start() throws LifecycleException {
  try {
    String configuredConfigurationClasses=containerConfig.getConfigurationClasses();
    if (configuredConfigurationClasses != null && configuredConfigurationClasses.trim().length() > 0) {
      this.configurationClasses=configuredConfigurationClasses.split(",");
    }
 else     if (containerConfig.isJettyPlus()) {
      if (VersionUtil.isGraterThenOrEqual(Server.getVersion(),"7.2")) {
        configurationClasses=JETTY_PLUS_CONFIGURATION_CLASSES;
      }
 else {
        configurationClasses=JETTY_PLUS_PRE_7_2_CONFIGURATION_CLASSES;
      }
    }
    server=new Server();
    Connector connector=new SelectChannelConnector();
    connector.setHost(containerConfig.getBindAddress());
    connector.setPort(containerConfig.getBindHttpPort());
    server.setConnectors(new Connector[]{connector});
    server.setHandler(new HandlerCollection(true));
    log.info("Starting Jetty Embedded Server " + Server.getVersion() + " [id:"+ server.hashCode()+ "]");
    server.start();
  }
 catch (  Exception e) {
    throw new LifecycleException("Could not start container",e);
  }
}
 

Example 72

From project eventtracker, under directory /http/src/test/java/com/ning/metrics/eventtracker/.

Source file: TestHttpSender.java

  20 
vote

@BeforeClass(alwaysRun=true) public void setUpGlobal() throws Exception {
  final int port=findFreePort();
  server=new Server(port);
  errorServer=new Server(port){
    @Override public void handle(    final AbstractHttpConnection connection) throws IOException, ServletException {
      final String target=connection.getRequest().getPathInfo();
      final Request request=connection.getRequest();
      final Response response=connection.getResponse();
      response.setStatus(404);
      handle(target,request,request,response);
    }
  }
;
  System.setProperty("eventtracker.collector.port",Integer.toString(port));
  final EventTrackerConfig config=new ConfigurationObjectFactory(System.getProperties()).build(EventTrackerConfig.class);
  sender=new HttpSender(config.getCollectorHost(),config.getCollectorPort(),config.getEventType(),config.getHttpMaxWaitTimeInMillis(),config.getHttpMaxKeepAlive().getMillis(),10);
  failureCallbackHandler=new CallbackHandler(){
    @Override public void onError(    final Throwable t,    final File event){
      logger.debug("Got error (good): " + t.getMessage());
    }
    @Override public void onSuccess(    final File event){
      Assert.fail("Got success when we were expecting failure. Uh oh.");
    }
  }
;
  successCallbackHandler=new CallbackHandler(){
    @Override public void onError(    final Throwable t,    final File event){
      Assert.fail("Got error (bad!): ",t);
    }
    @Override public void onSuccess(    final File event){
      logger.debug("Got success. Yay.");
    }
  }
;
  Assert.assertTrue(eventsFile.createNewFile());
  final FileWriter writer=new FileWriter(eventsFile);
  writer.write("{ \"eventName\":\"Hello\", \"payload\": { \"dontcare\": \"World\" } }");
  writer.close();
}
 

Example 73

From project grouperfish, under directory /service/src/main/java/com/mozilla/grouperfish/rest/jersey/.

Source file: JerseyGuiceRestService.java

  20 
vote

/** 
 * Initializes a Jersey based JAX-RS service using the given resource configuration. The procided confgiuration class must not be anonymous.
 */
public JerseyGuiceRestService(final Injector parentInjector,final Class<? extends ResourceConfig> resourceConfigClass){
  Assert.nonNull(parentInjector);
  Assert.nonNull(resourceConfigClass,resourceConfigClass.getCanonicalName());
  Assert.check(!resourceConfigClass.getCanonicalName().isEmpty());
  final int port=Integer.parseInt(System.getProperty(PROPERTY_PORT,PROPERTY_PORT_DEFAULT));
  server=new Server(port);
  final ServletContextHandler root=new ServletContextHandler(server,"/",ServletContextHandler.NO_SESSIONS);
  root.addEventListener(new GuiceServletContextListener(){
    @Override protected Injector getInjector(){
      return parentInjector.createChildInjector(new JerseyServletModule(){
        protected void configureServlets(){
          final Map<String,String> params=new HashMap<String,String>();
          params.put(PackagesResourceConfig.PROPERTY_PACKAGES,"jetty");
          params.put("com.sun.jersey.config.property.resourceConfigClass",resourceConfigClass.getCanonicalName());
          serve("/*").with(GuiceContainer.class,params);
        }
      }
);
    }
  }
);
  root.addFilter(GuiceFilter.class,"/*",null);
  root.addServlet(DefaultServlet.class,"/");
  server.setSendServerVersion(false);
  server.setSendDateHeader(false);
  server.setStopAtShutdown(true);
}
 

Example 74

From project httpcache4j, under directory /httpcache4j-it/src/test/java/org/codehaus/httpcache4j/.

Source file: AbstractCacheIntegrationTest.java

  20 
vote

@BeforeClass public static void setupServer() throws Exception {
  baseRequestURI=URI.create(String.format("http://localhost:%s/testbed/",JettyServer.PORT));
  baseCustomRequestURI=URI.create(String.format("http://localhost:%s/custom/",JettyServer.PORT));
  System.out.println("::: Starting server :::");
  jettyServer=new Server(JettyServer.PORT);
  final String webapp="target/testbed/";
  if (!TestUtil.getTestFile(webapp).exists()) {
    throw new IllegalStateException("WebApp dir does not exist!");
  }
  HandlerList handlerList=new HandlerList();
  Handler webAppHandler=new WebAppContext(webapp,"/testbed");
  handlerList.addHandler(webAppHandler);
  ServletContextHandler contextHandler=new ServletContextHandler(ServletContextHandler.SESSIONS);
  contextHandler.setContextPath("/custom");
  contextHandler.addServlet(VaryResourceServlet.class,"/*");
  handlerList.addHandler(contextHandler);
  jettyServer.setHandler(handlerList);
  jettyServer.start();
}
 

Example 75

From project ios-driver, under directory /server/src/main/java/org/uiautomation/ios/server/.

Source file: IOSServer.java

  20 
vote

private void init(IOSServerConfiguration options) throws IOSAutomationSetupException {
  this.options=options;
  this.port=options.getPort();
  server=new Server(new InetSocketAddress("0.0.0.0",options.getPort()));
  ServletContextHandler wd=new ServletContextHandler(server,"/wd/hub",true,false);
  wd.addServlet(UIAScriptProxyRegister.class,"/uiascriptproxy/register/*");
  wd.addServlet(UIAScriptServlet.class,"/uiascriptproxy/*");
  wd.addServlet(IOSServlet.class,"/*");
  wd.addServlet(ResourceServlet.class,"/resources/*");
  ServletContextHandler extra=new ServletContextHandler(server,"/",true,false);
  try {
    String ide="org.uiautomation.ios.ide.IDEServlet";
    Class<?> c=Class.forName(ide);
    Class<Servlet> r=(Class<Servlet>)c;
    extra.addServlet(r,"/ide/*");
  }
 catch (  Exception e) {
    System.err.println("couldn't find ide servlet");
  }
  HandlerList handlers=new HandlerList();
  handlers.setHandlers(new Handler[]{wd,extra});
  server.setHandler(handlers);
  IOSDriver driver=new IOSDriver(port);
  for (  String app : this.options.getSupportedApps()) {
    driver.addSupportedApplication(new IOSApplication(app));
  }
  wd.setAttribute(DRIVER,driver);
  Runtime.getRuntime().addShutdownHook(new Thread(){
    public void run(){
      try {
        server.stop();
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
    }
  }
);
}
 

Example 76

From project jackrabbit-oak, under directory /oak-run/src/main/java/org/apache/jackrabbit/oak/run/.

Source file: Main.java

  20 
vote

public HttpServer(String uri,String[] args){
  int port=java.net.URI.create(uri).getPort();
  if (port == -1) {
    port=PORT;
  }
  context=new ServletContextHandler(ServletContextHandler.SECURITY);
  context.setContextPath("/");
  if (args.length == 0) {
    System.out.println("Starting an in-memory repository");
    System.out.println(uri + " -> [memory]");
    kernels=new MicroKernel[]{new MicroKernelImpl()};
    addServlets(kernels[0],"");
  }
 else   if (args.length == 1) {
    System.out.println("Starting a standalone repository");
    System.out.println(uri + " -> " + args[0]);
    kernels=new MicroKernel[]{new MicroKernelImpl(args[0])};
    addServlets(kernels[0],"");
  }
 else {
    System.out.println("Starting a clustered repository");
    kernels=new MicroKernel[args.length];
    for (int i=0; i < args.length; i++) {
      System.out.println(uri + "/node" + i+ "/ -> "+ args[i]);
      kernels[i]=new MicroKernelImpl(args[i]);
      addServlets(kernels[i],"/node" + i);
    }
  }
  server=new Server(port);
  server.setHandler(context);
}
 

Example 77

From project jspwiki, under directory /tests/org/apache/wiki/web/.

Source file: TestContainer.java

  20 
vote

/** 
 * Prepares a Jetty server with its HTTP and shutdown handlers. Callers must start the server by calling  {@link #start()}.
 * @throws Exception you know, just in case
 */
public TestContainer() throws Exception {
  String contextFactoryClass=System.getProperty(INITIAL_CONTEXT_FACTORY);
  if (contextFactoryClass == null) {
    System.setProperty(INITIAL_CONTEXT_FACTORY,INITIAL_CONTEXT_FACTORY_JETTY);
    log.error("No JNDI context factory found; using org.eclipse.jndi.InitialContextFactory.");
    contextFactoryClass=INITIAL_CONTEXT_FACTORY_JETTY;
  }
  log.error("Initialized JNDI with context factory class=" + contextFactoryClass + ".");
  Context initCtx=new InitialContext();
  try {
    initCtx.lookup("java:comp");
  }
 catch (  NameNotFoundException e) {
    initCtx.bind("java:comp",new NamingContext(new Hashtable<String,Object>(),"java:comp",null,new InitialContextFactory.DefaultParser()));
    log.error("No JNDI java:comp namespace found; creating it,");
  }
  log.info("Initialized JNDI java:comp namespace.=" + contextFactoryClass);
  log.info("Creating new test container.");
  System.setProperty("org.eclipse.xml.XmlParser.NotValidating","true");
  server=new Server();
  server.setStopAtShutdown(true);
  SocketConnector connector=new SocketConnector();
  connector.setHost("localhost");
  connector.setPort(HTTP_PORT);
  connector.setMaxIdleTime(60000);
  server.setConnectors(new Connector[]{connector});
  log.info("added HTTP listener for port " + HTTP_PORT);
  ContextHandler shutDownContextHandler=new ContextHandler(SHUTDOWN_CMD);
  shutDownContextHandler.setHandler(new ShutdownHandler());
  handlerCollection.addHandler(shutDownContextHandler);
}
 

Example 78

From project koshinuke.java, under directory /test/java/org/koshinuke/test/.

Source file: JettyTestContainerFactory.java

  20 
vote

public JettyTestContainer(URI baseUri,SimpleAppDescriptor ad) throws IllegalArgumentException {
  this.baseUri=baseUri;
  try {
    ServletHolder holder=new ServletHolder(ServletContainer.class);
    holder.setInitParameter(ServletContainer.APPLICATION_CONFIG_CLASS,ad.getApplicationClass().getName());
    holder.setInitParameter(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS,GZIPContentEncodingFilter.class.getName());
    holder.setInitParameter(ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS,GZIPContentEncodingFilter.class.getName());
    ServletContextHandler sch=new ServletContextHandler();
    sch.setAttribute(Configuration.NAME,new File("src/test/koshinuke-test.properties").toURI().toURL());
    sch.setResourceBase("src/webapp");
    sch.addServlet(holder,"/*");
    this.server=new Server(this.baseUri.getPort());
    this.server.setHandler(sch);
  }
 catch (  MalformedURLException e) {
    throw new IllegalArgumentException(e);
  }
}
 

Example 79

From project odata4j, under directory /odata4j-cxf/src/main/java/org/odata4j/cxf/producer/server/.

Source file: CxfJettyServer.java

  20 
vote

@Override public ODataServer start(){
  if (odataApp == null)   throw new RuntimeException("ODataApplication not set");
  URL url;
  try {
    url=new URL(appBaseUri);
  }
 catch (  MalformedURLException e) {
    throw Throwables.propagate(e);
  }
  CXFNonSpringJaxrsServlet odataServlet=new CXFNonSpringJaxrsServlet();
  ServletHolder odataServletHolder=new ServletHolder(odataServlet);
  odataServletHolder.setInitParameter("javax.ws.rs.Application",odataApp.getCanonicalName());
  ServletContextHandler contextHandler=new ServletContextHandler(ServletContextHandler.SESSIONS);
  contextHandler.addServlet(odataServletHolder,normalizePath(url.getPath()) + "/*");
  if (rootApp != null) {
    CXFNonSpringJaxrsServlet rootServlet=new CXFNonSpringJaxrsServlet();
    ServletHolder rootServletHolder=new ServletHolder(rootServlet);
    rootServletHolder.setInitParameter("javax.ws.rs.Application",rootApp.getCanonicalName());
    contextHandler.addServlet(rootServletHolder,"/*");
  }
  server=new Server(url.getPort());
  server.setHandler(getHandlerCollection(contextHandler));
  try {
    server.start();
    return this;
  }
 catch (  Exception e) {
    throw Throwables.propagate(e);
  }
}
 

Example 80

From project ontology-broker, under directory /src/org/sc/probro/.

Source file: BrokerStart.java

  20 
vote

public BrokerStart(int port,String resourceBase){
  server=new Server(port);
  Map<String,String> params=new TreeMap<String,String>();
  params.put("org.apache.jasper.Constants.SERVLET_CLASSPATH","org.sc.probro.jsps");
  params.put("org.apache.jasper.servlet.JspServlet.classpath","org.sc.probro.jsps");
  context=new ServletContextHandler(ServletContextHandler.SESSIONS);
  context.setContextPath("/");
  context.setResourceBase(resourceBase);
  context.setInitParams(params);
  context.addEventListener(new FileCleanerCleanup());
  ResourceHandler recs=new ResourceHandler();
  recs.setResourceBase(resourceBase + "/static");
  recs.setCacheControl("max-age=3600");
  RequestLogHandler logHandler=new RequestLogHandler();
  HandlerList handlers=new HandlerList();
  handlers.setHandlers(new Handler[]{context,recs});
  logHandler.setHandler(handlers);
  server.setHandler(logHandler);
  NCSARequestLog requestLog=new NCSARequestLog("./logs/broker-yyyy_mm_dd.request.log");
  requestLog.setRetainDays(90);
  requestLog.setAppend(true);
  requestLog.setExtended(false);
  requestLog.setLogTimeZone("GMT");
  logHandler.setRequestLog(requestLog);
}
 

Example 81

From project qi4j-libraries, under directory /shiro-core/src/test/java/org/qi4j/library/shiro/.

Source file: AbstractServletTestSupport.java

  20 
vote

@Before public void before() throws Exception {
  InetAddress loopback=InetAddress.getLocalHost();
  int port=findFreePortOnIfaceWithPreference(loopback,8989);
  httpHost=new HttpHost(loopback.getHostAddress(),port);
  jetty=new Server(port);
  configureJetty(jetty);
  ServletContextHandler sch=new ServletContextHandler(jetty,"/",ServletContextHandler.SESSIONS | ServletContextHandler.NO_SECURITY);
  sch.addEventListener(new AbstractQi4jServletBootstrap(){
    public ApplicationAssembly assemble(    ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
      ApplicationAssembly app=applicationFactory.newApplicationAssembly();
      ModuleAssembly module=app.layer(TEST_LAYER).module(TEST_MODULE);
      AbstractServletTestSupport.this.assemble(module);
      return app;
    }
  }
);
  sch.addServlet(ServletUsingSecuredService.class,SECURED_SERVLET_PATH);
  configureServletContext(sch);
  jetty.start();
}
 

Example 82

From project security_1, under directory /security-web-sample/src/test/java/org/sonatype/security/sample/web/.

Source file: SampleAppIT.java

  20 
vote

protected void setUp() throws Exception {
  appPort=getFreePort();
  String baseName="target/test-classes/" + this.getClass().getName().replaceAll("\\.","/");
  File securityXml=new File(baseName + "-security.xml");
  FileUtils.copyFile(securityXml,new File(CONF_DIR,"security.xml"));
  File securityConfigXml=new File(baseName + "-security-configuration.xml");
  FileUtils.copyFile(securityConfigXml,new File(CONF_DIR,"security-configuration.xml"));
  appServer=new Server();
  SocketConnector connector=new SocketConnector();
  connector.setMaxIdleTime(1000 * 60 * 60);
  connector.setSoLingerTime(-1);
  connector.setPort(appPort);
  appServer.setConnectors(new Connector[]{connector});
  WebAppContext app=new WebAppContext();
  app.setServer(appServer);
  app.setContextPath("/sample");
  app.setWar("./target/sample.war");
  HandlerList handlers=new HandlerList();
  handlers.addHandler(app);
  appServer.setHandler(handlers);
  appServer.start();
}
 

Example 83

From project tapestry5-portlet, under directory /src/test/java/org/apache/tapestry5/test/.

Source file: Jetty7Runner.java

  20 
vote

public Jetty7Runner configure(String webappFolder,String contextPath,int port,int sslPort) throws Exception {
  this.port=port;
  this.sslPort=sslPort;
  String expandedPath=expand(webappFolder);
  description=String.format("<Jetty7Runner: %s:%s/%s (%s)",contextPath,port,sslPort,expandedPath);
  jettyServer=new Server(port);
  WebAppContext webapp=new WebAppContext();
  webapp.setContextPath(contextPath);
  webapp.setWar(expandedPath);
  File desc=new File(TapestryTestConstants.MODULE_BASE_DIR,"src/main/webapp/WEB-INF/plugin-web-testng.xml");
  webapp.setDescriptor(desc.getAbsolutePath());
  File keystoreFile=new File(TapestryTestConstants.MODULE_BASE_DIR,"src/test/conf/keystore");
  if (keystoreFile.exists()) {
    SslSelectChannelConnector sslConnector=new SslSelectChannelConnector();
    sslConnector.setPort(sslPort);
    sslConnector.setKeystore(keystoreFile.getPath());
    sslConnector.setPassword("tapestry");
    sslConnector.setKeyPassword("tapestry");
    jettyServer.addConnector(sslConnector);
  }
  jettyServer.setHandler(webapp);
  return this;
}
 

Example 84

From project components-ness-httpserver_1, under directory /src/main/java/com/nesscomputing/httpserver/.

Source file: AbstractJetty8HttpServer.java

  19 
vote

private void buildConnectors(final Server server){
  final Set<HttpConnector> connectors=Sets.newHashSet();
  for (  Map.Entry<String,HttpConnector> entry : getConnectors().entrySet()) {
    final String connectorName=entry.getKey();
    final HttpConnector connector=entry.getValue();
    if (connectors.contains(connector)) {
      LOG.warn("Multiple configurations for '%s', skipping",connector);
      continue;
    }
    connectors.add(connector);
    final SelectChannelConnector jettyConnector;
    if (connector.isSecure()) {
      final SslContextFactory sslContextFactory=new SslContextFactory(SslContextFactory.DEFAULT_KEYSTORE_PATH);
      if (httpServerConfig.getSSLKeystorePath() != null) {
        sslContextFactory.setKeyStoreType(httpServerConfig.getSSLKeystoreType());
        sslContextFactory.setKeyStorePath(httpServerConfig.getSSLKeystorePath());
        sslContextFactory.setKeyStorePassword(httpServerConfig.getSSLKeystorePassword());
      }
      jettyConnector=new SslSelectChannelConnector(sslContextFactory);
    }
 else {
      jettyConnector=new SelectChannelConnector();
    }
    jettyConnector.setPort(connector.getPort());
    jettyConnector.setHost(connector.getAddress());
    connector.setJettyConnector(jettyConnector);
    jettyConnector.setStatsOn(true);
    jettyConnector.setForwarded(httpServerConfig.isForwarded());
    jettyConnector.setMaxIdleTime(httpServerConfig.getMaxIdletime());
    jettyConnector.setResponseHeaderSize(httpServerConfig.getResponseHeaderSize());
    LOG.debug("Adding connector [%s] as %s",connectorName,connector);
    server.addConnector(jettyConnector);
  }
}
 

Example 85

From project gitblit, under directory /src/com/gitblit/.

Source file: GitBlitServer.java

  19 
vote

public ShutdownMonitorThread(Server server,Params params){
  this.server=server;
  setDaemon(true);
  setName(Constants.NAME + " Shutdown Monitor");
  ServerSocket skt=null;
  try {
    skt=new ServerSocket(params.shutdownPort,1,InetAddress.getByName("127.0.0.1"));
  }
 catch (  Exception e) {
    logger.warn("Could not open shutdown monitor on port " + params.shutdownPort,e);
  }
  socket=skt;
}
 

Example 86

From project jagger, under directory /chassis/core/src/main/java/com/griddynamics/jagger/.

Source file: JaggerLauncher.java

  19 
vote

private static void launchCometdCoordinationServer(final URL directory){
  LaunchTask jettyRunner=new LaunchTask(){
    public void run(){
      log.info("Starting Cometd Coordination Server");
      ApplicationContext context=loadContext(directory,COORDINATION_HTTP_CONFIGURATION,environmentProperties);
      Server jettyServer=(Server)context.getBean("jettyServer");
      try {
        jettyServer.start();
      }
 catch (      Exception e) {
        throw new RuntimeException(e);
      }
    }
  }
;
  builder.addMainTask(jettyRunner);
}
 

Example 87

From project jetty-maven-plugin, under directory /src/main/java/org/mortbay/jetty/plugin/.

Source file: Monitor.java

  19 
vote

public Monitor(int port,String key,Server[] servers,boolean kill) throws UnknownHostException, IOException {
  if (port <= 0)   throw new IllegalStateException("Bad stop port");
  if (key == null)   throw new IllegalStateException("Bad stop key");
  _key=key;
  _servers=servers;
  _kill=kill;
  setDaemon(true);
  setName("StopJettyPluginMonitor");
  _serverSocket=new ServerSocket(port,1,InetAddress.getByName("127.0.0.1"));
  _serverSocket.setReuseAddress(true);
}
 

Example 88

From project jetty-session-redis, under directory /src/main/java/com/ovea/jetty/session/redis/.

Source file: RedisSessionIdManager.java

  19 
vote

public RedisSessionIdManager(Server server,final String jndiName){
  super(server);
  this.jedisExecutor=new JedisExecutor(){
    JedisExecutor delegate;
    @Override public <V>V execute(    JedisCallback<V> cb){
      if (delegate == null) {
        try {
          InitialContext ic=new InitialContext();
          JedisPool jedisPool=(JedisPool)ic.lookup(jndiName);
          delegate=new PooledJedisExecutor(jedisPool);
        }
 catch (        Exception e) {
          throw new IllegalStateException("Unable to find instance of " + JedisExecutor.class.getName() + " in JNDI location "+ jndiName+ " : "+ e.getMessage(),e);
        }
      }
      return delegate.execute(cb);
    }
  }
;
}
 

Example 89

From project maven-hudson-dev-plugin, under directory /src/main/java/org/mortbay/jetty/plugin/.

Source file: Monitor.java

  19 
vote

public Monitor(int port,String key,Server[] servers,boolean kill) throws UnknownHostException, IOException {
  if (port <= 0)   throw new IllegalStateException("Bad stop port");
  if (key == null)   throw new IllegalStateException("Bad stop key");
  _key=key;
  _servers=servers;
  _kill=kill;
  setDaemon(true);
  setName("StopJettyPluginMonitor");
  _serverSocket=new ServerSocket(port,1,InetAddress.getByName("127.0.0.1"));
  _serverSocket.setReuseAddress(true);
}
 

Example 90

From project OpenConext-api, under directory /coin-api-war/src/test/java/nl/surfnet/coin/selenium/.

Source file: Oauth20AuthorizationGrantTestSelenium.java

  19 
vote

@Before public void startServer(){
  LOG.debug("Starting server for catching authorization code...");
  server=new MockHtppServer(8083){
    protected MockHandler createHandler(    Server server){
      return new MockHandler(server){
        @Override public void handle(        String target,        Request baseRequest,        HttpServletRequest request,        HttpServletResponse response) throws IOException, ServletException {
          if (request.getRequestURI().contains("favicon")) {
            LOG.debug("ignoring favicon-request.");
            return;
          }
          LOG.debug("Request to mock http server: {}",request);
          authorizationCode=new Verifier(request.getParameter("code"));
          response.setStatus(200);
        }
      }
;
    }
  }
;
  server.startServer();
}
 

Example 91

From project stubby4j, under directory /src/main/java/org/stubby/server/.

Source file: JettyOrchestrator.java

  19 
vote

public JettyOrchestrator(final YamlParser yamlParser,final Server server,final DataStore dataStore,final Map<String,String> commandLineArgs){
  this.yamlParser=yamlParser;
  this.server=server;
  this.dataStore=dataStore;
  this.commandLineArgs=commandLineArgs;
}