On Thu, Jan 11, 2024 at 6:44 PM Silvio Bierman <silvio@jambo.software>
wrote:

> Thank you for your reply Vaclav,
>
> Well, what you talk about was not the original problem but it is now the
> problem where I am stuck at :)
>
> My architecture is about a generic HandlerService and ContainerService
> abstractions that are meant for handling HTTP requests asynchronously
> (with custom Request/Response abstractions). The idea is that
> ContainerService instances (based on Jetty, Tomcat, ...) should be able
> to pick up and delegate to HandlerService instances. This should work
> inside an OSGI container when deployed as bundles but I also want to be
> able to hard-wire them into a monolithic application.
>
> I am embedding Jetty inside a bundle that should implement a
> ContainerService and it does indeed not find the its own ALPNProvider
> through ServiceLoader. I looked into SpiFly but it all seems a bit
> backwards to me when comparing it to my situation. I am not exposing
> anything Jetty/WebApp/Servlet from the bundle, it is purely an internal
> implementation detail of said bundle. Neither do I intend to do anything
> accross bundles with ALPN or any other ServiceLoader. I would prefer to
> hardwire Jetty to its own ALPN provider. Going through all kinds of
> hoops to get the ServiceLoader working at the OSGI level sounds all
> wrong. But if that is what it takes I will have to do it.
>

There is no other way to do this inside the OSGi environment as far as I
know. The ServiceLoader does not see the services inside OSGi bundles
unless its calls are instrumented to do it. There is an entire OSGi spec
section for this:
https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.loader.html


>
> Unfortunately I can not get the SpiFly setup working. Could you tell me
> a bit more? Do you deploy SpiFly as an OSGI bundle on its own or do you
> embed it inside the same bundle that embeds Jetty?


We deploy SPI Fly as its own bundle.


> Are you using the
> dynamic SpiFly mode?


Yes, we use the dynamic mode. One non-obvious thing with this is that only
STARTED state OSGi bundles will be inspected, instrumented, and have their
services registered.


> What Jetty version are you embedding?
>

Jetty 10. There are indubitably differences from Jetty 12 you are using.


