• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java HttpHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.glassfish.grizzly.http.server.HttpHandler的典型用法代码示例。如果您正苦于以下问题:Java HttpHandler类的具体用法?Java HttpHandler怎么用?Java HttpHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HttpHandler类属于org.glassfish.grizzly.http.server包,在下文中一共展示了HttpHandler类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: WebServer

import org.glassfish.grizzly.http.server.HttpHandler; //导入依赖的package包/类
public WebServer(URI endpoint) throws IOException {
  this.server = GrizzlyServerFactory.createHttpServer(endpoint, new HttpHandler() {

    @Override
    public void service(Request rqst, Response rspns) throws Exception {
      rspns.setStatus(HttpStatus.NOT_FOUND_404.getStatusCode(), "Not found");
      rspns.getWriter().write("404: not found");
    }
  });

  WebappContext context = new WebappContext("WebappContext", BASE_PATH);
  ServletRegistration registration = context.addServlet("ServletContainer", ServletContainer.class);
  registration.setInitParameter(ServletContainer.RESOURCE_CONFIG_CLASS,
      PackagesResourceConfig.class.getName());

  StringJoiner sj = new StringJoiner(",");
  for (String s : PACKAGES) {
    sj.add(s);
  }

  registration.setInitParameter(PackagesResourceConfig.PROPERTY_PACKAGES, sj.toString());
  registration.addMapping(BASE_PATH);
  context.deploy(server);
}
 
开发者ID:uber,项目名称:AthenaX,代码行数:25,代码来源:WebServer.java


示例2: startManagementHttpServer

import org.glassfish.grizzly.http.server.HttpHandler; //导入依赖的package包/类
private void startManagementHttpServer() throws Exception {
    final String httpManagementServerUrl = _properties.getProperty("managementurl", HTTP_MANAGEMENTSERVER_URL);
    final ResourceConfig config = new ResourceConfig().register(RaqetService.class).register(new RaqetBinder(_raqetControll));
    final CLStaticHttpHandler staticHttpHandler = new CLStaticHttpHandler(this.getClass().getClassLoader(), "/static/");


    _httpManagementServer = GrizzlyHttpServerFactory.createHttpServer(URI.create(httpManagementServerUrl), config);
    _httpManagementServer.getServerConfiguration().addHttpHandler(staticHttpHandler, "/gui/");
    /* Redirect users to the GUI */
    _httpManagementServer.getServerConfiguration().addHttpHandler(new HttpHandler() {
        @Override
        public void service(final Request request, final Response response) throws Exception {
            response.sendRedirect("/gui/");
        }
    }, "/index.html");
    _httpManagementServer.start();
}
 
开发者ID:raqet,项目名称:acquisition-server,代码行数:18,代码来源:Main.java


示例3: onMessage

import org.glassfish.grizzly.http.server.HttpHandler; //导入依赖的package包/类
@Override
public void onMessage(BlaubotMessage blaubotMessage) {
    eu.hgross.blaubot.blaubotcam.server.model.ImageMessage imageMessage = new eu.hgross.blaubot.blaubotcam.server.model.ImageMessage(blaubotMessage.getPayload());
    final String uniqueDeviceId = imageMessage.getUniqueDeviceId();
    CamDevice camDevice = mCamDevices.get(uniqueDeviceId);
    final boolean added;
    if (camDevice == null) {
        added = mCamDevices.putIfAbsent(uniqueDeviceId, new CamDevice(uniqueDeviceId)) == null;
    } else {
        added = false;
    }
    camDevice = mCamDevices.get(uniqueDeviceId);
    camDevice.putImageMessage(imageMessage);

    if (added) {
        // add the handler to the server
        HttpHandler httpHandler = new LiveVideoHttpHandler(camDevice);
        final String encodedDeviceId = EncodingUtil.encodeURIComponent(camDevice.getDeviceId());
        final String mjpegUri = URI_PATTERN.replace(URI_PATTERN_PARAM_ID, encodedDeviceId);
        final String singleJpegUri = URI_PATTERN.replace(URI_PATTERN_PARAM_ID, encodedDeviceId) + URI_ENDING_SINGLE_IMAGE;
        server.getServerConfiguration().addHttpHandler(httpHandler, mjpegUri, singleJpegUri);
    }
}
 
开发者ID:Blaubot,项目名称:Blaubot,代码行数:24,代码来源:IPCamServer.java


示例4: startServer

