Author: remy.maucherat(a)jboss.com
Date: 2012-10-02 12:08:29 -0400 (Tue, 02 Oct 2012)
New Revision: 2095
Added:
branches/7.2.x/src/main/java/org/jboss/web/JSONMessages.java
Modified:
branches/7.2.x/src/main/java/org/apache/tomcat/util/http/mapper/Mapper.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/json/JSONArray.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/json/JSONObject.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/json/JSONTokener.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/json/JSONWriter.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/BaseModelMBean.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/BaseNotificationBroadcaster.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/ManagedBean.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/Registry.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDOMSource.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsSerSource.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/modules/MbeansSource.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/NioServerSocketChannelFactory.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/SSLImplementation.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/URL.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/JSSESupport.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/NioJSSEImplementation.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/NioJSSESocketChannelFactory.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/NioJSSESupport.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/SecureNioChannel.java
branches/7.2.x/src/main/java/org/jboss/web/CoyoteLogger.java
branches/7.2.x/src/main/java/org/jboss/web/CoyoteMessages.java
Log:
Visual inspection of util (part 2) classes for i18n
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/http/mapper/Mapper.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/http/mapper/Mapper.java 2012-10-02
12:04:41 UTC (rev 2094)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/http/mapper/Mapper.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -17,6 +17,8 @@
package org.apache.tomcat.util.http.mapper;
+import static org.jboss.web.CoyoteMessages.MESSAGES;
+
import java.util.ArrayList;
import java.util.List;
@@ -223,7 +225,7 @@
pos = find(hosts, hostName);
}
if (pos < 0) {
- throw new IllegalStateException("No host found: " + hostName);
+ throw MESSAGES.mapperHostNotFound(hostName);
}
Host host = hosts[pos];
if (host.name.equals(hostName)) {
@@ -267,7 +269,7 @@
pos = find(hosts, hostName);
}
if (pos < 0) {
- throw new IllegalStateException("No host found: " + hostName);
+ throw MESSAGES.mapperHostNotFound(hostName);
}
Host host = hosts[pos];
if (host.name.equals(hostName)) {
@@ -377,7 +379,7 @@
Context[] contexts = host.contextList.contexts;
int pos2 = find(contexts, contextPath);
if( pos2<0 ) {
- throw new IllegalStateException("No context found: " +
contextPath );
+ throw MESSAGES.mapperContextNotFound(contextPath);
}
Context context = contexts[pos2];
if (context.name.equals(contextPath)) {
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/json/JSONArray.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/json/JSONArray.java 2012-10-02
12:04:41 UTC (rev 2094)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/json/JSONArray.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -24,6 +24,8 @@
SOFTWARE.
*/
+import static org.jboss.web.JSONMessages.MESSAGES;
+
import java.io.IOException;
import java.io.Writer;
import java.lang.reflect.Array;
@@ -112,7 +114,7 @@
} else if (c == '(') {
q = ')';
} else {
- throw x.syntaxError("A JSONArray text must start with
'['");
+ throw x.syntaxError(MESSAGES.arrayMustStartWithBracket());
}
if (x.nextClean() == ']') {
return;
@@ -138,11 +140,11 @@
case ']':
case ')':
if (q != c) {
- throw x.syntaxError("Expected a '" + new Character(q) +
"'");
+ throw x.syntaxError(MESSAGES.arrayCharExpected('q'));
}
return;
default:
- throw x.syntaxError("Expected a ',' or ']'");
+ throw x.syntaxError(MESSAGES.arrayEndExpected());
}
}
}
@@ -199,7 +201,7 @@
this.put(Array.get(array, i));
}
} else {
- throw new JSONException("JSONArray initial value should be a string or
collection or array.");
+ throw new JSONException(MESSAGES.arrayInvalidValue());
}
}
@@ -217,7 +219,7 @@
this.put(new JSONObject(Array.get(array, i),includeSuperClass));
}
} else {
- throw new JSONException("JSONArray initial value should be a string or
collection or array.");
+ throw new JSONException(MESSAGES.arrayInvalidValue());
}
}
@@ -233,7 +235,7 @@
public Object get(int index) throws JSONException {
Object o = opt(index);
if (o == null) {
- throw new JSONException("JSONArray[" + index + "] not
found.");
+ throw new JSONException(MESSAGES.arrayInvalidIndex(index));
}
return o;
}
@@ -259,7 +261,7 @@
((String)o).equalsIgnoreCase("true"))) {
return true;
}
- throw new JSONException("JSONArray[" + index + "] is not a
Boolean.");
+ throw new JSONException(MESSAGES.arrayInvalidType(index, "Boolean"));
}
@@ -278,8 +280,7 @@
((Number)o).doubleValue() :
Double.valueOf((String)o).doubleValue();
} catch (Exception e) {
- throw new JSONException("JSONArray[" + index +
- "] is not a number.");
+ throw new JSONException(MESSAGES.arrayInvalidType(index,
"Double"));
}
}
@@ -312,8 +313,7 @@
if (o instanceof JSONArray) {
return (JSONArray)o;
}
- throw new JSONException("JSONArray[" + index +
- "] is not a JSONArray.");
+ throw new JSONException(MESSAGES.arrayInvalidType(index,
"JSONArray"));
}
@@ -329,8 +329,7 @@
if (o instanceof JSONObject) {
return (JSONObject)o;
}
- throw new JSONException("JSONArray[" + index +
- "] is not a JSONObject.");
+ throw new JSONException(MESSAGES.arrayInvalidType(index,
"JSONObject"));
}
@@ -783,7 +782,7 @@
public JSONArray put(int index, Object value) throws JSONException {
JSONObject.testValidity(value);
if (index < 0) {
- throw new JSONException("JSONArray[" + index + "] not
found.");
+ throw new JSONException(MESSAGES.arrayInvalidIndex(index));
}
if (index < length()) {
this.myArrayList.set(index, value);
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/json/JSONObject.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/json/JSONObject.java 2012-10-02
12:04:41 UTC (rev 2094)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/json/JSONObject.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -24,6 +24,8 @@
SOFTWARE.
*/
+import static org.jboss.web.JSONMessages.MESSAGES;
+
import java.io.IOException;
import java.io.Writer;
import java.lang.reflect.Field;
@@ -176,13 +178,13 @@
String key;
if (x.nextClean() != '{') {
- throw x.syntaxError("A JSONObject text must begin with
'{'");
+ throw x.syntaxError(MESSAGES.objectMustStartWithBracket());
}
for (;;) {
c = x.nextClean();
switch (c) {
case 0:
- throw x.syntaxError("A JSONObject text must end with
'}'");
+ throw x.syntaxError(MESSAGES.objectMustEndWithBracket());
case '}':
return;
default:
@@ -200,7 +202,7 @@
x.back();
}
} else if (c != ':') {
- throw x.syntaxError("Expected a ':' after a key");
+ throw x.syntaxError(MESSAGES.objectExpectedKey());
}
putOnce(key, x.nextValue());
@@ -219,7 +221,7 @@
case '}':
return;
default:
- throw x.syntaxError("Expected a ',' or '}'");
+ throw x.syntaxError(MESSAGES.objectExpectedEnd());
}
}
}
@@ -452,8 +454,7 @@
} else if (o instanceof JSONArray) {
put(key, ((JSONArray)o).put(value));
} else {
- throw new JSONException("JSONObject[" + key +
- "] is not a JSONArray.");
+ throw new JSONException(MESSAGES.objectInvalidType(key,
"JSONArray"));
}
return this;
}
@@ -495,8 +496,7 @@
public Object get(String key) throws JSONException {
Object o = opt(key);
if (o == null) {
- throw new JSONException("JSONObject[" + quote(key) +
- "] not found.");
+ throw new JSONException(MESSAGES.objectNotFound(quote(key)));
}
return o;
}
@@ -521,8 +521,7 @@
((String)o).equalsIgnoreCase("true"))) {
return true;
}
- throw new JSONException("JSONObject[" + quote(key) +
- "] is not a Boolean.");
+ throw new JSONException(MESSAGES.objectInvalidType(key, "Boolean"));
}
@@ -540,8 +539,7 @@
((Number)o).doubleValue() :
Double.valueOf((String)o).doubleValue();
} catch (Exception e) {
- throw new JSONException("JSONObject[" + quote(key) +
- "] is not a number.");
+ throw new JSONException(MESSAGES.objectInvalidType(key,
"Double"));
}
}
@@ -575,8 +573,7 @@
if (o instanceof JSONArray) {
return (JSONArray)o;
}
- throw new JSONException("JSONObject[" + quote(key) +
- "] is not a JSONArray.");
+ throw new JSONException(MESSAGES.objectInvalidType(key, "JSONArray"));
}
@@ -593,8 +590,7 @@
if (o instanceof JSONObject) {
return (JSONObject)o;
}
- throw new JSONException("JSONObject[" + quote(key) +
- "] is not a JSONObject.");
+ throw new JSONException(MESSAGES.objectInvalidType(key,
"JSONObject"));
}
@@ -1073,7 +1069,7 @@
public JSONObject putOnce(String key, Object value) throws JSONException {
if (key != null && value != null) {
if (opt(key) != null) {
- throw new JSONException("Duplicate key \"" + key +
"\"");
+ throw new JSONException(MESSAGES.objectDuplicateKey(key));
}
put(key, value);
}
@@ -1258,13 +1254,11 @@
if (o != null) {
if (o instanceof Double) {
if (((Double)o).isInfinite() || ((Double)o).isNaN()) {
- throw new JSONException(
- "JSON does not allow non-finite numbers.");
+ throw new JSONException(MESSAGES.objectInfiniteNumber());
}
} else if (o instanceof Float) {
if (((Float)o).isInfinite() || ((Float)o).isNaN()) {
- throw new JSONException(
- "JSON does not allow non-finite numbers.");
+ throw new JSONException(MESSAGES.objectInfiniteNumber());
}
}
}
@@ -1433,7 +1427,7 @@
if (o instanceof String) {
return (String)o;
}
- throw new JSONException("Bad value from toJSONString: " + o);
+ throw new JSONException(MESSAGES.objectBadString(o));
}
if (value instanceof Number) {
return numberToString((Number) value);
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/json/JSONTokener.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/json/JSONTokener.java 2012-10-02
12:04:41 UTC (rev 2094)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/json/JSONTokener.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -1,5 +1,7 @@
package org.apache.tomcat.util.json;
+import static org.jboss.web.JSONMessages.MESSAGES;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
@@ -74,7 +76,7 @@
*/
public void back() throws JSONException {
if (useLastChar || index <= 0) {
- throw new JSONException("Stepping back two steps is not
supported");
+ throw new JSONException(MESSAGES.tokenerStepBack());
}
index -= 1;
useLastChar = true;
@@ -157,8 +159,7 @@
public char next(char c) throws JSONException {
char n = next();
if (n != c) {
- throw syntaxError("Expected '" + c + "' and instead
saw '" +
- n + "'");
+ throw syntaxError(MESSAGES.tokenerBadChar(c, n));
}
return n;
}
@@ -198,7 +199,7 @@
this.index += pos;
if (pos < n) {
- throw syntaxError("Substring bounds error");
+ throw syntaxError(MESSAGES.tokenerSubstring());
}
this.lastChar = buffer[n - 1];
@@ -241,7 +242,7 @@
case 0:
case '\n':
case '\r':
- throw syntaxError("Unterminated string");
+ throw syntaxError(MESSAGES.tokenerUnterminatedString());
case '\\':
c = next();
switch (c) {
@@ -366,7 +367,7 @@
s = sb.toString().trim();
if (s.equals("")) {
- throw syntaxError("Missing value");
+ throw syntaxError(MESSAGES.tokenerMissingValue());
}
return JSONObject.stringToValue(s);
}
@@ -407,16 +408,7 @@
* @return A JSONException object, suitable for throwing
*/
public JSONException syntaxError(String message) {
- return new JSONException(message + toString());
+ return new JSONException(message + index);
}
-
- /**
- * Make a printable string of this JSONTokener.
- *
- * @return " at character [this.index]"
- */
- public String toString() {
- return " at character " + index;
- }
}
\ No newline at end of file
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/json/JSONWriter.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/json/JSONWriter.java 2012-10-02
12:04:41 UTC (rev 2094)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/json/JSONWriter.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -1,5 +1,7 @@
package org.apache.tomcat.util.json;
+import static org.jboss.web.JSONMessages.MESSAGES;
+
import java.io.IOException;
import java.io.Writer;
@@ -109,7 +111,7 @@
*/
private JSONWriter append(String s) throws JSONException {
if (s == null) {
- throw new JSONException("Null pointer");
+ throw new JSONException(MESSAGES.writerNull());
}
if (this.mode == 'o' || this.mode == 'a') {
try {
@@ -126,7 +128,7 @@
this.comma = true;
return this;
}
- throw new JSONException("Value out of sequence.");
+ throw new JSONException(MESSAGES.writerValueOutOfSequence());
}
/**
@@ -145,7 +147,7 @@
this.comma = false;
return this;
}
- throw new JSONException("Misplaced array.");
+ throw new JSONException(MESSAGES.writerMisplacedArray());
}
/**
@@ -157,8 +159,8 @@
*/
private JSONWriter end(char m, char c) throws JSONException {
if (this.mode != m) {
- throw new JSONException(m == 'o' ? "Misplaced endObject."
:
- "Misplaced endArray.");
+ throw new JSONException(m == 'o' ?
MESSAGES.writerMisplacedObjectEnd() :
+ MESSAGES.writerMisplacedArrayEnd());
}
this.pop(m);
try {
@@ -200,7 +202,7 @@
*/
public JSONWriter key(String s) throws JSONException {
if (s == null) {
- throw new JSONException("Null key.");
+ throw new JSONException(MESSAGES.writerNullKey());
}
if (this.mode == 'k') {
try {
@@ -217,7 +219,7 @@
throw new JSONException(e);
}
}
- throw new JSONException("Misplaced key.");
+ throw new JSONException(MESSAGES.writerMisplacedKey());
}
@@ -240,7 +242,7 @@
this.comma = false;
return this;
}
- throw new JSONException("Misplaced object.");
+ throw new JSONException(MESSAGES.writerMisplacedObject());
}
@@ -252,11 +254,11 @@
*/
private void pop(char c) throws JSONException {
if (this.top <= 0) {
- throw new JSONException("Nesting error.");
+ throw new JSONException(MESSAGES.writerNestingError());
}
char m = this.stack[this.top - 1] == null ? 'a' : 'k';
if (m != c) {
- throw new JSONException("Nesting error.");
+ throw new JSONException(MESSAGES.writerNestingError());
}
this.top -= 1;
this.mode = this.top == 0 ? 'd' : this.stack[this.top - 1] == null ?
'a' : 'k';
@@ -269,7 +271,7 @@
*/
private void push(JSONObject jo) throws JSONException {
if (this.top >= maxdepth) {
- throw new JSONException("Nesting too deep.");
+ throw new JSONException(MESSAGES.writerNestingTooDeep());
}
this.stack[this.top] = jo;
this.mode = jo == null ? 'a' : 'k';
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/BaseModelMBean.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/BaseModelMBean.java 2012-10-02
12:04:41 UTC (rev 2094)
+++
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/BaseModelMBean.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -19,6 +19,8 @@
package org.apache.tomcat.util.modeler;
+import static org.jboss.web.CoyoteMessages.MESSAGES;
+
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Iterator;
@@ -46,8 +48,7 @@
import javax.management.modelmbean.InvalidTargetObjectTypeException;
import javax.management.modelmbean.ModelMBeanNotificationBroadcaster;
-import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
+import org.jboss.web.CoyoteLogger;
/*
* Changes from commons.modeler:
@@ -101,7 +102,6 @@
* @author Costin Manolache
*/
public class BaseModelMBean implements DynamicMBean, MBeanRegistration,
ModelMBeanNotificationBroadcaster {
- private static Logger log = Logger.getLogger(BaseModelMBean.class);
// ----------------------------------------------------------- Constructors
@@ -169,8 +169,8 @@
// Validate the input parameters
if (name == null)
throw new RuntimeOperationsException
- (new IllegalArgumentException("Attribute name is null"),
- "Attribute name is null");
+ (new IllegalArgumentException(MESSAGES.nullAttributeName()),
+ MESSAGES.nullAttributeName());
if( (resource instanceof DynamicMBean) &&
! ( resource instanceof BaseModelMBean )) {
@@ -196,16 +196,16 @@
t = e;
if (t instanceof RuntimeException)
throw new RuntimeOperationsException
- ((RuntimeException) t, "Exception invoking method " +
name);
+ ((RuntimeException) t, MESSAGES.errorGettingAttribute(name));
else if (t instanceof Error)
throw new RuntimeErrorException
- ((Error) t, "Error invoking method " + name);
+ ((Error) t, MESSAGES.errorGettingAttribute(name));
else
throw new MBeanException
- (e, "Exception invoking method " + name);
+ (e, MESSAGES.errorGettingAttribute(name));
} catch (Exception e) {
throw new MBeanException
- (e, "Exception invoking method " + name);
+ (e, MESSAGES.errorGettingAttribute(name));
}
// Return the results of this method invocation
@@ -224,8 +224,8 @@
// Validate the input parameters
if (names == null)
throw new RuntimeOperationsException
- (new IllegalArgumentException("Attribute names list is null"),
- "Attribute names list is null");
+ (new IllegalArgumentException(MESSAGES.nullAttributeNameList()),
+ MESSAGES.nullAttributeNameList());
// Prepare our response, eating all exceptions
AttributeList response = new AttributeList();
@@ -283,10 +283,9 @@
// Validate the input parameters
if (name == null)
throw new RuntimeOperationsException
- (new IllegalArgumentException("Method name is null"),
- "Method name is null");
+ (new IllegalArgumentException(MESSAGES.nullMethodName()),
+ MESSAGES.nullMethodName());
- if( log.isDebugEnabled()) log.debug("Invoke " + name);
MethodKey mkey = new MethodKey(name, signature);
Method method= managedBean.getInvoke(name, params, signature, this, resource);
@@ -302,22 +301,20 @@
}
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
- log.error("Exception invoking method " + name , t );
if (t == null)
t = e;
if (t instanceof RuntimeException)
throw new RuntimeOperationsException
- ((RuntimeException) t, "Exception invoking method " +
name);
+ ((RuntimeException) t, MESSAGES.errorInvokingMethod(name));
else if (t instanceof Error)
throw new RuntimeErrorException
- ((Error) t, "Error invoking method " + name);
+ ((Error) t, MESSAGES.errorInvokingMethod(name));
else
throw new MBeanException
- ((Exception)t, "Exception invoking method " + name);
+ ((Exception)t, MESSAGES.errorInvokingMethod(name));
} catch (Exception e) {
- log.error("Exception invoking method " + name , e );
throw new MBeanException
- (e, "Exception invoking method " + name);
+ (e, MESSAGES.errorInvokingMethod(name));
}
// Return the results of this method invocation
@@ -355,8 +352,7 @@
try {
return Class.forName(signature);
} catch (ClassNotFoundException e) {
- throw new ReflectionException
- (e, "Cannot find Class for " + signature);
+ throw new ReflectionException(e);
}
}
}
@@ -378,8 +374,8 @@
throws AttributeNotFoundException, MBeanException,
ReflectionException
{
- if( log.isDebugEnabled() )
- log.debug("Setting attribute " + this + " " + attribute
);
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled() )
+ CoyoteLogger.MODELER_LOGGER.debug("Setting attribute " + this +
" " + attribute );
if( (resource instanceof DynamicMBean) &&
! ( resource instanceof BaseModelMBean )) {
@@ -394,16 +390,16 @@
// Validate the input parameters
if (attribute == null)
throw new RuntimeOperationsException
- (new IllegalArgumentException("Attribute is null"),
- "Attribute is null");
+ (new IllegalArgumentException(MESSAGES.nullAttribute()),
+ MESSAGES.nullAttribute());
String name = attribute.getName();
Object value = attribute.getValue();
if (name == null)
throw new RuntimeOperationsException
- (new IllegalArgumentException("Attribute name is null"),
- "Attribute name is null");
+ (new IllegalArgumentException(MESSAGES.nullAttributeName()),
+ MESSAGES.nullAttributeName());
Object oldValue=null;
//if( getAttMap.get(name) != null )
@@ -425,23 +421,22 @@
t = e;
if (t instanceof RuntimeException)
throw new RuntimeOperationsException
- ((RuntimeException) t, "Exception invoking method " +
name);
+ ((RuntimeException) t, MESSAGES.errorSettingAttribute(name));
else if (t instanceof Error)
throw new RuntimeErrorException
- ((Error) t, "Error invoking method " + name);
+ ((Error) t, MESSAGES.errorSettingAttribute(name));
else
throw new MBeanException
- (e, "Exception invoking method " + name);
+ (e, MESSAGES.errorSettingAttribute(name));
} catch (Exception e) {
- log.error("Exception invoking method " + name , e );
throw new MBeanException
- (e, "Exception invoking method " + name);
+ (e, MESSAGES.errorSettingAttribute(name));
}
try {
sendAttributeChangeNotification(new Attribute( name, oldValue),
attribute);
} catch(Exception ex) {
- log.error("Error sending notification " + name, ex);
+ CoyoteLogger.MODELER_LOGGER.errorSendingNotification(ex);
}
//attributes.put( name, value );
// if( source != null ) {
@@ -509,8 +504,8 @@
if (resource == null)
throw new RuntimeOperationsException
- (new IllegalArgumentException("Managed resource is null"),
- "Managed resource is null");
+ (new IllegalArgumentException(MESSAGES.nullManagedResource()),
+ MESSAGES.nullManagedResource());
return resource;
@@ -548,8 +543,8 @@
{
if (resource == null)
throw new RuntimeOperationsException
- (new IllegalArgumentException("Managed resource is null"),
- "Managed resource is null");
+ (new IllegalArgumentException(MESSAGES.nullManagedResource()),
+ MESSAGES.nullManagedResource());
// if (!"objectreference".equalsIgnoreCase(type))
// throw new InvalidTargetObjectTypeException(type);
@@ -591,12 +586,12 @@
throws IllegalArgumentException {
if (listener == null)
- throw new IllegalArgumentException("Listener is null");
+ throw new IllegalArgumentException(MESSAGES.nullListener());
if (attributeBroadcaster == null)
attributeBroadcaster = new BaseNotificationBroadcaster();
- if( log.isDebugEnabled() )
- log.debug("addAttributeNotificationListener " + listener);
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled() )
+ CoyoteLogger.MODELER_LOGGER.debug("addAttributeNotificationListener
" + listener);
BaseAttributeFilter filter = new BaseAttributeFilter(name);
attributeBroadcaster.addNotificationListener
@@ -621,7 +616,7 @@
throws ListenerNotFoundException {
if (listener == null)
- throw new IllegalArgumentException("Listener is null");
+ throw new IllegalArgumentException(MESSAGES.nullListener());
if (attributeBroadcaster == null)
attributeBroadcaster = new BaseNotificationBroadcaster();
@@ -671,12 +666,12 @@
if (notification == null)
throw new RuntimeOperationsException
- (new IllegalArgumentException("Notification is null"),
- "Notification is null");
+ (new IllegalArgumentException(MESSAGES.nullNotification()),
+ MESSAGES.nullNotification());
if (attributeBroadcaster == null)
return; // This means there are no registered listeners
- if( log.isDebugEnabled() )
- log.debug( "AttributeChangeNotification " + notification );
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled() )
+ CoyoteLogger.MODELER_LOGGER.debug( "AttributeChangeNotification " +
notification );
attributeBroadcaster.sendNotification(notification);
}
@@ -736,8 +731,8 @@
if (notification == null)
throw new RuntimeOperationsException
- (new IllegalArgumentException("Notification is null"),
- "Notification is null");
+ (new IllegalArgumentException(MESSAGES.nullNotification()),
+ MESSAGES.nullNotification());
if (generalBroadcaster == null)
return; // This means there are no registered listeners
generalBroadcaster.sendNotification(notification);
@@ -761,8 +756,8 @@
if (message == null)
throw new RuntimeOperationsException
- (new IllegalArgumentException("Message is null"),
- "Message is null");
+ (new IllegalArgumentException(MESSAGES.nullMessage()),
+ MESSAGES.nullMessage());
Notification notification = new Notification
("jmx.modelmbean.generic", this, 1, message);
sendNotification(notification);
@@ -792,9 +787,9 @@
throws IllegalArgumentException {
if (listener == null)
- throw new IllegalArgumentException("Listener is null");
+ throw new IllegalArgumentException(MESSAGES.nullListener());
- if( log.isDebugEnabled() ) log.debug("addNotificationListener " +
listener);
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled() )
CoyoteLogger.MODELER_LOGGER.debug("addNotificationListener " + listener);
if (generalBroadcaster == null)
generalBroadcaster = new BaseNotificationBroadcaster();
@@ -808,8 +803,8 @@
if (attributeBroadcaster == null)
attributeBroadcaster = new BaseNotificationBroadcaster();
- if( log.isDebugEnabled() )
- log.debug("addAttributeNotificationListener " + listener);
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled() )
+ CoyoteLogger.MODELER_LOGGER.debug("addAttributeNotificationListener
" + listener);
attributeBroadcaster.addNotificationListener
(listener, filter, handback);
@@ -876,7 +871,7 @@
throws ListenerNotFoundException {
if (listener == null)
- throw new IllegalArgumentException("Listener is null");
+ throw new IllegalArgumentException(MESSAGES.nullListener());
if (generalBroadcaster == null)
generalBroadcaster = new BaseNotificationBroadcaster();
generalBroadcaster.removeNotificationListener(listener);
@@ -1116,8 +1111,8 @@
ObjectName name)
throws Exception
{
- if( log.isDebugEnabled())
- log.debug("preRegister " + resource + " " + name );
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled())
+ CoyoteLogger.MODELER_LOGGER.debug("preRegister " + resource +
" " + name );
oname=name;
if( resource instanceof MBeanRegistration ) {
oname = ((MBeanRegistration)resource).preRegister(server, name );
Modified:
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/BaseNotificationBroadcaster.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/BaseNotificationBroadcaster.java 2012-10-02
12:04:41 UTC (rev 2094)
+++
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/BaseNotificationBroadcaster.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -19,6 +19,8 @@
package org.apache.tomcat.util.modeler;
+import static org.jboss.web.CoyoteMessages.MESSAGES;
+
import java.util.ArrayList;
import java.util.Iterator;
@@ -228,7 +230,7 @@
int code=reg.getId(null, names[i]);
if( hooks.length < code ) {
// XXX reallocate
- throw new RuntimeException( "Too many hooks " + code );
+ throw MESSAGES.tooManyHooks(code);
}
NotificationListener listeners[]=hooks[code];
if( listeners== null ) {
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/ManagedBean.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/ManagedBean.java 2012-10-02
12:04:41 UTC (rev 2094)
+++
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/ManagedBean.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -19,6 +19,8 @@
package org.apache.tomcat.util.modeler;
+import static org.jboss.web.CoyoteMessages.MESSAGES;
+
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
@@ -366,7 +368,7 @@
if( clazz==null) {
throw new MBeanException
- (ex, "Cannot load ModelMBean class " + getClassName());
+ (ex, MESSAGES.errorLoadingModelMbean(getClassName()));
}
try {
// Stupid - this will set the default minfo first....
@@ -375,8 +377,7 @@
throw e;
} catch (Exception e) {
throw new MBeanException
- (e, "Cannot instantiate ModelMBean of class " +
- getClassName());
+ (e, MESSAGES.errorInstantiatingModelMbean(getClassName()));
}
}
@@ -487,11 +488,11 @@
AttributeInfo attrInfo = (AttributeInfo)attributes.get(aname);
// Look up the actual operation to be used
if (attrInfo == null)
- throw new AttributeNotFoundException(" Cannot find attribute "
+ aname + " for " + resource);
+ throw new
AttributeNotFoundException(MESSAGES.errorGettingAttribute(aname));
String getMethod = attrInfo.getGetMethod();
if (getMethod == null)
- throw new AttributeNotFoundException("Cannot find attribute " +
aname + " get method name");
+ throw new
AttributeNotFoundException(MESSAGES.errorGettingAttribute(aname));
Object object = null;
NoSuchMethodException exception = null;
@@ -512,7 +513,7 @@
}
if( exception != null )
throw new ReflectionException(exception,
- "Cannot find getter method " +
getMethod);
+ MESSAGES.errorGettingAttribute(aname));
//getAttMap.put( name, m );
}
@@ -528,12 +529,12 @@
if( m==null ) {
AttributeInfo attrInfo = (AttributeInfo)attributes.get(aname);
if (attrInfo == null)
- throw new AttributeNotFoundException(" Cannot find attribute "
+ aname);
+ throw new
AttributeNotFoundException(MESSAGES.errorSettingAttribute(aname));
// Look up the actual operation to be used
String setMethod = attrInfo.getSetMethod();
if (setMethod == null)
- throw new AttributeNotFoundException("Cannot find attribute " +
aname + " set method name");
+ throw new
AttributeNotFoundException(MESSAGES.errorSettingAttribute(aname));
String argType=attrInfo.getType();
@@ -558,8 +559,7 @@
}
if( exception != null )
throw new ReflectionException(exception,
- "Cannot find setter method " +
setMethod +
- " " + resource);
+ MESSAGES.errorSettingAttribute(aname));
//setAttMap.put( name, m );
}
@@ -577,16 +577,16 @@
if (params.length != signature.length)
throw new RuntimeOperationsException(
new IllegalArgumentException(
- "Inconsistent arguments and signature"),
- "Inconsistent arguments and signature");
+ MESSAGES.errorInvokingMethod(aname)),
+ MESSAGES.errorInvokingMethod(aname));
// Acquire the ModelMBeanOperationInfo information for
// the requested operation
OperationInfo opInfo = (OperationInfo)operations.get(aname);
if (opInfo == null)
throw new MBeanException(new ServiceNotFoundException(
- "Cannot find operation " + aname),
- "Cannot find operation " + aname);
+ MESSAGES.errorInvokingMethod(aname)),
+ MESSAGES.errorInvokingMethod(aname));
// Prepare the signature required by Java reflection APIs
// FIXME - should we use the signature from opInfo?
@@ -616,8 +616,7 @@
exception = e;
}
if (method == null) {
- throw new ReflectionException(exception, "Cannot find method "
- + aname + " with this signature");
+ throw new ReflectionException(exception,
MESSAGES.errorInvokingMethod(aname));
}
// invokeAttMap.put(mkey, method);
}
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/Registry.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/Registry.java 2012-10-02
12:04:41 UTC (rev 2094)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/Registry.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -40,8 +40,7 @@
import javax.management.ObjectName;
import org.apache.tomcat.util.modeler.modules.ModelerSource;
-import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
+import org.jboss.web.CoyoteLogger;
/*
Issues:
@@ -72,10 +71,6 @@
* @author Costin Manolache
*/
public class Registry implements RegistryMBean, MBeanRegistration {
- /**
- * The Log instance to which we will write our log messages.
- */
- private static Logger log = Logger.getLogger(Registry.class);
// Support for the factory methods
@@ -288,7 +283,7 @@
try {
unregisterComponent(new ObjectName(oname));
} catch (MalformedObjectNameException e) {
- log.info("Error creating object name " + e );
+ CoyoteLogger.MODELER_LOGGER.errorCreatingObjectName(e);
}
}
@@ -330,7 +325,7 @@
} catch( Exception t ) {
if( failFirst ) throw t;
- log.info("Error initializing " + current + " " +
t.toString());
+ CoyoteLogger.MODELER_LOGGER.errorInvokingOperation(operation, current);
}
}
}
@@ -524,7 +519,7 @@
try {
info=server.getMBeanInfo(oname);
} catch (Exception e) {
- log.info( "Can't find metadata for object" + oname );
+ CoyoteLogger.MODELER_LOGGER.noMetadata(oname);
return null;
}
@@ -551,7 +546,7 @@
try {
info=server.getMBeanInfo(oname);
} catch (Exception e) {
- log.info( "Can't find metadata " + oname );
+ CoyoteLogger.MODELER_LOGGER.noMetadata(oname);
return null;
}
MBeanOperationInfo attInfo[]=info.getOperations();
@@ -574,7 +569,7 @@
getMBeanServer().unregisterMBean(oname);
}
} catch( Throwable t ) {
- log.error( "Error unregistering mbean ", t);
+ CoyoteLogger.MODELER_LOGGER.errorUnregisteringMbean(oname, t);
}
}
@@ -589,13 +584,13 @@
if (server == null) {
if( MBeanServerFactory.findMBeanServer(null).size() > 0 ) {
server=(MBeanServer)MBeanServerFactory.findMBeanServer(null).get(0);
- if( log.isDebugEnabled() ) {
- log.debug("Using existing MBeanServer " +
(System.currentTimeMillis() - t1 ));
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled() ) {
+ CoyoteLogger.MODELER_LOGGER.debug("Using existing MBeanServer
" + (System.currentTimeMillis() - t1 ));
}
} else {
server=MBeanServerFactory.createMBeanServer();
- if( log.isDebugEnabled() ) {
- log.debug("Creating MBeanServer"+
(System.currentTimeMillis() - t1 ));
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled() ) {
+ CoyoteLogger.MODELER_LOGGER.debug("Creating MBeanServer"+
(System.currentTimeMillis() - t1 ));
}
}
}
@@ -621,8 +616,8 @@
// Search for a descriptor in the same package
if( managed==null ) {
// check package and parent packages
- if( log.isDebugEnabled() ) {
- log.debug( "Looking for descriptor ");
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled() ) {
+ CoyoteLogger.MODELER_LOGGER.debug( "Looking for descriptor ");
}
findDescriptor( beanClass, type );
@@ -630,8 +625,8 @@
}
if( bean instanceof DynamicMBean ) {
- if( log.isDebugEnabled() ) {
- log.debug( "Dynamic mbean support ");
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled() ) {
+ CoyoteLogger.MODELER_LOGGER.debug( "Dynamic mbean support ");
}
// Dynamic mbean
loadDescriptors("MbeansDescriptorsDynamicMBeanSource",
@@ -642,8 +637,8 @@
// Still not found - use introspection
if( managed==null ) {
- if( log.isDebugEnabled() ) {
- log.debug( "Introspecting ");
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled() ) {
+ CoyoteLogger.MODELER_LOGGER.debug( "Introspecting ");
}
// introspection
@@ -652,7 +647,7 @@
managed=findManagedBean(type);
if( managed==null ) {
- log.warn( "No metadata found for " + type );
+ CoyoteLogger.MODELER_LOGGER.noMetadata(type);
return null;
}
managed.setName( type );
@@ -709,8 +704,8 @@
public List load( String sourceType, Object source, String param)
throws Exception
{
- if( log.isTraceEnabled()) {
- log.trace("load " + source );
+ if( CoyoteLogger.MODELER_LOGGER.isTraceEnabled()) {
+ CoyoteLogger.MODELER_LOGGER.trace("load " + source );
}
String location=null;
String type=null;
@@ -776,12 +771,12 @@
public void registerComponent(Object bean, ObjectName oname, String type)
throws Exception
{
- if( log.isDebugEnabled() ) {
- log.debug( "Managed= "+ oname);
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled() ) {
+ CoyoteLogger.MODELER_LOGGER.debug( "Managed= "+ oname);
}
if( bean ==null ) {
- log.error("Null component " + oname );
+ CoyoteLogger.MODELER_LOGGER.nullComponent(oname);
return;
}
@@ -796,15 +791,15 @@
DynamicMBean mbean = managed.createMBean(bean);
if( getMBeanServer().isRegistered( oname )) {
- if( log.isDebugEnabled()) {
- log.debug("Unregistering existing component " + oname );
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled()) {
+ CoyoteLogger.MODELER_LOGGER.debug("Unregistering existing
component " + oname );
}
getMBeanServer().unregisterMBean( oname );
}
getMBeanServer().registerMBean( mbean, oname);
} catch( Exception ex) {
- log.error("Error registering " + oname, ex );
+ CoyoteLogger.MODELER_LOGGER.errorRegisteringMbean(oname, ex);
throw ex;
}
}
@@ -817,8 +812,8 @@
public void loadDescriptors( String packageName, ClassLoader classLoader ) {
String res=packageName.replace( '.', '/');
- if( log.isTraceEnabled() ) {
- log.trace("Finding descriptor " + res );
+ if( CoyoteLogger.MODELER_LOGGER.isTraceEnabled() ) {
+ CoyoteLogger.MODELER_LOGGER.trace("Finding descriptor " + res );
}
if( searchedPaths.get( packageName ) != null ) {
@@ -836,8 +831,8 @@
return;
}
- if (log.isDebugEnabled()) {
- log.debug( "Found " + dURL);
+ if (CoyoteLogger.MODELER_LOGGER.isDebugEnabled()) {
+ CoyoteLogger.MODELER_LOGGER.debug( "Found " + dURL);
}
searchedPaths.put( packageName, dURL );
try {
@@ -847,7 +842,7 @@
loadDescriptors("MbeansDescriptorsSerSource", dURL, null);
return;
} catch(Exception ex ) {
- log.error("Error loading " + dURL);
+ CoyoteLogger.MODELER_LOGGER.errorLoading(dURL);
}
return;
@@ -1009,13 +1004,14 @@
// should be removed
public void unregisterComponent( String domain, String name ) {
+ ObjectName oname= null;
try {
- ObjectName oname=new ObjectName( domain + ":" + name );
+ oname=new ObjectName( domain + ":" + name );
// XXX remove from our tables.
getMBeanServer().unregisterMBean( oname );
} catch( Throwable t ) {
- log.error( "Error unregistering mbean ", t );
+ CoyoteLogger.MODELER_LOGGER.errorUnregisteringMbean(oname, t);
}
}
Modified:
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDOMSource.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDOMSource.java 2012-10-02
12:04:41 UTC (rev 2094)
+++
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDOMSource.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -29,15 +29,13 @@
import org.apache.tomcat.util.modeler.OperationInfo;
import org.apache.tomcat.util.modeler.ParameterInfo;
import org.apache.tomcat.util.modeler.Registry;
-import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
+import org.jboss.web.CoyoteLogger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
public class MbeansDescriptorsDOMSource extends ModelerSource
{
- private static Logger log = Logger.getLogger(MbeansDescriptorsDOMSource.class);
Registry registry;
String location;
@@ -88,7 +86,7 @@
Node descriptorsN=doc.getDocumentElement();
//Node descriptorsN=DomUtil.getChild(doc, "mbeans-descriptors");
if( descriptorsN == null ) {
- log.error("No descriptors found");
+ CoyoteLogger.MODELER_LOGGER.noDescriptorsFound();
return;
}
@@ -100,7 +98,7 @@
}
if( firstMbeanN==null ) {
- log.error(" No mbean tags ");
+ CoyoteLogger.MODELER_LOGGER.noMbeansFound();
return;
}
@@ -155,8 +153,8 @@
// Add this info to our managed bean info
managed.addAttribute( ai );
- if (log.isTraceEnabled()) {
- log.trace("Create attribute " + ai);
+ if (CoyoteLogger.MODELER_LOGGER.isTraceEnabled()) {
+ CoyoteLogger.MODELER_LOGGER.trace("Create attribute " +
ai);
}
}
@@ -237,8 +235,8 @@
// Add this info to our managed bean info
managed.addNotification( ni );
- if (log.isTraceEnabled()) {
- log.trace("Created notification " + ni);
+ if (CoyoteLogger.MODELER_LOGGER.isTraceEnabled()) {
+ CoyoteLogger.MODELER_LOGGER.trace("Created notification
" + ni);
}
}
@@ -275,15 +273,15 @@
{
ParameterInfo pi=new ParameterInfo();
DomUtil.setAttributes(pi, paramN);
- if( log.isTraceEnabled())
- log.trace("Add param " + pi.getName());
+ if( CoyoteLogger.MODELER_LOGGER.isTraceEnabled())
+ CoyoteLogger.MODELER_LOGGER.trace("Add param " +
pi.getName());
oi.addParameter( pi );
}
// Add this info to our managed bean info
managed.addOperation( oi );
- if( log.isTraceEnabled()) {
- log.trace("Create operation " + oi);
+ if( CoyoteLogger.MODELER_LOGGER.isTraceEnabled()) {
+ CoyoteLogger.MODELER_LOGGER.trace("Create operation " +
oi);
}
}
@@ -295,9 +293,9 @@
}
long t2=System.currentTimeMillis();
- log.debug( "Reading descriptors ( dom ) " + (t2-t1));
+ CoyoteLogger.MODELER_LOGGER.debug( "Reading descriptors ( dom ) " +
(t2-t1));
} catch( Exception ex ) {
- log.error( "Error reading descriptors ", ex);
+ CoyoteLogger.MODELER_LOGGER.errorReadingDescriptors(ex);
}
}
}
Modified:
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java 2012-10-02
12:04:41 UTC (rev 2094)
+++
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -33,12 +33,10 @@
import org.apache.tomcat.util.modeler.OperationInfo;
import org.apache.tomcat.util.modeler.ParameterInfo;
import org.apache.tomcat.util.modeler.Registry;
-import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
+import org.jboss.web.CoyoteLogger;
public class MbeansDescriptorsIntrospectionSource extends ModelerSource
{
- private static Logger log =
Logger.getLogger(MbeansDescriptorsIntrospectionSource.class);
Registry registry;
String location;
@@ -88,7 +86,7 @@
mbeans.add(managed);
} catch( Exception ex ) {
- log.error( "Error reading descriptors ", ex);
+ CoyoteLogger.MODELER_LOGGER.errorReadingDescriptors(ex);
}
}
@@ -211,8 +209,8 @@
if( Modifier.isStatic(methods[j].getModifiers()))
continue;
if( ! Modifier.isPublic( methods[j].getModifiers() ) ) {
- if( log.isDebugEnabled())
- log.debug("Not public " + methods[j] );
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled())
+ CoyoteLogger.MODELER_LOGGER.debug("Not public " +
methods[j] );
continue;
}
if( methods[j].getDeclaringClass() == Object.class )
@@ -222,8 +220,8 @@
if( name.startsWith( "get" ) && params.length==0) {
Class ret=methods[j].getReturnType();
if( ! supportedType( ret ) ) {
- if( log.isDebugEnabled() )
- log.debug("Unsupported type " + methods[j]);
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled() )
+ CoyoteLogger.MODELER_LOGGER.debug("Unsupported type " +
methods[j]);
continue;
}
name=unCapitalize( name.substring(3));
@@ -234,8 +232,8 @@
} else if( name.startsWith( "is" ) && params.length==0) {
Class ret=methods[j].getReturnType();
if( Boolean.TYPE != ret ) {
- if( log.isDebugEnabled() )
- log.debug("Unsupported type " + methods[j] + "
" + ret );
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled() )
+ CoyoteLogger.MODELER_LOGGER.debug("Unsupported type " +
methods[j] + " " + ret );
continue;
}
name=unCapitalize( name.substring(2));
@@ -246,8 +244,8 @@
} else if( name.startsWith( "set" ) && params.length==1) {
if( ! supportedType( params[0] ) ) {
- if( log.isDebugEnabled() )
- log.debug("Unsupported type " + methods[j] + "
" + params[0]);
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled() )
+ CoyoteLogger.MODELER_LOGGER.debug("Unsupported type " +
methods[j] + " " + params[0]);
continue;
}
name=unCapitalize( name.substring(3));
@@ -329,7 +327,7 @@
ai.setSetMethod( sm.getName());
}
ai.setDescription("Introspected attribute " + name);
- if( log.isDebugEnabled()) log.debug("Introspected attribute "
+
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled())
CoyoteLogger.MODELER_LOGGER.debug("Introspected attribute " +
name + " " + gm + " " + sm);
if( gm==null )
ai.setReadable(false);
@@ -358,7 +356,7 @@
}
mbean.addOperation(op);
} else {
- log.error("Null arg " + name + " " + m );
+ CoyoteLogger.MODELER_LOGGER.debug("Null arg " + name +
" " + m );
}
}
@@ -384,13 +382,13 @@
}
*/
- if( log.isDebugEnabled())
- log.debug("Setting name: " + type );
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled())
+ CoyoteLogger.MODELER_LOGGER.debug("Setting name: " + type );
mbean.setName( type );
return mbean;
} catch( Exception ex ) {
- ex.printStackTrace();
+ CoyoteLogger.MODELER_LOGGER.errorReadingDescriptors(ex);
return null;
}
}
Modified:
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsSerSource.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsSerSource.java 2012-10-02
12:04:41 UTC (rev 2094)
+++
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsSerSource.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -16,6 +16,8 @@
*/
package org.apache.tomcat.util.modeler.modules;
+import static org.jboss.web.CoyoteMessages.MESSAGES;
+
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.net.URL;
@@ -24,13 +26,11 @@
import org.apache.tomcat.util.modeler.ManagedBean;
import org.apache.tomcat.util.modeler.Registry;
-import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
+import org.jboss.web.CoyoteLogger;
public class MbeansDescriptorsSerSource extends ModelerSource
{
- private static Logger log = Logger.getLogger(MbeansDescriptorsSerSource.class);
Registry registry;
String location;
String type;
@@ -81,7 +81,7 @@
stream=(InputStream)source;
}
if( stream==null ) {
- throw new Exception( "Can't process "+ source);
+ throw MESSAGES.invalidSource(source);
}
ObjectInputStream ois=new ObjectInputStream(stream);
Thread.currentThread().setContextClassLoader(ManagedBean.class.getClassLoader());
@@ -94,11 +94,10 @@
}
} catch( Exception ex ) {
- log.error( "Error reading descriptors " + source + " " +
ex.toString(),
- ex);
+ CoyoteLogger.MODELER_LOGGER.errorReadingDescriptors(ex);
throw ex;
}
long t2=System.currentTimeMillis();
- log.info( "Reading descriptors ( ser ) " + (t2-t1));
+ CoyoteLogger.MODELER_LOGGER.debug( "Reading descriptors ( ser ) " +
(t2-t1));
}
}
Modified:
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/modules/MbeansSource.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/modules/MbeansSource.java 2012-10-02
12:04:41 UTC (rev 2094)
+++
branches/7.2.x/src/main/java/org/apache/tomcat/util/modeler/modules/MbeansSource.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -35,8 +35,7 @@
import org.apache.tomcat.util.modeler.BaseModelMBean;
import org.apache.tomcat.util.modeler.ManagedBean;
import org.apache.tomcat.util.modeler.Registry;
-import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
+import org.jboss.web.CoyoteLogger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@@ -53,7 +52,6 @@
*/
public class MbeansSource extends ModelerSource implements MbeansSourceMBean
{
- private static Logger log = Logger.getLogger(MbeansSource.class);
Registry registry;
String type;
@@ -148,7 +146,7 @@
Node descriptorsN=document.getDocumentElement();
if( descriptorsN == null ) {
- log.error("No descriptors found");
+ CoyoteLogger.MODELER_LOGGER.noDescriptorsFound();
return;
}
@@ -156,8 +154,8 @@
if( firstMbeanN==null ) {
// maybe we have a single mlet
- if( log.isDebugEnabled() )
- log.debug("No child " + descriptorsN);
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled() )
+ CoyoteLogger.MODELER_LOGGER.debug("No child " +
descriptorsN);
firstMbeanN=descriptorsN;
}
@@ -188,8 +186,8 @@
objectName=DomUtil.getAttribute( mbeanN, "name" );
}
- if( log.isDebugEnabled())
- log.debug( "Processing mbean objectName=" + objectName
+
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled())
+ CoyoteLogger.MODELER_LOGGER.debug( "Processing mbean
objectName=" + objectName +
" code=" + code);
// args can be grouped in constructor or direct childs
@@ -214,7 +212,7 @@
object2Node.put( oname, mbeanN );
// XXX Arguments, loader !!!
} catch( Exception ex ) {
- log.error( "Error creating mbean " + objectName, ex);
+ CoyoteLogger.MODELER_LOGGER.errorCreatingMbean(objectName, ex);
}
Node firstAttN=DomUtil.getChild(mbeanN, "attribute");
@@ -230,8 +228,8 @@
String operation=DomUtil.getAttribute(mbeanN,
"operation");
- if( log.isDebugEnabled())
- log.debug( "Processing invoke objectName=" + name +
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled())
+ CoyoteLogger.MODELER_LOGGER.debug( "Processing invoke
objectName=" + name +
" code=" + operation);
try {
ObjectName oname=new ObjectName(name);
@@ -239,7 +237,7 @@
processArg( mbeanN );
server.invoke( oname, operation, null, null);
} catch (Exception e) {
- log.error( "Error in invoke " + name + " " +
operation);
+ CoyoteLogger.MODELER_LOGGER.errorInvoking(operation, name);
}
}
@@ -260,10 +258,10 @@
}
long t2=System.currentTimeMillis();
- log.info( "Reading mbeans " + (t2-t1));
+ CoyoteLogger.MODELER_LOGGER.debug( "Reading mbeans " + (t2-t1));
loading=false;
} catch( Exception ex ) {
- log.error( "Error reading mbeans ", ex);
+ CoyoteLogger.MODELER_LOGGER.errorReadingDescriptors(ex);
}
}
@@ -275,7 +273,7 @@
//log.info( "XXX UpdateField " + oname + " " + name + "
" + value);
Node n=(Node)object2Node.get( oname );
if( n == null ) {
- log.info( "Node not found " + oname );
+ CoyoteLogger.MODELER_LOGGER.nodeNotFound(oname);
return;
}
Node attNode=DomUtil.findChildWithAtt(n, "attribute", "name",
name);
@@ -310,9 +308,9 @@
FileOutputStream fos=new FileOutputStream(location);
DomUtil.writeXml(document, fos);
} catch (TransformerException e) {
- log.error( "Error writing");
+ CoyoteLogger.MODELER_LOGGER.errorWritingMbeans(e);
} catch (FileNotFoundException e) {
- log.error( "Error writing" ,e );
+ CoyoteLogger.MODELER_LOGGER.errorWritingMbeans(e);
}
}
}
@@ -327,8 +325,8 @@
value=DomUtil.getContent(descN);
}
try {
- if( log.isDebugEnabled())
- log.debug("Set attribute " + objectName + " " +
attName +
+ if( CoyoteLogger.MODELER_LOGGER.isDebugEnabled())
+ CoyoteLogger.MODELER_LOGGER.debug("Set attribute " + objectName
+ " " + attName +
" " + value);
ObjectName oname=new ObjectName(objectName);
// find the type
@@ -336,15 +334,13 @@
type=registry.getType( oname, attName );
if( type==null ) {
- log.info("Can't find attribute " + objectName + "
" + attName );
-
+ CoyoteLogger.MODELER_LOGGER.attributeNotFound(attName, objectName);
} else {
Object valueO=registry.convertValue( type, value);
server.setAttribute(oname, new Attribute(attName, valueO));
}
} catch( Exception ex) {
- log.error("Error processing attribute " + objectName + "
" +
- attName + " " + value, ex);
+ CoyoteLogger.MODELER_LOGGER.errorProcessingAttribute(attName, value,
objectName, ex);
}
}
Modified:
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/NioServerSocketChannelFactory.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/NioServerSocketChannelFactory.java 2012-10-02
12:04:41 UTC (rev 2094)
+++
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/NioServerSocketChannelFactory.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -35,9 +35,6 @@
*/
public abstract class NioServerSocketChannelFactory implements Cloneable {
- protected static org.jboss.logging.Logger log = org.jboss.logging.Logger
- .getLogger(NioServerSocketChannelFactory.class);
-
private static NioServerSocketChannelFactory theFactory;
protected Hashtable<String, Object> attributes = new Hashtable<String,
Object>();
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/net/SSLImplementation.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/SSLImplementation.java 2012-10-02
12:04:41 UTC (rev 2094)
+++
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/SSLImplementation.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -17,10 +17,11 @@
package
org.apache.tomcat.util.net;
-import java.net.Socket;
+import static org.jboss.web.CoyoteMessages.MESSAGES;
+
import javax.net.ssl.SSLSession;
-import org.apache.tomcat.util.net.jsse.NioJSSESocketChannelFactory;
+import org.jboss.web.CoyoteLogger;
/**
* {@code SSLImplementation}
@@ -34,10 +35,8 @@
* @author EKR & <a href="mailto:nbenothm@redhat.com">Nabil
Benothman</a>
*/
abstract public class SSLImplementation {
- private static org.jboss.logging.Logger logger = org.jboss.logging.Logger
- .getLogger(SSLImplementation.class);
- private static final String[] implementations = {
"org.apache.tomcat.util.net.jsse.NioJSSEImplementation" };
+ private static final String[] implementations = {
"org.apache.tomcat.util.net.jsse.JSSEImplementation" };
/**
* @return the default implementation of {@code SSLImplementation}
@@ -49,13 +48,13 @@
SSLImplementation impl = getInstance(implementations[i]);
return impl;
} catch (Exception e) {
- if (logger.isTraceEnabled())
- logger.trace("Error creating " + implementations[i], e);
+ if (CoyoteLogger.UTIL_LOGGER.isTraceEnabled())
+ CoyoteLogger.UTIL_LOGGER.trace("Error creating " +
implementations[i], e);
}
}
// If we can't instantiate any of these
- throw new ClassNotFoundException("Can't find any SSL
implementation");
+ throw new ClassNotFoundException(MESSAGES.noSslImplementation());
}
/**
@@ -73,10 +72,9 @@
Class<?> clazz = Class.forName(className);
return (SSLImplementation) clazz.newInstance();
} catch (Exception e) {
- if (logger.isDebugEnabled())
- logger.debug("Error loading SSL Implementation " + className,
e);
- throw new ClassNotFoundException("Error loading SSL Implementation
" + className + " :"
- + e.toString());
+ if (CoyoteLogger.UTIL_LOGGER.isDebugEnabled())
+ CoyoteLogger.UTIL_LOGGER.debug("Error loading SSL Implementation
" + className, e);
+ throw new
ClassNotFoundException(MESSAGES.errorLoadingSslImplementation(className), e);
}
}
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/net/URL.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/net/URL.java 2012-10-02 12:04:41
UTC (rev 2094)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/net/URL.java 2012-10-02 16:08:29
UTC (rev 2095)
@@ -18,6 +18,8 @@
package
org.apache.tomcat.util.net;
+import static org.jboss.web.CoyoteMessages.MESSAGES;
+
import java.io.Serializable;
import java.net.MalformedURLException;
import java.util.Locale;
@@ -150,7 +152,7 @@
}
if (protocol == null)
- throw new MalformedURLException("no protocol: " + original);
+ throw new MalformedURLException(MESSAGES.urlWithNoProtocol(original));
// Parse out any ref portion of the spec
i = spec.indexOf('#', start);
@@ -168,7 +170,7 @@
} catch (MalformedURLException e) {
throw e;
} catch (Exception e) {
- throw new MalformedURLException(e.toString());
+ throw new
MalformedURLException(MESSAGES.errorProcessingUrl(e.getMessage()));
}
}
@@ -477,8 +479,7 @@
if (index < 0)
break;
if (index == 0)
- throw new MalformedURLException
- ("Invalid relative URL reference");
+ throw new MalformedURLException(MESSAGES.invalidRelativeUrlReference());
int index2 = normalized.lastIndexOf('/', index - 1);
normalized = normalized.substring(0, index2) +
normalized.substring(index + 3);
@@ -493,8 +494,7 @@
int index = normalized.length() - 3;
int index2 = normalized.lastIndexOf('/', index - 1);
if (index2 < 0)
- throw new MalformedURLException
- ("Invalid relative URL reference");
+ throw new MalformedURLException(MESSAGES.invalidRelativeUrlReference());
normalized = normalized.substring(0, index2 + 1);
}
@@ -666,8 +666,7 @@
hStart = ipv6;
ipv6 = authority.indexOf(']', ipv6);
if( ipv6 < 0 ) {
- throw new MalformedURLException(
- "Closing ']' not
found in IPV6 address: " + authority);
+ throw new
MalformedURLException(MESSAGES.invalidIp6Address(authority));
} else {
at = ipv6-1;
}
@@ -679,7 +678,7 @@
port =
Integer.parseInt(authority.substring(colon + 1));
} catch (NumberFormatException e) {
- throw new MalformedURLException(e.toString());
+ throw new
MalformedURLException(MESSAGES.invalidIpAddress(authority, e.getMessage()));
}
host = authority.substring(hStart, colon);
} else {
@@ -708,8 +707,7 @@
return;
}
if (!path.startsWith("/"))
- throw new MalformedURLException
- ("Base path does not start with '/'");
+ throw new MalformedURLException(MESSAGES.invalidBasePath());
if (!path.endsWith("/"))
path += "/../";
path += spec.substring(start, limit);
Modified:
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java 2012-10-02
12:04:41 UTC (rev 2094)
+++
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -27,7 +27,6 @@
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
-import java.net.SocketException;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
@@ -96,9 +95,6 @@
private static final int defaultSessionCacheSize = 0;
private static final int defaultSessionTimeout = 86400;
- static org.jboss.logging.Logger log =
- org.jboss.logging.Logger.getLogger(JSSESocketFactory.class);
-
static {
boolean result = false;
SSLContext context;
@@ -177,7 +173,7 @@
try {
asock = (SSLSocket)socket.accept();
} catch (SSLException e){
- throw new SocketException("SSL handshake error" + e.toString());
+ throw new IOException(MESSAGES.sslHandshakeError(), e);
}
return asock;
}
@@ -186,7 +182,7 @@
// We do getSession instead of startHandshake() so we can call this multiple
times
SSLSession session = ((SSLSocket)sock).getSession();
if (session.getCipherSuite().equals("SSL_NULL_WITH_NULL_NULL"))
- throw new IOException("SSL handshake failed. Ciper suite in SSL Session
is SSL_NULL_WITH_NULL_NULL");
+ throw new IOException(MESSAGES.invalidSslCipherSuite());
if (!allowUnsafeLegacyRenegotiation && !RFC_5746_SUPPORTED) {
// Prevent further handshakes by removing all cipher suites
@@ -308,15 +304,15 @@
if(truststoreFile == null) {
truststoreFile = System.getProperty("javax.net.ssl.trustStore");
}
- if(log.isDebugEnabled()) {
- log.debug("Truststore = " + truststoreFile);
+ if(CoyoteLogger.UTIL_LOGGER.isDebugEnabled()) {
+ CoyoteLogger.UTIL_LOGGER.debug("Truststore = " + truststoreFile);
}
String truststorePassword = (String)attributes.get("truststorePass");
if( truststorePassword == null) {
truststorePassword =
System.getProperty("javax.net.ssl.trustStorePassword");
}
- if(log.isDebugEnabled()) {
- log.debug("TrustPass = " + truststorePassword);
+ if(CoyoteLogger.UTIL_LOGGER.isDebugEnabled()) {
+ CoyoteLogger.UTIL_LOGGER.debug("TrustPass = " +
truststorePassword);
}
String truststoreType = (String)attributes.get("truststoreType");
if( truststoreType == null) {
@@ -325,8 +321,8 @@
if(truststoreType == null) {
truststoreType = keystoreType;
}
- if(log.isDebugEnabled()) {
- log.debug("trustType = " + truststoreType);
+ if(CoyoteLogger.UTIL_LOGGER.isDebugEnabled()) {
+ CoyoteLogger.UTIL_LOGGER.debug("trustType = " + truststoreType);
}
String truststoreProvider =
(String)attributes.get("truststoreProvider");
@@ -337,8 +333,8 @@
if (truststoreProvider == null) {
truststoreProvider = keystoreProvider;
}
- if(log.isDebugEnabled()) {
- log.debug("trustProvider = " + truststoreProvider);
+ if(CoyoteLogger.UTIL_LOGGER.isDebugEnabled()) {
+ CoyoteLogger.UTIL_LOGGER.debug("trustProvider = " +
truststoreProvider);
}
if (truststoreFile != null){
@@ -582,13 +578,13 @@
try {
xparams.setMaxPathLength(Integer.parseInt(trustLength));
} catch(Exception ex) {
- log.warn("Bad maxCertLength: "+trustLength);
+ CoyoteLogger.UTIL_LOGGER.invalidMaxCertLength(trustLength);
}
}
params = xparams;
} else {
- throw new CRLException("CRLs not supported for type: "+algorithm);
+ throw new CRLException(MESSAGES.unsupportedCrl(algorithm));
}
return params;
}
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/JSSESupport.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/JSSESupport.java 2012-10-02
12:04:41 UTC (rev 2094)
+++
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/JSSESupport.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -17,6 +17,8 @@
package org.apache.tomcat.util.net.jsse;
+import static org.jboss.web.CoyoteMessages.MESSAGES;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -33,6 +35,7 @@
import org.apache.tomcat.util.net.Constants;
import org.apache.tomcat.util.net.SSLSupport;
+import org.jboss.web.CoyoteLogger;
/** JSSESupport
@@ -51,9 +54,6 @@
class JSSESupport implements SSLSupport {
- private static org.jboss.logging.Logger log =
- org.jboss.logging.Logger.getLogger(JSSESupport.class);
-
protected SSLSocket ssl;
protected SSLSession session;
@@ -87,7 +87,7 @@
try {
certs = session.getPeerCertificates();
} catch( Throwable t ) {
- log.debug("Error getting client certs",t);
+ CoyoteLogger.UTIL_LOGGER.debug("Error getting client certs", t);
return null;
}
if( certs==null ) return null;
@@ -107,12 +107,12 @@
new ByteArrayInputStream(buffer);
x509Certs[i] = (java.security.cert.X509Certificate)
cf.generateCertificate(stream);
} catch(Exception ex) {
- log.info("Error translating cert " + certs[i], ex);
+ CoyoteLogger.UTIL_LOGGER.errorTranslatingCertificate(certs[i], ex);
return null;
}
}
- if(log.isTraceEnabled())
- log.trace("Cert #" + i + " = " + x509Certs[i]);
+ if(CoyoteLogger.UTIL_LOGGER.isTraceEnabled())
+ CoyoteLogger.UTIL_LOGGER.trace("Cert #" + i + " = " +
x509Certs[i]);
}
if(x509Certs.length < 1)
return null;
@@ -144,7 +144,7 @@
protected void handShake() throws IOException {
if( ssl.getWantClientAuth() ) {
- log.debug("No client cert sent for want");
+ CoyoteLogger.UTIL_LOGGER.debug("No client cert sent for want");
} else {
ssl.setNeedClientAuth(true);
}
@@ -152,7 +152,7 @@
if (ssl.getEnabledCipherSuites().length == 0) {
// Handshake is never going to be successful.
// Assume this is because handshakes are disabled
- log.warn("SSL server initiated renegotiation is disabled, closing
connection");
+ CoyoteLogger.UTIL_LOGGER.disabledSslRenegociation();
session.invalidate();
ssl.close();
return;
@@ -166,12 +166,12 @@
ssl.startHandshake();
int maxTries = 60; // 60 * 1000 = example 1 minute time out
for (int i = 0; i < maxTries; i++) {
- if(log.isTraceEnabled())
- log.trace("Reading for try #" +i);
+ if(CoyoteLogger.UTIL_LOGGER.isTraceEnabled())
+ CoyoteLogger.UTIL_LOGGER.trace("Reading for try #" +i);
try {
int x = in.read(b);
} catch(SSLException sslex) {
- log.info("SSL Error getting client Certs",sslex);
+ CoyoteLogger.UTIL_LOGGER.trace("SSL Error getting client
Certs",sslex);
throw sslex;
} catch (IOException e) {
// ignore - presumably the timeout
@@ -182,7 +182,7 @@
}
ssl.setSoTimeout(oldTimeout);
if (listener.completed == false) {
- throw new SocketException("SSL Cert handshake timeout");
+ throw new SocketException(MESSAGES.sslHandshakeTimeout());
}
}
Modified:
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/NioJSSEImplementation.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/NioJSSEImplementation.java 2012-10-02
12:04:41 UTC (rev 2094)
+++
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/NioJSSEImplementation.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -18,8 +18,6 @@
package org.apache.tomcat.util.net.jsse;
-import java.net.Socket;
-
import javax.net.ssl.SSLSession;
import org.apache.tomcat.util.net.NioChannel;
@@ -37,9 +35,6 @@
static final String SSLClass = "javax.net.ssl.SSLEngine";
- static org.jboss.logging.Logger logger = org.jboss.logging.Logger
- .getLogger(NioJSSEImplementation.class);
-
private NioJSSEFactory factory = null;
/**
Modified:
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/NioJSSESocketChannelFactory.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/NioJSSESocketChannelFactory.java 2012-10-02
12:04:41 UTC (rev 2094)
+++
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/NioJSSESocketChannelFactory.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -165,7 +165,7 @@
NioChannel channel = new SecureNioChannel(asyncChannel, engine);
return channel;
} catch (Exception e) {
- throw new IOException(e);
+ throw new IOException(MESSAGES.sslHandshakeError(), e);
}
}
@@ -208,8 +208,7 @@
sslChannel.handshake();
if
(sslChannel.getSSLSession().getCipherSuite().equals("SSL_NULL_WITH_NULL_NULL"))
{
- throw new IOException(
- "SSL handshake failed. Ciper suite in SSL Session is
SSL_NULL_WITH_NULL_NULL");
+ throw new IOException(MESSAGES.invalidSslCipherSuite());
}
}
@@ -585,15 +584,15 @@
if (truststoreFile == null) {
truststoreFile = System.getProperty("javax.net.ssl.trustStore");
}
- if (log.isDebugEnabled()) {
- log.debug("Truststore = " + truststoreFile);
+ if (CoyoteLogger.UTIL_LOGGER.isDebugEnabled()) {
+ CoyoteLogger.UTIL_LOGGER.debug("Truststore = " + truststoreFile);
}
String truststorePassword = (String) attributes.get("truststorePass");
if (truststorePassword == null) {
truststorePassword =
System.getProperty("javax.net.ssl.trustStorePassword");
}
- if (log.isDebugEnabled()) {
- log.debug("TrustPass = " + truststorePassword);
+ if (CoyoteLogger.UTIL_LOGGER.isDebugEnabled()) {
+ CoyoteLogger.UTIL_LOGGER.debug("TrustPass = " + truststorePassword);
}
String truststoreType = (String) attributes.get("truststoreType");
if (truststoreType == null) {
@@ -602,8 +601,8 @@
if (truststoreType == null) {
truststoreType = keystoreType;
}
- if (log.isDebugEnabled()) {
- log.debug("trustType = " + truststoreType);
+ if (CoyoteLogger.UTIL_LOGGER.isDebugEnabled()) {
+ CoyoteLogger.UTIL_LOGGER.debug("trustType = " + truststoreType);
}
String truststoreProvider = (String) attributes.get("truststoreProvider");
if (truststoreProvider == null) {
@@ -612,8 +611,8 @@
if (truststoreProvider == null) {
truststoreProvider = keystoreProvider;
}
- if (log.isDebugEnabled()) {
- log.debug("trustProvider = " + truststoreProvider);
+ if (CoyoteLogger.UTIL_LOGGER.isDebugEnabled()) {
+ CoyoteLogger.UTIL_LOGGER.debug("trustProvider = " + truststoreProvider);
}
if (truststoreFile != null) {
@@ -652,13 +651,13 @@
try {
xparams.setMaxPathLength(Integer.parseInt(trustLength));
} catch (Exception ex) {
- log.warn("Bad maxCertLength: " + trustLength);
+ CoyoteLogger.UTIL_LOGGER.invalidMaxCertLength(trustLength);
}
}
params = xparams;
} else {
- throw new CRLException("CRLs not supported for type: " + algorithm);
+ throw new CRLException(MESSAGES.unsupportedCrl(algorithm));
}
return params;
}
Modified:
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/NioJSSESupport.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/NioJSSESupport.java 2012-10-02
12:04:41 UTC (rev 2094)
+++
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/NioJSSESupport.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -28,6 +28,7 @@
import org.apache.tomcat.util.net.Constants;
import org.apache.tomcat.util.net.SSLSupport;
+import org.jboss.web.CoyoteLogger;
/**
* {@code NioJSSESupport}
@@ -38,9 +39,6 @@
*/
class NioJSSESupport implements SSLSupport {
- private static org.jboss.logging.Logger log = org.jboss.logging.Logger
- .getLogger(NioJSSESupport.class);
-
protected SecureNioChannel channel;
protected SSLSession session;
@@ -126,7 +124,7 @@
try {
certs = session.getPeerCertificates();
} catch (Throwable t) {
- log.debug("Error getting client certs", t);
+ CoyoteLogger.UTIL_LOGGER.debug("Error getting client certs", t);
return null;
}
if (certs == null)
@@ -145,12 +143,12 @@
x509Certs[i] = (java.security.cert.X509Certificate) cf
.generateCertificate(stream);
} catch (Exception ex) {
- log.info("Error translating cert " + certs[i], ex);
+ CoyoteLogger.UTIL_LOGGER.errorTranslatingCertificate(certs[i], ex);
return null;
}
}
- if (log.isTraceEnabled())
- log.trace("Cert #" + i + " = " + x509Certs[i]);
+ if (CoyoteLogger.UTIL_LOGGER.isTraceEnabled())
+ CoyoteLogger.UTIL_LOGGER.trace("Cert #" + i + " = " +
x509Certs[i]);
}
if (x509Certs.length < 1)
return null;
Modified:
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/SecureNioChannel.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/SecureNioChannel.java 2012-10-02
12:04:41 UTC (rev 2094)
+++
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/jsse/SecureNioChannel.java 2012-10-02
16:08:29 UTC (rev 2095)
@@ -18,6 +18,8 @@
package org.apache.tomcat.util.net.jsse;
+import static org.jboss.web.CoyoteMessages.MESSAGES;
+
import java.io.IOException;
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
@@ -72,7 +74,7 @@
protected SecureNioChannel(AsynchronousSocketChannel channel, SSLEngine engine) {
super(channel);
if (engine == null) {
- throw new NullPointerException("null SSLEngine parameter");
+ throw MESSAGES.nullSslEngine();
}
this.sslEngine = engine;
@@ -97,8 +99,7 @@
@Deprecated
@Override
public Future<Integer> read(ByteBuffer dst) {
- throw new RuntimeException("Operation not supported for class " +
getClass().getName()
- + ". Use method readBytes(...) instead");
+ throw MESSAGES.operationNotSupported();
}
/*
@@ -203,7 +204,7 @@
checkHandshake();
if (handler == null) {
- throw new NullPointerException("'handler' parameter is null");
+ throw MESSAGES.nullHandler();
}
if ((offset < 0) || (length < 0) || (offset > dsts.length - length)) {
throw new IndexOutOfBoundsException();
@@ -257,8 +258,7 @@
@Deprecated
@Override
public Future<Integer> write(ByteBuffer src) {
- throw new RuntimeException("Operation not supported for class " +
getClass().getName()
- + ". Use method writeBytes(...) instead");
+ throw MESSAGES.operationNotSupported();
}
/*
@@ -374,7 +374,7 @@
checkHandshake();
if (handler == null) {
- throw new NullPointerException("'handler' parameter is null");
+ throw MESSAGES.nullHandler();
}
if ((offset < 0) || (length < 0) || (offset > srcs.length - length)) {
throw new IndexOutOfBoundsException();
@@ -587,8 +587,7 @@
// here we should trap BUFFER_OVERFLOW and call expand on the
// buffer for now, throw an exception, as we initialized the
// buffers in the constructor
- throw new IOException(this + " Unable to unwrap data, invalid status: "
- + result.getStatus());
+ throw new IOException(MESSAGES.errorUnwrappingData(result.getStatus().toString()));
}
// continue to unwrapping as long as the input buffer has stuff
} while (src.position() != 0);
@@ -642,8 +641,7 @@
*/
private void checkHandshake() {
if (!handshakeComplete) {
- throw new IllegalStateException(
- "Handshake incomplete, you must complete handshake before read/write
data.");
+ throw MESSAGES.incompleteHandshake();
}
}
@@ -694,7 +692,7 @@
nBytes = this.channel.read(this.netInBuffer).get();
}
if (nBytes < 0) {
- throw new IOException(this + " : EOF encountered during handshake
UNWRAP.");
+ throw new IOException(MESSAGES.errorUnwrappingHandshake());
} else {
boolean cont = false;
// Loop while we can perform pure SSLEngine data
@@ -745,14 +743,12 @@
while (this.netOutBuffer.hasRemaining()) {
if (this.channel.write(this.netOutBuffer).get() < 0) {
// Handle closed channel
- throw new IOException(this
- + " : EOF encountered during handshake WRAP.");
+ throw new IOException(MESSAGES.errorWrappingHandshake());
}
}
} else {
// Wrap should always work with our buffers
- throw new IOException("Unexpected status:" + res.getStatus()
- + " during handshake WRAP.");
+ throw new
IOException(MESSAGES.errorWrappingHandshakeStatus(res.getStatus().toString()));
}
break;
@@ -761,7 +757,7 @@
break;
case NOT_HANDSHAKING:
- throw new SSLHandshakeException("NOT_HANDSHAKING during handshake");
+ throw new SSLHandshakeException(MESSAGES.notHandshaking());
case FINISHED:
handshakeComplete = true;
break;
Modified: branches/7.2.x/src/main/java/org/jboss/web/CoyoteLogger.java
===================================================================
--- branches/7.2.x/src/main/java/org/jboss/web/CoyoteLogger.java 2012-10-02 12:04:41 UTC
(rev 2094)
+++ branches/7.2.x/src/main/java/org/jboss/web/CoyoteLogger.java 2012-10-02 16:08:29 UTC
(rev 2095)
@@ -24,6 +24,7 @@
import static org.jboss.logging.Logger.Level.DEBUG;
import java.net.InetAddress;
+import java.security.cert.Certificate;
import org.jboss.logging.BasicLogger;
import org.jboss.logging.Cause;
@@ -64,6 +65,16 @@
*/
CoyoteLogger BAYEUX_LOGGER = Logger.getMessageLogger(CoyoteLogger.class,
"org.apache.tomcat.bayeux");
+ /**
+ * A logger with the category of the package name.
+ */
+ CoyoteLogger MODELER_LOGGER = Logger.getMessageLogger(CoyoteLogger.class,
"org.apache.tomcat.util.modeler");
+
+ /**
+ * A logger with the category of the package name.
+ */
+ CoyoteLogger FILEUPLOAD_LOGGER = Logger.getMessageLogger(CoyoteLogger.class,
"org.apache.tomcat.util.http.fileupload");
+
@LogMessage(level = INFO)
@Message(id = 3000, value = "Coyote HTTP/1.1 starting on: %s")
void startHttpConnector(String name);
@@ -408,4 +419,84 @@
@Message(id = 3085, value = "Failed getting property %s on object %s")
void errorGettingProperty(String propertyName, Object object, @Cause Throwable t);
+ @LogMessage(level = WARN)
+ @Message(id = 3086, value = "Bad maximum certificate length %s")
+ void invalidMaxCertLength(String length);
+
+ @LogMessage(level = INFO)
+ @Message(id = 3087, value = "Error translating certificate %s")
+ void errorTranslatingCertificate(Certificate certificate, @Cause Throwable t);
+
+ @LogMessage(level = WARN)
+ @Message(id = 3088, value = "SSL server initiated renegotiation is disabled,
closing connection")
+ void disabledSslRenegociation();
+
+ @LogMessage(level = ERROR)
+ @Message(id = 3089, value = "No descriptors found")
+ void noDescriptorsFound();
+
+ @LogMessage(level = ERROR)
+ @Message(id = 3090, value = "No Mbeans found")
+ void noMbeansFound();
+
+ @LogMessage(level = ERROR)
+ @Message(id = 3091, value = "Error reading descriptors")
+ void errorReadingDescriptors(@Cause Throwable t);
+
+ @LogMessage(level = ERROR)
+ @Message(id = 3092, value = "Error creating MBean %s")
+ void errorCreatingMbean(String objectName, @Cause Throwable t);
+
+ @LogMessage(level = ERROR)
+ @Message(id = 3093, value = "Error invoking %s on %s")
+ void errorInvoking(String operation, String name);
+
+ @LogMessage(level = ERROR)
+ @Message(id = 3094, value = "Node not found %s")
+ void nodeNotFound(Object name);
+
+ @LogMessage(level = ERROR)
+ @Message(id = 3095, value = "Error writing MBeans")
+ void errorWritingMbeans(@Cause Throwable t);
+
+ @LogMessage(level = INFO)
+ @Message(id = 3096, value = "Can't find attribute %s on %s")
+ void attributeNotFound(String attributeName, String objectName);
+
+ @LogMessage(level = ERROR)
+ @Message(id = 3097, value = "Error processing attribute %s value %s on
%s")
+ void errorProcessingAttribute(String attributeName, String attributeValue, String
objectName, @Cause Throwable t);
+
+ @LogMessage(level = ERROR)
+ @Message(id = 3098, value = "Error sending notification")
+ void errorSendingNotification(@Cause Throwable t);
+
+ @LogMessage(level = ERROR)
+ @Message(id = 3099, value = "Error creating object name")
+ void errorCreatingObjectName(@Cause Throwable t);
+
+ @LogMessage(level = ERROR)
+ @Message(id = 3100, value = "Error invoking operation %s on %s")
+ void errorInvokingOperation(String operation, Object objectName);
+
+ @LogMessage(level = INFO)
+ @Message(id = 3101, value = "No metadata for %s")
+ void noMetadata(Object objectName);
+
+ @LogMessage(level = ERROR)
+ @Message(id = 3102, value = "Error unregistering MBean %s")
+ void errorUnregisteringMbean(Object objectName, @Cause Throwable t);
+
+ @LogMessage(level = ERROR)
+ @Message(id = 3103, value = "Null %s component")
+ void nullComponent(Object objectName);
+
+ @LogMessage(level = ERROR)
+ @Message(id = 3104, value = "Error registering MBean %s")
+ void errorRegisteringMbean(Object objectName, @Cause Throwable t);
+
+ @LogMessage(level = ERROR)
+ @Message(id = 3105, value = "Error loading %s")
+ void errorLoading(Object source);
+
}
Modified: branches/7.2.x/src/main/java/org/jboss/web/CoyoteMessages.java
===================================================================
--- branches/7.2.x/src/main/java/org/jboss/web/CoyoteMessages.java 2012-10-02 12:04:41 UTC
(rev 2094)
+++ branches/7.2.x/src/main/java/org/jboss/web/CoyoteMessages.java 2012-10-02 16:08:29 UTC
(rev 2095)
@@ -160,4 +160,118 @@
@Message(id = 2040, value = "Invalid escape character in cookie value")
IllegalArgumentException invalidEscapeCharacter();
+ @Message(id = 2041, value = "SSL handshake error")
+ String sslHandshakeError();
+
+ @Message(id = 2042, value = "SSL handshake failed, cipher suite in SSL Session
is SSL_NULL_WITH_NULL_NULL")
+ String invalidSslCipherSuite();
+
+ @Message(id = 2043, value = "Certificate revocation list is not supported for
algorithm %s")
+ String unsupportedCrl(String algorithm);
+
+ @Message(id = 2044, value = "SSL handshake timeout")
+ String sslHandshakeTimeout();
+
+ @Message(id = 2045, value = "Null SSL engine")
+ IllegalArgumentException nullSslEngine();
+
+ @Message(id = 2046, value = "Operation not supported")
+ RuntimeException operationNotSupported();
+
+ @Message(id = 2047, value = "Null handler")
+ IllegalArgumentException nullHandler();
+
+ @Message(id = 2048, value = "Unable to unwrap data, invalid status %s")
+ String errorUnwrappingData(String status);
+
+ @Message(id = 2049, value = "Handshake incomplete, you must complete handshake
before read/write data")
+ IllegalStateException incompleteHandshake();
+
+ @Message(id = 2050, value = "Error encountered during handshake unwrap")
+ String errorUnwrappingHandshake();
+
+ @Message(id = 2051, value = "Error encountered during handshake wrap")
+ String errorWrappingHandshake();
+
+ @Message(id = 2052, value = "Unexpected status %s during handshake wrap")
+ String errorWrappingHandshakeStatus(String status);
+
+ @Message(id = 2053, value = "NOT_HANDSHAKING during handshake")
+ String notHandshaking();
+
+ @Message(id = 2054, value = "Error loading SSL implementation %s")
+ String errorLoadingSslImplementation(String className);
+
+ @Message(id = 2055, value = "No SSL implementation")
+ String noSslImplementation();
+
+ @Message(id = 2056, value = "URL with no protocol: %s")
+ String urlWithNoProtocol(String url);
+
+ @Message(id = 2057, value = "Error processing URL: %s")
+ String errorProcessingUrl(String cause);
+
+ @Message(id = 2058, value = "Invalid relative URL reference")
+ String invalidRelativeUrlReference();
+
+ @Message(id = 2059, value = "Closing ']' not found in IPV6 address
%s")
+ String invalidIp6Address(String authority);
+
+ @Message(id = 2060, value = "Invalid IP address %s: %s")
+ String invalidIpAddress(String authority, String cause);
+
+ @Message(id = 2061, value = "Base path does not start with '/'")
+ String invalidBasePath();
+
+ @Message(id = 2062, value = "Cannot process source: %s")
+ IllegalStateException invalidSource(Object source);
+
+ @Message(id = 2063, value = "Attribute name is null")
+ String nullAttributeName();
+
+ @Message(id = 2064, value = "Error getting attribute %s")
+ String errorGettingAttribute(String name);
+
+ @Message(id = 2065, value = "Attribute name list is null")
+ String nullAttributeNameList();
+
+ @Message(id = 2066, value = "Method name is null")
+ String nullMethodName();
+
+ @Message(id = 2067, value = "Error invoking method %s")
+ String errorInvokingMethod(String name);
+
+ @Message(id = 2068, value = "Attribute is null")
+ String nullAttribute();
+
+ @Message(id = 2069, value = "Error setting attribute %s")
+ String errorSettingAttribute(String name);
+
+ @Message(id = 2070, value = "Null managed resource")
+ String nullManagedResource();
+
+ @Message(id = 2071, value = "Null listener")
+ String nullListener();
+
+ @Message(id = 2072, value = "Null notification")
+ String nullNotification();
+
+ @Message(id = 2073, value = "Null message")
+ String nullMessage();
+
+ @Message(id = 2074, value = "Too many hooks registered %s")
+ IllegalStateException tooManyHooks(int count);
+
+ @Message(id = 2075, value = "Cannot load model MBean %s")
+ String errorLoadingModelMbean(String className);
+
+ @Message(id = 2076, value = "Cannot instantiate model MBean %s")
+ String errorInstantiatingModelMbean(String className);
+
+ @Message(id = 2077, value = "No host found: %s")
+ IllegalStateException mapperHostNotFound(String hostName);
+
+ @Message(id = 2078, value = "No context found: %s")
+ IllegalStateException mapperContextNotFound(String contextPath);
+
}
Added: branches/7.2.x/src/main/java/org/jboss/web/JSONMessages.java
===================================================================
--- branches/7.2.x/src/main/java/org/jboss/web/JSONMessages.java
(rev 0)
+++ branches/7.2.x/src/main/java/org/jboss/web/JSONMessages.java 2012-10-02 16:08:29 UTC
(rev 2095)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012 Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.web;
+
+import org.jboss.logging.Cause;
+import org.jboss.logging.Message;
+import org.jboss.logging.MessageBundle;
+import org.jboss.logging.Messages;
+
+/**
+ * Logging IDs 8000-8200
+ * @author Remy Maucherat
+ */
+@MessageBundle(projectCode = "JBWEB")
+public interface JSONMessages {
+
+ /**
+ * The messages
+ */
+ JSONMessages MESSAGES = Messages.getBundle(JSONMessages.class);
+
+ @Message(id = 8000, value = "A JSONArray text must start with '[' at
")
+ String arrayMustStartWithBracket();
+
+ @Message(id = 8001, value = "Expected a '%s' at ")
+ String arrayCharExpected(char ch);
+
+ @Message(id = 8002, value = "Expected a ',' or ']' at ")
+ String arrayEndExpected();
+
+ @Message(id = 8003, value = "Array initial value should be a string or
collection or array")
+ String arrayInvalidValue();
+
+ @Message(id = 8004, value = "Index %s not found in array")
+ String arrayInvalidIndex(int index);
+
+ @Message(id = 8005, value = "Array value at %s does not correspond to type
%s")
+ String arrayInvalidType(int index, String type);
+
+ @Message(id = 8006, value = "A JSONObject text must begin with '{' at
")
+ String objectMustStartWithBracket();
+
+ @Message(id = 8007, value = "A JSONObject text must end with '}' at
")
+ String objectMustEndWithBracket();
+
+ @Message(id = 8008, value = "Expected a ':' after a key at ")
+ String objectExpectedKey();
+
+ @Message(id = 8009, value = "Expected a ',' or '}' at ")
+ String objectExpectedEnd();
+
+ @Message(id = 8010, value = "JSONObject[%s] does not correspond to type
%s")
+ String objectInvalidType(String key, String type);
+
+ @Message(id = 8011, value = "JSONObject[%s] not found")
+ String objectNotFound(String key);
+
+ @Message(id = 8012, value = "Duplicate key %s")
+ String objectDuplicateKey(String key);
+
+ @Message(id = 8013, value = "JSON does not allow non-finite numbers")
+ String objectInfiniteNumber();
+
+ @Message(id = 8014, value = "Bad value from toJSONString: %s")
+ String objectBadString(Object o);
+
+ @Message(id = 8015, value = "Stepping back two steps is not supported")
+ String tokenerStepBack();
+
+ @Message(id = 8016, value = "Expected '%s' and instead saw '%s'
at ")
+ String tokenerBadChar(char expected, char found);
+
+ @Message(id = 8017, value = "Substring bounds error at ")
+ String tokenerSubstring();
+
+ @Message(id = 8018, value = "Unterminated string at ")
+ String tokenerUnterminatedString();
+
+ @Message(id = 8019, value = "Missing value at ")
+ String tokenerMissingValue();
+
+ @Message(id = 8020, value = "Null string")
+ String writerNull();
+
+ @Message(id = 8021, value = "Value out of sequence")
+ String writerValueOutOfSequence();
+
+ @Message(id = 8023, value = "Misplaced array")
+ String writerMisplacedArray();
+
+ @Message(id = 8024, value = "Misplaced array end")
+ String writerMisplacedArrayEnd();
+
+ @Message(id = 8025, value = "Misplaced object end")
+ String writerMisplacedObjectEnd();
+
+ @Message(id = 8026, value = "Null key")
+ String writerNullKey();
+
+ @Message(id = 8027, value = "Misplaced key")
+ String writerMisplacedKey();
+
+ @Message(id = 8028, value = "Misplaced object")
+ String writerMisplacedObject();
+
+ @Message(id = 8029, value = "Nesting error")
+ String writerNestingError();
+
+ @Message(id = 8030, value = "Nesting too deep")
+ String writerNestingTooDeep();
+
+}