// Path: api/src/main/java/org/jboss/osgi/resolver/XBundleRevision.java
// public interface XBundleRevision extends XResource, BundleRevision {
// 
//     /**
//      * Get the associated {@link XBundle}
//      */
//     XBundle getBundle();
// 
//     /**
//      * Get the {@link XBundleWiringSupport} associated with this resource
//      */
//     XBundleWiringSupport getWiringSupport();
// 
//     /**
//      * Get the bundle canonical name
//      *
//      * [symbolicName:version]
//      */
//     String getCanonicalName();
// 
//     /**
//      * Get the associated {@link ModuleIdentifier}
//      * or null if the revision is not resolved
//      */
//     ModuleIdentifier getModuleIdentifier();
// 
//     /**
//      * Get the associated {@link ModuleIdentifier}
//      * or null if the revision is not resolved
//      */
//     ModuleClassLoader getModuleClassLoader();
// 
//     /**
//      * @see {@link Bundle#getResource(String)}
//      */
//     URL getResource(String name);
// 
//     /**
//      * @see {@link Bundle#getResources(String)}
//      */
//     Enumeration<URL> getResources(String name) throws IOException;
// 
//     /**
//      * @see {@link Bundle#findEntries(String, String, boolean)}
//      */
//     Enumeration<URL> findEntries(String path, String filePattern, boolean recursive);
// 
//     /**
//      * @see {@link Bundle#getEntry(String)}
//      */
//     URL getEntry(String path);
// 
//     /**
//      * @see {@link Bundle#getEntryPaths(String)}
//      */
//     Enumeration<String> getEntryPaths(String path);
// 
//     /**
//      * True if this revision is a fragment
//      */
//     boolean isFragment();
// }


import java.util.List;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.osgi.metadata.OSGiMetaData;
import org.jboss.osgi.metadata.OSGiMetaDataBuilder;
import org.jboss.osgi.resolver.XBundleRevision;
import org.osgi.framework.Version;
import org.osgi.framework.namespace.PackageNamespace;
import org.osgi.resource.Capability;
    private OSGiMetaDataProcessor()
    {
    }

    public static OSGiMetaData loadOsgiMetaData(Module module)
    {
        // Get symbolic name & version
        ModuleIdentifier moduleId = module.getIdentifier();
        String symbolicName = moduleId.getName();
        Version version;
        try {
            version = Version.parseVersion(moduleId.getSlot());
        }
        catch (IllegalArgumentException ex) {
            version = Version.emptyVersion;
        }
        final OSGiMetaDataBuilder builder = OSGiMetaDataBuilder.createBuilder(symbolicName, version);

        // Add a package capability for every exported path
        new ModuleExportPackagesCollector(module) {

            @Override
            protected void addPackage(String packageName)
            {
                builder.addExportPackages(packageName);
            }
        }.collectExportPackages();
        return builder.getOSGiMetaData();
    }

// Path: api/src/main/java/org/jboss/osgi/resolver/XBundleRevision.java
// public interface XBundleRevision extends XResource, BundleRevision {
// 
//     /**
//      * Get the associated {@link XBundle}
//      */
//     XBundle getBundle();
// 
//     /**
//      * Get the {@link XBundleWiringSupport} associated with this resource
//      */
//     XBundleWiringSupport getWiringSupport();
// 
//     /**
//      * Get the bundle canonical name
//      *
//      * [symbolicName:version]
//      */
//     String getCanonicalName();
// 
//     /**
//      * Get the associated {@link ModuleIdentifier}
//      * or null if the revision is not resolved
//      */
//     ModuleIdentifier getModuleIdentifier();
// 
//     /**
//      * Get the associated {@link ModuleIdentifier}
//      * or null if the revision is not resolved
//      */
//     ModuleClassLoader getModuleClassLoader();
// 
//     /**
//      * @see {@link Bundle#getResource(String)}
//      */
//     URL getResource(String name);
// 
//     /**
//      * @see {@link Bundle#getResources(String)}
//      */
//     Enumeration<URL> getResources(String name) throws IOException;
// 
//     /**
//      * @see {@link Bundle#findEntries(String, String, boolean)}
//      */
//     Enumeration<URL> findEntries(String path, String filePattern, boolean recursive);
// 
//     /**
//      * @see {@link Bundle#getEntry(String)}
//      */
//     URL getEntry(String path);
// 
//     /**
//      * @see {@link Bundle#getEntryPaths(String)}
//      */
//     Enumeration<String> getEntryPaths(String path);
// 
//     /**
//      * True if this revision is a fragment
//      */
//     boolean isFragment();
// }


// Path: api/src/main/java/org/jboss/osgi/resolver/spi/OSGiMetaDataProcessor.java
import java.util.List;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.osgi.metadata.OSGiMetaData;
import org.jboss.osgi.metadata.OSGiMetaDataBuilder;
import org.jboss.osgi.resolver.XBundleRevision;
import org.osgi.framework.Version;
import org.osgi.framework.namespace.PackageNamespace;
import org.osgi.resource.Capability;

    private OSGiMetaDataProcessor()
    {
    }

    public static OSGiMetaData loadOsgiMetaData(Module module)
    {
        // Get symbolic name & version
        ModuleIdentifier moduleId = module.getIdentifier();
        String symbolicName = moduleId.getName();
        Version version;
        try {
            version = Version.parseVersion(moduleId.getSlot());
        }
        catch (IllegalArgumentException ex) {
            version = Version.emptyVersion;
        }
        final OSGiMetaDataBuilder builder = OSGiMetaDataBuilder.createBuilder(symbolicName, version);

        // Add a package capability for every exported path
        new ModuleExportPackagesCollector(module) {

            @Override
            protected void addPackage(String packageName)
            {
                builder.addExportPackages(packageName);
            }
        }.collectExportPackages();
        return builder.getOSGiMetaData();
    }

    public static OSGiMetaData getOsgiMetaData(XBundleRevision brev)