@Override protected List<Class<?>> stepsTypes() { List<Class<?>> types = new ArrayList<Class<?>>(); for (ComponentAdapter<?> adapter : parent.getComponentAdapters()) { if (hasAnnotatedMethods(adapter.getComponentImplementation())) { types.add(adapter.getComponentImplementation()); } } return types; }
/** * Construct an AssimilatingBehavior. The <code>type</code> may not implement the type of the * component instance. If the component instance <b>does</b> implement the interface, no proxy is * used though. * * @param type The class type used as key. * @param delegate The delegated {@link ComponentAdapter}. * @param proxyFactory The {@link ProxyFactory} to use. * @throws PicoCompositionException Thrown if the <code>type</code> is not compatible and cannot * be proxied. */ public AssimilatingBehavior( final Class type, final ComponentAdapter delegate, final ProxyFactory proxyFactory) throws PicoCompositionException { super(delegate); this.type = type; this.proxyFactory = proxyFactory; final Class delegationType = delegate.getComponentImplementation(); this.isCompatible = type.isAssignableFrom(delegationType); if (!isCompatible) { if (!proxyFactory.canProxy(type)) { throw new PicoCompositionException("Cannot create proxy for type " + type.getName()); } final Method[] methods = type.getMethods(); for (final Method method : methods) { try { delegationType.getMethod(method.getName(), method.getParameterTypes()); } catch (final NoSuchMethodException e) { throw new PicoCompositionException( "Cannot create proxy for type " + type.getName() + ", because of incompatible method " + method.toString()); } } } }
public Object remove(final Object o) { ComponentAdapter adapter = mutablePicoContainer.removeComponent(o); if (adapter != null) { // if previously an instance was registered, return it, otherwise return the type return adapter instanceof InstanceAdapter ? adapter.getComponentInstance(mutablePicoContainer, ComponentAdapter.NOTHING.class) : adapter.getComponentImplementation(); } else { return null; } }
@Override public Class<?> apply(ComponentAdapter<?> input) { return input.getComponentImplementation(); }