> Any pointers would be very much appreciated.
>
> Kind regards,
>
> Silvio
>
>
> On 02-01-2024 10:33, Vaclav Haisman wrote:
> >
> >
> > On Tue, Dec 26, 2023 at 5:52 PM Silvio Bierman <silvio@jambo.software>
> > wrote:
> >
> >     Hello all,
> >
> >     I am using Felix framework 7.0.5 and am trying to create a bundle
> >     that
> >     embeds Jetty 12. Once I put the Jetty dependencies inside the bundle
> >     starting it does no longer cause ServiceEvents in the
> >     ServiceListeners I
> >
> >
> > I am not sure if I understand your issue in the entirety but here is
> > something:
> >
> > Are you embedding the entire Jetty JARs into your own OSGi bundle? I
> > am doing this and I had an issue where the ServiceLoader services were
> > not being registered with OSGi and were not being provided/wired into
> > ServiceLoader.load() calls. In the end, I had to add all the
> > Require-Capability and Provide-Capability into my own OSGi bundle's
> > META-INF/MANIFEST.MF. This is a snippet from the pom.xml:
> >
> > <Require-Capability>
> > osgi.extender; filter:="(osgi.extender=osgi.serviceloader.processor)",
> > osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)",
> >
> osgi.serviceloader;filter:="(osgi.serviceloader=javax.servlet.ServletContainerInitializer)";resolution:=optional;cardinality:=multiple,
> >
> osgi.serviceloader;filter:="(osgi.serviceloader=org.eclipse.jetty.http.HttpFieldPreEncoder)";cardinality:=multiple,
> >
> osgi.serviceloader;filter:="(osgi.serviceloader=org.eclipse.jetty.webapp.Configuration)";cardinality:=multiple,
> >
> osgi.serviceloader;filter:="(osgi.serviceloader=org.eclipse.jetty.xml.ConfigurationProcessorFactory)";resolution:=optional;cardinality:=multiple,
> >
> osgi.serviceloader;filter:="(osgi.serviceloader=org.eclipse.jetty.util.security.CredentialProvider)";resolution:=optional;cardinality:=multiple,
> >
> osgi.serviceloader;filter:="(osgi.serviceloader=org.eclipse.jetty.security.Authenticator$Factory)";resolution:=optional;cardinality:=multiple,
> >
> osgi.serviceloader;filter:="(osgi.serviceloader=org.eclipse.jetty.io.ssl.ALPNProcessor$Server)";resolution:=optional;cardinality:=multiple
> > </Require-Capability>
> > <Provide-Capability>
> >
> osgi.serviceloader;osgi.serviceloader="org.eclipse.jetty.http.HttpFieldPreEncoder";register:="org.eclipse.jetty.http.Http1FieldPreEncoder",
> >
> osgi.serviceloader;osgi.serviceloader="org.eclipse.jetty.http.HttpFieldPreEncoder";register:="org.eclipse.jetty.http2.hpack.HpackFieldPreEncoder",
> >
> osgi.serviceloader;osgi.serviceloader="org.eclipse.jetty.io.ssl.ALPNProcessor$Server";register:="org.eclipse.jetty.alpn.java.server.JDK9ServerALPNProcessor",
> >
> osgi.serviceloader;osgi.serviceloader="org.eclipse.jetty.webapp.Configuration";register:="org.eclipse.jetty.webapp.WebXmlConfiguration",
> >
> osgi.serviceloader;osgi.serviceloader="org.eclipse.jetty.webapp.Configuration";register:="org.eclipse.jetty.webapp.WebInfConfiguration",
> >
> osgi.serviceloader;osgi.serviceloader="org.eclipse.jetty.webapp.Configuration";register:="org.eclipse.jetty.webapp.WebAppConfiguration",
> >
> osgi.serviceloader;osgi.serviceloader="org.eclipse.jetty.webapp.Configuration";register:="org.eclipse.jetty.webapp.ServletsConfiguration",
> >
> osgi.serviceloader;osgi.serviceloader="org.eclipse.jetty.webapp.Configuration";register:="org.eclipse.jetty.webapp.MetaInfConfiguration",
> >
> osgi.serviceloader;osgi.serviceloader="org.eclipse.jetty.webapp.Configuration";register:="org.eclipse.jetty.webapp.JspConfiguration",
> >
> osgi.serviceloader;osgi.serviceloader="org.eclipse.jetty.webapp.Configuration";register:="org.eclipse.jetty.webapp.JndiConfiguration",
> >
> osgi.serviceloader;osgi.serviceloader="org.eclipse.jetty.webapp.Configuration";register:="org.eclipse.jetty.webapp.JmxConfiguration",
> >
> osgi.serviceloader;osgi.serviceloader="org.eclipse.jetty.webapp.Configuration";register:="org.eclipse.jetty.webapp.JaspiConfiguration",
> >
> osgi.serviceloader;osgi.serviceloader="org.eclipse.jetty.webapp.Configuration";register:="org.eclipse.jetty.webapp.JaasConfiguration",
> >
> osgi.serviceloader;osgi.serviceloader="org.eclipse.jetty.webapp.Configuration";register:="org.eclipse.jetty.webapp.JettyWebXmlConfiguration",
> >
> osgi.serviceloader;osgi.serviceloader="org.eclipse.jetty.webapp.Configuration";register:="org.eclipse.jetty.webapp.FragmentConfiguration",
> >
> osgi.serviceloader;osgi.serviceloader="org.eclipse.jetty.webapp.Configuration";register:="org.eclipse.jetty.plus.webapp.PlusConfiguration",
> >
> osgi.serviceloader;osgi.serviceloader="org.eclipse.jetty.webapp.Configuration";register:="org.eclipse.jetty.plus.webapp.EnvConfiguration",
> >
> osgi.serviceloader;osgi.serviceloader="org.eclipse.jetty.webapp.Configuration";register:="org.eclipse.jetty.annotations.AnnotationConfiguration"
> > </Provide-Capability>
> >
> > This requires use of Apache SPI-Fly.
> >
> >     have registered on the BundleContext. The bundle does not instantiate
> >     anything Jetty related yet (well, it did but I removed all code
> >     that did
> >     anything with Jetty), only the dependencies are in the POM and
> >     they are
> >     embedded in the bundle with
> >     <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency> which
> >     causes the Jetty jars to appear inside the packaged bundle.
> >
> >     When I remove the <Embed-Dependency/> the ServiceEvents occur as
> >     expected. But I need the Jetty dependencies in the bundle.
> >
> >     Any ideas?
> >
> >     Kind regards,
> >
> >     Silvio
> >
> >
> > --
> >
> > --
> > VH
>

-- 

-- 
VH

-- 
This electronic communication and the information and any files transmitted 
with it, or attached to it, are confidential and are intended solely for 
the use of the individual or entity to whom it is addressed and may contain 
information that is confidential, legally privileged, protected by privacy 
laws, or otherwise restricted from disclosure to anyone else. If you are 
not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, you are hereby notified that any use, 
copying, distributing, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender, delete it from your computer, and 
destroy any printed copy of it.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to