Package com.sonymobile.backlogtool.dbupdate

Examples of com.sonymobile.backlogtool.dbupdate.DbUpdater


            ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(true);
            scanner.addIncludeFilter(new AnnotationTypeFilter(DbUpdate.class));
            List<DbUpdater> updateList = new ArrayList<DbUpdater>();
            for (BeanDefinition bd : scanner.findCandidateComponents("com.sonymobile.backlogtool.dbupdate")) {
                try {
                    DbUpdater updater = (DbUpdater) Class.forName(bd.getBeanClassName()).newInstance();
                    updateList.add(updater);

                } catch (ClassNotFoundException e) {
                    e.printStackTrace();
                } catch (InstantiationException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
            //Attempt to run all updates in order
            Collections.sort(updateList);
            for (DbUpdater updater : updateList) {
                if (updater.getFromVersion() == schemaVersion.getVersion()) {
                    boolean success = updater.update(sessionFactory);
                    String updateName = updater.getClass().getSimpleName();
                    if (success) {
                        System.out.println("Ran schema update " + updateName);
                        System.out.println("New schema version " + updater.getToVersion());
                        schemaVersion.setVersion(updater.getToVersion());
                    } else {
                        System.out.println("Failed to make schema update " + updateName);
                    }
                }
            }
View Full Code Here

TOP

Related Classes of com.sonymobile.backlogtool.dbupdate.DbUpdater

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.