felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guillaume Sauthier (OW2)" <guillaume.sauth...@ow2.org>
Subject Re: [iPOJO] Publishing an OSGi service, annotated with iPOJO's @Component and @Provides after manual instantiating
Date Thu, 14 Feb 2013 10:06:38 GMT
Having a component class means that iPOJO is the sole lifecycle controller.
It will decide when (depending on the dependencies availability) the
instance will be created (or not).

So, either you have to make ProtocolInstanceImpl not a component anymore
(you'll gain the lifecycle control), but you'll loose iPOJO's sweetness
(services injection, configuration, ....).

Or you also can use iPOJO's Factory services.
Just @Requires a Factory instance:
@Requires(from="<your-component-name>") Factory factory;
And then createComponentInstance(giving configuration properties).

--G


2013/2/12 Alexander Tumin <iamtakingiteasy@eientei.org>

> Hello, i have a felix OSGi system and iPOJO bundles in it, managing
> service dependencies for all other bundles.
>
> And i have three types of public services (interfaces) in this system:
>
> - Subscriber        -- represents a participant in system's messaging.
> - ProtocolInstance  -- represents a connection via specific protocol to a
> specific server
> - ProtocolManager   -- (Singletone, Factory?) manages (creates and
> pre-configures) ProtocolInstance`s.
>
> And also i have a single instance for whole system of:
> - ConnectionManager -- which listens for ProtocolManager`s publications
> and asks them for appropriate ProtocolInstance`s when time and conditions
> are right.
>
> Public services above are implemented and annotated in the following way:
>
> --->3---
>
> @Provides
> @Instantiate
> @Component
> ConnectionManager    implements Subscriber
>
> @Provides
> @Instantiate
> @Component
> ProtocolManagerImpl  implements ProtocolManager
>
> @Provides
> @Component
> ProtocolInstanceImpl implements ProtocolInstance, Subscriber
>
> --->3---
>
> in that way, i wish the following actions to happen:
> - Some authorized bundle asks a ConnectionManager to perform a connection
> to server X via protocol Y
> - ConnectionManager looks up ProtocolManager service in it's internal list
> of published ProtocolManager`s for manager of protocol Y
> (ProtocolManagerYImpl instance) and if finds it - asks this manager to
> create a connection to server X
> - Asked ProtocolManagerYImpl creates a ProtocolInstanceYImpl and returns
> it to ConnectionManager, so he can connect() or disconnect() this instance
>
> The problem i faced is lying on the last step. I could create an
> apropriate ProtocolInstance, but it won't be published as OSGi service
> despite it's iPOJO annotations upon mere `new ProtocolInstanceYImpl(**
> argsSpecifyingServerXConnectio**nData);`.
>
> But it is not like nothing happens and regular ProtocolInstanceYImpl
> instance is created - it's, as far as i understood by poking debugger, gets
> augmented with bunch of fields with underscores in names.
> Also, this fields disappear when i remove iPOJO annotations from this
> ProtocolInstanceYImpl class.
>
> So, my question it: how do i integrate into iPOJO-fied system the object
> insttance i created by hand?
> Or, if it is a wrong question, how do i create a regular (non-singletone)
> instance that way it will be integrated (published, binded, injected, etc)
> into the system?
>
> Thanks.
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@felix.**apache.org<users-unsubscribe@felix.apache.org>
> For additional commands, e-mail: users-help@felix.apache.org
>
>

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