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


Java ODataService类代码示例

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


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

示例1: createService

import org.apache.olingo.odata2.api.ODataService; //导入依赖的package包/类
@Override
public ODataService createService(ODataContext ctx) throws ODataException
{
   ODataService res = null;

   // Gets the last `root` segment of the URL
   // Stores this value in the `serviceName` variable
   // if the URL is http://dhus.gael.fr/odata/v1/Products/...
   //               \__________________________/\_________...
   //                          ROOT                ODATA
   // serviceName:="v1"
   // The length of the `root` part of the URL can be extended with the servlet's split parameter.
   // see http://http://olingo.apache.org/doc/odata2/index.html
   List<PathSegment> pathSegs = ctx.getPathInfo().getPrecedingSegments();
   String serviceName = pathSegs.get(pathSegs.size() - 1).getPath();

   if (serviceName.equals(SERVICE_NAME))
   {
      EdmProvider edmProvider = new Model();
      ODataSingleProcessor oDataProcessor = new Processor();

      res = createODataSingleProcessorService(edmProvider, oDataProcessor);
   }

   return res;
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:27,代码来源:ServiceFactory.java

示例2: createService

import org.apache.olingo.odata2.api.ODataService; //导入依赖的package包/类
/**
 * Creates an OData Service based on the values set in
 * {@link org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext} and
 * {@link org.apache.olingo.odata2.api.processor.ODataContext}.
 */
@Override
public final ODataService createService(final ODataContext ctx) throws ODataException {

	oDataContext = ctx;

	// Initialize OData JPA Context
	oDataJPAContext = initializeODataJPAContext();

	validatePreConditions();

	ODataJPAFactory factory = ODataJPAFactory.createFactory();
	ODataJPAAccessFactory accessFactory = factory.getODataJPAAccessFactory();

	// OData JPA Processor
	if (oDataJPAContext.getODataContext() == null) {
		oDataJPAContext.setODataContext(ctx);
	}

	ODataSingleProcessor odataJPAProcessor = new ODataJPAProcessor(oDataJPAContext);

	// OData Entity Data Model Provider based on JPA
	EdmProvider edmProvider = accessFactory.createJPAEdmProvider(oDataJPAContext);

	return createODataSingleProcessorService(edmProvider, odataJPAProcessor);
}
 
开发者ID:sapmentors,项目名称:lemonaid,代码行数:31,代码来源:JPAServiceFactory.java

示例3: createService

import org.apache.olingo.odata2.api.ODataService; //导入依赖的package包/类
@Override
public ODataService createService(final ODataContext ctx) throws ODataException {

  assertNotNull(ctx);
  assertNotNull(ctx.getAcceptableLanguages());
  assertNotNull(ctx.getParameter(ODataContext.HTTP_SERVLET_REQUEST_OBJECT));

  final Map<String, List<String>> requestHeaders = ctx.getRequestHeaders();
  final String host = requestHeaders.get("Host").get(0);

  String tmp[] = host.split(":", 2);
  String port = (tmp.length == 2 && tmp[1] != null) ? tmp[1] : "80";

  // access and validation in synchronized block
  final JanosServiceFactory service = PORT_2_SERVICE.get(port);
  return service.createService(ctx);
}
 
开发者ID:mibo,项目名称:janos,代码行数:18,代码来源:FitStaticServiceFactory.java

示例4: handle

import org.apache.olingo.odata2.api.ODataService; //导入依赖的package包/类
private Response handle(final ODataHttpMethod method) throws ODataException {
  request = ODataRequest.fromRequest(request).method(method).build();

  ODataContextImpl context = new ODataContextImpl(request, serviceFactory);
  context.setParameter(ODataContext.HTTP_SERVLET_REQUEST_OBJECT, httpRequest);

  ODataService service = serviceFactory.createService(context);
  if(service == null){
    return returnNoServiceResponse(ODataInternalServerErrorException.NOSERVICE);
  }
  service.getProcessor().setContext(context);
  context.setService(service);

  ODataRequestHandler requestHandler = new ODataRequestHandler(serviceFactory, service, context);

  final ODataResponse odataResponse = requestHandler.handle(request);
  final Response response = RestUtil.convertResponse(odataResponse);

  return response;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:21,代码来源:ODataSubLocator.java

示例5: serviceInstance

import org.apache.olingo.odata2.api.ODataService; //导入依赖的package包/类
@Test
public void serviceInstance() throws Exception {
  ODataServlet servlet = new ODataServlet();
  prepareServlet(servlet);
  prepareRequest(reqMock, "", "/servlet-path");
  Mockito.when(reqMock.getPathInfo()).thenReturn("/request-path-info");
  Mockito.when(reqMock.getRequestURI()).thenReturn("http://localhost:8080/servlet-path/request-path-info");
  ODataServiceFactory factory = Mockito.mock(ODataServiceFactory.class);
  ODataService service = Mockito.mock(ODataService.class);
  Mockito.when(factory.createService(Mockito.any(ODataContext.class))).thenReturn(service);
  ODataProcessor processor = Mockito.mock(ODataProcessor.class);
  Mockito.when(service.getProcessor()).thenReturn(processor);
  Mockito.when(reqMock.getAttribute(ODataServiceFactory.FACTORY_INSTANCE_LABEL)).thenReturn(factory);
  Mockito.when(respMock.getOutputStream()).thenReturn(Mockito.mock(ServletOutputStream.class));

  servlet.service(reqMock, respMock);

  Mockito.verify(factory).createService(Mockito.any(ODataContext.class));
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:20,代码来源:ODataServletTest.java

示例6: executeAndValidateRequest

import org.apache.olingo.odata2.api.ODataService; //导入依赖的package包/类
private void executeAndValidateRequest(final ODataHttpMethod method,
    final List<String> pathSegments,
    final Map<String, String> queryParameters,
    final String httpHeaderName, final String httpHeaderValue,
    final String requestContentType,
    final HttpStatusCodes expectedStatusCode) throws ODataException {

  ODataServiceFactory serviceFactory = mock(ODataServiceFactory.class);
  final ODataService service = mockODataService(serviceFactory);
  when(serviceFactory.createService(any(ODataContext.class))).thenReturn(service);

  final ODataRequest request = mockODataRequest(method, pathSegments, queryParameters,
      httpHeaderName, httpHeaderValue, requestContentType);
  final ODataContextImpl context = new ODataContextImpl(request, serviceFactory);

  final ODataResponse response = new ODataRequestHandler(serviceFactory, service, context).handle(request);
  assertNotNull(response);
  assertEquals(expectedStatusCode == null ? HttpStatusCodes.PAYMENT_REQUIRED : expectedStatusCode,
      response.getStatus());
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:21,代码来源:ODataRequestHandlerValidationTest.java

示例7: setupBatchHandler

import org.apache.olingo.odata2.api.ODataService; //导入依赖的package包/类
@Before
public void setupBatchHandler() throws Exception {
  ODataProcessor processor = new LocalProcessor();
  ODataService serviceMock = mock(ODataService.class);
  when(serviceMock.getBatchProcessor()).thenReturn((BatchProcessor) processor);
  when(serviceMock.getEntitySetProcessor()).thenReturn((EntitySetProcessor) processor);
  when(serviceMock.getEntitySimplePropertyProcessor()).thenReturn((EntitySimplePropertyProcessor) processor);
  when(serviceMock.getProcessor()).thenReturn(processor);
  Edm mockEdm = MockFacade.getMockEdm();
  when(serviceMock.getEntityDataModel()).thenReturn(mockEdm);
  List<String> supportedContentTypes = Arrays.asList(
      HttpContentType.APPLICATION_JSON_UTF8, HttpContentType.APPLICATION_JSON);
  when(serviceMock.getSupportedContentTypes(EntityMediaProcessor.class)).thenReturn(supportedContentTypes);
  when(serviceMock.getSupportedContentTypes(EntityProcessor.class)).thenReturn(supportedContentTypes);
  when(serviceMock.getSupportedContentTypes(EntitySimplePropertyProcessor.class)).thenReturn(supportedContentTypes);
  handler = new BatchHandlerImpl(mock(ODataServiceFactory.class), serviceMock);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:18,代码来源:BatchHandlerTest.java

示例8: createService

import org.apache.olingo.odata2.api.ODataService; //导入依赖的package包/类
@Override
  public ODataService createService(final ODataContext ctx) throws ODataException {

    assertNotNull(ctx);
    assertNotNull(ctx.getAcceptableLanguages());
    assertNotNull(ctx.getParameter(ODataContext.HTTP_SERVLET_REQUEST_OBJECT));

    final Map<String, List<String>> requestHeaders = ctx.getRequestHeaders();
    final String host = requestHeaders.get("Host").get(0);

    String tmp[] = host.split(":", 2);
    String port = (tmp.length == 2 && tmp[1] != null) ? tmp[1] : "80";

    // access and validation in synchronized block
    synchronized (PORT_2_SERVICE) {
      final ODataService service = PORT_2_SERVICE.get(port);
//      if (service == null) {
//        throw new IllegalArgumentException("no static service set for JUnit test");
//      }
      return service;
    }
  }
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:23,代码来源:FitStaticServiceFactory.java

示例9: createService

import org.apache.olingo.odata2.api.ODataService; //导入依赖的package包/类
@Override
public ODataService createService(ODataContext ctx) throws ODataException {
	List<Class<?>> edmClasses = new ArrayList<Class<?>>();
	edmClasses.add(com.sap.jam.samples.jira.plugin.odata.server.models.ODataIssue.class);
	edmClasses.add(com.sap.jam.samples.jira.plugin.odata.server.models.ODataFilter.class);
	
	return RuntimeDelegate.createODataSingleProcessorService(
			new AnnotationEdmProvider(edmClasses),
       		new JiraODataProcessor(ctx));
}
 
开发者ID:SAP,项目名称:SAPJamWorkPatternJIRAIntegration,代码行数:11,代码来源:JIRAODataServiceFactory.java

示例10: createAnnotationService

import org.apache.olingo.odata2.api.ODataService; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public ODataService createAnnotationService(final String modelPackage) throws ODataException {
  AnnotationEdmProvider edmProvider = new AnnotationEdmProvider(modelPackage);
  AnnotationInMemoryDs dataSource = new AnnotationInMemoryDs(modelPackage);
  AnnotationValueAccess valueAccess = new AnnotationValueAccess();

  // Edm via Annotations and ListProcessor via AnnotationDS with AnnotationsValueAccess
  return RuntimeDelegate.createODataSingleProcessorService(edmProvider,
      new ListsProcessor(dataSource, valueAccess));
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:14,代码来源:AnnotationServiceFactoryImpl.java

示例11: createFromPackage

import org.apache.olingo.odata2.api.ODataService; //导入依赖的package包/类
@Test
public void createFromPackage() throws ODataException {
  AnnotationServiceFactoryImpl factory = new AnnotationServiceFactoryImpl();
  ODataService service = factory.createAnnotationService(Building.class.getPackage().getName());

  Assert.assertNotNull(service);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:8,代码来源:AnnotationServiceFactoryImplTest.java

示例12: createFromAnnotatedClasses

import org.apache.olingo.odata2.api.ODataService; //导入依赖的package包/类
@Test
public void createFromAnnotatedClasses() throws ODataException {
  AnnotationServiceFactoryImpl factory = new AnnotationServiceFactoryImpl();
  final Collection<Class<?>> annotatedClasses = new ArrayList<Class<?>>();
  annotatedClasses.add(RefBase.class);
  annotatedClasses.add(Building.class);
  annotatedClasses.add(Employee.class);
  annotatedClasses.add(Manager.class);
  annotatedClasses.add(Photo.class);
  annotatedClasses.add(Room.class);
  annotatedClasses.add(Team.class);
  ODataService service = factory.createAnnotationService(annotatedClasses);

  Assert.assertNotNull(service);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:16,代码来源:AnnotationServiceFactoryImplTest.java

示例13: createFromClasses

import org.apache.olingo.odata2.api.ODataService; //导入依赖的package包/类
@Test(expected = ODataException.class)
public void createFromClasses() throws ODataException {
  AnnotationServiceFactoryImpl factory = new AnnotationServiceFactoryImpl();

  final Collection<Class<?>> notAnnotatedClasses = new ArrayList<Class<?>>();
  notAnnotatedClasses.add(String.class);
  notAnnotatedClasses.add(Long.class);
  ODataService service = factory.createAnnotationService(notAnnotatedClasses);

  Assert.assertNotNull(service);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:12,代码来源:AnnotationServiceFactoryImplTest.java

示例14: mock

import org.apache.olingo.odata2.api.ODataService; //导入依赖的package包/类
public ODataService mock() throws ODataException {
  ODataService odataService = EasyMock.createMock(ODataService.class);
  EasyMock.expect(odataService.getEntityDataModel()).andReturn(mockEdm());
  EasyMock.replay(odataService);
  return odataService;

}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:8,代码来源:ODataServiceMock.java

示例15: createService

import org.apache.olingo.odata2.api.ODataService; //导入依赖的package包/类
/**
 * Creates an OData Service based on the values set in
 * {@link org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext} and
 * {@link org.apache.olingo.odata2.api.processor.ODataContext}.
 */
@Override
public final ODataService createService(final ODataContext ctx) throws ODataException {

  oDataContext = ctx;

  // Initialize OData JPA Context
  oDataJPAContext = initializeODataJPAContext();

  validatePreConditions();

  ODataJPAFactory factory = ODataJPAFactory.createFactory();
  ODataJPAAccessFactory accessFactory = factory.getODataJPAAccessFactory();

  // OData JPA Processor
  if (oDataJPAContext.getODataContext() == null) {
    oDataJPAContext.setODataContext(ctx);
  }

  ODataSingleProcessor odataJPAProcessor = createCustomODataProcessor(oDataJPAContext);
  if(odataJPAProcessor == null) {
    odataJPAProcessor = accessFactory.createODataProcessor(oDataJPAContext);
  }
  // OData Entity Data Model Provider based on JPA
  EdmProvider edmProvider = accessFactory.createJPAEdmProvider(oDataJPAContext);

  return createODataSingleProcessorService(edmProvider, odataJPAProcessor);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:33,代码来源:ODataJPAServiceFactory.java


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