本文整理汇总了Java中org.apache.olingo.server.api.ODataHttpHandler类的典型用法代码示例。如果您正苦于以下问题:Java ODataHttpHandler类的具体用法?Java ODataHttpHandler怎么用?Java ODataHttpHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ODataHttpHandler类属于org.apache.olingo.server.api包,在下文中一共展示了ODataHttpHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: service
import org.apache.olingo.server.api.ODataHttpHandler; //导入依赖的package包/类
@Override
public void service(HttpServletRequest request, HttpServletResponse response)
throws IOException {
Client client = (Client) request.getAttribute(Client.class.getName());
String schemaName = (String) request.getAttribute(ODataFilter.SCHEMA_NAME);
org.teiid.metadata.Schema teiidSchema = client.getMetadataStore().getSchema(schemaName);
if (teiidSchema == null || !isVisible(client.getVDB(), teiidSchema)) {
// TODO: send error response, this is exception
throw new TeiidRuntimeException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16022));
}
OData odata = OData.newInstance();
Schema schema = OData4EntitySchemaBuilder.buildMetadata(teiidSchema);
Edm edm = odata.createEdm(new TeiidEdmProvider(client.getMetadataStore(), schema));
ODataHttpHandler handler = odata.createHandler(edm);
boolean prepared = true;
if (request.getParameter("prepared") != null) { //$NON-NLS-1$
prepared = Boolean.getBoolean(request.getParameter("prepared")); //$NON-NLS-1$
}
handler.register(new TeiidProcessor(client, prepared));
handler.process(request, response);
}
示例2: service
import org.apache.olingo.server.api.ODataHttpHandler; //导入依赖的package包/类
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
HttpSession session = req.getSession(true);
Storage storage = (Storage) session.getAttribute(Storage.class.getName());
if (storage == null) {
storage = new Storage();
session.setAttribute(Storage.class.getName(), storage);
}
// create odata handler and configure it with EdmProvider and Processor
OData odata = OData.newInstance();
ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>());
ODataHttpHandler handler = odata.createHandler(edm);
handler.register(new DemoEntityCollectionProcessor(storage));
handler.register(new DemoEntityProcessor(storage));
handler.register(new DemoPrimitiveProcessor(storage));
// let the handler do the work
handler.process(req, resp);
} catch (RuntimeException e) {
LOG.error("Server Error occurred in ExampleServlet", e);
throw new ServletException(e);
}
}
示例3: service
import org.apache.olingo.server.api.ODataHttpHandler; //导入依赖的package包/类
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
OData odata = OData.newInstance();
ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>());
HttpSession session = req.getSession(true);
Storage storage = (Storage) session.getAttribute(Storage.class.getName());
if (storage == null) {
storage = new Storage(odata, edm.getEdm());
session.setAttribute(Storage.class.getName(), storage);
}
ODataHttpHandler handler = odata.createHandler(edm);
handler.register(new DemoEntityCollectionProcessor(storage));
handler.register(new DemoEntityProcessor(storage));
handler.register(new DemoPrimitiveProcessor(storage));
// let the handler do the work
handler.process(req, resp);
} catch (RuntimeException e) {
LOG.error("Server Error occurred in ExampleServlet", e);
throw new ServletException(e);
}
}
示例4: service
import org.apache.olingo.server.api.ODataHttpHandler; //导入依赖的package包/类
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
HttpSession session = req.getSession(true);
Storage storage = (Storage) session.getAttribute(Storage.class.getName());
if (storage == null) {
storage = new Storage();
session.setAttribute(Storage.class.getName(), storage);
}
// create odata handler and configure it with EdmProvider and Processor
OData odata = OData.newInstance();
ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>());
ODataHttpHandler handler = odata.createHandler(edm);
handler.register(new DemoEntityCollectionProcessor(storage));
handler.register(new DemoEntityProcessor(storage));
handler.register(new DemoPrimitiveProcessor(storage));
// let the handler do the work
handler.process(req, resp);
} catch (RuntimeException e) {
LOG.error("Server Error occurred in ExampleServlet", e);
throw new ServletException(e);
}
}
示例5: service
import org.apache.olingo.server.api.ODataHttpHandler; //导入依赖的package包/类
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
HttpSession session = req.getSession(true);
Storage storage = (Storage) session.getAttribute(Storage.class.getName());
if (storage == null) {
storage = new Storage();
session.setAttribute(Storage.class.getName(), storage);
}
// create odata handler and configure it with EdmProvider and Processor
OData odata = OData.newInstance();
ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>());
ODataHttpHandler handler = odata.createHandler(edm);
handler.register(new DemoEntityCollectionProcessor(storage));
handler.register(new DemoEntityProcessor(storage));
handler.register(new DemoPrimitiveProcessor(storage));
// let the handler do the work
handler.process(req, resp);
} catch (RuntimeException e) {
LOG.error("Server Error occurred in DemoServlet", e);
throw new ServletException(e);
}
}
示例6: service
import org.apache.olingo.server.api.ODataHttpHandler; //导入依赖的package包/类
@Override
protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
try {
// create odata handler and configure it with EdmProvider and Processor
OData odata = OData.newInstance();
ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>());
ODataHttpHandler handler = odata.createHandler(edm);
handler.register(new DemoEntityCollectionProcessor());
// let the handler do the work
handler.process(req, resp);
} catch (RuntimeException e) {
LOG.error("Server Error occurred in ExampleServlet", e);
throw new ServletException(e);
}
}
示例7: service
import org.apache.olingo.server.api.ODataHttpHandler; //导入依赖的package包/类
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
HttpSession session = req.getSession(true);
Storage storage = (Storage) session.getAttribute(Storage.class.getName());
if (storage == null) {
storage = new Storage();
session.setAttribute(Storage.class.getName(), storage);
}
// create odata handler and configure it with EdmProvider and Processor
OData odata = OData.newInstance();
ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>());
ODataHttpHandler handler = odata.createHandler(edm);
handler.register(new DemoEntityCollectionProcessor(storage));
handler.register(new DemoEntityProcessor(storage));
handler.register(new DemoPrimitiveProcessor(storage));
handler.register(new DemoActionProcessor(storage));
// let the handler do the work
handler.process(req, resp);
} catch (RuntimeException e) {
LOG.error("Server Error occurred in ExampleServlet", e);
throw new ServletException(e);
}
}
示例8: service
import org.apache.olingo.server.api.ODataHttpHandler; //导入依赖的package包/类
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
HttpSession session = req.getSession(true);
Storage storage = (Storage) session.getAttribute(Storage.class.getName());
if (storage == null) {
storage = new Storage();
session.setAttribute(Storage.class.getName(), storage);
}
// create odata handler and configure it with EdmProvider and Processor
OData odata = OData.newInstance();
ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>());
ODataHttpHandler handler = odata.createHandler(edm);
handler.register(new DemoEntityCollectionProcessor(storage));
handler.register(new DemoEntityProcessor(storage));
handler.register(new DemoPrimitiveProcessor(storage));
handler.register(new DemoBatchProcessor(storage));
// let the handler do the work
handler.process(req, resp);
} catch (RuntimeException e) {
LOG.error("Server Error occurred in ExampleServlet", e);
throw new ServletException(e);
}
}
示例9: service
import org.apache.olingo.server.api.ODataHttpHandler; //导入依赖的package包/类
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
HttpSession session = req.getSession(true);
Storage storage = (Storage) session.getAttribute(Storage.class.getName());
if (storage == null) {
storage = new Storage();
session.setAttribute(Storage.class.getName(), storage);
}
// create odata handler and configure it with EdmProvider and Processor
OData odata = OData.newInstance();
ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>());
ODataHttpHandler handler = odata.createHandler(edm);
handler.register(new DemoEntityCollectionProcessor(storage));
handler.register(new DemoEntityProcessor(storage));
handler.register(new DemoPrimitiveProcessor(storage));
// let the handler do the work
handler.process(req, resp);
} catch (RuntimeException e) {
LOG.error("Server Error occurred in ExampleServlet", e);
throw new ServletException(e);
}
}
示例10: service
import org.apache.olingo.server.api.ODataHttpHandler; //导入依赖的package包/类
@Override
protected void service(final HttpServletRequest req, final HttpServletResponse resp)
throws ServletException, IOException {
try {
HttpSession session = req.getSession(true);
DataProvider dataProvider = (DataProvider) session.getAttribute(DataProvider.class.getName());
if (dataProvider == null) {
dataProvider = new DataProvider();
session.setAttribute(DataProvider.class.getName(), dataProvider);
LOG.info("Created new data provider.");
}
OData odata = OData.newInstance();
ServiceMetadata edm = odata.createServiceMetadata(new CarsEdmProvider(), new ArrayList<EdmxReference>());
ODataHttpHandler handler = odata.createHandler(edm);
handler.register(new CarsProcessor(dataProvider));
handler.process(req, resp);
} catch (RuntimeException e) {
LOG.error("Server Error", e);
throw new ServletException(e);
}
}
示例11: process
import org.apache.olingo.server.api.ODataHttpHandler; //导入依赖的package包/类
public void process(final HttpServletRequest request, HttpServletResponse response) throws SQLException{
SessionContext context = createContext(request);
setSession(createSession(context));
OData odata = OData.newInstance();
SQLEdmProvider edmProvider = new SQLEdmProvider(getSession().getMetaData());
edmProvider.setCursors(cursors);
edmProvider.setFunctions(functions);
ServiceMetadata edm = odata.createServiceMetadata(edmProvider, new ArrayList<EdmxReference>());
ODataHttpHandler handler = odata.createHandler(edm);
SQLEntityCollectionProcessor processor = new SQLEntityCollectionProcessor(getSession());
processor.setCursors(cursors);
handler.register(processor);
handler.register(new SQLEntityProcessor(getSession()));
handler.register(new SQLPrimitiveProcessor(getSession(),functions));
handler.register(new CustomContentTypes());
handler.register(new SQLBatchProcessor());
handler.register( new SQLErrorProcessor(config));
handler.process(request, response);
}
示例12: service
import org.apache.olingo.server.api.ODataHttpHandler; //导入依赖的package包/类
@Override
protected void service(
HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String serviceName = extractServiceName(request);
if (serviceName == null) {
response.sendError(
HttpServletResponse.SC_BAD_REQUEST, "Service name required in URI path");
return;
}
CsdlEdmProvider edmProvider = toEdmProvider(serviceName);
if (edmProvider == null) {
response.sendError(
HttpServletResponse.SC_NOT_FOUND, "Unknown service name " + serviceName);
return;
}
OData odata = OData.newInstance();
ServiceMetadata metadata = odata.createServiceMetadata(edmProvider, Collections.emptyList());
ODataHttpHandler handler = odata.createHandler(metadata);
for (Processor processor : processors) {
handler.register(processor);
}
HttpServletRequestWrapper requestWrapper = new HttpServletRequestWrapper(request) {
@Override
public String getServletPath() {
return request.getServletPath() + '/' + serviceName;
}
};
handler.process(requestWrapper, response);
}
示例13: service
import org.apache.olingo.server.api.ODataHttpHandler; //导入依赖的package包/类
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
OData odata = ElasticOData.newInstance();
ServiceMetadata matadata = createServiceMetadata(req, odata, createEdmProvider());
ODataHttpHandler handler = odata.createHandler(matadata);
registerProcessors(handler);
handler.process(req, resp);
}
示例14: prepareHandler
import org.apache.olingo.server.api.ODataHttpHandler; //导入依赖的package包/类
private ODataHttpHandler prepareHandler() {
OData oData = OData.newInstance();
ServiceMetadata edm = oData.createServiceMetadata(new CarsEdmProvider(), new ArrayList<EdmxReference>());
ODataHttpHandler handler = oData.createHandler(edm);
return handler;
}
示例15: service
import org.apache.olingo.server.api.ODataHttpHandler; //导入依赖的package包/类
@Override
protected void service(final HttpServletRequest req, final HttpServletResponse resp)
throws ServletException, IOException {
try {
/*
* create odata handler and configure it with CsdlEdmProvider and Processor. todo: this needs
* to be rewritten the list does not have to be recreated each time. The advantage of this is
* that the multiple threads calling this are seperated.
*/
OData odata = OData.newInstance();
ServiceMetadata edm = odata.createServiceMetadata(new RedHxServiceEdmProvider(),
new ArrayList<EdmxReference>());
ODataHttpHandler handler = odata.createHandler(edm);
System.out.println("HFB5: in service call. " + req.getAuthType() + ", " + req.getContentType()
+ ", " + req.getPathInfo());
handler.register(new RedHxChassisCollectionProcessor());
handler.register(new RedHxDiscoveryProcessor(odata, edm.getEdm()));
// let the handler do the work
handler.process(req, resp);
/**
* todo Olingo source. fix ODataHandler line 203 public void register(final Processor
* processor) { processors.add(0, processor); }
*
* so that it can not insert duplicte Processor classes.
*/
} catch (RuntimeException ex) {
LOG.error("Server Error occurred in RedHxServlet", ex);
throw new ServletException(ex);
}
}