Package org.apache.cayenne.modeler

Examples of org.apache.cayenne.modeler.FileClassLoadingService


            return;
        }

        try {

            FileClassLoadingService classLoader = new FileClassLoadingService();

            List<File> oldPathFiles = ((FileClassLoadingService) getApplication()
                    .getClassLoadingService()).getPathFiles();

            Collection details = new ArrayList<String>();
            for (int i = 0; i < oldPathFiles.size(); i++) {
                details.add(oldPathFiles.get(i).getAbsolutePath());
            }

            Preferences classPathPreferences = getApplication().getPreferencesNode(
                    ClasspathPreferences.class,
                    "");
            if (editor.getChangedPreferences().containsKey(classPathPreferences)) {
                Map<String, String> map = editor.getChangedPreferences().get(
                        classPathPreferences);

                Iterator iterator = map.entrySet().iterator();
                while (iterator.hasNext()) {
                    Map.Entry en = (Map.Entry) iterator.next();
                    String key = (String) en.getKey();
                    if (!details.contains(key)) {
                        details.add(key);
                    }
                }
            }

            if (editor.getRemovedPreferences().containsKey(classPathPreferences)) {
                Map<String, String> map = editor.getRemovedPreferences().get(
                        classPathPreferences);

                Iterator iterator = map.entrySet().iterator();
                while (iterator.hasNext()) {
                    Map.Entry en = (Map.Entry) iterator.next();
                    String key = (String) en.getKey();
                    if (details.contains(key)) {
                        details.remove(key);
                    }
                }
            }

            if (details.size() > 0) {

                // transform preference to file...
                Transformer transformer = new Transformer() {

                    public Object transform(Object object) {
                        String pref = (String) object;
                        return new File(pref);
                    }
                };

                classLoader.setPathFiles(CollectionUtils.collect(details, transformer));
            }

            Class<Driver> driverClass = classLoader.loadClass(
                    Driver.class,
                    currentDataSource.getJdbcDriver());
            Driver driver = driverClass.newInstance();

            // connect via Cayenne DriverDataSource - it addresses some driver issues...
View Full Code Here

TOP

Related Classes of org.apache.cayenne.modeler.FileClassLoadingService

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.