>>>>> Tim Ward <[email protected]>: > Would it not be easier to: > Use the Http Service Whiteboard support for resource serving, rather than > having the ReactServlet? That’s a big bit of boilerplate for serving some > static content. It should be much simpler using component > properties/annotations - see > https://osgi.org/specification/osgi.cmpn/7.0.0/service.http.whiteboard.html#d0e121459 > > <https://osgi.org/specification/osgi.cmpn/7.0.0/service.http.whiteboard.html#d0e121459>
Yes it might be... There are after all, just two files that needs to be served: the initial index.html file and the bundle.js file it references (the react app and everything is needs, CSS, fonts, images etc. are packed into bundle.js using webpack). However, there is a bit of special-casing, such as this: https://github.com/steinarb/ukelonn/blob/using-react/ukelonn.bundle/src/main/java/no/priv/bang/ukelonn/impl/UkelonnServlet.java#L48 that needs to match this https://github.com/steinarb/ukelonn/blob/using-react/ukelonn.bundle/src/main/frontend/components/App.js#L30 so that it is actually possible to enter or reload the URLs created by the react router into a browser and not get 404. I haven't found any way to achive single point of change for these values, and react needs to include the servlet context (in this case, "/ukelonn") while the servlets' URLs, are relative to the servlet context. > Use the JAX-RS whiteboard to directly register a JAX-RS resource, avoiding > the need to teach people about launching Jersey (something that they probably > care very little about). It’s really very simple to do - see > https://osgi.org/specification/osgi.cmpn/7.0.0/service.jaxrs.html#service.jaxrs.resource.services > > <https://osgi.org/specification/osgi.cmpn/7.0.0/service.jaxrs.html#service.jaxrs.resource.services> > Hm... is this available in some form in OSGi 6 as well? Or is this OSGi 7 only? As I've mentioned elsewhere in this thread I ran into some strange issues when I tried karaf 4.2.0, and I haven't spent time figuring them out yet. > Using those features should be able to make the example more concise and > compelling. Indeed. Seems like there is lots of interesting stuff in OSGi 7, so I should probably get there as soon as possible.
