Emily, First of all you don't get null injected from a reference or a reference-list. In the case of an optional reference-list you get an empty collection injected. Yes this is easy to check and process for optionality.
For optional services you get a proxy injected at bean creation even if no matching service exists. You need to catch the ServiceUnavailableException and cope with it. You can't really use reference-listeners because there will always be a gap where you could end up with a ServiceUnavailableException. I think what you want is no service damping and to have the services directly injected, but this isn't the blueprint way. Sorry, sucks doesn't it. Alasdair On 15 November 2010 10:39, Emily Jiang <[email protected]> wrote: > I noticed an inconvenient behaviour on optional service reference. In order > to get optional service reference working, I have to create a > reference-listener to identify whether the service is available or not. For > optional reference-list, I don't need to have a reference listener as I can > just check whether the injection is null or not. > > e.g. <reference id="ref1" interface="a.b.aService" availablity="optional"/> > > In order to get the above working, I have to create a reference listener to > track the optional service. Otherwise, the client will wait for the above > service a.b.aService until blueprint timeout(treat as mandatory service > dependency). > > However, the reference-list for optional service reference works without the > need of using reference listener to track for the optional services. > > The blueprint specification did not specify this behaviour changes between > optional service reference and reference list. Have I missed something? > > > -- > Thanks > Emily > ================= > Emily Jiang > [email protected] > -- Alasdair Nottingham [email protected]
