Richard,

I am currently downloading the osgi book as I write this. But going back
over what I did. I added the id's again to @Bind, and @Unbind, when I did
this. it now adds a TidgetSaasmDevice, but only 1, then only until i close
the GUI driving these binding functions do the rest get added before it[GUI]
is completely closed. 

I am confused as to why the GUI added them correctly (except for the copy)
when I had the @Requires, but not now?

I apologize for all the questions, I am relatively new to the felix
framework.

Mark-Anthony


Richard S. Hall wrote:
> 
>   On 8/11/10 14:16, mhutton86 wrote:
> I am not sure.
> 
> I do know that @Requires and @Bind/@Unbind are independent of each 
> other, although they can be used together. There are basically two ways 
> to have your dependencies injected:
> 
>    1. Field injection (i.e., @Requires)
>    2. Method injection (i.e., @Bind/@Unbind)
> 
> iPOJO does allow you to use both at the same time, but typically in such 
> situations the bind/unbind methods are more for notification purposes or 
> for obtaining service properties.
> 
> -> richard
> 
>>
>>
>> Richard S. Hall wrote:
>>>    If you have @Bind/@Unbind and use them to maintain your own list,
>>> then
>>> why do you need @Requires at all?
>>>
>>> ->  richard
>>>
>>> On 8/11/10 13:17, mhutton86 wrote:
>>>> I have a service that I require
>>>>
>>>> @Requires(optional=true, id="tidget_devices",
>>>> filter="(!(serviceName=file
>>>> reader))")
>>>> private TidgetSaasmDevice[] initialTidgets;
>>>>
>>>> but these TidgetSaasmDevices are not ready off the bat, and have to be
>>>> added
>>>> via late-binding
>>>> @Bind(id="tidget_devices")
>>>> private synchronized void addTidgetSaasmDevice(TidgetSaasmDevice
>>>> newTidget)
>>>> {...}
>>>>
>>>> @Unbind(id="tidget_devices")
>>>> private synchronized void removeTidgetSaasmDevice(TidgetSaasmDevice
>>>> newTidget){...}
>>>>
>>>> since TidgetSaasmDevice[] is an array. adding to it is a pain. so I
>>>> have
>>>> a
>>>> List to take care of this.
>>>>
>>>> // dynamic list for adding tidgets
>>>> private List<TidgetSaasmDevice>   tidgets = new
>>>> ArrayList<TidgetSaasmDevice>();
>>>>
>>>> but the problem when I start felix, is that a tidget is always loaded
>>>> twice
>>>> (random). due to the initial @Requires dependency trying to be
>>>> fulfilled.
>>>> @optional = true, won't solve this (not surprising). I can solve this
>>>> by
>>>> checking if this node is already added before trying to add it again.
>>>> but
>>>> this does not work ans is more of a hack then a fix.
>>>>
>>>> Any ideas?
>>>>
>>>> Example Output:
>>>> adding: tidget-saasm COM22-0
>>>> adding: tidget-saasm COM9-0
>>>> adding: tidget-saasm COM22-1
>>>> adding: tidget-saasm COM29-0
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 
> 



-- 
View this message in context: 
http://old.nabble.com/%40requires-with-late-binding-headaches-tp29410576p29411687.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to