The problem with the above solution is that you will end up in a race where
a service might already be registered without a proxy, then what? So you
should try to avoid ordering issues in your design otherwise you will
regret it later.

What really should happen is that the thing creating the service should add
the proxy around the service before the service is ever published. An
extender is an ideal place to do this. Felix DM, and IPojo are ideal for
this use case since they imperative APIs for managing services and can be
"trained" to add proxies based on arbitrary heuristics.

It's a wish I have also for Felix SCR.

Sincerely,
- Ray

On Thu, Oct 6, 2016 at 6:45 AM, Martin Nielsen <mny...@gmail.com> wrote:

> I think what i wrote might have made more sense in my own head:) I
> apologize for the lousy problem description.
> Maybe an actual use case would help:
>
> I would like to use the OSGi serviceregistry to proxy specific interfaces.
> For example:
> Say that i attempt to get a serviceReference for an interface with a
> mybatis annotation on it. What i would like is that the service registry
> returns a proxy that i define (My idea was through something like a
> ServiceBindingInterceptor). The proxy should then be closed down again when
> get unget method is called on the service.
>
> Basically, i would like to supply a proxy implementation of interfaces in
> certain situations, but still allow for the serviceregistry lifecycle
> (get/unget) to handle opening and closing the proxies.
>
> It doesn't have to use any specific part of the runtime, i just spotted the
> interceptors and mistook their purpose a bit i think.
>
> On Thu, Oct 6, 2016 at 12:32 PM, Clement Escoffier <
> clement.escoff...@gmail.com> wrote:
>
> > Hi,
> >
> > The service binding interceptor requires to have a “service” available.
> > You should be able to do what you want by either:
> >
> > - combining a “default-implementation” strategy and a binding interceptor
> > (it would require to have the dependency marked as optional)
> > - or create your own handler that inject what you want to inject (
> > http://felix.apache.org/documentation/subprojects/
> > apache-felix-ipojo/apache-felix-ipojo-devguide/how-to-
> > write-your-own-handler.html <http://felix.apache.org/
> > documentation/subprojects/apache-felix-ipojo/apache-
> > felix-ipojo-devguide/how-to-write-your-own-handler.html>)
> >
> > Clement
> >
> >
> > > On 6 oct. 2016, at 04:02, Martin Nielsen <mny...@gmail.com> wrote:
> > >
> > > Hello everyone
> > >
> > > I am looking at the felix servicebinding interceptors with a certain
> > amount
> > > of enthusiasm, but i am having trouble figuring out if they can solve a
> > > specific task.
> > >
> > > http://felix.apache.org/documentation/subprojects/
> > apache-felix-ipojo/apache-felix-ipojo-userguide/ipojo-
> > advanced-topics/service-binding-interceptors.html
> > >
> > > What i would like to do is the following: Whenever a ServiceReference
> is
> > > requested for an interface (No matter which one), i want an interceptor
> > to
> > > examine it. If the interface meets some criteria, the an interceptor
> > should
> > > create a proxy for that interface, regardless of a matching
> > implementation
> > > being registered.
> > > So: Even if no object is actually registered as a service to that
> > > interface, i want the interceptor to return a proxy anyway. Is that
> > > possible to do in any way?
> > >
> > > Thank you in advance.
> > >
> > > -Martin
> >
> >
>



-- 
*Raymond Augé* <http://www.liferay.com/web/raymond.auge/profile>
 (@rotty3000)
Senior Software Architect *Liferay, Inc.* <http://www.liferay.com>
 (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance <http://osgi.org> (@OSGiAlliance)

Reply via email to