Package org.apache.felix.ipojo

Examples of org.apache.felix.ipojo.ConfigurationException


     * @throws ConfigurationException if the manipulation metadata cannot be found
     */
    public PojoMetadata(Element metadata) throws ConfigurationException {
        Element[] elems = metadata.getElements("manipulation", "");
        if (elems == null) {
            throw new ConfigurationException("The component " + metadata.getAttribute("classname") + " has no manipulation metadata");
        }
        Element manip = elems[0];
        m_className = manip.getAttribute("classname");
        m_super = manip.getAttribute("super");

View Full Code Here


        m_handler = handler;
        m_manager = manager;
        m_field = field;

        if (value == null) {
            throw new ConfigurationException("Cannot create properties without a value");
        }

        if (name == null) {
            if (m_field == null) {
                m_name = method;
View Full Code Here

            } else {
                // Non array, complex type.
                try {
                    return context.getBundle().loadClass(type);
                } catch (ClassNotFoundException e) {
                    throw new ConfigurationException("Class not found exception in setValue on " + type, e);
                } catch (SecurityException e) {
                    throw new ConfigurationException("Security exception in setValue on " + type, e);
                } catch (IllegalArgumentException e) {
                    throw new ConfigurationException("Argument issue when calling the constructor of the type " + type, e);
                }
            }
        }
    }
View Full Code Here

        try {
            Class clazz = context.getBundle().loadClass(internalType);
            Object[] object = (Object[]) Array.newInstance(clazz, 0);
            return object.getClass();
        } catch (ClassNotFoundException e) {
            throw new ConfigurationException("Class not found exception in setValue on " + internalType, e);
        } catch (SecurityException e) {
            throw new ConfigurationException("Security Exception in setValue on " + internalType, e);
        } catch (IllegalArgumentException e) {
            throw new ConfigurationException("Argument issue when calling the constructor of the type " + internalType, e);
        }
    }
View Full Code Here

                    valueOf.setAccessible(true);
                }
                 // Invoke the static method
                return valueOf.invoke(null, new String[] {strValue});
            } catch (InvocationTargetException e) {
                throw new ConfigurationException("Cannot create an enumerated value for " + type
                        + " with " + strValue, e.getTargetException());
            } catch (Exception e) {
                throw new ConfigurationException("Cannot create an enumerated value for " + type
                        + " with " + strValue, e);
            }
        }

        // Else it is a neither a primitive type neither a String -> create
        // the object by calling a constructor with a string in argument.
        try {
            Constructor cst = type.getConstructor(new Class[] { String.class });
            return cst.newInstance(new Object[] { strValue });
        } catch (SecurityException e) {
            throw new ConfigurationException("Security exception during the creation of " + type, e);
        } catch (NoSuchMethodException e) {
            throw new ConfigurationException("Constructor not found exception during the creation of " + type, e);
        } catch (IllegalArgumentException e) {
            throw new ConfigurationException("Argument issue when calling the constructor of the type " + type, e);
        } catch (InstantiationException e) {
            throw new ConfigurationException("Instantiation problem  " + type, e);
        } catch (IllegalAccessException e) {
            throw new ConfigurationException("Illegal Access " + type, e);
        } catch (InvocationTargetException e) {
            throw new ConfigurationException("Invocation problem during the creation of " + type, e.getTargetException());
        }

    }
View Full Code Here

            for (int i = 0; i < values.length; i++) {
                object[i] = cst.newInstance(new Object[] { values[i].trim() });
            }
            return object;
        } catch (NoSuchMethodException e) {
            throw new ConfigurationException("Constructor not found exception in setValue on " + interntype.getName(), e);
        } catch (IllegalArgumentException e) {
            throw new ConfigurationException("Argument issue when calling the constructor of the type " + interntype.getName(), e);
        } catch (InstantiationException e) {
            throw new ConfigurationException("Instantiation problem  " + interntype.getName(), e);
        } catch (IllegalAccessException e) {
            throw new ConfigurationException("Illegal Access Exception in  " + interntype.getName(), e);
        } catch (InvocationTargetException e) {
            throw new ConfigurationException("Invocation problem " + interntype.getName(), e.getTargetException());
        }
    }
View Full Code Here

        if (! dependency.getSpecification().isInterface()
                || dependency.isAggregate()  && dependency.getAggregateType() == AggregateDependencyInjectionType.ARRAY
                || dependency.isAggregate()  && dependency.getAggregateType() == AggregateDependencyInjectionType.VECTOR) {
            dependency.setProxy(false);
            if (dependency.getConstructorParameterIndex() != -1) {
                throw new ConfigurationException("The dependency " + DependencyHandler.getDependencyIdentifier
                        (dependency) + " has an inconsistent configuration. - reason: the service specification " +
                        "or container do not support proxy, which is required for constructor injection");
            }
            dependency.getHandler().info("Proxy disabled for " + DependencyHandler.getDependencyIdentifier
                    (dependency) + " - the service specification or container do not support proxy");
View Full Code Here

                       case 2 :
                           // Constraints on the second argument, must be a service reference, a dictionary or a map
                           if (!ServiceReference.class.getName().equals(parameters[1])
                               && ! Dictionary.class.getName().equals(parameters[1])
                               && ! Map.class.getName().equals(parameters[1])) {
                                throw new ConfigurationException("The method " + callback.getMethodName() + " of " +
                                        DependencyHandler.getDependencyIdentifier(dependency) + " is not a valid " +
                                        "dependency callback - reason: the second argument (" + parameters[1] +
                                        ")  must be a service reference, a dictionary or a map.");
                                }
                           callback.setArgument(parameters);
                           break;
                       default:
                           // Invalid signature.
                           throw new ConfigurationException("The method " + callback.getMethodName() + " of " +
                                   DependencyHandler.getDependencyIdentifier(dependency) + " is not a valid " +
                                   "dependency callback - reason: the signature is invalid");
                    }
                }
            }
View Full Code Here

                                                                    PojoMetadata manipulation) throws
            ConfigurationException {
        if (dependency.getConstructorParameterIndex() != -1) {
            MethodMetadata[] constructors = manipulation.getConstructors();
            if (constructors == null  || constructors.length == 0) {
                throw new ConfigurationException("The constructor parameter attribute of " + DependencyHandler
                        .getDependencyIdentifier(dependency) + " is inconsistent - reason: there is no constructor in" +
                        " the component class (" + dependency.getHandler().getInstanceManager().getClassName() + ")");
            }

            //TODO Consider only the first constructor. This is a limitation we should think about,
            // how to determine which constructor to use. Only one constructor should have annotations,
            // it could be use as hint.
            MethodMetadata constructor = constructors[0];
            if (! (constructor.getMethodArguments().length > dependency.getConstructorParameterIndex())) {
                throw new ConfigurationException("The constructor parameter attribute of " + DependencyHandler
                        .getDependencyIdentifier(dependency) + " is inconsistent - reason: the constructor with the " +
                        "signature " + Arrays.toString(constructor.getMethodArguments()) + " has not enough " +
                        "parameters");
            }
View Full Code Here

     */
    private static void ensureThatTheFieldIsInComponentClass(Dependency dependency, PojoMetadata manipulation) throws ConfigurationException {
        if (dependency.getField() != null) {
            FieldMetadata field = manipulation.getField(dependency.getField());
            if (field == null) {
                throw new ConfigurationException("Incorrect field injection for " + DependencyHandler
                        .getDependencyIdentifier(dependency) + " - reason: the field " + dependency.getField() + " is" +
                        " not in the component class (" + dependency.getHandler().getInstanceManager().getClassName()
                      + ")");
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.ConfigurationException

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.