import org.glassfish.grizzly.http.server.HttpHandler; //导入依赖的package包/类
public <T extends DaggerServletContextListener> void startServer(Class<T> listenerClass) {
    LOGGER.info("Starting test server");

    WebappContext context = new WebappContext("Test", getUri().getRawPath());
    context.addListener(listenerClass);

    daggerFilter = new DaggerFilter();
    FilterRegistration filterRegistration = context.addFilter("daggerFilter", daggerFilter);
    filterRegistration.addMappingForUrlPatterns(null, "/*");

    ServletRegistration servletRegistration = context.addServlet("TestServlet", new HttpServlet() {
    });
    servletRegistration.addMapping("/dagger-jersey/*");

    try {
        httpServer = GrizzlyServerFactory.createHttpServer(getUri(), (HttpHandler) null);
        context.deploy(httpServer);
        httpServer.start();
        LOGGER.info("Test server started");
    } catch (IOException e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:johnlcox,项目名称:dagger-servlet,代码行数:24,代码来源:GrizzlyTestServer.java


示例5: addHandler

import org.glassfish.grizzly.http.server.HttpHandler; //导入依赖的package包/类
public void addHandler(final String data, final String path) {
    final HttpHandler httpHandler = new HttpHandler() {

        @Override
        public void service(final Request request, final Response response)
                throws Exception {
            response.getWriter().write(data);
        }
    };

    server.getServerConfiguration().addHttpHandler(httpHandler, "/" + path);
}
 
开发者ID:fcrepo4-exts,项目名称:fcrepo-mint,代码行数:13,代码来源:ContainerWrapper.java


示例6: configureHttpServer

import org.glassfish.grizzly.http.server.HttpHandler; //导入依赖的package包/类
private void configureHttpServer() {
    NetworkListener listener = new NetworkListener(config.getName(), config.getServerHost(), config.getServerPort());
    httpServer.addListener(listener);

    httpServer.getServerConfiguration().addHttpHandler(new HttpHandler() {
        @Override
        public void service(Request request, Response response) throws Exception {
            response.suspend();
            rootActor.tell(new GrizzlyHTTPRequest(request, response), ActorRef.noSender());
        }
    });
}
 
开发者ID:jembi,项目名称:openhim-mediator-engine-java,代码行数:13,代码来源:MediatorServer.java


示例7: handleRootContext

import org.glassfish.grizzly.http.server.HttpHandler; //导入依赖的package包/类
private void handleRootContext(HttpServer server, final String mainDir, final GatfConfigToolMojo mojo) {
	server.getServerConfiguration().addHttpHandler(
	    new HttpHandler() {
	        public void service(Request request, Response response) throws Exception {
	        	new CacheLessStaticHttpHandler(mainDir).service(request, response);
	        }
	    }, "/");
	
	server.getServerConfiguration().addHttpHandler(new GatfProjectZipHandler(mojo), "/projectZip");
}
 
开发者ID:sumeetchhetri,项目名称:gatf,代码行数:11,代码来源:GatfConfigToolMojo.java


示例8: get

import org.glassfish.grizzly.http.server.HttpHandler; //导入依赖的package包/类
@Override
protected HttpHandler get(Injector injector, Configurations configurations) {

    /* Setup our object mapper (could be qualified with path) */
    final ObjectMapper mapper = getInstance(injector, ObjectMapper.class, path);

    final Map<Class<?>, Integer> contractPriorities = new HashMap<>();
    contractPriorities.put(MessageBodyWriter.class, Integer.MIN_VALUE);
    contractPriorities.put(MessageBodyReader.class, Integer.MIN_VALUE);
    config.register(new JacksonJsonProvider(mapper,
                new Annotations[] { Annotations.JACKSON, Annotations.JAXB }),
                Collections.unmodifiableMap(contractPriorities));

    /* Create a ServiceLocator parent of all locators and inject the configurations */
    final ServiceLocator locator = ServiceLocatorFactory.create(injector, path);

    /* Set up the ObjectMapper that will be used by this application */
    ServiceLocatorUtilities.addOneConstant(locator, mapper, null, ObjectMapper.class);

    /* Create a brand new Grizzly HTTP container from Jersey */
    log.debug("Jersey application at \"%s\" initializing", path.value());
    GrizzlyHttpContainer container = GrizzlyHttpContainerFactory.create(config, locator);
    log.info("Jersey application at \"%s\" initialized successfully", path.value());

    /* Create our handler and add it to our server configuration  */
    final HttpServer server = injector.getInstance(HttpServer.class);
    server.getServerConfiguration().addHttpHandler(container, path.value());
    log.info("Serving \"%s\" using Jersey application \"%s\"", path.value(), config.getApplicationName());

    /* All done! */
    return container;
}
 
开发者ID:usrz,项目名称:java-libs-httpd,代码行数:33,代码来源:RestHandlerProvider.java


示例9: setup

import org.glassfish.grizzly.http.server.HttpHandler; //导入依赖的package包/类
@Inject
private void setup(Injector injector, HttpServer server) {
    final HttpHandler httpHandler;
    if (handler == null) {
        httpHandler = injector.getInstance(key);
    } else {
        injector.injectMembers(handler);
        httpHandler = handler;
    }

    server.getServerConfiguration().addHttpHandler(httpHandler, path);
    log.info("Serving \"%s\" using handler %s", path, httpHandler.getClass().getName());
}
 
开发者ID:usrz,项目名称:java-libs-httpd,代码行数:14,代码来源:HttpHandlerProvider.java


示例10: publishService

import org.glassfish.grizzly.http.server.HttpHandler; //导入依赖的package包/类
@Override
public void publishService(SoapWebService soapWebService) {
    String path = transportInfo.getBasePath() + soapWebService.getServicePath();
    log.info("Publishing soap web service "+soapWebService.getClass().getName()+" as: " + transportInfo.toUriString() + soapWebService.getServicePath() + "?wsdl");
    HttpHandler jaxwsHandler = new JaxwsHandler(soapWebService, false);
    httpServer.getServerConfiguration().addHttpHandler(jaxwsHandler,
            //see https://java.net/projects/grizzly/lists/users/archive/2014-11/message/7 for why this is done.
            HttpHandlerRegistration.bulder()
                    .contextPath(path)
                    .urlPattern("")
                    .build());
}
 
开发者ID:optimaize,项目名称:anythingworks,代码行数:13,代码来源:GrizzlySoapWebServicePublisher.java


示例11: createContainer

import org.glassfish.grizzly.http.server.HttpHandler; //导入依赖的package包/类
@Override
public <T> T createContainer(Class<T> type, Application application) throws ProcessingException {
    if (HttpHandler.class == type || GrizzlyHttpContainer.class == type) {
        return type.cast(new GrizzlyHttpContainer(application));
    }

    return null;
}
 
开发者ID:icode,项目名称:ameba-container-grizzly,代码行数:9,代码来源:GrizzlyHttpContainerProvider.java


示例12: init

import org.glassfish.grizzly.http.server.HttpHandler; //导入依赖的package包/类
public void init(String[] context) {
    logger.trace("Init-ing DiscoDJ");
    DiscoDjContainerLifecycleListener lifecycleListener = new DiscoDjContainerLifecycleListener();
    ResourceConfig rc = new ResourceConfig();
    rc.packages("com.totalchange.discodj.ws");
    rc.register(lifecycleListener);
    server = GrizzlyHttpServerFactory.createHttpServer(
            URI.create("http://0.0.0.0:58008/discodj/resources/api"), rc);

    HttpHandler mediaHandler = lifecycleListener.getInjector().getInstance(
            DiscoDjMediaHttpHandler.class);
    server.getServerConfiguration().addHttpHandler(mediaHandler,
            "/discodj/resources/media");
}
 
开发者ID:KolonelKustard,项目名称:discodj,代码行数:15,代码来源:DiscoDjApplication.java


示例13: addHandler

import org.glassfish.grizzly.http.server.HttpHandler; //导入依赖的package包/类
public void addHandler(HttpHandler handler, String url) {
	sercfg.addHttpHandler(handler, url);
}
 
开发者ID:coderczp,项目名称:HtmlSocket,代码行数:4,代码来源:PullServer.java


示例14: addHandler

import org.glassfish.grizzly.http.server.HttpHandler; //导入依赖的package包/类
private void addHandler(HttpHandlerPath path, Provider<HttpHandler> provider) {
    binder().bind(HttpHandler.class)
            .annotatedWith(path)
            .toProvider(provider)
            .asEagerSingleton();
}
 
开发者ID:usrz,项目名称:java-libs-httpd,代码行数:7,代码来源:ServerBuilder.java


示例15: get

import org.glassfish.grizzly.http.server.HttpHandler; //导入依赖的package包/类
@Override
public HttpHandler get() {
    return handler;
}
 
开发者ID:usrz,项目名称:java-libs-httpd,代码行数:5,代码来源:FileHandlerProvider.java


示例16: HttpHandlerProvider

import org.glassfish.grizzly.http.server.HttpHandler; //导入依赖的package包/类
public HttpHandlerProvider(Key<? extends HttpHandler> key, HttpHandlerPath path) {
    this.path = notNull(path, "Null path").value();
    this.key = notNull(key, "Null handler key");
    handler = null;
}
 
开发者ID:usrz,项目名称:java-libs-httpd,代码行数:6,代码来源:HttpHandlerProvider.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Pipeline类代码示例发布时间:2022-05-21
下一篇:
Java GetClusterMetricsRequest类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap