shell/console/src/main/java/org/apache/karaf/shell/console/impl/Converters.java [129:175]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    public Object convert(Class<?> desiredType, final Object in) throws Exception
    {
        if (desiredType == Bundle.class)
        {
            return convertBundle(in);
        }

        if (desiredType == ServiceReference.class)
        {
            return convertServiceReference(in);
        }

        if (desiredType == Class.class)
        {
            try
            {
                return Class.forName(in.toString());
            }
            catch (ClassNotFoundException e)
            {
                return null;
            }
        }

        if (desiredType.isAssignableFrom(String.class) && in instanceof InputStream)
        {
            return read(((InputStream) in));
        }

        if (in instanceof Function && desiredType.isInterface()
            && desiredType.getDeclaredMethods().length == 1)
        {
            return Proxy.newProxyInstance(desiredType.getClassLoader(),
                new Class[] { desiredType }, new InvocationHandler()
                {
                    Function command = ((Function) in);

                    public Object invoke(Object proxy, Method method, Object[] args)
                        throws Throwable
                    {
                        return command.execute(null, Arrays.asList(args));
                    }
                });
        }

        return null;
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/Converters.java [131:177]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    public Object convert(Class<?> desiredType, final Object in) throws Exception
    {
        if (desiredType == Bundle.class)
        {
            return convertBundle(in);
        }

        if (desiredType == ServiceReference.class)
        {
            return convertServiceReference(in);
        }

        if (desiredType == Class.class)
        {
            try
            {
                return Class.forName(in.toString());
            }
            catch (ClassNotFoundException e)
            {
                return null;
            }
        }

        if (desiredType.isAssignableFrom(String.class) && in instanceof InputStream)
        {
            return read(((InputStream) in));
        }

        if (in instanceof Function && desiredType.isInterface()
            && desiredType.getDeclaredMethods().length == 1)
        {
            return Proxy.newProxyInstance(desiredType.getClassLoader(),
                new Class[] { desiredType }, new InvocationHandler()
                {
                    Function command = ((Function) in);

                    public Object invoke(Object proxy, Method method, Object[] args)
                        throws Throwable
                    {
                        return command.execute(null, Arrays.asList(args));
                    }
                });
        }

        return null;
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



