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


Java CXFNonSpringJaxrsServlet类代码示例

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


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

示例1: getODataServletRegistrationBean

import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet; //导入依赖的package包/类
@Bean
public ServletRegistrationBean getODataServletRegistrationBean() {
	ServletRegistrationBean odataServletRegistrationBean = new ServletRegistrationBean(new CXFNonSpringJaxrsServlet(), "/odata.svc/*");
	Map<String, String> initParameters = new HashMap<String, String>();
	initParameters.put("javax.ws.rs.Application", "org.apache.olingo.odata2.core.rest.app.ODataApplication");
	initParameters.put("org.apache.olingo.odata2.service.factory", "com.sap.mentors.lemonaid.odata.JPAServiceFactory");
	odataServletRegistrationBean.setInitParameters(initParameters);
	return odataServletRegistrationBean;
}
 
开发者ID:sapmentors,项目名称:lemonaid,代码行数:10,代码来源:CxfServletRegister.java

示例2: getODataServletRegistrationBean

import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet; //导入依赖的package包/类
@Bean
public ServletRegistrationBean getODataServletRegistrationBean() {
	ServletRegistrationBean odataServletRegistrationBean = new ServletRegistrationBean(new CXFNonSpringJaxrsServlet(), "/odata.svc/*");
	Map<String, String> initParameters = new HashMap<String, String>();
	initParameters.put("javax.ws.rs.Application", "org.apache.olingo.odata2.core.rest.app.ODataApplication");
	initParameters.put("org.apache.olingo.odata2.service.factory", "com.penninkhof.odata.utils.JPAServiceFactory");
	odataServletRegistrationBean.setInitParameters(initParameters);
	return odataServletRegistrationBean;
}
 
开发者ID:jpenninkhof,项目名称:odata-boilerplate,代码行数:10,代码来源:CxfServletRegister.java

示例3: loadCases

