Package org.picocontainer

Examples of org.picocontainer.PicoCompositionException


            } else if (Map.class.isAssignableFrom(collectionType)) {
                result = getMapInstance(container, collectionType, adapterMap);
            } else if (Collection.class.isAssignableFrom(collectionType)) {
                result = getCollectionInstance(container, (Class<? extends Collection>) collectionType, adapterMap);
            } else {
                throw new PicoCompositionException(expectedType + " is not a collective type");
            }
        }
        return result;
    }
View Full Code Here


            final Class valueType = getValueType(expectedType);
            final Collection componentAdapters =
                    getMatchingComponentAdapters(container, adapter, componentKeyType, valueType).values();
            if (componentAdapters.isEmpty()) {
                if (!emptyCollection) {
                    throw new PicoCompositionException(expectedType
                            + " not resolvable, no components of type "
                            + valueType.getName()
                            + " available");
                }
            } else {
                for (Object componentAdapter1 : componentAdapters) {
                    final ComponentAdapter componentAdapter = (ComponentAdapter) componentAdapter1;
                    componentAdapter.verify(container);
                }
            }
        } else {
            throw new PicoCompositionException(expectedType + " is not a collective type");
        }
    }
View Full Code Here

                result.add(container.getComponent(componentAdapter.getComponentKey()));
            }
            return result;
        } catch (InstantiationException e) {
            ///CLOVER:OFF
            throw new PicoCompositionException(e);
            ///CLOVER:ON
        } catch (IllegalAccessException e) {
            ///CLOVER:OFF
            throw new PicoCompositionException(e);
            ///CLOVER:ON
        }
    }
View Full Code Here

                result.put(key, container.getComponent(key));
            }
            return result;
        } catch (InstantiationException e) {
            ///CLOVER:OFF
            throw new PicoCompositionException(e);
            ///CLOVER:ON
        } catch (IllegalAccessException e) {
            ///CLOVER:OFF
            throw new PicoCompositionException(e);
            ///CLOVER:ON
        }
    }
View Full Code Here

     */
    public void verify(PicoContainer container, ComponentAdapter<?> adapter,
                       Type expectedType, NameBinding expectedNameBinding,
                       boolean useNames, Annotation binding) throws PicoException {
        if (!isAssignable(expectedType)) {
            throw new PicoCompositionException(
                expectedType + " is not assignable from " +
                        (value != null ? value.getClass().getName() : "null"));
        }
    }
View Full Code Here

    protected Class<Void> invoke(final Object target) {
        final Method method = getMethod();
        try {
            method.invoke(target, getArguments());
        } catch (IllegalArgumentException e) {
            throw new PicoCompositionException("Can't call " + method.getName() + " on " + target, e);
        } catch (IllegalAccessException e) {
            throw new PicoCompositionException("Can't call " + method.getName() + " on " + target, e);
        } catch (InvocationTargetException e) {
            throw new PicoCompositionException("Failed when calling " + method.getName() + " on " + target, e
                    .getTargetException());
        }
        return Void.TYPE;
    }
View Full Code Here

        public <T> ComponentAdapter<T> createComponentAdapter(ComponentMonitor componentMonitor, LifecycleStrategy lifecycleStrategy, Properties componentProperties, Object componentKey, Class<T> componentImplementation, Parameter... parameters) throws PicoCompositionException {
            boolean useNames = AbstractBehaviorFactory.arePropertiesPresent(componentProperties, Characteristics.USE_NAMES, true);
            if (injectionMethod.getDeclaringClass().isAssignableFrom(componentImplementation)) {
                return componentMonitor.newInjector(new MethodInjector.ByReflectionMethod(componentKey, componentImplementation, parameters, componentMonitor, lifecycleStrategy, injectionMethod, useNames));
            } else {
                throw new PicoCompositionException("method [" + injectionMethod + "] not on impl " + componentImplementation.getName());
            }
        }
View Full Code Here

        if (kvs.length == 2) {
            addConfig(kvs[0], kvs[1]);
        } else if (kvs.length == 1) {
            addConfig(kvs[0], "true");
        } else if (kvs.length > 2) {
            throw new PicoCompositionException(
                "Argument name'"+separator+"'value pair '" + argument + "' has too many '"+separator+"' characters");
        }
    }
View Full Code Here

    private String state = CONSTRUCTED;

    /** {@inheritDoc} **/
    public void removingComponent() {
        if (isStarted()) {
            throw new PicoCompositionException("Cannot remove components after the container has started");
        }

        if (isDisposed()) {
            throw new PicoCompositionException("Cannot remove components after the container has been disposed");
        }
    }
View Full Code Here

    protected T caughtInstantiationException(final ComponentMonitor componentMonitor,
                                                final Constructor<T> constructor,
                                                final InstantiationException e, final PicoContainer container) {
        // can't get here because checkConcrete() will catch it earlier, but see PICO-191
        componentMonitor.instantiationFailed(container, this, constructor, e);
        throw new PicoCompositionException("Should never get here");
    }
View Full Code Here

TOP

Related Classes of org.picocontainer.PicoCompositionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.