public static Object createCompositeServiceProxy ( ClassLoader classLoader , Object [ ] services , Class < ? > [ ] serviceInterfaces , boolean allowMultipleInheritance ) { Set < Class < ? > > interfaces = collectInterfaces ( services , serviceInterfaces ) ; final Map < Class < ? > , Object > serviceClassToInstanceMapping = buildServiceMap ( services , allowMultipleInheritance , interfaces ) ; // now create the proxy return Proxy . newProxyInstance ( classLoader , interfaces . toArray ( new Class < ? > [ 0 ] ) , new InvocationHandler ( ) { @ Override public Object invoke ( Object proxy , Method method , Object [ ] args ) throws Throwable { Class < ? > clazz = method . getDeclaringClass ( ) ; if ( clazz == Object . class ) { return proxyObjectMethods ( method , proxy , args ) ; } return method . invoke ( serviceClassToInstanceMapping . get ( clazz ) , args ) ; } } ) ; }
Creates a composite service using all of the given services and implementing the given interfaces .