[cvs] expresso commit by rimovm: Take a stab at removing a few
Checkstyle
JCorporate Ltd
jcorp at jcorp2.servlets.net
Fri Nov 12 09:18:38 PST 2004
Log Message:
-----------
Take a stab at removing a few Checkstyle errors.
Modified Files:
--------------
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc:
CurrentLogin.java
Revision Data
-------------
Index: CurrentLogin.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/CurrentLogin.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/CurrentLogin.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/CurrentLogin.java -u -r1.17 -r1.18
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/CurrentLogin.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/CurrentLogin.java
@@ -73,33 +73,35 @@
import java.util.ArrayList;
import java.util.Hashtable;
-
/**
- * Bean that stores current login info in session; implements session binding listener
+ * Bean that stores current login info in session; implements
+ * session binding listener
* so that it can hear when session is terminated.
- * This class be overriden and replaced with subclass by adding a line to expresso-config.xml under
+ * This class be overriden and replaced with subclass by adding a
+ * line to expresso-config.xml under
* 'class-handlers', like
- * class-handler name="CurrentLogin" classHandler="my.subclass.of.CurrentLogin"
+ * class-handler name="CurrentLogin"
+ * classHandler="my.subclass.of.CurrentLogin"
* This override will allow custom handling in the session bind/unbind events.
* @author Michael Nash; Larry Hamel (CodeGuild)
* @since Expresso 4.0
*/
public class CurrentLogin
- implements HttpSessionBindingListener,
- Serializable {
+ implements HttpSessionBindingListener,
+ Serializable {
/**
- * The sessionID assigned to this login
+ * The sessionID assigned to this login.
*/
private String sessionId = "";
/**
- * User name assigned to this login
+ * User name assigned to this login.
*/
private String userName = User.UNKNOWN_USER;
/**
- * This login's remote ip address
+ * This login's remote ip address.
*/
private String ipAddress = "";
@@ -109,7 +111,7 @@
private long loggedInAt = 0;
/**
- * The integer uid for this login
+ * The integer uid for this login.
*/
private int uid = 0;
@@ -118,24 +120,42 @@
*/
private String dbName = "default";
+ /**
+ * The messages for the user.
+ */
private ArrayList messages = null;
+ /**
+ * Table of attributes.
+ */
private Hashtable attribHash = null;
+
/**
* The session key that we can use to get the currentlogin from
* a person's session.
*/
public static final String LOGIN_KEY = "CurrentLogin";
+ /**
+ * The log4j Logger.
+ */
private transient static Logger slog = null;
- public static synchronized Logger getLogger() {
- if (slog == null) slog = Logger.getLogger(CurrentLogin.class);
- return slog;
+ /**
+ * Loads the Log4j Logger if necessary.
+ * @return Logger instance.
+ */
+ public static Logger getLogger() {
+ synchronized(CurrentLogin.class) {
+ if (slog == null) {
+ slog = Logger.getLogger(CurrentLogin.class);
+ }
+ return slog;
+ }
}
/**
- * old constructor
+ * Old constructor
* @param newSessionId the session id as returned by the servlet container
* @param newUserName the user login name
* @param newIPAddress the user's ip address
@@ -145,9 +165,9 @@
*
* @deprecated use newInstance() instead; 9/04 v5.5+
*/
- public CurrentLogin(String newSessionId, String newUserName,
- String newIPAddress, String newDataContext,
- long newLoggedInAt, int newUid) {
+ public CurrentLogin(final String newSessionId, final String newUserName,
+ final String newIPAddress, final String newDataContext,
+ final long newLoggedInAt, final int newUid) {
sessionId = newSessionId;
userName = newUserName;
ipAddress = newIPAddress;
@@ -157,17 +177,17 @@
}
/**
- * Main constructor
+ * Main constructor.
* @param newUserName the user login name
* @param newIPAddress the user's ip address
* @param newDataContext the data context for the login
* @param newUid the new user id
*
*/
- private CurrentLogin(String newUserName,
- String newIPAddress,
- String newDataContext,
- int newUid) {
+ private CurrentLogin(final String newUserName,
+ final String newIPAddress,
+ final String newDataContext,
+ final int newUid) {
userName = newUserName;
ipAddress = newIPAddress;
loggedInAt = System.currentTimeMillis();
@@ -176,16 +196,16 @@
}
/**
- * default constructor
+ * Default constructor.
*/
public CurrentLogin() {
}
/**
- * add message
- * @param newMessage
+ * Add message to the current login.
+ * @param newMessage The New Message.
*/
- public synchronized void addMessage(String newMessage) {
+ public synchronized void addMessage(final String newMessage) {
if (messages == null) {
messages = new ArrayList();
}
@@ -196,6 +216,7 @@
/**
* Gets the current messages associated with this current login and
* then automatically removes them.
+ * @return ArrayList of messages.
*/
public synchronized ArrayList getAndClearMessages() {
if (messages != null) {
@@ -209,23 +230,23 @@
}
/**
- * Bean method that sets the user name for the login
- * @param newUserName
+ * Bean method that sets the user name for the login.
+ * @param newUserName the new user name.
*/
- public void setUserName(String newUserName) {
+ public void setUserName(final String newUserName) {
userName = newUserName;
}
/**
- * Bean method that setse the database context name for the login
- * @param newDBName
+ * Bean method that setse the database context name for the login.
+ * @param newDBName the database context.
*/
- public void setDBName(String newDBName) {
+ public void setDBName(final String newDBName) {
dbName = newDBName;
}
/**
- * Bean method that gets the session id
+ * Bean method that gets the session id.
* @return java.lang.String the server's session id
*/
public String getSessionId() {
@@ -233,7 +254,7 @@
}
/**
- * Bean method that gets the currently logged in user name
+ * Bean method that gets the currently logged in user name.
* @return java.lang.String
*/
public String getUserName() {
@@ -241,7 +262,7 @@
}
/**
- * Bean method that gets the current uid
+ * Bean method that gets the current uid.
* @return integer
*/
public int getUid() {
@@ -249,7 +270,7 @@
}
/**
- * Bean method that gets the current database name
+ * Bean method that gets the current database name.
* @return java.lang.String
*/
public String getDBName() {
@@ -267,18 +288,20 @@
/**
* This class listens to the binding of this object to the session.
* Can be overriden, but be sure to call this super method.
+ * @param evt The HttpSession Binding Event.
*/
- public void valueBound(HttpSessionBindingEvent evt) {
+ public void valueBound(final HttpSessionBindingEvent evt) {
sessionId = evt.getSession().getId();
ConfigManager.addSession(this);
}
/**
* This class listens to the unbinding of this object to the session.
- * Clears this login object from the config system. Can be overriden, but be sure to
- * call this super method.
+ * Clears this login object from the config system. Can be overriden,
+ * but be sure to call this super method.
+ * @param evt The HttpSessionBindingEvent that is the source.
*/
- public void valueUnbound(HttpSessionBindingEvent evt) {
+ public void valueUnbound(final HttpSessionBindingEvent evt) {
ConfigManager.removeSession(sessionId);
sessionId = null;
}
@@ -289,29 +312,34 @@
* @param newUserName the user name of the person logging in
* @param newIPAddress the client ip address
* @param dataContext the data context to log into.
+ * @param newUid The new user id.
* @return The constructed CurrentLogin instance
*/
public static CurrentLogin newInstance(
- String newUserName,
- String newIPAddress,
- String dataContext,
- int newUid) {
+ final String newUserName,
+ final String newIPAddress,
+ final String dataContext,
+ final int newUid) {
// check for override
String className = ConfigManager.getClassHandler(LOGIN_KEY);
CurrentLogin loginInstance = null;
if (className != null) {
try {
- loginInstance = (CurrentLogin) Class.forName(className).newInstance();
- } catch (Exception e) {
+ loginInstance = (CurrentLogin) Class.forName(className).
+ newInstance();
+ }
+ catch (Exception e) {
getLogger().error(e);
}
}
if (loginInstance == null) {
// use default--this class
- loginInstance = new CurrentLogin(newUserName, newIPAddress, dataContext, newUid);
- } else {
+ loginInstance = new CurrentLogin(newUserName, newIPAddress,
+ dataContext, newUid);
+ }
+ else {
loginInstance.setUserName(newUserName);
loginInstance.setIpAddress(newIPAddress);
loginInstance.setDBName(dataContext);
@@ -322,7 +350,6 @@
return loginInstance;
}
-
/**
* Object construction. Constructs a new instance of a Current login.
* This function will allow pluggable CurrentLogins
@@ -331,89 +358,100 @@
* @param newUserName the user name of the person logging in
* @param newIPAddress the client ip address
* @param dataContext the data context to log into.
+ * @param newLoggedInAt system time that the person logged in.
+ * @param newUid The new user id.
* @return The constructed CurrentLogin instance
- *
* @deprecated use other newInstance instead; 9/04 v.5.5+
*/
- public static CurrentLogin newInstance(String newSessionId,
- String newUserName,
- String newIPAddress,
- String dataContext,
- long newLoggedInAt,
- int newUid) {
+ public static CurrentLogin newInstance(final String newSessionId,
+ final String newUserName,
+ final String newIPAddress,
+ final String dataContext,
+ final long newLoggedInAt,
+ final int newUid) {
CurrentLogin alogin = new CurrentLogin(newUserName, newIPAddress,
- dataContext, newUid);
+ dataContext, newUid);
alogin.loggedInAt = newLoggedInAt;
alogin.sessionId = newSessionId;
return alogin;
}
/**
- * convenience setter
+ * Convenience setter.
* @param loggedInAt timestamp in milliseconds
*/
- public void setLoggedInAt(long loggedInAt) {
+ public void setLoggedInAt(final long loggedInAt) {
this.loggedInAt = loggedInAt;
}
/**
- * get an attribute stored in hashtable in session
+ * Get an attribute stored in hashtable in session.
* @param key hashkey
+ * @return Object or null if the attribute isn't set.
*/
- public Object getAttribute( String key ) {
+ public Object getAttribute(final String key) {
Object result = null;
- if ( attribHash != null && key != null ) result = attribHash.get(key);
+ if (attribHash != null && key != null) {
+ result = attribHash.get(key);
+ }
return result;
}
/**
- * set an attribute stored in hashtable in session
+ * Set an attribute stored in hashtable in session.
* @param key hashkey
* @param attribute to be stored
*/
- public void setAttribute(String key, Object attribute) {
+ public void setAttribute(final String key, final Object attribute) {
if (attribute == null) {
removeAttribute(key);
return;
}
- if ( attribHash == null ) attribHash = new Hashtable();
+ if (attribHash == null) {
+ attribHash = new Hashtable();
+ }
- if ( key != null ) attribHash.put(key, attribute);
+ if (key != null) {
+ attribHash.put(key, attribute);
+ }
}
/**
- * remove an attribute stored in hashtable in session
+ * Remove an attribute stored in hashtable in session.
* @param key hashkey
*/
- public void removeAttribute(String key) {
- if (attribHash != null && key != null ) attribHash.remove(key);
+ public void removeAttribute(final String key) {
+ if (attribHash != null && key != null) {
+ attribHash.remove(key);
+ }
}
/**
- * convenience setter
+ * Convenience setter.
*
* @param theIpAddress address of this login
*/
- public void setIpAddress(String theIpAddress) {
+ public void setIpAddress(final String theIpAddress) {
this.ipAddress = theIpAddress;
}
/**
- * convenience setter
+ * Convenience setter.
*
* @param theUid user ID of this login
*/
- public void setUid(int theUid) {
+ public void setUid(final int theUid) {
this.uid = theUid;
}
/**
- * convenience setter
+ * Convenience setter.
*
* @param theSessionId ID of this session
*/
- public void setSessionId(String theSessionId) {
+ public void setSessionId(final String theSessionId) {
this.sessionId = theSessionId;
}
- } /* CurrentLogin */
+}
+/* CurrentLogin */
More information about the cvs
mailing list