import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet; //导入依赖的package包/类
@TestFactory
@Override
public Stream<DynamicTest> loadCases(String param) throws IOException, URISyntaxException {
    return super.loadCases(param)
                .map(test -> DynamicTest.dynamicTest(test.getDisplayName(), () -> {
                    try {
                        ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
                        servletContextHandler.setContextPath("/");

                        // CXF Servlet
                        ServletHolder cxfServletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet());
                        cxfServletHolder.setInitParameter("jaxrs.serviceClasses", TestServerResource.class.getName());
                        servletContextHandler.addServlet(cxfServletHolder, "/*");


                        server = new Server(4442);
                        server.setHandler(servletContextHandler);
                        server.start();

                        Log.setLog(new StdErrLog());

                        test.getExecutable().execute();
                    } finally {
                        try {
                            server.stop();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }));
}
 
开发者ID:MegafonWebLab,项目名称:histone-java2,代码行数:32,代码来源:HttpTranslatorTest.java

示例4: concreteTest

import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet; //导入依赖的package包/类
@Test
public void concreteTest() throws Exception {

    HistoneTestCase.Case testCase = new HistoneTestCase.Case();
    testCase.setExpectedResult("true");
    testCase.setContext(getMap());
    testCase.setInput("{{var response = loadJSON('http://127.0.0.1:4442/', [headers: ['via': 123]])}}{{response -> isArray() && response.headers['via'] != '123'}}");
    try {
        ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
        servletContextHandler.setContextPath("/");

        // CXF Servlet
        ServletHolder cxfServletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet());
        cxfServletHolder.setInitParameter("jaxrs.serviceClasses", TestServerResource.class.getName());
        servletContextHandler.addServlet(cxfServletHolder, "/*");

        server = new Server(4442);
        server.setHandler(servletContextHandler);

        server.start();
        Log.setLog(new StdErrLog());

        new CoreTestConsumer(parser, rtti, evaluator).accept(testCase);
    } finally {
        try {
            server.stop();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:MegafonWebLab,项目名称:histone-java2,代码行数:32,代码来源:HttpConcreteTest.java

示例5: launchService

import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet; //导入依赖的package包/类
public static void launchService(int port, String indexPath)
        throws IOException, LifecycleException {

    Tomcat server = new Tomcat();
    Context context = server.addContext("/", new File(".").getAbsolutePath());
    System.setProperty(INDEX_PATH_PROP, indexPath);

    Wrapper servlet = context.createWrapper();
    servlet.setName("CXFNonSpringJaxrs");
    servlet.setServletClass(CXFNonSpringJaxrsServlet.class.getName());
    servlet.addInitParameter("jaxrs.serviceClasses", SearchResource.class.getName() + " " + HealthCheckAPI.class.getName());

    servlet.setLoadOnStartup(1);
    context.addChild(servlet);
    context.addServletMapping("/api/*", "CXFNonSpringJaxrs");

    System.out.println("Starting Embedded Tomcat on port : " + port );
    server.setPort(port);
    server.start();
    server.getServer().await();
}
 
开发者ID:chrismattmann,项目名称:lucene-geo-gazetteer,代码行数:22,代码来源:Launcher.java

示例6: doTest

import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet; //导入依赖的package包/类
@Test
    public void doTest() throws Exception {
        String tpl = "{{var a = loadJSON('http://127.0.0.1:4442/testCache'), b = false && loadJSON('http://127.0.0.1:4442/testCache'),ba = false && loadJSON('http://127.0.0.1:4442/testCache'),bb = false && loadJSON('http://127.0.0.1:4442/testCache')}}{{var r = a + b + ba + bb}}{{var c =  [key: loadJSON('http://127.0.0.1:4442/testCache', [data: [ololo: r]]).requestCount, r:r]}}{{c.key = 2}}";
        String expectedAST = "[29,[24,[29,\"true\"],[6,[6,[6,[6,[6,[6,[15,1,3],[16,2,0]],[18,5,6]],[18,6,6]],[17,7,8]],[17,7,7]],[19,8,8]],[29,\"false\"]]]";
//        String expectedAST = "[29,[23,9,0],[21,0,0]]";
        String expectedResult = "true";

        Translator translator = new Translator();

//        AstNode tree = AstJsonProcessor.read(expectedAST);
//
        AstNode tree = parser.process(tpl, "");

        SsaOptimizer optimizer = new SsaOptimizer();
        optimizer.process(tree);

        expectedAST = AstJsonProcessor.write(tree);

        byte[] classBytes = translator.compile("Template1", tree);
        Map<String, byte[]> classes = Collections.singletonMap("Template1", classBytes);

        ByteClassLoader loader = new ByteClassLoader(new URL[]{}, getClass().getClassLoader(), classes);
        Class<?> t = loader.loadClass("Template1");

        StdLibrary library = new StdLibrary(converter);

        Template template = (Template) t.newInstance();
        template.setStdLibrary(library);
        template.setConverter(converter);

        Assert.assertEquals(template.getStringAst(), expectedAST);

        String baseURI = "acceptance/simple/function/global";

        Context context = Context.createRoot(baseURI, US_LOCALE, rtti, new DefaultPropertyHolder());

        ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
        servletContextHandler.setContextPath("/");

        // CXF Servlet
        ServletHolder cxfServletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet());
        cxfServletHolder.setInitParameter("jaxrs.serviceClasses", TestServerResource.class.getName());
        servletContextHandler.addServlet(cxfServletHolder, "/*");


        Server server = new Server(4442);
        server.setHandler(servletContextHandler);
        server.start();
        Log.setLog(new StdErrLog());


//        if (testCase.getContext() != null) {
//        for (Map.Entry<String, Object> entry : getMap().entrySet()) {
//            if (entry.getKey().equals("this")) {
//                context.put("this", CompletableFuture.completedFuture(converter.constructFromObject(entry.getValue())));
//            } else {
//                context.getVars().put(entry.getKey(), CompletableFuture.completedFuture(converter.constructFromObject(entry.getValue())));
//            }
//        }
//        }

        String result = template.render(context)
                                .thenCompose(v -> RttiUtils.callToString(context, v))
                                .thenApply(n -> ((StringEvalNode) n).getValue())
                                .join();
        Assert.assertEquals(result, expectedResult);
    }
 
开发者ID:MegafonWebLab,项目名称:histone-java2,代码行数:68,代码来源:SimpleTranslatorTest.java

示例7: loadCases

import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet; //导入依赖的package包/类
@TestFactory
@Override
public Stream<DynamicTest> loadCases(String param) throws IOException, URISyntaxException {
    return super.loadCases(param)
                .map(test -> DynamicTest.dynamicTest(test.getDisplayName(), () -> {
                    try {
                        ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
                        servletContextHandler.setContextPath("/");

                        // CXF Servlet
                        ServletHolder cxfServletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet());
                        cxfServletHolder.setInitParameter("jaxrs.serviceClasses", TestServerResource.class.getName());
                        servletContextHandler.addServlet(cxfServletHolder, "/*");


                        server = new Server(4442);
                        server.setHandler(servletContextHandler);
                        server.start();
                        Log.setLog(new StdErrLog());

                        test.getExecutable().execute();
                    } finally {
                        try {
                            server.stop();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }));
}
 
开发者ID:MegafonWebLab,项目名称:histone-java2,代码行数:31,代码来源:HttpResourceLoaderTest.java

示例8: setupRestApiContextHandler

import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet; //导入依赖的package包/类
private static ServletContextHandler setupRestApiContextHandler(ZeppelinConfiguration conf) {
  final ServletHolder cxfServletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet());
  cxfServletHolder.setInitParameter("javax.ws.rs.Application", ZeppelinServer.class.getName());
  cxfServletHolder.setName("rest");
  cxfServletHolder.setForcedPath("rest");

  final ServletContextHandler cxfContext = new ServletContextHandler();
  cxfContext.setSessionHandler(new SessionHandler());
  cxfContext.setContextPath(conf.getServerContextPath());
  cxfContext.addServlet(cxfServletHolder, "/api/*");

  cxfContext.addFilter(new FilterHolder(CorsFilter.class), "/*",
      EnumSet.allOf(DispatcherType.class));
  return cxfContext;
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:16,代码来源:ZeppelinServer.java

示例9: main

import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    // create dummy backend
    DummyOrderService dummy = new DummyOrderService();
    dummy.setupDummyOrders();

    // create rider order service with dummy backend
    RestOrderService orderService = new RestOrderService();
    orderService.setOrderService(dummy);

    // create JAX-RS application with our rider order serivce
    RestOrderApplication app = new RestOrderApplication(orderService);

    // setup servlet holder with a CXF jax-rs servlet to handle the app
    Servlet servlet = new CXFNonSpringJaxrsServlet(app);
    ServletHolder holder = new ServletHolder(servlet);
    holder.setName("rider");
    holder.setForcedPath("/");
    ServletContextHandler context = new ServletContextHandler();
    context.addServlet(holder, "/*");

    // create and start the jetty server (non blocking)
    Server server = new Server(9000);
    server.setHandler(context);
    server.start();

    // keep the JVM running
    Console console = System.console();
    System.out.println("Server started on http://localhost:9000/");
    System.out.println("");

    // If you run the main class from IDEA/Eclipse then you may not have a console, which is null)
    if (console != null) {
        System.out.println("  Press ENTER to stop server");
        console.readLine();
    } else {
        System.out.println("  Stopping after 5 minutes or press ctrl + C to stop");
        Thread.sleep(5 * 60 * 1000);
    }

    // stop jetty server
    server.stop();
    System.exit(0);
}
 
开发者ID:camelinaction,项目名称:camelinaction2,代码行数:44,代码来源:RestOrderServer.java

示例10: setupResourcesContextHandler

import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet; //导入依赖的package包/类
private static ServletContextHandler setupResourcesContextHandler(
		VarOneConfiguration conf) {
	final ServletHolder cxfServletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet());
    cxfServletHolder.setInitParameter("javax.ws.rs.Application", VarOneServer.class.getName());
    cxfServletHolder.setName("rest");
    cxfServletHolder.setForcedPath("rest");

    final ServletContextHandler cxfContext = new ServletContextHandler();
    cxfContext.setSessionHandler(new SessionHandler());
    cxfContext.setContextPath(conf.getServerContextPath());
    cxfContext.addServlet(cxfServletHolder, "/rest/*");

    return cxfContext;
}
 
开发者ID:SparkMonitor,项目名称:varOne,代码行数:15,代码来源:VarOneServer.java

示例11: createContextHandler

import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet; //导入依赖的package包/类
private ServletContextHandler createContextHandler(final Class<? extends ODataServiceFactory> factoryClass)
    throws Exception {
  ServletHolder odataServletHolder = null;

  switch (servletType) {
  case JAXRS_SERVLET:
    odataServletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet());
    odataServletHolder.setInitParameter("javax.ws.rs.Application",
        "org.apache.olingo.odata2.core.rest.app.ODataApplication");
    odataServletHolder.setInitParameter(ODataServiceFactory.FACTORY_LABEL, factoryClass.getCanonicalName());
    break;
  case ODATA_SERVLET:
    String odataServlet = "org.apache.olingo.odata2.core.servlet.ODataServlet";
    final HttpServlet httpServlet = (HttpServlet) Class.forName(odataServlet).newInstance();
    odataServletHolder = new ServletHolder(httpServlet);
    odataServletHolder.setInitParameter(ODataServiceFactory.FACTORY_LABEL, factoryClass.getCanonicalName());
    break;
  default:
  }

  if (pathSplit > 0) {
    odataServletHolder.setInitParameter(ODataServiceFactory.PATH_SPLIT_LABEL, Integer.toString(pathSplit));
  }

  final ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
  contextHandler.setContextPath("/abc");
  contextHandler.addServlet(odataServletHolder, path + "/*");
  return contextHandler;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:30,代码来源:TestServer.java

示例12: createContextHandler

import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet; //导入依赖的package包/类
private ServletContextHandler createContextHandler() {
  final CXFNonSpringJaxrsServlet odataServlet = new CXFNonSpringJaxrsServlet();
  final ServletHolder odataServletHolder = new ServletHolder(odataServlet);
  odataServletHolder.setInitParameter("javax.ws.rs.Application",
      ODataApplication_.class.getName());

  final ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
  contextHandler.addServlet(odataServletHolder, endpoint.getPath() + "/*");
  return contextHandler;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:11,代码来源:ODataApplicationTest.java

示例13: cxfServlet

import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet; //导入依赖的package包/类
@Produces
@Dependent
public ServletDescriptor cxfServlet(RestServerConfiguration restServerConfiguration) {
    String servletMapping = restServerConfiguration.getRestServletMapping();
    List<WebInitParam> params = new ArrayList<>();
    if(enableSseTransport) {
        params.add(new WebParam(CXFNonSpringJaxrsServlet.TRANSPORT_ID, SseHttpTransportFactory.TRANSPORT_ID));
    }
    WebInitParam[] initParams = params.toArray(new WebInitParam[params.size()]);
    return new ServletDescriptor("CXF",null, new String[]{servletMapping},1, initParams,true,CXFCdiServlet.class);
}
 
开发者ID:hammock-project,项目名称:hammock,代码行数:12,代码来源:CXFProvider.java

示例14: setupRestApiContextHandler

import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet; //导入依赖的package包/类
private static ServletContextHandler setupRestApiContextHandler() {
    final ServletHolder cxfServletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet());
    cxfServletHolder.setInitParameter("javax.ws.rs.Application", ExplorerServer.class.getName());
    cxfServletHolder.setName("rest");
    cxfServletHolder.setForcedPath("rest");

    final ServletContextHandler cxfContext = new ServletContextHandler();
    cxfContext.setSessionHandler(new SessionHandler());
    cxfContext.setContextPath("/api");
    cxfContext.addServlet(cxfServletHolder, "/*");
    cxfContext.addFilter(new FilterHolder(CorsFilter.class), "/*",
            EnumSet.allOf(DispatcherType.class));
    return cxfContext;
}
 
开发者ID:Stratio,项目名称:Explorer,代码行数:15,代码来源:ExplorerServer.java


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