Package org.apache.felix.service.command

Examples of org.apache.felix.service.command.Descriptor


        if ((methods != null) && (methods.size() > 0))
        {
            for (Method m : methods)
            {
                Descriptor d = m.getAnnotation(Descriptor.class);
                if (d == null)
                {
                    System.out.println("\n" + m.getName());
                }
                else
                {
                    System.out.println("\n" + m.getName() + " - " + d.value());
                }

                System.out.println("   scope: " + name.substring(0, name.indexOf(':')));

                // Get flags and options.
                Class[] paramTypes = m.getParameterTypes();
                Map<String, Parameter> flags = new TreeMap();
                Map<String, String> flagDescs = new TreeMap();
                Map<String, Parameter> options = new TreeMap();
                Map<String, String> optionDescs = new TreeMap();
                List<String> params = new ArrayList();
                Annotation[][] anns = m.getParameterAnnotations();
                for (int paramIdx = 0; paramIdx < anns.length; paramIdx++)
                {
                    Parameter p = findAnnotation(anns[paramIdx], Parameter.class);
                    d = findAnnotation(anns[paramIdx], Descriptor.class);
                    if (p != null)
                    {
                        if (p.presentValue().equals(Parameter.UNSPECIFIED))
                        {
                            options.put(p.names()[0], p);
                            if (d != null)
                            {
                                optionDescs.put(p.names()[0], d.value());
                            }
                        }
                        else
                        {
                            flags.put(p.names()[0], p);
                            if (d != null)
                            {
                                flagDescs.put(p.names()[0], d.value());
                            }
                        }
                    }
                    else if (d != null)
                    {
                        params.add(paramTypes[paramIdx].getSimpleName());
                        params.add(d.value());
                    }
                    else
                    {
                        params.add(paramTypes[paramIdx].getSimpleName());
                        params.add("");
View Full Code Here


        Assert.assertNotNull(findDescriptionAnnotation(hello));
        Assert.assertNull(findDescriptionAnnotation(print));
    }

    private String findDescriptionAnnotation(Method method) {
        Descriptor descriptor = method.getAnnotation(Descriptor.class);
        if (descriptor != null) {
            return descriptor.value();
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.apache.felix.service.command.Descriptor

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.