You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ad...@apache.org on 2017/07/05 13:59:16 UTC

[09/34] james-project git commit: JAMES-2085 JpaMigrator should not use System.out

JAMES-2085 JpaMigrator should not use System.out


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/99b49877
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/99b49877
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/99b49877

Branch: refs/heads/master
Commit: 99b49877415558d19fcf05a6308bf2ef96b1730f
Parents: fc97d22
Author: benwa <bt...@linagora.com>
Authored: Mon Jul 3 16:20:09 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Wed Jul 5 17:13:47 2017 +0700

----------------------------------------------------------------------
 .../james/mailbox/jpa/migrator/JpaMigrator.java    | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/99b49877/mailbox/tool/src/main/java/org/apache/james/mailbox/jpa/migrator/JpaMigrator.java
----------------------------------------------------------------------
diff --git a/mailbox/tool/src/main/java/org/apache/james/mailbox/jpa/migrator/JpaMigrator.java b/mailbox/tool/src/main/java/org/apache/james/mailbox/jpa/migrator/JpaMigrator.java
index 6b5adc4..2eea2e0 100644
--- a/mailbox/tool/src/main/java/org/apache/james/mailbox/jpa/migrator/JpaMigrator.java
+++ b/mailbox/tool/src/main/java/org/apache/james/mailbox/jpa/migrator/JpaMigrator.java
@@ -26,12 +26,16 @@ import javax.persistence.Persistence;
 
 import org.apache.james.mailbox.jpa.migrator.command.JpaMigrateCommand;
 import org.apache.james.mailbox.jpa.migrator.exception.JpaMigrateException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * The class that will manage the migration commands for the James JPA database.
  * All SQL commands should be moved from JAVA code to a separate file.
  */
 public class JpaMigrator {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(JpaMigrator.class);
     
     /**
      * The package name where all commands reside.
@@ -44,30 +48,25 @@ public class JpaMigrator {
      * You can also invoke with many JIRA at once. They will be all serially executed.</p>
      * 
      * TODO Extract the SQL in JAVA classes to XML file.
-     * TODO Log with slf4j.
      * 
      * @param jiras the JIRAs numbers
      * @throws JpaMigrateException 
      */
     public static void main(String[] jiras) throws JpaMigrateException {
-        
+
         try {
-            
             EntityManagerFactory factory = Persistence.createEntityManagerFactory("JamesMigrator");
             EntityManager em = factory.createEntityManager();
 
             for (String jira: jiras) {
                 JpaMigrateCommand jiraJpaMigratable = (JpaMigrateCommand) Class.forName(JPA_MIGRATION_COMMAND_PACKAGE + "." + jira.toUpperCase(Locale.US) + JpaMigrateCommand.class.getSimpleName()).newInstance();
-                System.out.println("Now executing " + jira + " migration.");
+                LOGGER.info("Now executing " + jira + " migration.");
                 em.getTransaction().begin();
                 jiraJpaMigratable.migrate(em);
                 em.getTransaction().commit();
-                System.out.println(jira + " migration is successfully achieved.");
+                LOGGER.info(jira + " migration is successfully achieved.");
             }
-            
-        }
-        
-        catch (Throwable t) {
+        } catch (Throwable t) {
             throw new JpaMigrateException(t);
         }
         


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org