public List < ComponentDeclaration > getDeclaredComponentsFromJAR ( InputStream jarFile ) throws IOException { ZipInputStream zis = new ZipInputStream ( jarFile ) ; List < ComponentDeclaration > componentDeclarations = null ; List < ComponentDeclaration > componentOverrideDeclarations = null ; for ( ZipEntry entry = zis . getNextEntry ( ) ; entry != null && ( componentDeclarations == null || componentOverrideDeclarations == null ) ; entry = zis . getNextEntry ( ) ) { if ( entry . getName ( ) . equals ( ComponentAnnotationLoader . COMPONENT_LIST ) ) { componentDeclarations = getDeclaredComponents ( zis ) ; } else if ( entry . getName ( ) . equals ( ComponentAnnotationLoader . COMPONENT_OVERRIDE_LIST ) ) { componentOverrideDeclarations = getDeclaredComponents ( zis ) ; } } // Merge all overrides found with a priority of 0. This is purely for backward compatibility since the // override files is now deprecated. if ( componentOverrideDeclarations != null ) { if ( componentDeclarations == null ) { componentDeclarations = new ArrayList <> ( ) ; } for ( ComponentDeclaration componentOverrideDeclaration : componentOverrideDeclarations ) { componentDeclarations . add ( new ComponentDeclaration ( componentOverrideDeclaration . getImplementationClassName ( ) , 0 ) ) ; } } return componentDeclarations ; }
Get all components listed in a JAR file .