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


Java WebApplication类代码示例

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


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

示例1: initiate

import com.sun.jersey.spi.container.WebApplication; //导入依赖的package包/类
@Override
protected void initiate(ResourceConfig rc, WebApplication wa) {
    try {
        //Register the OfflineRestFilter
        String filters = (String) rc.getProperties().get(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS);
        rc.getProperties().put(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS,
                filters + ",org.artifactory.rest.filter.OfflineRestFilter");
        //Register the lICENSERestFilter
        filters = (String) rc.getProperties().get(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS);
        rc.getProperties().put(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS,
                filters + ",org.artifactory.rest.filter.LicenseRestFilter");
        //Register spring as component provider
        ArtifactoryContext artifactoryContext = (ArtifactoryContext) getServletContext().getAttribute(
                ArtifactoryContext.APPLICATION_CONTEXT_KEY);
        SpringComponentProviderFactory springComponentProviderFactory =
                new SpringComponentProviderFactory(rc, (ConfigurableApplicationContext) artifactoryContext);
        wa.initiate(rc, springComponentProviderFactory);
    } catch (RuntimeException e) {
        log.error("Exception in initialization of the Rest servlet");
        throw e;
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:23,代码来源:ArtifactoryRestServlet.java

示例2: initiate

import com.sun.jersey.spi.container.WebApplication; //导入依赖的package包/类
@Override
protected void initiate(ResourceConfig rc, WebApplication wa) {
  Application app = createApplication();
  try {
    // initialize the Jetty system
    rc.add(app);
    wa.initiate(rc, new SpringComponentProviderFactory(rc, getContext()));
    
  } catch (RuntimeException ex) {
    s_logger.error("Exception occurred during intialization", ex);
    throw ex;
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:14,代码来源:OpenGammaSpringServlet.java

示例3: initiate

import com.sun.jersey.spi.container.WebApplication; //导入依赖的package包/类
@Override
protected void initiate(ResourceConfig rc, WebApplication wa) {
  Application app = createApplication();
  try {
    // initialize the Jetty system
    // if more advanced control is needed, the second line can take an IoCComponentProviderFactory
    rc.add(app);
    wa.initiate(rc);
    
  } catch (RuntimeException ex) {
    s_logger.error("Exception occurred during intialization", ex);
    throw ex;
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:15,代码来源:OpenGammaServlet.java

示例4: ProvidesResource

import com.sun.jersey.spi.container.WebApplication; //导入依赖的package包/类
@Inject
public ProvidesResource(DaggerContainer daggerContainer, WebApplication webApplication, Providers providers,
                        FeaturesAndProperties featuresAndProperties, MessageBodyWorkers messageBodyWorkers,
                        ExceptionMapperContext exceptionMapperContext, ResourceContext resourceContext) {
    assertNotNull(daggerContainer);
    assertNotNull(webApplication);
    assertNotNull(providers);
    assertNotNull(featuresAndProperties);
    assertNotNull(messageBodyWorkers);
    assertNotNull(exceptionMapperContext);
    assertNotNull(resourceContext);
}
 
开发者ID:johnlcox,项目名称:dagger-servlet,代码行数:13,代码来源:JerseyModuleProvidesTest.java

示例5: configure

import com.sun.jersey.spi.container.WebApplication; //导入依赖的package包/类
@Override
protected void configure(WebConfig wc,
                         ResourceConfig rc,
                         WebApplication wa) {
  super.configure(wc, rc, wa);
  Set<Object> singletons = rc.getSingletons();
  singletons.add(new WebAppApiProvider());
}
 
开发者ID:apache,项目名称:incubator-slider,代码行数:9,代码来源:AgentWebApp.java

示例6: createContainer

import com.sun.jersey.spi.container.WebApplication; //导入依赖的package包/类
@Override
public NettyContainer createContainer(Class<NettyContainer> type, ResourceConfig resourceConfig,
                                      WebApplication application) throws ContainerException {
    Preconditions.checkNotNull(type);
    Preconditions.checkNotNull(application);
    if (!type.equals(NettyContainer.class)) {
        logger.error(
                "Netty container provider can only create container of type {}. Invoked to create container of type {}",
                NettyContainer.class.getName(), type.getName());
    }
    return new NettyContainer(application);
}
 
开发者ID:Netflix,项目名称:karyon,代码行数:13,代码来源:NettyContainerProvider.java

示例7: createContainer

import com.sun.jersey.spi.container.WebApplication; //导入依赖的package包/类
public NettyHandlerContainer createContainer(Class<NettyHandlerContainer> clazz, ResourceConfig config,WebApplication webApp)
           throws ContainerException {
	if (clazz != NettyHandlerContainer.class) {
		return null;
	}
	return new NettyHandlerContainer(webApp, config);
}
 
开发者ID:Netflix,项目名称:recipes-rss,代码行数:8,代码来源:JerseyContainerProvider.java

示例8: initialize

import com.sun.jersey.spi.container.WebApplication; //导入依赖的package包/类
@Before
public void initialize() throws Exception {
    webApplication = mock(WebApplication.class, RETURNS_MOCKS);
}
 
开发者ID:cvent,项目名称:pangaea,代码行数:5,代码来源:EnvironmentModifierFilterTest.java

示例9: testFilterContainerRequest

import com.sun.jersey.spi.container.WebApplication; //导入依赖的package包/类
/**
 * リクエストフィルタとしてメソッド/ヘッダオーバライドを実施していることを確認.
 * X-FORWARDED-PROTO、X-FORWARDED-HOSTヘッダでリクエストUri, Base UriのPROTO, HOST部が書き換わることを確認。
 * @throws URISyntaxException URISyntaxException
 */
@Test
public void testFilterContainerRequest() throws URISyntaxException {
    // 被テストオブジェクトを準備
    PersoniumCoreContainerFilter containerFilter = new PersoniumCoreContainerFilter();
    // ContainerRequiestを準備
    WebApplication wa = mock(WebApplication.class);
    InBoundHeaders headers = new InBoundHeaders();
    // メソッドオーバーライド
    headers.add(PersoniumCoreUtils.HttpHeaders.X_HTTP_METHOD_OVERRIDE, HttpMethod.OPTIONS);
    // ヘッダオーバーライド
    String authzValue = "Bearer tokenstring";
    String acceptValue = "text/html";
    String contentTypeValue = "application/xml";
    headers.add(PersoniumCoreUtils.HttpHeaders.X_OVERRIDE, HttpHeaders.AUTHORIZATION + ": " + authzValue);
    headers.add(HttpHeaders.ACCEPT, contentTypeValue);
    headers.add(PersoniumCoreUtils.HttpHeaders.X_OVERRIDE, HttpHeaders.ACCEPT + ": " + acceptValue);
    headers.add(HttpHeaders.CONTENT_TYPE, contentTypeValue);

    // X-FORWARDED-* 系のヘッダ設定
    String scheme = "https";
    String host = "example.org";
    headers.add(PersoniumCoreUtils.HttpHeaders.X_FORWARDED_PROTO, scheme);
    headers.add(PersoniumCoreUtils.HttpHeaders.X_FORWARDED_HOST, host);

    ContainerRequest request = new ContainerRequest(wa, HttpMethod.POST,
            new URI("http://dc1.example.com/hoge"),
            new URI("http://dc1.example.com/hoge/hoho"),
            headers, null);

    // HttpServletRequestのmockを準備
    HttpServletRequest mockServletRequest = mock(HttpServletRequest.class);
    when(mockServletRequest.getRequestURL()).thenReturn(new StringBuffer("http://dc1.example.com"));

    ServletContext mockServletContext = mock(ServletContext.class);
    when(mockServletContext.getContextPath()).thenReturn("");
    when(mockServletRequest.getServletContext()).thenReturn(mockServletContext);
    containerFilter.setHttpServletRequest(mockServletRequest);

    // 被テスト処理の実行
    ContainerRequest filteredRequest = containerFilter.filter(request);

    // 結果の検証。
    Assert.assertEquals(HttpMethod.OPTIONS, filteredRequest.getMethod());
    Assert.assertEquals(authzValue, filteredRequest.getHeaderValue(HttpHeaders.AUTHORIZATION));
    Assert.assertEquals(acceptValue, filteredRequest.getHeaderValue(HttpHeaders.ACCEPT));

    Assert.assertEquals(contentTypeValue, filteredRequest.getHeaderValue(HttpHeaders.CONTENT_TYPE));
    Assert.assertEquals(scheme, filteredRequest.getRequestUri().getScheme());
    Assert.assertEquals(host, filteredRequest.getRequestUri().getHost());
}
 
开发者ID:personium,项目名称:personium-core,代码行数:56,代码来源:PersoniumCoreContainerFilterTest.java

示例10: PersoniumCoreContainerFilter

import com.sun.jersey.spi.container.WebApplication; //导入依赖的package包/类
/**
 * 認証なしのOPTIONSメソッドがリクエストされた場合にpersoniumで受け付けている全メソッドが返却されること.
 * @throws URISyntaxException URISyntaxException
 */
@Test
public void 認証なしのOPTIONSメソッドがリクエストされた場合にpersoniumで受け付けている全メソッドが返却されること() throws URISyntaxException {
    // 被テストオブジェクトを準備
    PersoniumCoreContainerFilter containerFilter = new PersoniumCoreContainerFilter();
    // ContainerRequiestを準備
    WebApplication wa = mock(WebApplication.class);
    InBoundHeaders headers = new InBoundHeaders();
    // X-FORWARDED-* 系のヘッダ設定
    String scheme = "https";
    String host = "example.org";
    headers.add(PersoniumCoreUtils.HttpHeaders.X_FORWARDED_PROTO, scheme);
    headers.add(PersoniumCoreUtils.HttpHeaders.X_FORWARDED_HOST, host);
    ContainerRequest request = new ContainerRequest(wa, HttpMethod.OPTIONS,
            new URI("http://dc1.example.com/hoge"),
            new URI("http://dc1.example.com/hoge/hoho"),
            headers, null);
    // HttpServletRequestのmockを準備
    HttpServletRequest mockServletRequest = mock(HttpServletRequest.class);
    when(mockServletRequest.getRequestURL()).thenReturn(new StringBuffer("http://dc1.example.com"));
    ServletContext mockServletContext = mock(ServletContext.class);
    when(mockServletContext.getContextPath()).thenReturn("");
    when(mockServletRequest.getServletContext()).thenReturn(mockServletContext);
    containerFilter.setHttpServletRequest(mockServletRequest);
    try {
        containerFilter.filter(request);
    } catch (WebApplicationException e) {
        Response response = e.getResponse();
        assertEquals(response.getStatus(), HttpStatus.SC_OK);
        MultivaluedMap<String, Object> meta = response.getMetadata();
        List<Object> values = meta.get("Access-Control-Allow-Methods");
        assertEquals(values.size(), 1);
        String value = (String) values.get(0);
        String[] methods = value.split(",");
        Map<String, String> masterMethods = new HashMap<String, String>();
        masterMethods.put(HttpMethod.OPTIONS, "");
        masterMethods.put(HttpMethod.GET, "");
        masterMethods.put(HttpMethod.POST, "");
        masterMethods.put(HttpMethod.PUT, "");
        masterMethods.put(HttpMethod.DELETE, "");
        masterMethods.put(HttpMethod.HEAD, "");
        masterMethods.put(io.personium.common.utils.PersoniumCoreUtils.HttpMethod.MERGE, "");
        masterMethods.put(io.personium.common.utils.PersoniumCoreUtils.HttpMethod.MKCOL, "");
        masterMethods.put(io.personium.common.utils.PersoniumCoreUtils.HttpMethod.MOVE, "");
        masterMethods.put(io.personium.common.utils.PersoniumCoreUtils.HttpMethod.PROPFIND, "");
        masterMethods.put(io.personium.common.utils.PersoniumCoreUtils.HttpMethod.PROPPATCH, "");
        masterMethods.put(io.personium.common.utils.PersoniumCoreUtils.HttpMethod.ACL, "");
        for (String method : methods) {
            if (method.trim() == "") {
                continue;
            }
            String m = masterMethods.remove(method.trim());
            if (m == null) {
                fail("Method " + method + " is not defined.");
            }
        }
        if (!masterMethods.isEmpty()) {
            fail("UnExcpected Error.");
        }
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:65,代码来源:OptionsMethodTest.java

示例11: initiate

import com.sun.jersey.spi.container.WebApplication; //导入依赖的package包/类
@Override
protected void initiate(ResourceConfig config, WebApplication webapp) {
    this.webapp = webapp;
    webapp.initiate(config, new ServletGuiceComponentProviderFactory(config, injector));
}
 
开发者ID:jclawson,项目名称:dropwizardry,代码行数:6,代码来源:GuiceContainer.java

示例12: getWebApplication

import com.sun.jersey.spi.container.WebApplication; //导入依赖的package包/类
public WebApplication getWebApplication() {
    return webapp;
}
 
开发者ID:jclawson,项目名称:dropwizardry,代码行数:4,代码来源:GuiceContainer.java

示例13: webApp

import com.sun.jersey.spi.container.WebApplication; //导入依赖的package包/类
@Override
public WebApplication webApp(com.sun.jersey.guice.spi.container.servlet.GuiceContainer guiceContainer) {
    return container.getWebApplication();
}
 
开发者ID:jclawson,项目名称:dropwizardry,代码行数:5,代码来源:JerseyContainerModule.java

示例14: webApplication

import com.sun.jersey.spi.container.WebApplication; //导入依赖的package包/类
@Provides
public WebApplication webApplication(DaggerContainer daggerContainer) {
    return daggerContainer.getWebApplication();
}
 
开发者ID:johnlcox,项目名称:dagger-servlet,代码行数:5,代码来源:JerseyModule.java

示例15: provideProviders

import com.sun.jersey.spi.container.WebApplication; //导入依赖的package包/类
@Provides
public Providers provideProviders(WebApplication webApplication) {
    return webApplication.getProviders();
}
 
开发者ID:johnlcox,项目名称:dagger-servlet,代码行数:5,代码来源:JerseyModule.java


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