public List<MetaTypeInformationSpecification> getMetatypeInformation() {

        try {
            for (Map.Entry<String, List<File>> prodEntry : prodJars.entrySet()) {
                List<File> jars = prodEntry.getValue();
                String productName = prodEntry.getKey();
                for (File jar : jars) {
                    JarFile jarFile = new JarFile(jar);
                    Enumeration<JarEntry> entries = jarFile.entries();
                    List<String> metatypePath = new ArrayList<String>();
                    HashMap<String, URL> metatypePropMap = new HashMap<String, URL>();

                    //can we optimize for jars with no metatype?
                    while (entries.hasMoreElements()) {
                        JarEntry entry = entries.nextElement();
                        String entryName = entry.getName();
                        if (entry.isDirectory())
                            continue;

                        if (entryName.endsWith(XML_EXT) && entryName.startsWith(METATYPE_PAT)) {
                            metatypePath.add(entryName);
                        }
                        if (entryName.endsWith(PROP_EXT)) {
                            metatypePropMap.put(entryName, new URL("jar:" + jar.toURI() + "!/" + entryName));
                        }
                    }

                    boolean generateNewMetatype = true;
                    //combine all the metatypes while filling in the messages
                    for (String metatype : metatypePath) {
                        JarEntry metatypeEntry = jarFile.getJarEntry(metatype);
                        InputStream metatypeInputStream = jarFile.getInputStream(metatypeEntry);
                        //replace properties with jarFile
                        parse(metatypeInputStream, jarFile, generateNewMetatype, metatypePropMap, productName);
                        generateNewMetatype = false;
                    }
                }
            }
        } catch (IOException ioe) {
            throw new RuntimeException(ioe);
        } catch (XMLStreamException xse) {
            throw new RuntimeException(xse);
        }

        return metatypeList;
    }
public List < MetaTypeInformationSpecification > getMetatypeInformation ( ) { try { for ( Map . Entry < String , List < File > > prodEntry : prodJars . entrySet ( ) ) { List < File > jars = prodEntry . getValue ( ) ; String productName = prodEntry . getKey ( ) ; for ( File jar : jars ) { JarFile jarFile = new JarFile ( jar ) ; Enumeration < JarEntry > entries = jarFile . entries ( ) ; List < String > metatypePath = new ArrayList < String > ( ) ; HashMap < String , URL > metatypePropMap = new HashMap < String , URL > ( ) ; while ( entries . hasMoreElements ( ) ) { JarEntry entry = entries . nextElement ( ) ; String entryName = entry . getName ( ) ; if ( entry . isDirectory ( ) ) continue ; if ( entryName . endsWith ( XML_EXT ) && entryName . startsWith ( METATYPE_PAT ) ) { metatypePath . add ( entryName ) ; } if ( entryName . endsWith ( PROP_EXT ) ) { metatypePropMap . put ( entryName , new URL ( "jar:" + jar . toURI ( ) + "!/" + entryName ) ) ; } } boolean generateNewMetatype = true ; for ( String metatype : metatypePath ) { JarEntry metatypeEntry = jarFile . getJarEntry ( metatype ) ; InputStream metatypeInputStream = jarFile . getInputStream ( metatypeEntry ) ; parse ( metatypeInputStream , jarFile , generateNewMetatype , metatypePropMap , productName ) ; generateNewMetatype = false ; } } } } catch ( IOException ioe ) { throw new RuntimeException ( ioe ) ; } catch ( XMLStreamException xse ) { throw new RuntimeException ( xse ) ; } return metatypeList ; }
Since we don't have have the luxury of OSGi framework getting the OCDs for us,
we need to look up all the metatype.xml files from each jar manually and
construct a metatypeinformation which will be passed to SchemaWriter

@param jars
@return StreamSource containing all the metatype XMLs