You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by My Kro <my...@gmail.com> on 2015/10/09 01:47:27 UTC
[Java] [Olingo V4] Integrating with HttpServer
First off, I'm completely new to Olingo, and only slightly less new to
javax.ws.rs I'm afraid.
I have a legacy Java application to which I've added a jersey instance:
ResourceConfig config = new MyResourceConfig();
HttpServer server = JdkHttpServerFactory.createHttpServer(myURI, config);
Spent a day creating resources and playing around with URL syntax, till I
learnt about the OData standard. Great I thought and grabbed Olingo V4 hot
off the press. But the tutorials assume that I'm building a new web
application, or at least a HttpServlet implementation.
A recent post on this mailing list indicated that while the
javax.ws.rs dependency
has been dropped in V4 I could still attach the handler somehow. So I've
copied some files from the Cars sample and this is as far as I've got:
public void attach(HttpServer server) throws IllegalStateException {
try {
DataProvider dataProvider = new DataProvider();
OData odata = OData.newInstance();
EdmxReference reference = new
EdmxReference(URI.create("../v4.0/cs02/vocabularies/Org.OData.Core.V1.xml"));
reference.addInclude(new EdmxReferenceInclude("Org.OData.Core.V1", "Core"));
ServiceMetadata serviceMetadata = odata.createServiceMetadata(
new CarsEdmProvider(),
Collections.singletonList(reference));
ODataHttpHandler handler = odata.createHandler(serviceMetadata);
handler.register(new CarsProcessor(dataProvider));
// Attach to our server we created before
server.createContext("odata.svc", handler);
***** COMPILE ERROR *****
The method createContext(String, HttpHandler) in the type HttpServer is not
applicable for the arguments (String, ODataHttpHandler)
**********************************
} catch (final RuntimeException e) {
}
}
I'm afraid I'm stuck here, would greatly appreciate any assistance to glue
OData to my HTTPServer, or at least a whack over the head and a pointer to
a better way. Thanks :)
RE: delta token odata provider example
Posted by "Amend, Christian" <ch...@sap.com>.
Hi,
the best source is the Olingo website tutorial section: http://olingo.apache.org/doc/odata2/index.html
Here is the tutorial for plain delta: http://olingo.apache.org/doc/odata2/tutorials/delta.html
Here for JPA delta: http://olingo.apache.org/doc/odata2/tutorials/DeltaQuerySupport.html
Best Regards,
Christian
From: GuopingZhang [mailto:goodier_cn@hotmail.com]
Sent: Montag, 12. Oktober 2015 10:11
To: user@olingo.apache.org
Subject: delta token odata provider example
Does anyone have a delta token odata provider example ?
Thanks!
delta token odata provider example
Posted by GuopingZhang <go...@hotmail.com>.
Does anyone have a delta token odata provider example ?
Thanks!
Re: [Java] [Olingo V4] Integrating with HttpServer
Posted by "Bolz, Michael" <mi...@sap.com>.
Hi,
First, to process requests with “java.ws.rs” you have to annotate a class/method accordingly to “javax.ws.rs <http://javax.ws.rs/>” with the “@Path” annotation (see code sample below).
Within this method you then can do the same as in the samples (with the HttpServlet).
Second, I will check also your issue about how do you use the Jersey instance. However, therefore I have to read more about Jersey ;o)
Best Regards,
Michael
…
@Ptath(”/“)
public class SampleJaxRs {
@GET
public void handleGetRequests() {
// olingo read stuff
}
}
OR
@Path("/{servicename}/*")
public void handleRequest() {…}
> On 09 Oct 2015, at 01:47, My Kro <my...@gmail.com> wrote:
>
> First off, I'm completely new to Olingo, and only slightly less new to javax.ws.rs <http://javax.ws.rs/> I'm afraid.
>
> I have a legacy Java application to which I've added a jersey instance:
>
> ResourceConfig config = new MyResourceConfig();
> HttpServer server = JdkHttpServerFactory.createHttpServer(myURI, config);
>
> Spent a day creating resources and playing around with URL syntax, till I learnt about the OData standard. Great I thought and grabbed Olingo V4 hot off the press. But the tutorials assume that I'm building a new web application, or at least a HttpServlet implementation.
>
> A recent post on this mailing list indicated that while the javax.ws.rs <http://javax.ws.rs/> dependency has been dropped in V4 I could still attach the handler somehow. So I've copied some files from the Cars sample and this is as far as I've got:
>
> public void attach(HttpServer server) throws IllegalStateException {
> try {
> DataProvider dataProvider = new DataProvider();
>
> OData odata = OData.newInstance();
> EdmxReference reference = new EdmxReference(URI.create("../v4.0/cs02/vocabularies/Org.OData.Core.V1.xml"));
> reference.addInclude(new EdmxReferenceInclude("Org.OData.Core.V1", "Core"));
>
> ServiceMetadata serviceMetadata = odata.createServiceMetadata(
> new CarsEdmProvider(),
> Collections.singletonList(reference));
> ODataHttpHandler handler = odata.createHandler(serviceMetadata);
> handler.register(new CarsProcessor(dataProvider));
>
> // Attach to our server we created before
> server.createContext("odata.svc", handler);
>
> ***** COMPILE ERROR *****
> The method createContext(String, HttpHandler) in the type HttpServer is not applicable for the arguments (String, ODataHttpHandler)
> **********************************
>
> } catch (final RuntimeException e) {
> }
> }
>
> I'm afraid I'm stuck here, would greatly appreciate any assistance to glue OData to my HTTPServer, or at least a whack over the head and a pointer to a better way. Thanks :)