Package org.jconfig.utils

Examples of org.jconfig.utils.ResourceLocator


     * @throws ConfigurationManagerException thrown if the "_config.script" isn't found
     */
    public Configuration load(String configurationName) throws ConfigurationManagerException {
        String fileName = configurationName+"_config.script";
        try {
            ResourceLocator locator = new ResourceLocator(fileName);
            InputStream is = locator.findResource(fileName);
            BufferedReader nis = new BufferedReader(new InputStreamReader(is));           
            String line;
            Vector content = new Vector();
            while ((line=nis.readLine()) != null ) {
                content.add(line);
View Full Code Here


            uri = uri.substring(1);
        }
        uri += ".xml";
        try {
            //File file = new File(".", request.getUri());
            File file = new ResourceLocator(uri).getFile();
            if (file.exists()) {
                fis = new FileInputStream(file);
                int ch = fis.read(bytes, 0, BUFFER_SIZE);
                while (ch!=-1) {
                    output.write(bytes, 0, ch);
View Full Code Here

     *@throws  ConfigurationManagerException  if the file cannot be processed
     */
    public Configuration load(String configurationName,ConfigurationParser parser) throws ConfigurationManagerException {
    InputStream is = null;
        try {
            is = new ResourceLocator(filename).getInputStream();
            if ( is == null ) {
              ErrorReporter.getErrorHandler().reportError("File not found:"+filename);
                is = new ResourceLocator("config.xml").getInputStream();
            }
        } catch (IOException e) {
          ErrorReporter.getErrorHandler().reportError("Cannot load file:"+filename,e);
            throw new ConfigurationManagerException(e.getLocalizedMessage());
        }
View Full Code Here

    /**
     * This method should store all categories and properties.
     */
    public void store(Configuration configuration) throws ConfigurationManagerException {
        try {
      store( new ResourceLocator(filename).getFile(),configuration);
    } catch (IOException e) {
      ErrorReporter.getErrorHandler().reportError("File "+filename+" could not be found",e);
      throw new ConfigurationManagerException("File "+filename+" could not be found");
    }
    }
View Full Code Here

    /**
     * @see org.jconfig.handler.ConfigurationHandler#getFile()
     */
    public File getFile() {
        try {
      return new ResourceLocator(filename).getFile();
    } catch (IOException e) {
      ErrorReporter.getErrorHandler().reportError("File not found",e);
      return null;
    }
    }
View Full Code Here

        try {
            InputStream inputStream = null;
            if(file.exists()) {
                inputStream = new FileInputStream(file);
            } else {
                ResourceLocator locator = new ResourceLocator(file.getName());
                inputStream = locator.getInputStream();
            }
            if ( inputStream == null ) {
              ErrorReporter.getErrorHandler().reportError("Cannot find the properties file");
                throw new ConfigurationManagerException("Cannot find the properties file");
            }
View Full Code Here

     * @throws ConfigurationManagerException thrown if the "_config.script" isn't found
     */
    public Configuration load(String configurationName) throws ConfigurationManagerException {
        fileName = configurationName+"_config.script";
    try {
      ResourceLocator locator = new ResourceLocator(fileName);
      InputStream is = locator.findResource(fileName);
      return load(configurationName,is);
    }
    catch (IOException e) {
      ErrorReporter.getErrorHandler().reportError("Error while trying to read file",e);
            throw new ConfigurationManagerException("Error while trying to read file");
View Full Code Here

        return null;
    }

  public File getFile() {
    try {
      return new ResourceLocator(fileName).getFile();
    } catch (IOException e) {
      ErrorReporter.getErrorHandler().reportError("File not found",e);
      return null;
    }
  }
View Full Code Here

        }
    }
   
    private void loadJDBCProperties() throws ConfigurationManagerException {
        try {
            ResourceLocator locator = new ResourceLocator("jconfig.properties");
            InputStream is = locator.getInputStream();
            // it is possible that the jconfig.properties does not exist, we get null
            if ( is != null ) {
                Properties jcfProperties = new Properties();
                jcfProperties.load( is );
                driver = jcfProperties.getProperty("org.jconfig.jdbc.driver");
View Full Code Here

    }
   
    protected Connection JDBCLogin() throws ConfigurationManagerException {       
        try {
            Class.forName("org.hsqldb.jdbcDriver");
            String dbName = new ResourceLocator("configDB").getFile().getAbsolutePath();
            return DriverManager.getConnection("jdbc:hsqldb:"+ dbName,"sa","");
        }
        catch (Exception e) {
            ErrorReporter.getErrorHandler().reportError("Cannot load the jdbc driver", e);
            throw new ConfigurationManagerException("Cannot load the jdbc driver:"+e.getMessage());
View Full Code Here

TOP

Related Classes of org.jconfig.utils.ResourceLocator

Copyright © 2018 www.massapicom. 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.