Package org.apache.felix.ipojo.parser

Examples of org.apache.felix.ipojo.parser.MethodMetadata


        }

        // updated method
        String upd = confs[0].getAttribute("updated");
        if (upd != null) {
            MethodMetadata method = getPojoMetadata().getMethod(upd);
            if (method == null) {
                throw new ConfigurationException("The updated method is not found in the class "
                        + getInstanceManager().getClassName());
            } else if (method.getMethodArguments().length == 0) {
                m_updated = new Callback(upd, new Class[0], false, getInstanceManager());
            } else if (method.getMethodArguments().length == 1
                    && method.getMethodArguments()[0].equals(Dictionary.class.getName())) {
                m_updated = new Callback(upd, new Class[] {Dictionary.class}, false, getInstanceManager());
            } else {
                throw new ConfigurationException("The updated method is found in the class "
                        + getInstanceManager().getClassName() + " must have either no argument or a Dictionary");
            }
View Full Code Here


            String eorb = sub[i].getAttribute(EXCEPTIONONROLLBACK_ATTRIBUTE);

            if (method == null) {
                throw new ConfigurationException("A transactionnal element must specified the method attribute");
            }
            MethodMetadata meta = this.getPojoMetadata().getMethod(method);
            if (meta == null) {
                throw new ConfigurationException("A transactionnal method is not in the pojo class : " + method);
            }

            int timeout = 0;
View Full Code Here

                        return injected;
                    }
                });
            } else if (element.containsAttribute("method")) {
                String method = element.getAttribute("method");
                MethodMetadata mm = getFactory().getPojoMetadata().getMethod(method,
                        new String[]{BundleContext.class.getName()});
                if (mm == null) {
                    getLogger().log(Log.WARNING, "Cannot find the method " + method + " in the class " +
                            getInstanceManager().getClassName() + ", super classes lookup will be attempted");
                }
View Full Code Here

        }

        // updated method
        String upd = confs[0].getAttribute("updated");
        if (upd != null) {
            MethodMetadata method = getPojoMetadata().getMethod(upd);
            if (method == null) {
                throw new ConfigurationException("The updated method is not found in the class "
                        + getInstanceManager().getClassName());
            } else if (method.getMethodArguments().length == 0) {
                m_updated = new Callback(upd, new Class[0], false, getInstanceManager());
            } else if (method.getMethodArguments().length == 1
                    && method.getMethodArguments()[0].equals(Dictionary.class.getName())) {
                m_updated = new Callback(upd, new Class[]{Dictionary.class}, false, getInstanceManager());
            } else {
                throw new ConfigurationException("The updated method is found in the class "
                        + getInstanceManager().getClassName() + " must have either no argument or a Dictionary");
            }
View Full Code Here

            String method = hooksMetadata[i].getAttribute("method");
            if (method == null) {
                throw new ConfigurationException("Lifecycle callback : A callback needs to contain a method attribute");
            }
           
            MethodMetadata met = meta.getMethod(method, new String[0]);
           
            int transition = -1;
            String trans = hooksMetadata[i].getAttribute("transition");
            if (trans == null) {
                throw new ConfigurationException("Lifecycle callback : the transition attribute is missing");
View Full Code Here

    private static void ensureThatCallbacksAreCoherent(Dependency dependency, PojoMetadata manipulation) throws
            ConfigurationException {
        DependencyCallback[] callbacks = dependency.getCallbacks();
        if (callbacks != null) {
            for (DependencyCallback callback : callbacks) {
                MethodMetadata metadata = manipulation.getMethod(callback.getMethodName());
                if (metadata == null) {
                    dependency.getHandler().debug("A dependency callback " + callback.getMethodName() + " of " +
                            DependencyHandler.getDependencyIdentifier(dependency) + " does not " +
                            "exist in the implementation class, will try the parent classes");
                } else {
                    String[] parameters = metadata.getMethodArguments();
                   switch(parameters.length) {
                       case 0 : // Just a notification method.
                            callback.setArgument(parameters);
                            break;
                       case 1 :
View Full Code Here

            }

            //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 String extractSpecificationFromMethods(Dependency dependency, DependencyCallback[] callbacks,
                                                          PojoMetadata manipulation) throws ConfigurationException {
        String type = null;
        for (DependencyCallback callback : callbacks) {
            MethodMetadata metadata = manipulation.getMethod(callback.getMethodName());
            if (metadata != null) {
                String[] parameters = metadata.getMethodArguments();
                if (parameters.length == || parameters.length == 2) {
                    if (! ServiceReference.class.getName().equals(parameters[0])
                        && ! Dictionary.class.getName().equals(parameters[0])
                        && ! Map.class.getName().equals(parameters[0])) {
                        if (type == null) {
View Full Code Here

        assertEquals("Check return", method.getMethodReturn(), "void");
  }
 
  public void testTwoArgsMethod() {
      PojoMetadata manip = SimpleMultipleCheckServiceProvider;
        MethodMetadata method = manip.getMethods("doNothing")[0];
        assertEquals("Check args count", 2, method.getMethodArguments().length);
    assertEquals("Check args - 1", method.getMethodArguments()[0], "java.lang.Object");
        assertEquals("Check args - 2", method.getMethodArguments()[1], "java.lang.String");
    assertEquals("Check return", method.getMethodReturn(), "java.lang.Object");
       
        method = manip.getMethod("doNothing", new String[] {"java.lang.Object", "java.lang.String"});
        assertEquals("Check args count", 2, method.getMethodArguments().length);
        assertEquals("Check args - 1", method.getMethodArguments()[0], "java.lang.Object");
        assertEquals("Check args - 2", method.getMethodArguments()[1], "java.lang.String");
        assertEquals("Check return", method.getMethodReturn(), "java.lang.Object");
  }
View Full Code Here

        assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "boolean[]");   
  }
 
  public void testNoArgMethod() {
      PojoMetadata manip = SimpleMultipleCheckServiceProvider;
    MethodMetadata method = manip.getMethod("check");
    assertEquals("Check no args", method.getMethodArguments().length, 0);
    assertEquals("Check return", method.getMethodReturn(), "boolean");
       
        method = manip.getMethod("check", new String[0]);
        assertEquals("Check no args", method.getMethodArguments().length, 0);
        assertEquals("Check return", method.getMethodReturn(), "boolean");
  }
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.parser.MethodMetadata

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.