public static < T > T [ ] getBeans ( Class < T > interfaceClass ) { Object object = serviceMap . get ( interfaceClass . getName ( ) ) ; if ( object == null ) return null ; if ( object instanceof Object [ ] ) { return ( T [ ] ) object ; } else { Object array = Array . newInstance ( interfaceClass , 1 ) ; Array . set ( array , 0 , object ) ; return ( T [ ] ) array ; } }
Get a list of cached singleton objects from service map by interface class . If there is only one object in the serviceMap then construct the list with this only object .