private List loadDescriptor()

in tools/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/checks/SCRCheck.java [164:365]


    private List<ComponentMetadata> loadDescriptor(final CheckContext ctx, final File file) throws IOException, MojoExecutionException {
        XmlHandler handler = new XmlHandler( new Bundle() {

            @Override
            public int compareTo(Bundle o) {
                return 0;
            }

            @Override
            public void update(InputStream input) throws BundleException {
                // nothing to do
            }

            @Override
            public void update() throws BundleException {
                // nothing to do
            }

            @Override
            public void uninstall() throws BundleException {
                // nothing to do
            }

            @Override
            public void stop(int options) throws BundleException {
                // nothing to do
            }

            @Override
            public void stop() throws BundleException {
                // nothing to do
            }

            @Override
            public void start(int options) throws BundleException {
                // nothing to do
            }

            @Override
            public void start() throws BundleException {
                // nothing to do
            }

            @Override
            public Class<?> loadClass(String name) throws ClassNotFoundException {
                return null;
            }

            @Override
            public boolean hasPermission(Object permission) {
                return false;
            }

            @Override
            public Version getVersion() {
                return null;
            }

            @Override
            public String getSymbolicName() {
                return null;
            }

            @Override
            public int getState() {
                return 0;
            }

            @Override
            public Map<X509Certificate, List<X509Certificate>> getSignerCertificates(int signersType) {
                return null;
            }

            @Override
            public ServiceReference<?>[] getServicesInUse() {
                return null;
            }

            @Override
            public Enumeration<URL> getResources(String name) throws IOException {
                return null;
            }

            @Override
            public URL getResource(String name) {
                return null;
            }

            @Override
            public ServiceReference<?>[] getRegisteredServices() {
                return null;
            }

            @Override
            public String getLocation() {
                return file.getAbsolutePath();
            }

            @Override
            public long getLastModified() {
                return 0;
            }

            @Override
            public Dictionary<String, String> getHeaders(String locale) {
                return null;
            }

            @Override
            public Dictionary<String, String> getHeaders() {
                return null;
            }

            @Override
            public Enumeration<String> getEntryPaths(String path) {
                return null;
            }

            @Override
            public URL getEntry(final String path) {
                try {
                    return new File(ctx.getRootDir(), path).toURI().toURL();
                } catch (final MalformedURLException e) {
                    return null;
                }
            }

            @Override
            public File getDataFile(String filename) {
                return null;
            }

            @Override
            public long getBundleId() {
                return 0;
            }

            @Override
            public BundleContext getBundleContext() {
                return null;
            }

            @Override
            public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse) {
                return null;
            }

            @Override
            public <A> A adapt(Class<A> type) {
                return null;
            }
        }, new BundleLogger() {

            @Override
            public void log(Level level, String message, Throwable ex) {
               // nothing to do
                
            }

            @Override
            public void log(Level level, String message, Throwable ex, Object... args) {
               // nothing to do
                
            }

            @Override
            public boolean isLogEnabled(Level level) {
                return false;
            }

            @Override
            public ComponentLogger component(Bundle m_bundle, String implementationClassName, String name) {
                // nothing to do
                return null;
            }
        }, false, false, null );
        try {
            final SAXParserFactory factory = SAXParserFactory.newInstance();
            factory.setNamespaceAware(true);
            final SAXParser parser = factory.newSAXParser();
            parser.parse(file, handler);

            for ( final ComponentMetadata metadata : handler.getComponentMetadataList() ) {
                try {
                    // validate the component metadata
                    metadata.validate();


                } catch ( final ComponentException t ) {
                    ctx.reportError("Invalid component descriptor " + file.getAbsolutePath() + " for " + metadata.getName() + " : "
                             + t.getMessage());
                }
            }

            return handler.getComponentMetadataList();
        } catch ( final Exception e) {
            if ( e instanceof MojoExecutionException ) {
                throw (MojoExecutionException)e;
            }
            throw new MojoExecutionException(e.getMessage(), e);
        }
    }