Search in sources :

Example 1 with FeatureDetector

use of org.flywaydb.core.internal.util.FeatureDetector in project flyway by flyway.

the class ClassPathScanner method createLocationScanner.

/**
     * Creates an appropriate location scanner for this url protocol.
     *
     * @param protocol The protocol of the location url to scan.
     * @return The location scanner or {@code null} if it could not be created.
     */
private ClassPathLocationScanner createLocationScanner(String protocol) {
    if (locationScannerCache.containsKey(protocol)) {
        return locationScannerCache.get(protocol);
    }
    if ("file".equals(protocol)) {
        FileSystemClassPathLocationScanner locationScanner = new FileSystemClassPathLocationScanner();
        locationScannerCache.put(protocol, locationScanner);
        resourceNameCache.put(locationScanner, new HashMap<URL, Set<String>>());
        return locationScanner;
    }
    if ("jar".equals(protocol) || "war".equals(protocol) || //WebLogic
    "zip".equals(protocol) || //WebSphere
    "wsjar".equals(protocol)) {
        JarFileClassPathLocationScanner locationScanner = new JarFileClassPathLocationScanner();
        locationScannerCache.put(protocol, locationScanner);
        resourceNameCache.put(locationScanner, new HashMap<URL, Set<String>>());
        return locationScanner;
    }
    FeatureDetector featureDetector = new FeatureDetector(classLoader);
    if (featureDetector.isJBossVFSv3Available() && "vfs".equals(protocol)) {
        JBossVFSv3ClassPathLocationScanner locationScanner = new JBossVFSv3ClassPathLocationScanner();
        locationScannerCache.put(protocol, locationScanner);
        resourceNameCache.put(locationScanner, new HashMap<URL, Set<String>>());
        return locationScanner;
    }
    if (featureDetector.isOsgiFrameworkAvailable() && (// Felix
    "bundle".equals(protocol) || //Equinox
    "bundleresource".equals(protocol))) {
        OsgiClassPathLocationScanner locationScanner = new OsgiClassPathLocationScanner();
        locationScannerCache.put(protocol, locationScanner);
        resourceNameCache.put(locationScanner, new HashMap<URL, Set<String>>());
        return locationScanner;
    }
    return null;
}
Also used : TreeSet(java.util.TreeSet) Set(java.util.Set) JBossVFSv3ClassPathLocationScanner(org.flywaydb.core.internal.util.scanner.classpath.jboss.JBossVFSv3ClassPathLocationScanner) URL(java.net.URL) FeatureDetector(org.flywaydb.core.internal.util.FeatureDetector)

Example 2 with FeatureDetector

use of org.flywaydb.core.internal.util.FeatureDetector in project flyway by flyway.

the class EnvInfoServlet method doGet.

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String appserver;
    if (Environment.runningOnGoogleAppEngine()) {
        appserver = "Google AppEngine";
    } else {
        FeatureDetector featureDetector = new FeatureDetector(Thread.currentThread().getContextClassLoader());
        if (featureDetector.isJBossVFSv2Available()) {
            appserver = "JBoss 5";
        } else if (featureDetector.isJBossVFSv3Available()) {
            appserver = "JBoss 6+";
        } else {
            appserver = "Other";
        }
    }
    String database = ((DriverDataSource) flyway.getDataSource()).getUrl();
    PrintWriter writer = response.getWriter();
    writer.print("{\"status\":\"OK\"," + " \"appserver\":\"" + appserver + "\"," + " \"database\":\"" + database + "\"}");
}
Also used : DriverDataSource(org.flywaydb.core.internal.util.jdbc.DriverDataSource) FeatureDetector(org.flywaydb.core.internal.util.FeatureDetector) PrintWriter(java.io.PrintWriter)

Aggregations

FeatureDetector (org.flywaydb.core.internal.util.FeatureDetector)2 PrintWriter (java.io.PrintWriter)1 URL (java.net.URL)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 DriverDataSource (org.flywaydb.core.internal.util.jdbc.DriverDataSource)1 JBossVFSv3ClassPathLocationScanner (org.flywaydb.core.internal.util.scanner.classpath.jboss.JBossVFSv3ClassPathLocationScanner)1