[ 
https://issues.apache.org/jira/browse/FELIX-303?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12772109#action_12772109
 ] 

Pierre De Rop commented on FELIX-303:
-------------------------------------

Hello Marcel, 

There is minor bug in the attached patch -> dm-patch.tgz

In ServiceDependency.java, the method getCallbackInstances() is wrong because 
it includes the composition instances in the returned array,
even if setCallbacks(Object instance, String added, String removed) has been 
used:


    private synchronized Object[] getCallbackInstances() {
      Object[] callbackInstances = ((ServiceImpl) 
m_service).getCompositionInstances(); 
        if (m_callbackInstance == null) {
            return callbackInstances;
        }
        Object[] res = new Object[callbackInstances.length+1];
        res[0] = m_callbackInstance; //this could also be extended to an 
array...?
        System.arraycopy(callbackInstances, 0, res, 1, 
callbackInstances.length);
        return res;
    }


Don't you think that the following method implementation should be used instead:

    private synchronized Object[] getCallbackInstances() {
        return m_callbackInstance != null ? 
            new Object[] { m_callbackInstance } : ((ServiceImpl) 
m_service).getCompositionInstances();
    }




> Support for compositions
> ------------------------
>
>                 Key: FELIX-303
>                 URL: https://issues.apache.org/jira/browse/FELIX-303
>             Project: Felix
>          Issue Type: New Feature
>          Components: Dependency Manager
>    Affects Versions: felix-0.8.0
>            Reporter: Marcel Offermans
>            Assignee: Marcel Offermans
>         Attachments: dm-patch.tgz, proxy.patch.txt
>
>
> When creating service implementations out of POJO's, the more complex 
> implementations will often be composed out of several POJO's, using 
> composition instead of inheritance. This means instead of one implementation, 
> you have N implementations. The consequences of this are that for both the 
> callbacks and the injected services, you want to be able to explicitly 
> specify one of more instances, instead of assuming there's only one. The API 
> needs to be extended to support this (basically adding a parameter of type 
> Object[] for some of the methods).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to