struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [09/10] struts-examples git commit: Final clean up for comitting CRUD TODOs
Date Fri, 07 Jul 2017 05:34:09 GMT
Final clean up for comitting CRUD TODOs


Project: http://git-wip-us.apache.org/repos/asf/struts-examples/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts-examples/commit/dec0643f
Tree: http://git-wip-us.apache.org/repos/asf/struts-examples/tree/dec0643f
Diff: http://git-wip-us.apache.org/repos/asf/struts-examples/diff/dec0643f

Branch: refs/heads/master
Commit: dec0643fb2eb005d4dde3582f402299431b75fb4
Parents: 1ce1a4f
Author: Antonio Sánchez <adsn37@gmail.com>
Authored: Mon May 5 17:08:03 2014 +0200
Committer: Antonio Sánchez <adsn37@gmail.com>
Committed: Mon May 5 17:08:03 2014 +0200

----------------------------------------------------------------------
 .../apache/struts/crud/action/PersonAction.java | 22 +++++++-------------
 .../apache/struts/crud/dao/MemoryPersonDao.java |  7 ++++---
 crud/src/main/resources/log4j.xml               | 10 +++++----
 3 files changed, 17 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts-examples/blob/dec0643f/crud/src/main/java/org/apache/struts/crud/action/PersonAction.java
----------------------------------------------------------------------
diff --git a/crud/src/main/java/org/apache/struts/crud/action/PersonAction.java b/crud/src/main/java/org/apache/struts/crud/action/PersonAction.java
index 044f057..efa8569 100755
--- a/crud/src/main/java/org/apache/struts/crud/action/PersonAction.java
+++ b/crud/src/main/java/org/apache/struts/crud/action/PersonAction.java
@@ -12,21 +12,12 @@ import org.apache.struts.crud.service.PersonService;
 /**
  * Acts as a controller to handle actions related to editing a Person.
  * 
- * TODO logging
- * TODO prepareInput 
- * TODO use templates for patterns: X is required... Person... in properties file
- * 
- * SUBTASK Fully i18e application: database text data; static text in jsp; validation.xml;
links for locales.
- * SUBTASK Definitely, improve 'country' implementation
- * SUBTASK add jetty and tomcat plugins to pom.xml
- * SUBTASK look & feel like that of showcase applications; enhance visualization (style,
css)
- * 
  * @author bruce phillips
  * @author antonio sánchez
  */
 public class PersonAction extends ActionSupport implements Preparable {
     
-    private static final Logger LOGGER = Logger.getLogger(PersonAction.class.getName());
+    private static final Logger LOG = Logger.getLogger(PersonAction.class.getName());
     private PersonService personService = new DefaultPersonService();
     private Person person;
     private Person[] persons;
@@ -37,36 +28,37 @@ public class PersonAction extends ActionSupport implements Preparable
{
 
     @Override
     public void prepare() throws Exception {
-        
-        LOGGER.info("In prepare method");
         carModelsAvailable = personService.getCarModels();
         sports = personService.getSports();
         countries = personService.getCountries();
         genders = personService.getGenders();
+        LOG.info("Prepared support data for Person entity.");        
         
         if (person != null && person.getPersonId() != null) {
             person = personService.getPerson(person.getPersonId());
+            LOG.info("Preparing actual data for Person: " + person);
         }
     }
 
     /**
      * Get all persons for display in the view.
-     * @return success
      */
     public String list() {
         persons = personService.getAllPersons();
+        LOG.info("Listing persons");
         return SUCCESS;
     }
     
     /**
      * Save the state of the Person object instance field.
-     * @return success
      */
     public String save() {
         if (person.getPersonId() == null) {
             personService.insertPerson(person);
+            LOG.info("Created new Person: " + person);
         } else {
             personService.updatePerson(person);
+            LOG.info("Updated Person: " + person);
         }
         return SUCCESS;
     }
@@ -74,10 +66,10 @@ public class PersonAction extends ActionSupport implements Preparable
{
     /**
      * Delete from Person identified by the person
      * instance field's personId value.
-     * @return 
      */
     public String delete() {
         personService.deletePerson(person.getPersonId());
+        LOG.info("Deleted Person: " + person);
         return SUCCESS;
     }
     

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/dec0643f/crud/src/main/java/org/apache/struts/crud/dao/MemoryPersonDao.java
----------------------------------------------------------------------
diff --git a/crud/src/main/java/org/apache/struts/crud/dao/MemoryPersonDao.java b/crud/src/main/java/org/apache/struts/crud/dao/MemoryPersonDao.java
index 514db8d..9bf1603 100755
--- a/crud/src/main/java/org/apache/struts/crud/dao/MemoryPersonDao.java
+++ b/crud/src/main/java/org/apache/struts/crud/dao/MemoryPersonDao.java
@@ -2,8 +2,8 @@ package org.apache.struts.crud.dao;
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import org.apache.log4j.Logger;
+import org.apache.struts.crud.action.PersonAction;
 import org.apache.struts.crud.model.Person;
 
 /**
@@ -13,6 +13,7 @@ import org.apache.struts.crud.model.Person;
  * @author antonio sanchez
  */
 public class MemoryPersonDao implements PersonDao {
+    private static final Logger LOG = Logger.getLogger(MemoryPersonDao.class.getName());
 
     private final static List<Person> persons;
 
@@ -29,7 +30,7 @@ public class MemoryPersonDao implements PersonDao {
                 try {
                     return (Person) p.clone();
                 } catch (CloneNotSupportedException ex) {
-                    //TODO LOG Logger.getLogger(MemoryPersonDao.class.getName()).log(Level.SEVERE,
null, ex);
+                    LOG.error("Unexpected exception cloning Person");
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/dec0643f/crud/src/main/resources/log4j.xml
----------------------------------------------------------------------
diff --git a/crud/src/main/resources/log4j.xml b/crud/src/main/resources/log4j.xml
index a642174..6645aae 100755
--- a/crud/src/main/resources/log4j.xml
+++ b/crud/src/main/resources/log4j.xml
@@ -10,14 +10,16 @@
     </appender>
  
     <!-- specify the logging level for loggers from other libraries -->
-
-    <logger name="org.apache.struts">
-    	 <level value="INFO" />
+    <logger name="com.opensymphony">
+        <level value="DEBUG" />
+    </logger>    
+    <logger name="org.apache.struts2">
+    	 <level value="DEBUG" />
     </logger>
   
    <!-- for all other loggers log only debug and above log messages -->
      <root>
-        <priority value="WARN"/> 
+        <priority value="INFO"/> 
         <appender-ref ref="STDOUT" /> 
      </root> 
     


Mime
View raw message