private Object openOrRead ( final String path , final boolean open ) throws SecurityException { final String methodName = open ? "open" : "read" ; final Object /* Optional<InputStream> */ optionalInputStream = ReflectionUtils . invokeMethod ( moduleReader , methodName , String . class , path , /* throwException = */ true ) ; if ( optionalInputStream == null ) { throw new IllegalArgumentException ( "Got null result from moduleReader." + methodName + "(name)" ) ; } final Object /* InputStream */ inputStream = ReflectionUtils . invokeMethod ( optionalInputStream , "get" , /* throwException = */ true ) ; if ( inputStream == null ) { throw new IllegalArgumentException ( "Got null result from moduleReader." + methodName + "(name).get()" ) ; } return inputStream ; }
Use the proxied ModuleReader to open the named resource as an InputStream .