Package com.activesession.scanner

Source Code of com.activesession.scanner.PropertiesScanner

package com.activesession.scanner;

import sun.reflect.generics.reflectiveObjects.NotImplementedException;

import java.io.*;
import java.net.URI;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.PathMatcher;
import java.sql.Connection;
import java.util.Properties;

/**
* Created with IntelliJ IDEA.
* User: koki
* Date: 12/14/13
* Time: 12:20 AM
* To change this template use File | Settings | File Templates.
*/

public class PropertiesScanner {
    private final static String PROPERTIES_FILE = "db-config.properties"; // name of db configuration file name
    private final static String BASE_DIR = "."; // working dir
    private static boolean find = false;

    private static final String DB_DRIVER = "db.driver";

    private static File propertiesFile = null;

    public PropertiesScanner () {
        throw new NotImplementedException(); // TODO when is fully implemented
    }

    public void Scan() {
        getFile(BASE_DIR);
    }

    private static void getFile(String directoryName) {
        File directory = new File(directoryName);
        File[] fList = directory.listFiles();
        if(fList!=null){
            for (File file : fList) {
                if (file.isFile()) {
                    if (file.getName().contains(PROPERTIES_FILE)) {
                        System.out.println(file.toString());
                        propertiesFile = file;
                    }
                } else if (file.isDirectory()) {
                    getFile(file.getAbsolutePath());
                }
            }
        }
    }

    private boolean checkFile() throws IOException {
        Properties properties = new Properties();

        FileInputStream fileInputStream = new FileInputStream(propertiesFile);
        properties.load (fileInputStream);

        String driver = (String) properties.get(DB_DRIVER);
        if (driver == null) {
            return false;
        } else {
            return true;
        }
    }

    public static void initConnection(Connection connection) {
        // TODO make this method init connection in PersistenceContextImpl from here automaticly
    }


    public static void main(String[] args) {
        PropertiesScanner scanner = new PropertiesScanner();
        scanner.Scan();
    }

}
TOP

Related Classes of com.activesession.scanner.PropertiesScanner

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.