public boolean canHandle()

in jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/handler/JBIDeploymentListener.java [47:71]


    public boolean canHandle(File artifact) {
        try {
            // Accept jars and zips
            if (!artifact.getName().endsWith(".zip") &&
                    !artifact.getName().endsWith(".jar")) {
                return false;
            }
            JarFile jar = new JarFile(artifact);
            JarEntry entry = jar.getJarEntry(DescriptorFactory.DESCRIPTOR_FILE);
            // Only handle JBI artifacts
            if (entry == null) {
                return false;
            }
            // Only handle non OSGi bundles
            Manifest m = jar.getManifest();
            if (m != null &&
                    m.getMainAttributes().getValue(new Attributes.Name("Bundle-SymbolicName")) != null &&
                    m.getMainAttributes().getValue(new Attributes.Name("Bundle-Version")) != null) {
                return false;
            }
            return true;
        } catch (Exception e) {
            return false;
        }
    }