Commit 30eeb75a authored by Matt Tucker's avatar Matt Tucker Committed by matt

Code tweaks.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@750 b35dd754-fafc-0310-a699-88a17e54d16e
parent d3c3b9e8
...@@ -16,7 +16,7 @@ import org.jivesoftware.util.Log; ...@@ -16,7 +16,7 @@ import org.jivesoftware.util.Log;
import java.io.File; import java.io.File;
/** /**
* Starts the core XMPP server. A ootstrap class that configures classloaders * Starts the core XMPP server. A bootstrap class that configures classloaders
* to ensure easy, dynamic server startup. * to ensure easy, dynamic server startup.
* *
* This class should be for standalone mode only. Jive Messenger servers launched * This class should be for standalone mode only. Jive Messenger servers launched
...@@ -29,9 +29,9 @@ import java.io.File; ...@@ -29,9 +29,9 @@ import java.io.File;
* <li>Start the server</li> * <li>Start the server</li>
* </ul> * </ul>
* *
* Note: if the enviroment property messenger.lib.directory is specified ServerStarter will attempt * Note: if the enviroment property <tt>messenger.lib.directory</tt> is specified
* to use this value as the value for messenger's lib directory. If the property is not specified * ServerStarter will attempt to use this value as the value for messenger's lib
* the default value of ../lib will be used. * directory. If the property is not specified the default value of ../lib will be used.
* *
* @author Iain Shigeoka * @author Iain Shigeoka
*/ */
......
...@@ -84,7 +84,7 @@ public class MulticastDNSService extends BasicModule { ...@@ -84,7 +84,7 @@ public class MulticastDNSService extends BasicModule {
public void stop() { public void stop() {
if (jmdns != null) { if (jmdns != null) {
try { try {
jmdns.unregisterService(serviceInfo); jmdns.close();
} }
catch (Exception e) { } catch (Exception e) { }
} }
...@@ -92,11 +92,7 @@ public class MulticastDNSService extends BasicModule { ...@@ -92,11 +92,7 @@ public class MulticastDNSService extends BasicModule {
public void destroy() { public void destroy() {
if (jmdns != null) { if (jmdns != null) {
try { jmdns = null;
jmdns.close();
jmdns = null;
}
catch (Exception e) { }
} }
} }
} }
\ No newline at end of file
...@@ -14,35 +14,36 @@ package org.jivesoftware.util; ...@@ -14,35 +14,36 @@ package org.jivesoftware.util;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
/** /**
* This class assists skin writers in getting parameters. * Assists JSP writers in getting parameters and attributes.
*/ */
public class ParamUtils { public class ParamUtils {
/** /**
* Gets a parameter as a string. * Returns a parameter as a string.
* *
* @param request The HttpServletRequest object, known as "request" in a * @param request the HttpServletRequest object, known as "request" in a
* JSP page. * JSP page.
* @param name The name of the parameter you want to get * @param name the name of the parameter you want to get
* @return The value of the parameter or null if the parameter was not * @return the value of the parameter or null if the parameter was not
* found or if the parameter is a zero-length string. * found or if the parameter is a zero-length string.
*/ */
public static String getParameter(HttpServletRequest request, String name) { public static String getParameter(HttpServletRequest request, String name) {
return getParameter(request, name, false); return getParameter(request, name, false);
} }
/** /**
* Gets a parameter as a string. * Returns a parameter as a string.
* *
* @param request The HttpServletRequest object, known as "request" in a * @param request the HttpServletRequest object, known as "request" in a
* JSP page. * JSP page.
* @param name The name of the parameter you want to get * @param name the name of the parameter you want to get
* @param emptyStringsOK Return the parameter values even if it is an empty string. * @param emptyStringsOK teturn the parameter values even if it is an empty string.
* @return The value of the parameter or null if the parameter was not * @return the value of the parameter or null if the parameter was not
* found. * found.
*/ */
public static String getParameter(HttpServletRequest request, public static String getParameter(HttpServletRequest request, String name,
String name, boolean emptyStringsOK) { boolean emptyStringsOK)
{
String temp = request.getParameter(name); String temp = request.getParameter(name);
if (temp != null) { if (temp != null) {
if (temp.equals("") && !emptyStringsOK) { if (temp.equals("") && !emptyStringsOK) {
...@@ -84,28 +85,28 @@ public class ParamUtils { ...@@ -84,28 +85,28 @@ public class ParamUtils {
} }
/** /**
* Gets a parameter as a boolean. * Returns a parameter as a boolean.
* *
* @param request The HttpServletRequest object, known as "request" in a * @param request the HttpServletRequest object, known as "request" in a
* JSP page. * JSP page.
* @param name The name of the parameter you want to get * @param name the name of the parameter you want to get
* @return True if the value of the parameter was "true", false otherwise. * @return true if the value of the parameter was "true", false otherwise.
*/ */
public static boolean getBooleanParameter(HttpServletRequest request, public static boolean getBooleanParameter(HttpServletRequest request, String name) {
String name) {
return getBooleanParameter(request, name, false); return getBooleanParameter(request, name, false);
} }
/** /**
* Gets a parameter as a boolean. * Returns a parameter as a boolean.
* *
* @param request The HttpServletRequest object, known as "request" in a * @param request the HttpServletRequest object, known as "request" in a
* JSP page. * JSP page.
* @param name The name of the parameter you want to get * @param name the name of the parameter you want to get
* @return True if the value of the parameter was "true", false otherwise. * @return true if the value of the parameter was "true", false otherwise.
*/ */
public static boolean getBooleanParameter(HttpServletRequest request, public static boolean getBooleanParameter(HttpServletRequest request,
String name, boolean defaultVal) { String name, boolean defaultVal)
{
String temp = request.getParameter(name); String temp = request.getParameter(name);
if ("true".equals(temp) || "on".equals(temp)) { if ("true".equals(temp) || "on".equals(temp)) {
return true; return true;
...@@ -119,13 +120,13 @@ public class ParamUtils { ...@@ -119,13 +120,13 @@ public class ParamUtils {
} }
/** /**
* Gets a parameter as an int. * Returns a parameter as an int.
* *
* @param request The HttpServletRequest object, known as "request" in a * @param request the HttpServletRequest object, known as "request" in a
* JSP page. * JSP page.
* @param name The name of the parameter you want to get * @param name the name of the parameter you want to get
* @return The int value of the parameter specified or the default value if * @return the int value of the parameter specified or the default value if
* the parameter is not found. * the parameter is not found.
*/ */
public static int getIntParameter(HttpServletRequest request, public static int getIntParameter(HttpServletRequest request,
String name, int defaultNum) { String name, int defaultNum) {
...@@ -145,13 +146,13 @@ public class ParamUtils { ...@@ -145,13 +146,13 @@ public class ParamUtils {
} }
/** /**
* Gets a list of int parameters. * Returns a list of int parameters.
* *
* @param request The HttpServletRequest object, known as "request" in a * @param request the HttpServletRequest object, known as "request" in a
* JSP page. * JSP page.
* @param name The name of the parameter you want to get * @param name the name of the parameter you want to get
* @param defaultNum The default value of a parameter, if the parameter * @param defaultNum the default value of a parameter, if the parameter
* can't be converted into an int. * can't be converted into an int.
*/ */
public static int[] getIntParameters(HttpServletRequest request, public static int[] getIntParameters(HttpServletRequest request,
String name, int defaultNum) { String name, int defaultNum) {
...@@ -172,13 +173,13 @@ public class ParamUtils { ...@@ -172,13 +173,13 @@ public class ParamUtils {
} }
/** /**
* Gets a parameter as a double. * Returns a parameter as a double.
* *
* @param request The HttpServletRequest object, known as "request" in a * @param request the HttpServletRequest object, known as "request" in a
* JSP page. * JSP page.
* @param name The name of the parameter you want to get * @param name the name of the parameter you want to get
* @return The double value of the parameter specified or the default value * @return the double value of the parameter specified or the default value
* if the parameter is not found. * if the parameter is not found.
*/ */
public static double getDoubleParameter(HttpServletRequest request, String name, double defaultNum) { public static double getDoubleParameter(HttpServletRequest request, String name, double defaultNum) {
String temp = request.getParameter(name); String temp = request.getParameter(name);
...@@ -197,13 +198,13 @@ public class ParamUtils { ...@@ -197,13 +198,13 @@ public class ParamUtils {
} }
/** /**
* Gets a parameter as a long. * Returns a parameter as a long.
* *
* @param request The HttpServletRequest object, known as "request" in a * @param request the HttpServletRequest object, known as "request" in a
* JSP page. * JSP page.
* @param name The name of the parameter you want to get * @param name the name of the parameter you want to get
* @return The long value of the parameter specified or the default value if * @return the long value of the parameter specified or the default value if
* the parameter is not found. * the parameter is not found.
*/ */
public static long getLongParameter(HttpServletRequest request, String name, long defaultNum) { public static long getLongParameter(HttpServletRequest request, String name, long defaultNum) {
String temp = request.getParameter(name); String temp = request.getParameter(name);
...@@ -222,16 +223,17 @@ public class ParamUtils { ...@@ -222,16 +223,17 @@ public class ParamUtils {
} }
/** /**
* Gets a list of long parameters. * Returns a list of long parameters.
* *
* @param request The HttpServletRequest object, known as "request" in a * @param request the HttpServletRequest object, known as "request" in a
* JSP page. * JSP page.
* @param name The name of the parameter you want to get * @param name the name of the parameter you want to get
* @param defaultNum The default value of a parameter, if the parameter * @param defaultNum the default value of a parameter, if the parameter
* can't be converted into a long. * can't be converted into a long.
*/ */
public static long[] getLongParameters(HttpServletRequest request, public static long[] getLongParameters(HttpServletRequest request, String name,
String name, long defaultNum) { long defaultNum)
{
String[] paramValues = request.getParameterValues(name); String[] paramValues = request.getParameterValues(name);
if (paramValues == null || paramValues.length == 0) { if (paramValues == null || paramValues.length == 0) {
return new long[0]; return new long[0];
...@@ -249,30 +251,29 @@ public class ParamUtils { ...@@ -249,30 +251,29 @@ public class ParamUtils {
} }
/** /**
* Gets a parameter as a string. * Returns an attribute as a string.
* *
* @param request The HttpServletRequest object, known as "request" in a * @param request the HttpServletRequest object, known as "request" in a JSP page.
* JSP page. * @param name the name of the parameter you want to get
* @param name The name of the parameter you want to get * @return the value of the parameter or null if the parameter was not
* @return The value of the parameter or null if the parameter was not * found or if the parameter is a zero-length string.
* found or if the parameter is a zero-length string.
*/ */
public static String getAttribute(HttpServletRequest request, String name) { public static String getAttribute(HttpServletRequest request, String name) {
return getAttribute(request, name, false); return getAttribute(request, name, false);
} }
/** /**
* Gets a parameter as a string. * Returns an attribute as a string.
* *
* @param request The HttpServletRequest object, known as "request" in a * @param request the HttpServletRequest object, known as "request" in a JSP page.
* JSP page. * @param name the name of the parameter you want to get.
* @param name The name of the parameter you want to get * @param emptyStringsOK return the parameter values even if it is an empty string.
* @param emptyStringsOK Return the parameter values even if it is an empty string. * @return the value of the parameter or null if the parameter was not
* @return The value of the parameter or null if the parameter was not * found.
* found.
*/ */
public static String getAttribute(HttpServletRequest request, public static String getAttribute(HttpServletRequest request, String name,
String name, boolean emptyStringsOK) { boolean emptyStringsOK)
{
String temp = (String)request.getAttribute(name); String temp = (String)request.getAttribute(name);
if (temp != null) { if (temp != null) {
if (temp.equals("") && !emptyStringsOK) { if (temp.equals("") && !emptyStringsOK) {
...@@ -288,15 +289,13 @@ public class ParamUtils { ...@@ -288,15 +289,13 @@ public class ParamUtils {
} }
/** /**
* Gets an attribute as a boolean. * Returns an attribute as a boolean.
* *
* @param request The HttpServletRequest object, known as "request" in a * @param request the HttpServletRequest object, known as "request" in a JSP page.
* JSP page. * @param name the name of the attribute you want to get.
* @param name The name of the attribute you want to get * @return true if the value of the attribute is "true", false otherwise.
* @return True if the value of the attribute is "true", false otherwise.
*/ */
public static boolean getBooleanAttribute(HttpServletRequest request, public static boolean getBooleanAttribute(HttpServletRequest request, String name) {
String name) {
String temp = (String)request.getAttribute(name); String temp = (String)request.getAttribute(name);
if (temp != null && temp.equals("true")) { if (temp != null && temp.equals("true")) {
return true; return true;
...@@ -307,16 +306,14 @@ public class ParamUtils { ...@@ -307,16 +306,14 @@ public class ParamUtils {
} }
/** /**
* Gets an attribute as a int. * Returns an attribute as a int.
* *
* @param request The HttpServletRequest object, known as "request" in a * @param request the HttpServletRequest object, known as "request" in a JSP page.
* JSP page. * @param name the name of the attribute you want to get.
* @param name The name of the attribute you want to get * @return the int value of the attribute or the default value if the
* @return The int value of the attribute or the default value if the * attribute is not found or is a zero length string.
* attribute is not found or is a zero length string.
*/ */
public static int getIntAttribute(HttpServletRequest request, public static int getIntAttribute(HttpServletRequest request, String name, int defaultNum) {
String name, int defaultNum) {
String temp = (String)request.getAttribute(name); String temp = (String)request.getAttribute(name);
if (temp != null && !temp.equals("")) { if (temp != null && !temp.equals("")) {
int num = defaultNum; int num = defaultNum;
...@@ -333,16 +330,14 @@ public class ParamUtils { ...@@ -333,16 +330,14 @@ public class ParamUtils {
} }
/** /**
* Gets an attribute as a long. * Returns an attribute as a long.
* *
* @param request The HttpServletRequest object, known as "request" in a * @param request the HttpServletRequest object, known as "request" in a JSP page.
* JSP page. * @param name the name of the attribute you want to get.
* @param name The name of the attribute you want to get * @return the long value of the attribute or the default value if the
* @return The long value of the attribute or the default value if the * attribute is not found or is a zero length string.
* attribute is not found or is a zero length string.
*/ */
public static long getLongAttribute(HttpServletRequest request, public static long getLongAttribute(HttpServletRequest request, String name, long defaultNum) {
String name, long defaultNum) {
String temp = (String)request.getAttribute(name); String temp = (String)request.getAttribute(name);
if (temp != null && !temp.equals("")) { if (temp != null && !temp.equals("")) {
long num = defaultNum; long num = defaultNum;
......
...@@ -27,8 +27,8 @@ public abstract class WebBean { ...@@ -27,8 +27,8 @@ public abstract class WebBean {
public JspWriter out; public JspWriter out;
public void init(HttpServletRequest request, HttpServletResponse response, public void init(HttpServletRequest request, HttpServletResponse response,
HttpSession session, ServletContext app, JspWriter out) { HttpSession session, ServletContext app, JspWriter out)
{
this.request = request; this.request = request;
this.response = response; this.response = response;
this.session = session; this.session = session;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment