Thanks Peter. Perhaps the example code might give you some idea what I'm looking for: http://bit.ly/dhnyfK.
The basic pattern I'm looking for is as follows: how can I compel and bind to specific types of services whose types are known only at runtime? If the types were determined at build time or the number of types is not too big, I could produce a number of component definitions in DS and that will solve my problem. What if that was not true? For a concrete example, suppose I need to deserialize (string -> object) a number of things in a file based on their types. The file might have <entry type="foo" value="..."/> <entry type="bar" value="..."/> ... My component would go over these entries and need to find a "converter" service based on the type that will provide a conversion service. So when my app processes the line for type=foo, it needs a converter service of type=foo, and so on. It is not easy to control for which types I need converters before runtime, and potentially they may be numerous. I'm looking for a solution to problems like this utilizing a DI service (whether it's DS, Blueprint, or something else) that will enable me to keep things POJO. I'm still coming up to speed with DS and Blueprint, so there might be a very simple solution that I did not think of... Thanks in advance! Regards, Sangjin On Mon, Jun 14, 2010 at 2:21 AM, Peter Kriens <[email protected]>wrote: > I am not sure what you try to achieve? Could you give a concrete example? > > Kind regards, > > Peter Kriens > > > On 11 jun 2010, at 03:43, Christopher Armstrong wrote: > > > Hi Sangjin > > > > Not that I recommend this solution, but you should take a look at the > synchronous service filter part of the 4.2 specification. This is the > ultimate way to create services on demand when a service is requested (not > through some external means, which is when you use ConfigAdmin). > > > > Cheers > > Chris > > > > On 11/06/2010 5:25 AM, Sangjin Lee wrote: > >> Thanks for the quick reply. That's what I suspected, but I wanted to be > sure. So, injecting a reference target has no effect on a factory component? > I get ComponentExceptions under some situations, so it seems it is *not* > used to bind a service but is used to check/resolve it... > >> > >> Is there a better way to achieve what I'm trying to achieve (create > dynamic instances of services that will be used to bind to specific service > instances based on properties)? Perhaps Blueprint? > >> > >> Thanks, > >> Sangjin > >> > >> On Thu, Jun 10, 2010 at 11:24 AM, Agemo Cui <[email protected]<mailto: > [email protected]>> wrote: > >> > >> Hi, > >> > >> I don't think this is gonna work. As I understand, the > >> ComponentFactory service has the same dependencies as the factory > >> component. So the service to be injected into the factory > >> component is already decided when the ComponentFactory service is > >> available. > >> > >> Regards, > >> Agemo > >> > >> On Thu, Jun 10, 2010 at 1:53 PM, Sangjin Lee <[email protected] > >> <mailto:[email protected]>> wrote: > >> > >> I have a question on the behavior of > >> ComponentFactory.newInstance() when you inject a reference > >> target dynamically. > >> > >> I have a factory component that has a unary mandatory > >> reference to some service, but the target is intentionally > >> left blank (so I can provide it dynamically). When I > >> instantiate a specific instance, I want to pass in a > >> particular type so this specific instance can bind to the > >> right service instance. The code snippet is at > >> http://bit.ly/dy8kFy. > >> > >> I am basically adding a property for "service.target" = > >> "(type=foo)", so at runtime this binds specifically to a > >> service instance of type=foo. Will this pattern work? > >> > >> Also, if so, how does ComponentFactory.newInstance() behave > >> if that service is not registered yet? Will it fail > >> immediately or will it block/wait until that particular > >> service is registered? > >> > >> In a bigger context, I'm trying to see if I can use this > >> pattern as a way to "compel" a specific service with a type > >> dynamically at runtime. Is there a better pattern to compel a > >> specific service type dynamically? Thanks much! > >> > >> Regards, > >> Sangjin > >> > >> _______________________________________________ > >> OSGi Developer Mail List > >> [email protected] <mailto:[email protected]> > >> https://mail.osgi.org/mailman/listinfo/osgi-dev > >> > >> > >> > >> _______________________________________________ > >> OSGi Developer Mail List > >> [email protected] <mailto:[email protected]> > >> https://mail.osgi.org/mailman/listinfo/osgi-dev > >> > >> > >> > >> _______________________________________________ > >> OSGi Developer Mail List > >> [email protected] > >> https://mail.osgi.org/mailman/listinfo/osgi-dev > > > > _______________________________________________ > > OSGi Developer Mail List > > [email protected] > > https://mail.osgi.org/mailman/listinfo/osgi-dev > > > _______________________________________________ > OSGi Developer Mail List > [email protected] > https://mail.osgi.org/mailman/listinfo/osgi-dev >
_______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
