Package org.picocontainer

Examples of org.picocontainer.PicoIntrospectionException


                  {
                     LOG.debug("Can't call " + method.getName() + " on " + o, e);
                  }
                  continue;
               }
               throw new PicoIntrospectionException("Can't call " + method.getName() + " on " + o, e);
            }
            catch (IllegalAccessException e)
            {
               if (ignoreError)
               {
                  if (LOG.isDebugEnabled())
                  {
                     LOG.debug("Can't call " + method.getName() + " on " + o, e);
                  }
                  continue;
               }
               throw new PicoIntrospectionException("Can't call " + method.getName() + " on " + o, e);
            }
            catch (InvocationTargetException e)
            {
               if (ignoreError)
               {
                  if (LOG.isDebugEnabled())
                  {
                     LOG.debug("Failed when calling " + method.getName() + " on " + o, e.getTargetException());
                  }
                  continue;
               }
               throw new PicoIntrospectionException("Failed when calling " + method.getName() + " on " + o,
                  e.getTargetException());
            }
         }
      }
      finally
View Full Code Here


        org.jacorb.orb.ORB jorb =
            (org.jacorb.orb.ORB) container.getComponentInstance(ORB.class);
       
        if (jorb == null)
        {
            throw new PicoIntrospectionException("Need JacORB ORB");
        }
    }
View Full Code Here

                    long startTime = System.currentTimeMillis();
                    method.invoke(o, null);
                    componentMonitor.invoked(method, o, System.currentTimeMillis() - startTime);
                } catch (IllegalArgumentException e) {
                    componentMonitor.invocationFailed(method, o, e);
                    throw new PicoIntrospectionException("Can't call " + method.getName() + " on " + o, e);
                } catch (IllegalAccessException e) {
                    componentMonitor.invocationFailed(method, o, e);
                    throw new PicoIntrospectionException("Can't call " + method.getName() + " on " + o, e);
                } catch (InvocationTargetException e) {
                    componentMonitor.invocationFailed(method, o, e);
                    throw new PicoIntrospectionException("Failed when calling " + method.getName() + " on " + o, e.getTargetException());
                }
            }
        } finally {
            componentInstances.clear();
        }
View Full Code Here

     * @see org.picocontainer.Parameter#verify(org.picocontainer.PicoContainer,
     *           org.picocontainer.ComponentAdapter, java.lang.Class)
     */
    public void verify(PicoContainer container, ComponentAdapter adapter, Class expectedType) throws PicoException {
        if (!checkPrimitive(expectedType) && !expectedType.isInstance(value)) {
            throw new PicoIntrospectionException(expectedType.getClass().getName()
                    + " is not assignable from "
                    + value.getClass().getName());
        }
    }
View Full Code Here

            classes = new Class[]{(Class) getDelegate().getComponentKey()};
        } else if (componentKey instanceof Class[]) {
            classes = (Class[]) componentKey;
        } else {
            if(strict) {
                throw new PicoIntrospectionException("In strict mode, " + getClass().getName() + " only allows components registered with interface keys (java.lang.Class or java.lang.Class[])");
            }
            return getDelegate().getComponentInstance(container);
        }

        Class[] interfaces = verifyInterfacesOnly(classes);
View Full Code Here

    }

    private Class[] verifyInterfacesOnly(Class[] classes) {
        for (int i = 0; i < classes.length; i++) {
            if(!classes[i].isInterface()) {
                throw new PicoIntrospectionException("Class keys must be interfaces. " + classes[i] + " is not an interface.");
            }
        }
        return classes;
    }
View Full Code Here

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

    public void testThrownRuntimeExceptionIsUnwrapped() {
        Mock mockPico = mock(PicoContainer.class);
        PicoVisitor visitor = new VerifyingVisitor();
        Error exception = new Error("junit");
        mockPico.expects(once()).method("accept").with(same(visitor)).will(
                throwException(new PicoIntrospectionException("message", exception)));
        try {
            visitor.traverse(mockPico.proxy());
            fail("PicoIntrospectionException expected");
        } catch (RuntimeException e) {
            assertEquals("message", e.getMessage());
View Full Code Here

        this.type = type;
        this.proxyFactory = proxyFactory;
        this.isCompatible = type.isAssignableFrom(delegate.getComponentImplementation());
        if (!isCompatible) {
            if (!proxyFactory.canProxy(type)) {
                throw new PicoIntrospectionException("Cannot create proxy for type " + type.getName());
            }
            // TODO: Check method compatiblity
        }
    }
View Full Code Here

            interfaces = new Class[]{(Class) componentKey};
        } else {
            interfaces = ClassHierarchyIntrospector.getAllInterfaces(getComponentImplementation());
        }
        if (interfaces.length == 0) {
            throw new PicoIntrospectionException("Can't proxy implementation for "
                    + getComponentImplementation().getName()
                    + ". It does not implement any interfaces.");
        }
        return interfaces;
    }
View Full Code Here

TOP

Related Classes of org.picocontainer.PicoIntrospectionException

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.