camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brad Johnson <brad.john...@mediadriver.com>
Subject Re: CamelBlueprintTestSupport No bean could be found in the registry
Date Mon, 08 Feb 2016 17:22:56 GMT
Perhaps I confused matters.  The interface canonical name is the key to the
registry and the stub is the implementation.  I'm not sure if PojoSR
proxies that as it would be in an actual OSGi environment but I'm guessing
that it does.
As you know the proxy class in OSGi dynamically implements the interface
and acts as the intermediary to calls to the actual implementation.

The OSGi/PojoSR are using the interface name as the key for look up. But he
was having a problem when he ran his two bundles of the second bundle not
finding the interface in the registry for a service that was being exported
by his first bundle.  If the first bundle is in his POM with a scope of
test then it should be available during testing.

Sorry if I sewed confusion there.

Brad

On Mon, Feb 8, 2016 at 9:19 AM, Quinn Stevenson <quinn@pronoia-solutions.com
> wrote:

> I’m a little confused here - asService take the object implementing the
> interface and the service property key/values - I’m not sure how that could
> even work as an interface instead of the implementation object.  The
> service interface is provided earlier in the call ( the key in services.put
> ), and I like having the string there as well so I don’t have to add
> dependencies to my project all the time (when I’m using OSGi classes that
> are provided by the framework).
>
> That said, I’m always looking for ways to simplify tests - do you have an
> idea on how this could work?  Maybe you could do a prototype that we could
> see?
>
>
> > On Feb 7, 2016, at 6:43 PM, Brad Johnson <brad.johnson@mediadriver.com>
> wrote:
> >
> > According
> > to my humble opinion, the asService() method should ideally have
> Interface
> > instead of Implementation argument.
> >
> > The asService is there to create a proxy to the actual implementation
> class
> > I believe.  What you are actually putting in the registry is a key of the
> > value of the full package and class name of the interface.  That's what
> > blueprint is going to look up the service based upon.  The value is what
> > you put in as the implementation.
> >
> > In a true blueprint environment that implementation will be hidden
> behind a
> > proxy object that exposes the interface.  Any bundle wanting to use that
> > proxied implementation then just tells it what the package anc class name
> > of the interface are.  In other words, when that interface is fetched
> from
> > the OSGi registry and handed to the requester, the requester doesn't know
> > what concrete implementation it is talking to. It may be a test stub, it
> > may be the actual implementation.  In fact, if you try to then cast that
> to
> > the concrete implementation of the class it will fail because what it
> finds
> > is a proxy of the interface.  This also makes it possible to hot swap
> > bundles at run time because the proxy stays the same but the
> implementation
> > changes.
> >
> > I'm still mystified why your test class wasn't picking up the service
> from
> > your first bundle though.  If you have have it exported and referenced
> and
> > listed as a test dependency in your client bundle then it should be
> > automatically loaded up.  One of those pieces sounds as if it is missing.
> >
> >  @Override
> >    protected void
> > addServicesOnStartup(Map<String,KeyValueHolder&lt;Object, Dictionary>>
> > services) {
> >        services.put( MyServiceInterface.class.getName(), asService(new
> > StubServiceImplementation(), "implementation", "stub"));
> >    }
> >
> >
> > On Fri, Feb 5, 2016 at 4:53 PM, enigma <send2shekar@gmail.com> wrote:
> >
> >> Thank you and Have a good weekend! :)
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://camel.465427.n5.nabble.com/CamelBlueprintTestSupport-No-bean-could-be-found-in-the-registry-tp5777228p5777317.html
> >> Sent from the Camel - Users mailing list archive at Nabble.com.
> >>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message