@Override
 public <T> T createEndpoint(Application application, Class<T> endpointType)
     throws IllegalArgumentException, UnsupportedOperationException {
   if (application instanceof ResourceConfig) {
     return ContainerFactory.createContainer(endpointType, (ResourceConfig) application);
   } else {
     return ContainerFactory.createContainer(endpointType, new ApplicationAdapter(application));
   }
 }
Example #2
0
  public void start() {
    this.host =
        ConfigurationManager.getConfigInstance()
            .getString("netty.http.host", "not-found-in-configuration");
    this.port =
        ConfigurationManager.getConfigInstance().getInt("netty.http.port", Integer.MIN_VALUE);

    final PackagesResourceConfig rcf =
        new PackagesResourceConfig(
            ConfigurationManager.getConfigInstance()
                .getString("jersey.resources.package", "not-found-in-configuration"));

    nettyServer =
        NettyServer.builder()
            .host(host)
            .port(port)
            .addHandler(
                "jerseyHandler", ContainerFactory.createContainer(NettyHandlerContainer.class, rcf))
            .numBossThreads(NettyServer.cpus)
            .numWorkerThreads(NettyServer.cpus * 4)
            .build();
    try {
      karyonServer.start();
    } catch (Exception exc) {
      throw new RuntimeException("Cannot start karyon server.", exc);
    }
  }
Example #3
0
  /** @param args */
  public static void main(String[] args) {
    // TODO Auto-generated method stub
    try {
      HttpServer server = HttpServerFactory.create("http://localhost:8080/");
      HttpHandler handler = ContainerFactory.createContainer(HttpHandler.class);
      server.removeContext("/");
      HttpContext cc = server.createContext("/", handler);

      cc.setAuthenticator(
          new BasicAuthenticator("mms") {
            @Override
            public boolean checkCredentials(String user, String pass) {
              User tmp = new sql().getUser(user, pass);
              if (tmp == null) return false;
              else return true;
            }
          });

      server.start();
      JOptionPane.showMessageDialog(null, "Server beenden", "Close", JOptionPane.ERROR_MESSAGE);
      server.stop(0);
    } catch (IllegalArgumentException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
 @Override
 public HttpHandler getObject() throws Exception {
   ResourceConfig resourceConfig = new DefaultResourceConfig();
   resourceConfig.getProperties().putAll(properties);
   resourceConfig.getFeatures().putAll(features);
   return ContainerFactory.createContainer(
       HttpHandler.class,
       resourceConfig,
       new SpringComponentProviderFactory(resourceConfig, applicationContext));
 }