You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wink.apache.org by ro...@apache.org on 2010/07/06 17:36:49 UTC
svn commit: r960918 [3/3] - in /incubator/wink/trunk:
wink-client/src/main/java/org/apache/wink/client/
wink-client/src/main/java/org/apache/wink/client/handlers/
wink-client/src/main/java/org/apache/wink/client/internal/
wink-client/src/main/java/org/...
Added: incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/i18n/MessagesTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/i18n/MessagesTest.java?rev=960918&view=auto
==============================================================================
--- incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/i18n/MessagesTest.java (added)
+++ incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/i18n/MessagesTest.java Tue Jul 6 15:36:47 2010
@@ -0,0 +1,531 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.wink.common.internal.i18n;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.Vector;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ * Intent of MessagesTest class is to check the specified translation properties files against the java source code for:
+ *
+ * 1) checks that the strings that should be externalized are externalized (only debug messages do not need to be externalized)
+ * 2) checks that all keys referred to by Messages.getMessage actually exist
+ * 3) checks that there are no unused keys in the resource.properties file
+ * 4) checks that the number of params matches up with the number of braces {} in a formatted log string
+ *
+ */
+public class MessagesTest extends TestCase {
+
+ private String workSpacePath = null;
+ private MessageStringsCache messageStrings = null;
+ private Properties unusedProps;
+
+ // some necessary pre-compiled patterns:
+ static final Pattern patternForNoLogger = Pattern.compile("\\G.*?((Messages\\s*?\\.\\s*?getMessage.*?));", Pattern.COMMENTS);
+ static final Pattern patternIntRequired = Pattern.compile("\\G.*?\\{(\\d+?)}", Pattern.COMMENTS);
+ static final Pattern patternIntNotRequired = Pattern.compile("\\G.*?\\{}", Pattern.COMMENTS);
+
+ // default resource file in case of unittest environment
+ private static String defaultResourceFile = "wink-common/src/main/resources/org/apache/wink/common/internal/i18n/resource.properties";
+ static {
+ defaultResourceFile = defaultResourceFile.replace("/", System.getProperty("file.separator"));
+ }
+
+
+ /**
+ *
+ * A cache to hold the formatted strings with their brace counts, so counts have to be taken again
+ * and again for a formatted string that is used many times.
+ *
+ */
+ private static class MessageStringsCache {
+
+ // the cache
+ private HashMap<String, Integer> stringsToBraceCount = new HashMap<String, Integer>();
+ private Properties messageProps = null;
+
+ /**
+ * Keeps a copy of the original message properties as a convenience to users of this class.
+ *
+ * @param props original message properties
+ */
+ public MessageStringsCache(Properties props) {
+ messageProps = new Properties();
+ messageProps.putAll(props);
+ }
+
+ /**
+ *
+ * @param key into the messages properties
+ * @param filePath param is passed to produce meaningful failure message only
+ * @return
+ */
+ public String getFormattedStringByKey(String key, String filePath) {
+ String formattedString = messageProps.getProperty(key);
+ if (formattedString == null) {
+ fail("Expected to find non-null property with key \n" + key + "\n used by\n" + filePath);
+ } else if (formattedString.equals("")) {
+ fail("Expected to find non-empty property with key \n" + key + "\n used by\n" + filePath);
+ }
+ return formattedString;
+ }
+
+ /**
+ *
+ * @param key srcFile into the messages properties
+ * @param intRequired if braces are formatted with an integer n, like {n}, intRequired should be set to true
+ * @param filePath param is passed to produce meaningful failure message only
+ * @return count of all {} when intRequired = false or unique {n} occurrences when intRequired = true
+ */
+ public int getBraceCountByKey(String key, boolean intRequired, String filePath) {
+ String formattedString = getFormattedStringByKey(key, filePath);
+ if (formattedString != null) {
+ return getBraceCount(formattedString, intRequired);
+ }
+ return -1;
+ }
+
+ /**
+ *
+ * @param string the actual formatted message string
+ * @param intRequired if braces are formatted with an integer n, like {n}, intRequired should be set to true
+ * @return count of all {} when intRequired = false or unique {n} occurrences when intRequired = true
+ */
+ public int getBraceCount(String string, boolean intRequired) {
+ if (!stringsToBraceCount.containsKey(string)) {
+ // count the number of occurrences of {} or {n} where n is an int
+ Pattern pattern;
+ if (intRequired) {
+ pattern = patternIntRequired;
+ } else {
+ pattern = patternIntNotRequired;
+ }
+ Matcher matcher = pattern.matcher(string);
+ int counter = 0;
+ if (intRequired) {
+ // string may contain multiple {0} constructs. We want to count the unique integers
+ HashSet<String> ints = new HashSet<String>();
+ while(matcher.find()) {
+ ints.add(matcher.group(1));
+ }
+ counter = ints.size();
+ } else {
+ while(matcher.find()) {
+ counter++;
+ }
+ }
+ stringsToBraceCount.put(string, counter);
+ }
+ return stringsToBraceCount.get(string);
+ }
+
+ }
+
+
+ @Override
+ public void setUp() {
+ try {
+ unusedProps = new Properties();
+ System.out.println("Loading properties from: " + getWorkspacePath() + defaultResourceFile);
+ unusedProps.load(new FileInputStream(getWorkspacePath() + defaultResourceFile));
+ messageStrings = new MessageStringsCache(unusedProps);
+ } catch (Throwable t) {
+ fail("Could not load properties due to: " + t + ": " + t.getMessage());
+ }
+ }
+
+ /**
+ * Filter to determine which files to scan. Scanner will only accept *.java files, but additional
+ * exclusion filters may be specified on the command line.
+ *
+ */
+ private static class JavaSrcFilenameFilter implements FilenameFilter {
+
+ /**
+ * @param dir path up to, but not including, the filename
+ * @param name of the file
+ * @return true if dir and name satisfy all of the filter rules
+ */
+ public boolean accept(File dir, String name) {
+ // try to filter down to just production code source
+ String dirString = dir.toString();
+ if (!dirString.contains(".svn")
+ && !dirString.contains("src" + System.getProperty("file.separator") + "test")
+ && !dirString.contains("wink-examples")
+ && !dirString.contains("wink-itests")
+ && !dirString.contains("wink-component-test-support")
+ && !dirString.contains("wink-assembly")
+ && name.endsWith(".java")) {
+ return true;
+ }
+ return false;
+ }
+
+ }
+
+
+ /**
+ * recursively collect list of filtered files
+ *
+ * @param directory
+ * @param filter
+ * @return
+ */
+ private static Collection<File> listFiles(File directory,
+ FilenameFilter filter) {
+ Vector<File> files = new Vector<File>();
+ File[] entries = directory.listFiles();
+ for (File entry : entries) {
+ if (filter == null || filter.accept(directory, entry.getName())) {
+ files.add(entry);
+ }
+ if (entry.isDirectory()) {
+ files.addAll(listFiles(entry, filter));
+ }
+ }
+ return files;
+ }
+
+
+ /**
+ * Used in junit only
+ * @return full filesystem path to the workspace root
+ */
+ private String getWorkspacePath() {
+ if (workSpacePath == null) {
+ // set up the default properties file in the location where the RestServlet will find it upon test execution
+ String classPath = System.getProperty("java.class.path");
+
+ StringTokenizer tokenizer = new StringTokenizer(classPath, System.getProperty("path.separator"));
+ while (tokenizer.hasMoreElements()) {
+ String temp = tokenizer.nextToken();
+ if (temp.endsWith("test-classes")) {
+ if (!temp.startsWith(System.getProperty("file.separator"))) {
+ // must be on Windows. get rid of "c:"
+ temp = temp.substring(2, temp.length());
+ }
+ workSpacePath = temp;
+ break;
+ }
+ }
+
+ if (workSpacePath == null) {
+ fail("Failed to find test-classes directory to assist in finding workspace root");
+ }
+ // move up to peer path of wink-common (so, minus wink-common/target/test-classes
+ workSpacePath = workSpacePath.substring(0, workSpacePath.length() - 31);
+ }
+ return workSpacePath;
+ }
+
+ /**
+ * extracts the quoted string, and splits the string at the first comma not in quotes.
+ * String parameter will be something like either of the following:
+ *
+ * Messages.getMessage("someKeyToMessageProps", object1, object2)
+ * Messages.getMessage(SOME_STATIC_VAR, object1)
+ * Messages.getMessage(SOME_STATIC_VAR), object1
+ * "there was a problem with {} and {}", object1, object2
+ *
+ * Result will be an array of strings, like:
+ *
+ * {"someKeyToMessageProps", " object1, object2"}
+ * {"SOME_STATIC_VAR", " object1"}
+ * {"SOME_STATIC_VAR"}
+ * {"there was a problem with {} and {}", " object1, object2"}
+ *
+ * @param string to parse
+ * @param fileText the full text of the file being scanned, in case we need to go retrieve the value of a static var
+ * @param filePath param is passed to produce meaningful failure message only
+ * @return
+ */
+ private String[] splitString(String string, String fileText, String filePath) {
+ String copy = new String(string);
+ copy = copy.replace("\\\"", ""); // replace any escaped quotes
+
+ // extract the part past Messages.getMessage, if necessary:
+ if (!copy.startsWith("\"")) {
+ // get whatever is between the matched parens:
+ Pattern extractStringInParen = Pattern.compile("Messages\\s*\\.\\s*getMessage(FromBundle)??\\s*\\(\\s*(.*)");
+ Matcher matcher = extractStringInParen.matcher(copy);
+ if (matcher.matches()) {
+ copy = matcher.group(2);
+ }
+ }
+
+ if (!copy.startsWith("\"")) {
+ // it's likely a static var, not a hard-coded string, so split on the commas and be done with it; best effort
+ StringTokenizer tokenizer = new StringTokenizer(copy, ",");
+ String[] strings = new String[2];
+ String staticVar = tokenizer.nextToken().trim();
+
+ // go extract the real value of staticVar, which will be the key into the resource properties file
+ Pattern extractStaticVarValuePattern = Pattern.compile(".*" + staticVar + "\\s*=\\s*\"(.*?)\"\\s*;.*");
+ Matcher matcher = extractStaticVarValuePattern.matcher(fileText);
+ if (matcher.matches()) {
+ strings[0] = matcher.group(1);
+ } else {
+ fail("Could not find value of variable " + staticVar + " in " + filePath);
+ }
+
+ String restOfString = null;
+ if (tokenizer.hasMoreTokens()) {
+ restOfString = "";
+ while (tokenizer.hasMoreTokens()) {
+ restOfString += "," + tokenizer.nextToken().trim();
+ }
+ restOfString = restOfString.substring(1);// skip first comma
+ }
+ strings[1] = restOfString;
+ return strings;
+ }
+
+ // look for a the sequence quote followed by comma
+ ByteArrayInputStream bais = new ByteArrayInputStream(copy.getBytes());
+ boolean outsideQuotedString = false;
+ int endHardStringCounter = 1;
+ // skip past the first quote
+ int ch = bais.read();
+ // find the matched quote and end paren; best effort here
+ int endParenCounter = 1;
+ int parenDepth = 1;
+ boolean hardStringDone = false;
+ while ((ch = bais.read()) != -1) {
+ if (ch == '"' && !outsideQuotedString)
+ outsideQuotedString = true;
+ else if ((ch == ',') && outsideQuotedString)
+ hardStringDone = true;
+ else if ((ch == ')') && outsideQuotedString && ((--parenDepth) == 0))
+ break;
+ else if ((ch == '(') && outsideQuotedString) {
+ parenDepth++;
+ }
+ else if (ch == '"' && outsideQuotedString) // the quoted string continues, like: "we have " + count + " apples"
+ outsideQuotedString = false;
+
+ endParenCounter++;
+ if (!hardStringDone)
+ endHardStringCounter++;
+ }
+ try {
+ bais.close();
+ } catch (IOException e) {
+ }
+ String hardCodedString = copy.substring(1, endHardStringCounter-1).trim();
+
+ // clean up, if necessary:
+ while (hardCodedString.endsWith("\""))
+ hardCodedString = hardCodedString.substring(0, hardCodedString.length()-1);
+
+ String restOfString = null;
+ if (endHardStringCounter < copy.length()) {
+ restOfString = copy.substring(endHardStringCounter, endParenCounter);
+ restOfString = restOfString.substring(restOfString.indexOf(",")+1); // skip the first comma
+ restOfString = restOfString.trim();
+ }
+ return new String[]{hardCodedString, restOfString};
+ }
+
+ /*
+ * inspect the string. Note the parens of the
+ * passed String parameter may not be balanced.
+ *
+ * String will be something like either of the following:
+ *
+ * Messages.getMessage("someKeyToMessageProps"), object1, object2
+ * "there was a problem with {} and {}", object1, object2
+ *
+ * srcFile param is so we can print an informative failure message.
+ * unusedProps is so we can delete key/value pairs as we encounter them in source, so we can make sure there
+ * are no unnecessary key/value pairs in the message file
+ */
+ private void parseAndInspect(String string, boolean externalizationRequired, String fileText, String filePath, Properties unusedProps) {
+ // expect a string with unmatched parens, but we don't care. We just want to know if the messages file has
+ // the string if Messages.getMessage is called, and if the number of {} in the string matches up with the num of params
+
+ // clean up a bit
+ string = string.trim();
+ if (string.endsWith(")")) {
+ string = string.substring(0, string.length() - 1);
+ string = string.trim();
+ }
+
+ if (!string.startsWith("Messages") && string.startsWith("\"") && externalizationRequired) {
+ fail("Externalization is required for parameter " + "\"" + string + "\" statement in " + filePath);
+ }
+
+ // short circuit: message passed to logger is just a variable, like Exception.getMessage(), so there's nothing to check
+ if (!string.startsWith("Messages") && !string.startsWith("\"")) {
+ return;
+ }
+
+ String[] splitString;
+ splitString = splitString(string, fileText, filePath); // split between quoted part of the first param, and the rest
+
+ if (splitString.length == 0) {
+ // means we couldn't find the value of the static var used as the key into Messages.getMessage
+ // error message already printed, nothing else to check
+ return;
+ }
+
+ int chickenLips = 0;
+ if (string.startsWith("Messages")) {
+ chickenLips = messageStrings.getBraceCountByKey(splitString[0], true, filePath);
+ if (chickenLips == -1) {
+ // no key was found, error message already printed, nothing else to check
+ return;
+ }
+ unusedProps.remove(splitString[0]);
+ } else if (string.startsWith("\"")) {
+ chickenLips = messageStrings.getBraceCount(splitString[0], false);
+ }
+ // ok, there better be chickenLips many more tokens!
+ int remainingParams = 0;
+ if (splitString[1] != null) {
+ StringTokenizer tokenizer = new StringTokenizer(splitString[1], ",");
+ remainingParams = tokenizer.countTokens();
+ }
+ // SLF4J logger can take an extra exception param
+ if (chickenLips == remainingParams-1) {
+ // token count may be one greater than chickenlips, since messages may be something like:
+ // logger.debug("abcd", new RuntimeException());
+ // or:
+ // logger.error(Messages.getMessage("saxParseException", type.getName()), e);
+// System.out.print("\nWARNING: Expected " + chickenLips + " parameters, but found " + tokenizer.countTokens() + (string.startsWith("Messages") ? " for key " : " for formatted string ") +
+// "\"" + splitString[0] + "\" in " + srcFile + ". SLF4J allows an Exception as a parameter with no braces in the formatted message, but you should confirm this is ok.");
+ return;
+ }
+ if (remainingParams != chickenLips) {
+ fail("Expected " + chickenLips + " parameters, but found " + remainingParams + (string.startsWith("Messages") ? " for key " : " for formatted string ") +
+ "\"" + splitString[0] + "\" in " + filePath);
+ }
+ }
+
+ /**
+ * getFilteredFileContents will filter out all comments in .java source files and return the contents
+ * in a single line. A single space character replaces newlines.
+ * @param file
+ * @return
+ * @throws IOException
+ */
+ private static String getFilteredFileContents(File file) {
+ String fileText = "";
+ try {
+ FileInputStream fis = new FileInputStream(file);
+ BufferedReader br = new BufferedReader(new InputStreamReader(fis));
+ String line = null;
+ while((line = br.readLine()) != null) {
+ // get rid of single-line comments
+ int eol = line.indexOf("//");
+ if (eol == -1) {
+ fileText += line;
+ } else {
+ fileText += line.substring(0, eol);
+ }
+ fileText += " "; // to be safe, since we're smashing the whole file down into one line
+ }
+ br.close();
+ fis.close();
+ } catch (IOException e) {
+ fail(e.getMessage() + " while reading " + file.getAbsolutePath());
+ }
+ return fileText.replaceAll("/\\*.*?\\*/", ""); // get rid of comment blocks
+
+ }
+
+
+ // check all production code .java files for all calls to Logger.debug, error, warn, and info to ensure
+ // that the formatted string is correct, and that the reference, if any, to resource.properties keys is correct.
+ public void testMessages() throws IOException {
+
+ // to find the Logger variable name:
+ Pattern patternLoggerRef = Pattern.compile(".*?\\s+?Logger\\s+?([\\p{Alnum}|_]+).*");
+
+ int progressCounter = 0;
+ ArrayList<File> files = new ArrayList<File>();
+ String path = getWorkspacePath();
+
+ System.out.println("Collecting list of files to scan...");
+ files.addAll(listFiles(new File(path), new JavaSrcFilenameFilter()));
+ System.out.println("Checking " + files.size() + " files.");
+ for (File file: files) {
+ String fileText = getFilteredFileContents(file);
+ Matcher matcher = patternLoggerRef.matcher(fileText);
+ String loggerVariableName = null;
+
+ // indicate some progress for IDE users
+ System.out.print(".");
+ progressCounter++;
+ if(progressCounter % 10 == 0) {
+ System.out.println(progressCounter);
+ }
+
+
+ if (matcher.matches()) {
+ loggerVariableName = matcher.group(1);
+ }
+
+ // now that we know what the logger variable name is, we can inspect any calls made to its methods:
+ // (we can't really use regex here to match balanced parentheses)
+ ArrayList<Pattern> betweenLoggersPatterns = new ArrayList<Pattern>();
+ if (loggerVariableName != null) {
+ betweenLoggersPatterns.add(Pattern.compile("\\G.*?" + loggerVariableName + "\\s*?\\.\\s*?(info|debug|error|warn)\\s*?\\((.*?);", Pattern.COMMENTS));
+ betweenLoggersPatterns.add(patternForNoLogger); // some patterns may get checked twice, but that's ok
+ } else {
+ betweenLoggersPatterns.add(patternForNoLogger);
+ }
+
+ for (Pattern betweenLoggersPattern: betweenLoggersPatterns.toArray(new Pattern[]{})) {
+ Matcher betweenLoggersMatcher = betweenLoggersPattern.matcher(fileText);
+ while (betweenLoggersMatcher.find()) {
+ parseAndInspect(betweenLoggersMatcher.group(2), !betweenLoggersMatcher.group(1).equals("debug"), fileText, file.getAbsolutePath(), unusedProps);
+ }
+ }
+ }
+ if (!unusedProps.isEmpty()) {
+ Set<Object> keys = unusedProps.keySet();
+ for (Object key : keys.toArray()) {
+ System.err.println("key \"" + key + "\" is unused.");
+ }
+ fail("There are some unused key/value pairs in one or more of your properties message files. See System.err for this test for the list of unused keys.");
+ }
+ System.out.println("Done.");
+ }
+
+}
\ No newline at end of file
Modified: incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/app/AppTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/app/AppTest.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/app/AppTest.java (original)
+++ incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/app/AppTest.java Tue Jul 6 15:36:47 2010
@@ -35,6 +35,7 @@ import javax.xml.namespace.QName;
import junit.framework.TestCase;
import org.apache.wink.common.RestException;
+import org.apache.wink.common.internal.i18n.Messages;
import org.apache.wink.common.internal.model.ModelUtils;
import org.apache.wink.common.internal.utils.JAXBUtils;
import org.apache.wink.common.model.atom.AtomCategory;
@@ -143,7 +144,7 @@ public class AppTest extends TestCase {
try {
cats.setScheme("scheme");
} catch (RestException e) {
- assertEquals("cannot mix inline and out-of-line categories attributes", e.getMessage());
+ assertEquals(Messages.getMessage("cannotMixInlineAndOutOfLine"), e.getMessage());
}
cats = new AppCategories();
@@ -151,7 +152,7 @@ public class AppTest extends TestCase {
try {
cats.setFixed(AppYesNo.YES);
} catch (RestException e) {
- assertEquals("cannot mix inline and out-of-line categories attributes", e.getMessage());
+ assertEquals(Messages.getMessage("cannotMixInlineAndOutOfLine"), e.getMessage());
}
cats = new AppCategories();
@@ -160,7 +161,7 @@ public class AppTest extends TestCase {
try {
cats.setHref("scheme");
} catch (RestException e) {
- assertEquals("cannot mix inline and out-of-line categories attributes", e.getMessage());
+ assertEquals(Messages.getMessage("cannotMixInlineAndOutOfLine"), e.getMessage());
}
cats = new AppCategories();
Modified: incubator/wink/trunk/wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/JsonArrayProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/JsonArrayProvider.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/JsonArrayProvider.java (original)
+++ incubator/wink/trunk/wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/JsonArrayProvider.java Tue Jul 6 15:36:47 2010
@@ -89,7 +89,7 @@ public class JsonArrayProvider implement
try {
jsonString = t.toString(2);
} catch (JSONException e) {
- logger.error(Messages.getMessage("jsonFailWriteJSONArray"));
+ logger.error(Messages.getMessage("jsonFailWriteJSONArray")); //$NON-NLS-1$
throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
}
@@ -98,18 +98,18 @@ public class JsonArrayProvider implement
callbackParam =
uriInfo.getQueryParameters().getFirst(RestConstants.REST_PARAM_JSON_CALLBACK);
} catch (Exception e) {
- logger.debug("Could not get the URI callback param", e);
+ logger.debug("Could not get the URI callback param", e); //$NON-NLS-1$
}
Charset charset = Charset.forName(ProviderUtils.getCharset(mediaType));
OutputStreamWriter writer = new OutputStreamWriter(entityStream, charset);
if (callbackParam != null) {
writer.write(callbackParam);
- writer.write("(");
+ writer.write("("); //$NON-NLS-1$
}
writer.write(jsonString);
if (callbackParam != null) {
- writer.write(")");
+ writer.write(")"); //$NON-NLS-1$
}
writer.flush();
}
@@ -131,7 +131,7 @@ public class JsonArrayProvider implement
return new JSONArray(new JSONTokener(ProviderUtils
.createReader(entityStream, mediaType)));
} catch (JSONException e) {
- logger.error(Messages.getMessage("jsonFailReadJSONArray"));
+ logger.error(Messages.getMessage("jsonFailReadJSONArray")); //$NON-NLS-1$
throw new WebApplicationException(e, Response.Status.BAD_REQUEST);
}
}
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/DeploymentConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/DeploymentConfiguration.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/DeploymentConfiguration.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/DeploymentConfiguration.java Tue Jul 6 15:36:47 2010
@@ -97,9 +97,9 @@ public class DeploymentConfiguration imp
private static final String VALIDATE_LOCATION_HEADER =
"wink.validateLocationHeader"; //$NON-NLS-1$
private static final String DEFAULT_RESPONSE_CHARSET =
- "wink.response.defaultCharset"; // $NON-NLS-1$
+ "wink.response.defaultCharset"; // $NON-NLS-1$ //$NON-NLS-1$
private static final String USE_ACCEPT_CHARSET =
- "wink.response.useAcceptCharset"; // $NON-NLS-1$
+ "wink.response.useAcceptCharset"; // $NON-NLS-1$ //$NON-NLS-1$
// handler chains
private RequestHandlersChain requestHandlersChain;
private ResponseHandlersChain responseHandlersChain;
@@ -360,18 +360,18 @@ public class DeploymentConfiguration imp
mediaTypeMapper.addMappings(handlersFactory.getMediaTypeMappings());
} catch (ClassNotFoundException e) {
if (logger.isErrorEnabled()) {
- logger.error(Messages.getMessage("isNotAClassWithMsgFormat",
+ logger.error(Messages.getMessage("isNotAClassWithMsgFormat", //$NON-NLS-1$
mediaTypeMapperFactoryClassName), e);
}
} catch (InstantiationException e) {
if (logger.isErrorEnabled()) {
logger.error(Messages
- .getMessage("classInstantiationExceptionWithMsgFormat",
+ .getMessage("classInstantiationExceptionWithMsgFormat", //$NON-NLS-1$
mediaTypeMapperFactoryClassName), e);
}
} catch (IllegalAccessException e) {
if (logger.isErrorEnabled()) {
- logger.error(Messages.getMessage("classIllegalAccessWithMsgFormat",
+ logger.error(Messages.getMessage("classIllegalAccessWithMsgFormat", //$NON-NLS-1$
mediaTypeMapperFactoryClassName), e);
}
}
@@ -389,7 +389,7 @@ public class DeploymentConfiguration imp
String handlersFactoryClassName = properties.getProperty(HANDLERS_FACTORY_CLASS_PROP);
if (handlersFactoryClassName != null) {
try {
- logger.debug("Handlers Factory Class is: {}", handlersFactoryClassName);
+ logger.debug("Handlers Factory Class is: {}", handlersFactoryClassName); //$NON-NLS-1$
// use ClassUtils.getClass instead of Class.forName so we have
// classloader visibility into the Web module in J2EE
// environments
@@ -408,13 +408,13 @@ public class DeploymentConfiguration imp
errorUserHandlers = (List<ResponseHandler>)handlersFactory.getErrorHandlers();
}
} catch (ClassNotFoundException e) {
- logger.error(Messages.getMessage("isNotAClassWithMsgFormat",
+ logger.error(Messages.getMessage("isNotAClassWithMsgFormat", //$NON-NLS-1$
handlersFactoryClassName), e);
} catch (InstantiationException e) {
- logger.error(Messages.getMessage("classInstantiationExceptionWithMsgFormat",
+ logger.error(Messages.getMessage("classInstantiationExceptionWithMsgFormat", //$NON-NLS-1$
handlersFactoryClassName), e);
} catch (IllegalAccessException e) {
- logger.error(Messages.getMessage("classIllegalAccessWithMsgFormat",
+ logger.error(Messages.getMessage("classIllegalAccessWithMsgFormat", //$NON-NLS-1$
handlersFactoryClassName), e);
}
}
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/RequestProcessor.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/RequestProcessor.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/RequestProcessor.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/RequestProcessor.java Tue Jul 6 15:36:47 2010
@@ -167,12 +167,12 @@ public class RequestProcessor {
// run the response handler chain
configuration.getResponseHandlersChain().run(msgContext);
- logger.debug("Attempting to release resource instance");
+ logger.debug("Attempting to release resource instance"); //$NON-NLS-1$
isReleaseResourcesCalled = true;
try {
releaseResources(msgContext);
} catch (Exception e) {
- logger.debug("Caught exception when releasing resource object", e);
+ logger.debug("Caught exception when releasing resource object", e); //$NON-NLS-1$
throw e;
}
} catch (Throwable t) {
@@ -193,7 +193,7 @@ public class RequestProcessor {
try {
releaseResources(originalContext);
} catch (Exception e2) {
- logger.debug("Caught exception when releasing resource object", e2);
+ logger.debug("Caught exception when releasing resource object", e2); //$NON-NLS-1$
}
}
} catch (Exception e) {
@@ -203,7 +203,7 @@ public class RequestProcessor {
try {
releaseResources(originalContext);
} catch (Exception e2) {
- logger.debug("Caught exception when releasing resource object", e2);
+ logger.debug("Caught exception when releasing resource object", e2); //$NON-NLS-1$
}
}
throw e;
@@ -219,7 +219,7 @@ public class RequestProcessor {
if (searchResult != null) {
List<ResourceInstance> resourceInstances = searchResult.getData().getMatchedResources();
for (ResourceInstance res : resourceInstances) {
- logger.debug("Releasing resource instance");
+ logger.debug("Releasing resource instance"); //$NON-NLS-1$
res.releaseInstance(msgContext);
}
}
@@ -228,39 +228,38 @@ public class RequestProcessor {
private void logException(Throwable t) {
String exceptionName = t.getClass().getSimpleName();
String messageFormat =
- Messages.getMessage("exceptionOccurredDuringInvocation", exceptionName);
+ Messages.getMessage("exceptionOccurredDuringInvocation", exceptionName); //$NON-NLS-1$
if (t instanceof WebApplicationException) {
WebApplicationException wae = (WebApplicationException)t;
int statusCode = wae.getResponse().getStatus();
Status status = Response.Status.fromStatusCode(statusCode);
- String statusSep = "";
- String statusMessage = "";
+ String statusSep = ""; //$NON-NLS-1$
+ String statusMessage = ""; //$NON-NLS-1$
if (status != null) {
- statusSep = " - ";
+ statusSep = " - "; //$NON-NLS-1$
statusMessage = status.toString();
}
exceptionName =
- String.format("%s (%d%s%s)", exceptionName, statusCode, statusSep, statusMessage);
+ String.format("%s (%d%s%s)", exceptionName, statusCode, statusSep, statusMessage); //$NON-NLS-1$
if (statusCode >= 500) {
if (logger.isDebugEnabled()) {
- logger.debug(messageFormat, t);
+ logger.debug(messageFormat, t); //$NON-NLS-1$
} else {
- logger.info(messageFormat);
+ logger.info(messageFormat); //$NON-NLS-1$
}
} else {
- // don't log the whole call stack for sub-500 return codes
- // unless debugging
+ // don't log the whole call stack for sub-500 return codes unless debugging
if (logger.isDebugEnabled()) {
- logger.debug(messageFormat, t);
+ logger.debug(messageFormat, t); //$NON-NLS-1$
} else {
- logger.info(messageFormat);
+ logger.info(messageFormat); //$NON-NLS-1$
}
}
} else {
if (logger.isDebugEnabled()) {
- logger.debug(messageFormat, t);
+ logger.debug(messageFormat, t); //$NON-NLS-1$
} else {
- logger.info(messageFormat);
+ logger.info(messageFormat); //$NON-NLS-1$
}
}
}
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/application/ApplicationProcessor.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/application/ApplicationProcessor.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/application/ApplicationProcessor.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/application/ApplicationProcessor.java Tue Jul 6 15:36:47 2010
@@ -54,9 +54,9 @@ public class ApplicationProcessor {
private final boolean isSystemApplication;
public ApplicationProcessor(Application application,
- ResourceRegistry resourceRegistry,
- ProvidersRegistry providersRegistry,
- boolean isSystemApplication) {
+ ResourceRegistry resourceRegistry,
+ ProvidersRegistry providersRegistry,
+ boolean isSystemApplication) {
super();
this.application = application;
this.resourceRegistry = resourceRegistry;
@@ -118,18 +118,18 @@ public class ApplicationProcessor {
} else {
if (logger.isWarnEnabled()) {
logger.warn(Messages
- .getMessage("classNotADynamicResourceNorResourceNorProvider", obj
- .getClass().getName()));
+ .getMessage("classNotADynamicResourceNorResourceNorProvider", obj //$NON-NLS-1$
+ .getClass().getName()));
}
}
} catch (Exception e) {
- logger.warn(Messages.getMessage("exceptionOccurredDuringInstanceProcessing", obj
- .getClass().getCanonicalName()));
- logger.warn(Messages.getMessage("listExceptionDuringInstanceProcessing"), e);
+ logger.warn(Messages.getMessage("exceptionOccurredDuringInstanceProcessing", obj //$NON-NLS-1$
+ .getClass().getCanonicalName()));
+ logger.warn(Messages.getMessage("listExceptionDuringInstanceProcessing"), e); //$NON-NLS-1$
} catch (NoClassDefFoundError e) {
- logger.warn(Messages.getMessage("exceptionOccurredDuringInstanceProcessing", obj
- .getClass().getCanonicalName()));
- logger.warn(Messages.getMessage("listExceptionDuringInstanceProcessing"), e);
+ logger.warn(Messages.getMessage("exceptionOccurredDuringInstanceProcessing", obj //$NON-NLS-1$
+ .getClass().getCanonicalName()));
+ logger.warn(Messages.getMessage("listExceptionDuringInstanceProcessing"), e); //$NON-NLS-1$
}
}
}
@@ -148,21 +148,21 @@ public class ApplicationProcessor {
providersRegistry.addProvider(cls, priority, isSystemApplication);
} else {
if (logger.isWarnEnabled()) {
- logger.warn(Messages.getMessage("classNotAResourceNorProvider", cls
- .getName()));
+ logger.warn(Messages.getMessage("classNotAResourceNorProvider", cls //$NON-NLS-1$
+ .getName()));
}
}
} catch (Exception e) {
if (logger.isWarnEnabled()) {
- logger.warn(Messages.getMessage("exceptionOccurredDuringClassProcessing", cls
- .getName()));
- logger.warn(Messages.getMessage("listExceptionDuringClassProcessing"), e);
+ logger.warn(Messages.getMessage("exceptionOccurredDuringClassProcessing", cls //$NON-NLS-1$
+ .getName()));
+ logger.warn(Messages.getMessage("listExceptionDuringClassProcessing"), e); //$NON-NLS-1$
}
} catch (NoClassDefFoundError e) {
if (logger.isWarnEnabled()) {
- logger.warn(Messages.getMessage("exceptionOccurredDuringClassProcessing", cls
- .getCanonicalName()));
- logger.warn(Messages.getMessage("listExceptionDuringClassProcessing"), e);
+ logger.warn(Messages.getMessage("exceptionOccurredDuringClassProcessing", cls //$NON-NLS-1$
+ .getCanonicalName()));
+ logger.warn(Messages.getMessage("listExceptionDuringClassProcessing"), e); //$NON-NLS-1$
}
}
}
@@ -183,21 +183,21 @@ public class ApplicationProcessor {
providersRegistry.addProvider(obj, priority, isSystemApplication);
} else {
if (logger.isWarnEnabled()) {
- logger.warn(Messages.getMessage("classNotAResourceNorProvider", obj
- .getClass().getName()));
+ logger
+ .warn(Messages.getMessage("classNotAResourceNorProvider", obj.getClass())); //$NON-NLS-1$
}
}
} catch (Exception e) {
if (logger.isWarnEnabled()) {
- logger.warn(Messages.getMessage("exceptionOccurredDuringSingletonProcessing",
- obj.getClass().getCanonicalName()));
- logger.warn(Messages.getMessage("listExceptionDuringSingletonProcessing"), e);
+ logger.warn(Messages.getMessage("exceptionOccurredDuringSingletonProcessing", obj //$NON-NLS-1$
+ .getClass().getCanonicalName()));
+ logger.warn(Messages.getMessage("listExceptionDuringSingletonProcessing"), e); //$NON-NLS-1$
}
} catch (NoClassDefFoundError e) {
if (logger.isWarnEnabled()) {
- logger.warn(Messages.getMessage("exceptionOccurredDuringSingletonProcessing",
- obj.getClass().getCanonicalName()));
- logger.warn(Messages.getMessage("listExceptionDuringSingletonProcessing"), e);
+ logger.warn(Messages.getMessage("exceptionOccurredDuringSingletonProcessing", //$NON-NLS-1$
+ obj.getClass().getCanonicalName()));
+ logger.warn(Messages.getMessage("listExceptionDuringSingletonProcessing"), e); //$NON-NLS-1$
}
}
}
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/contexts/RequestImpl.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/contexts/RequestImpl.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/contexts/RequestImpl.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/contexts/RequestImpl.java Tue Jul 6 15:36:47 2010
@@ -79,7 +79,7 @@ public class RequestImpl implements Requ
// see C007
// http://jcp.org/aboutJava/communityprocess/maintenance/jsr311/311ChangeLog.html
public ResponseBuilder evaluatePreconditions() {
- logger.debug("evaluatePreconditions() called");
+ logger.debug("evaluatePreconditions() called"); //$NON-NLS-1$
// the resource does not exist yet so any If-Match header would result
// in a precondition failed
@@ -88,7 +88,7 @@ public class RequestImpl implements Requ
try {
EntityTagMatchHeader ifMatchHeader = null;
ifMatchHeader = ifMatchHeaderDelegate.fromString(ifMatch);
- logger.debug("ifMatchHeaderDelegate returned {}", ifMatchHeader);
+ logger.debug("ifMatchHeaderDelegate returned {}", ifMatchHeader); //$NON-NLS-1$
} catch (IllegalArgumentException e) {
throw new WebApplicationException(e, Response.Status.BAD_REQUEST);
}
@@ -97,7 +97,7 @@ public class RequestImpl implements Requ
ResponseBuilder responseBuilder = delegate.createResponseBuilder();
responseBuilder.status(HttpServletResponse.SC_PRECONDITION_FAILED);
logger
- .debug("evaluatePreconditions() returning built response because there was no match due to no entity tag");
+ .debug("evaluatePreconditions() returning built response because there was no match due to no entity tag"); //$NON-NLS-1$
return responseBuilder;
}
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/contexts/ServerMediaTypeCharsetAdjuster.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/contexts/ServerMediaTypeCharsetAdjuster.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/contexts/ServerMediaTypeCharsetAdjuster.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/contexts/ServerMediaTypeCharsetAdjuster.java Tue Jul 6 15:36:47 2010
@@ -63,7 +63,7 @@ public class ServerMediaTypeCharsetAdjus
logger.debug("Media Type not explicitly set on Response so going to correct charset parameter if necessary"); //$NON-NLS-1$
if (ProviderUtils.getCharsetOrNull(mediaType) == null) { //$NON-NLS-1$
try {
- String charsetValue = "UTF-8";
+ String charsetValue = "UTF-8"; //$NON-NLS-1$
if (config.isUseAcceptCharset()) {
// configuration says to inspect and use the Accept-Charset header to determine response charset
HttpHeaders requestHeaders = null;
@@ -72,7 +72,7 @@ public class ServerMediaTypeCharsetAdjus
}
charsetValue = ProviderUtils.getCharset(mediaType, requestHeaders);
}
- String newMediaTypeStr = mediaType.toString() + ";charset=" + charsetValue;
+ String newMediaTypeStr = mediaType.toString() + ";charset=" + charsetValue; //$NON-NLS-1$
mediaType = MediaType.valueOf(newMediaTypeStr);
httpHeaders.putSingle(HttpHeaders.CONTENT_TYPE, newMediaTypeStr);
logger.debug("Changed media type to be {} in Content-Type HttpHeader", newMediaTypeStr); //$NON-NLS-1$
@@ -83,7 +83,7 @@ public class ServerMediaTypeCharsetAdjus
}
}
} else {
- logger.debug("No default charset was applied to the response Content-Type header due to deployment configuration directive."); // $NON-NLS-1$
+ logger.debug("No default charset was applied to the response Content-Type header due to deployment configuration directive."); // $NON-NLS-1$ //$NON-NLS-1$
}
logger.debug("setDefaultCharsetOnMediaTypeHeader() exit returning {}", mediaType); //$NON-NLS-1$
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FindRootResourceHandler.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FindRootResourceHandler.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FindRootResourceHandler.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FindRootResourceHandler.java Tue Jul 6 15:36:47 2010
@@ -102,7 +102,7 @@ public class FindRootResourceHandler imp
// instances used; the subresource is dead)
List<ResourceInstance> resourceInstances = result.getData().getMatchedResources();
for (ResourceInstance res : resourceInstances) {
- logger.debug("Releasing resource instance");
+ logger.debug("Releasing resource instance"); //$NON-NLS-1$
res.releaseInstance(context);
}
}
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FlushResultHandler.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FlushResultHandler.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FlushResultHandler.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FlushResultHandler.java Tue Jul 6 15:36:47 2010
@@ -219,9 +219,10 @@ public class FlushResultHandler extends
FlushHeadersOutputStream outputStream =
new FlushHeadersOutputStream(httpResponse, httpHeaders, responseMediaType);
if (logger.isDebugEnabled()) {
- logger.debug("{}.writeTo({}, {}, {}) being called", new Object[] { //$NON-NLS-1$
+ logger.debug("{}@{}.writeTo({}, {}, {}) being called", new Object[] { //$NON-NLS-1$
+ dataContentHandler.getClass().getName(),
Integer.toHexString(System.identityHashCode(dataContentHandler)), entity,
- rawType, responseMediaType.toString(), outputStream});
+ responseMediaType.toString(), outputStream});
}
dataContentHandler
.writeTo(entity,
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/PopulateResponseMediaTypeHandler.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/PopulateResponseMediaTypeHandler.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/PopulateResponseMediaTypeHandler.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/PopulateResponseMediaTypeHandler.java Tue Jul 6 15:36:47 2010
@@ -44,7 +44,7 @@ public class PopulateResponseMediaTypeHa
LoggerFactory
.getLogger(PopulateResponseMediaTypeHandler.class);
- private static final MediaType APPLICATION_TYPE = new MediaType("application", "*"); //$NON-NLS-1$ //$NON-NLS-2$
+ private static final MediaType APPLICATION_TYPE = new MediaType("application", "*"); //$NON-NLS-1$ //$NON-NLS-2$
private boolean errorFlow = false;
@@ -199,7 +199,7 @@ public class PopulateResponseMediaTypeHa
if (!useOctetStream && (candidate.getMediaType().equals(MediaType.WILDCARD_TYPE) || candidate
.getMediaType().equals(APPLICATION_TYPE))) {
logger
- .debug("If necessary, use an application/octet-stream because there is a wildcard", //$NON-NLS-1$
+ .debug("If necessary, use an application/octet-stream because there is a wildcard: {}", //$NON-NLS-1$
candidate.getMediaType());
useOctetStream = true;
}
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ResourceRecordFactory.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ResourceRecordFactory.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ResourceRecordFactory.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ResourceRecordFactory.java Tue Jul 6 15:36:47 2010
@@ -138,7 +138,7 @@ public class ResourceRecordFactory {
}
} else {
throw new IllegalArgumentException(Messages
- .getMessage("rootResourceInstanceIsAnInvalidResource", instance.getClass()
+ .getMessage("rootResourceInstanceIsAnInvalidResource", instance.getClass() //$NON-NLS-1$
.getCanonicalName()));
}
} else {
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ResourceRegistry.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ResourceRegistry.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ResourceRegistry.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ResourceRegistry.java Tue Jul 6 15:36:47 2010
@@ -443,7 +443,7 @@ public class ResourceRegistry {
}
if (methodRecords.size() == 0) {
if (logger.isInfoEnabled()) {
- logger.info(Messages.getMessage("noMethodInClassSupportsHTTPMethod", resource
+ logger.info(Messages.getMessage("noMethodInClassSupportsHTTPMethod", resource //$NON-NLS-1$
.getResourceClass().getName(), context.getRequest().getMethod()));
}
Set<String> httpMethods = getOptions(resource);
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ServletContextAccessor.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ServletContextAccessor.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ServletContextAccessor.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ServletContextAccessor.java Tue Jul 6 15:36:47 2010
@@ -69,7 +69,6 @@ public class ServletContextAccessor exte
return (T)new HttpServletResponseWrapperImpl();
}
- throw new IllegalArgumentException(Messages
- .getMessage("invalidServletContextAccessor", contextClass));
+ throw new IllegalArgumentException(Messages.getMessage("invalidServletContextAccessor", contextClass)); //$NON-NLS-1$
}
}
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/AdminServlet.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/AdminServlet.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/AdminServlet.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/AdminServlet.java Tue Jul 6 15:36:47 2010
@@ -419,7 +419,7 @@ public class AdminServlet extends Abstra
Marshaller marshaller = JAXBUtils.createMarshaller(resourceCtx);
marshaller.marshal(jaxbObject, writer);
} catch (JAXBException e) {
- throw new ServletException(Messages.getMessage("adminServletFailMarshalObject",
+ throw new ServletException(Messages.getMessage("adminServletFailMarshalObject", //$NON-NLS-1$
jaxbObject.getClass().getName()), e);
}
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestFilter.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestFilter.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestFilter.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestFilter.java Tue Jul 6 15:36:47 2010
@@ -110,7 +110,7 @@ public class RestFilter implements Filte
}
} else {
logger
- .debug("Filter {} did not expect a non-HttpServletRequest and/or non-HttpServletResponse but letting chain continue"); //$NON-NLS-1$
+ .debug("Filter {} did not expect a non-HttpServletRequest and/or non-HttpServletResponse but letting chain continue", this); //$NON-NLS-1$
chain.doFilter(servletRequest, servletResponse);
}
}
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestServlet.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestServlet.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestServlet.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestServlet.java Tue Jul 6 15:36:47 2010
@@ -68,11 +68,12 @@ public class RestServlet extends Abstrac
private static final Logger logger =
LoggerFactory
.getLogger(RestServlet.class);
- public static final String APPLICATION_INIT_PARAM = "javax.ws.rs.Application"; //$NON-NLS-1$
- public static final String PROPERTIES_DEFAULT_FILE = "META-INF/wink-default.properties"; //$NON-NLS-1$
- public static final String PROPERTIES_INIT_PARAM = "propertiesLocation"; //$NON-NLS-1$
- public static final String APP_LOCATION_PARAM = "applicationConfigLocation"; //$NON-NLS-1$
- public static final String DEPLOYMENT_CONF_PARAM = "deploymentConfiguration"; //$NON-NLS-1$
+
+ public static final String APPLICATION_INIT_PARAM = "javax.ws.rs.Application"; //$NON-NLS-1$
+ public static final String PROPERTIES_DEFAULT_FILE = "META-INF/wink-default.properties"; //$NON-NLS-1$
+ public static final String PROPERTIES_INIT_PARAM = "propertiesLocation"; //$NON-NLS-1$
+ public static final String APP_LOCATION_PARAM = "applicationConfigLocation"; //$NON-NLS-1$
+ public static final String DEPLOYMENT_CONF_PARAM = "deploymentConfiguration"; //$NON-NLS-1$
@Override
public void init() throws ServletException {
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/contentencode/ContentEncodingRequestFilter.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/contentencode/ContentEncodingRequestFilter.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/contentencode/ContentEncodingRequestFilter.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/contentencode/ContentEncodingRequestFilter.java Tue Jul 6 15:36:47 2010
@@ -65,15 +65,15 @@ public class ContentEncodingRequestFilte
.getLogger(ContentEncodingRequestFilter.class);
public void init(FilterConfig arg0) throws ServletException {
- logger.debug("init({}) entry", arg0);
+ logger.debug("init({}) entry", arg0); //$NON-NLS-1$
/* do nothing */
- logger.debug("init() exit");
+ logger.debug("init() exit"); //$NON-NLS-1$
}
public void destroy() {
- logger.debug("destroy() entry");
+ logger.debug("destroy() entry"); //$NON-NLS-1$
/* do nothing */
- logger.debug("destroy() exit");
+ logger.debug("destroy() exit"); //$NON-NLS-1$
}
private String getContentEncoding(HttpServletRequest httpServletRequest) {
@@ -89,31 +89,31 @@ public class ContentEncodingRequestFilte
ServletResponse servletResponse,
FilterChain chain) throws IOException, ServletException {
if (logger.isDebugEnabled()) {
- logger.debug("doFilter({}, {}, {}) entry", new Object[] {servletRequest,
+ logger.debug("doFilter({}, {}, {}) entry", new Object[] {servletRequest, //$NON-NLS-1$
servletResponse, chain});
}
if (servletRequest instanceof HttpServletRequest && servletResponse instanceof HttpServletResponse) {
HttpServletRequest httpServletRequest = (HttpServletRequest)servletRequest;
String contentEncoding = getContentEncoding(httpServletRequest);
- logger.debug("Content-Encoding was {}", contentEncoding);
+ logger.debug("Content-Encoding was {}", contentEncoding); //$NON-NLS-1$
if (contentEncoding != null) {
- if ("gzip".equals(contentEncoding) || "deflate".equals(contentEncoding)) {
+ if ("gzip".equals(contentEncoding) || "deflate".equals(contentEncoding)) { //$NON-NLS-1$ //$NON-NLS-2$
logger
- .debug("Wrapping HttpServletRequest because Content-Encoding was set to gzip or deflate");
+ .debug("Wrapping HttpServletRequest because Content-Encoding was set to gzip or deflate"); //$NON-NLS-1$
httpServletRequest =
new HttpServletRequestContentEncodingWrapperImpl(httpServletRequest,
contentEncoding);
- logger.debug("Invoking chain with wrapped HttpServletRequest");
+ logger.debug("Invoking chain with wrapped HttpServletRequest"); //$NON-NLS-1$
chain.doFilter(httpServletRequest, servletResponse);
- logger.debug("doFilter exit()");
+ logger.debug("doFilter exit()"); //$NON-NLS-1$
return;
}
}
}
logger
- .debug("Invoking normal chain since Content-Encoding request header was not understood");
+ .debug("Invoking normal chain since Content-Encoding request header was not understood"); //$NON-NLS-1$
chain.doFilter(servletRequest, servletResponse);
- logger.debug("doFilter exit()");
+ logger.debug("doFilter exit()"); //$NON-NLS-1$
}
static class DecoderServletInputStream extends ServletInputStream {
@@ -204,18 +204,18 @@ public class ContentEncodingRequestFilte
@Override
public ServletInputStream getInputStream() throws IOException {
- logger.debug("getInputStream() entry");
+ logger.debug("getInputStream() entry"); //$NON-NLS-1$
if (inputStream == null) {
inputStream = super.getInputStream();
- if ("gzip".equals(contentEncoding)) {
- logger.debug("Wrapping ServletInputStream with GZIPDecoder");
+ if ("gzip".equals(contentEncoding)) { //$NON-NLS-1$
+ logger.debug("Wrapping ServletInputStream with GZIPDecoder"); //$NON-NLS-1$
inputStream = new GZIPDecoderInputStream(inputStream);
- } else if ("deflate".equals(contentEncoding)) {
- logger.debug("Wrapping ServletInputStream with Inflater");
+ } else if ("deflate".equals(contentEncoding)) { //$NON-NLS-1$
+ logger.debug("Wrapping ServletInputStream with Inflater"); //$NON-NLS-1$
inputStream = new InflaterDecoderInputStream(inputStream);
}
}
- logger.debug("getInputStream() exit - returning {}", inputStream);
+ logger.debug("getInputStream() exit - returning {}", inputStream); //$NON-NLS-1$
return inputStream;
}
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/contentencode/ContentEncodingResponseFilter.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/contentencode/ContentEncodingResponseFilter.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/contentencode/ContentEncodingResponseFilter.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/contentencode/ContentEncodingResponseFilter.java Tue Jul 6 15:36:47 2010
@@ -73,22 +73,22 @@ public class ContentEncodingResponseFilt
.createHeaderDelegate(AcceptEncoding.class);
public void init(FilterConfig arg0) throws ServletException {
- logger.debug("init({}) entry", arg0);
+ logger.debug("init({}) entry", arg0); //$NON-NLS-1$
/* do nothing */
- logger.debug("init() exit");
+ logger.debug("init() exit"); //$NON-NLS-1$
}
public void destroy() {
- logger.debug("destroy() entry");
+ logger.debug("destroy() entry"); //$NON-NLS-1$
/* do nothing */
- logger.debug("destroy() exit");
+ logger.debug("destroy() exit"); //$NON-NLS-1$
}
public void doFilter(ServletRequest servletRequest,
ServletResponse servletResponse,
FilterChain chain) throws IOException, ServletException {
if (logger.isDebugEnabled()) {
- logger.debug("doFilter({}, {}, {}) entry", new Object[] {servletRequest,
+ logger.debug("doFilter({}, {}, {}) entry", new Object[] {servletRequest, //$NON-NLS-1$
servletResponse, chain});
}
/*
@@ -97,30 +97,30 @@ public class ContentEncodingResponseFilt
if (servletRequest instanceof HttpServletRequest && servletResponse instanceof HttpServletResponse) {
HttpServletRequest httpServletRequest = (HttpServletRequest)servletRequest;
final AcceptEncoding acceptEncoding = getAcceptEncodingHeader(httpServletRequest);
- logger.debug("AcceptEncoding header was {}", acceptEncoding);
+ logger.debug("AcceptEncoding header was {}", acceptEncoding); //$NON-NLS-1$
if (acceptEncoding != null && (acceptEncoding.isAnyEncodingAllowed() || acceptEncoding
.getAcceptableEncodings().size() > 0)) {
- logger.debug("AcceptEncoding header was set so wrapping HttpServletResponse");
+ logger.debug("AcceptEncoding header was set so wrapping HttpServletResponse"); //$NON-NLS-1$
HttpServletResponseContentEncodingWrapperImpl wrappedServletResponse =
new HttpServletResponseContentEncodingWrapperImpl(
(HttpServletResponse)servletResponse,
acceptEncoding);
- logger.debug("Passing on request and response down the filter chain");
+ logger.debug("Passing on request and response down the filter chain"); //$NON-NLS-1$
chain.doFilter(servletRequest, wrappedServletResponse);
- logger.debug("Finished filter chain");
+ logger.debug("Finished filter chain"); //$NON-NLS-1$
EncodedOutputStream encodedOutputStream =
wrappedServletResponse.getEncodedOutputStream();
if (encodedOutputStream != null) {
- logger.debug("Calling encodedOutputStream finish");
+ logger.debug("Calling encodedOutputStream finish"); //$NON-NLS-1$
encodedOutputStream.finish();
}
- logger.debug("doFilter exit()");
+ logger.debug("doFilter exit()"); //$NON-NLS-1$
return;
}
}
- logger.debug("AcceptEncoding header not found so processing like normal request");
+ logger.debug("AcceptEncoding header not found so processing like normal request"); //$NON-NLS-1$
chain.doFilter(servletRequest, servletResponse);
- logger.debug("doFilter exit()");
+ logger.debug("doFilter exit()"); //$NON-NLS-1$
}
/**
@@ -130,23 +130,23 @@ public class ContentEncodingResponseFilt
* @return
*/
static AcceptEncoding getAcceptEncodingHeader(HttpServletRequest httpServletRequest) {
- logger.debug("getAcceptEncodingHeader({}) entry", httpServletRequest);
+ logger.debug("getAcceptEncodingHeader({}) entry", httpServletRequest); //$NON-NLS-1$
Enumeration<String> acceptEncodingEnum =
httpServletRequest.getHeaders(HttpHeaders.ACCEPT_ENCODING);
StringBuilder sb = new StringBuilder();
if (acceptEncodingEnum.hasMoreElements()) {
sb.append(acceptEncodingEnum.nextElement());
while (acceptEncodingEnum.hasMoreElements()) {
- sb.append(",");
+ sb.append(","); //$NON-NLS-1$
sb.append(acceptEncodingEnum.nextElement());
}
String acceptEncodingHeader = sb.toString();
- logger.debug("acceptEncodingHeader is {} so returning as AcceptEncodingHeader",
+ logger.debug("acceptEncodingHeader is {} so returning as AcceptEncodingHeader", //$NON-NLS-1$
acceptEncodingHeader);
return acceptEncodingHeaderDelegate.fromString(acceptEncodingHeader);
}
- logger.debug("No Accept-Encoding header");
- logger.debug("getAcceptEncodingHeader() exit - returning null");
+ logger.debug("No Accept-Encoding header"); //$NON-NLS-1$
+ logger.debug("getAcceptEncodingHeader() exit - returning null"); //$NON-NLS-1$
return null;
}
@@ -221,7 +221,7 @@ public class ContentEncodingResponseFilt
@Override
public void isFirstWrite() {
- response.addHeader(HttpHeaders.CONTENT_ENCODING, "gzip");
+ response.addHeader(HttpHeaders.CONTENT_ENCODING, "gzip"); //$NON-NLS-1$
response.addHeader(HttpHeaders.VARY, HttpHeaders.ACCEPT_ENCODING);
}
}
@@ -238,7 +238,7 @@ public class ContentEncodingResponseFilt
@Override
public void isFirstWrite() {
- response.addHeader(HttpHeaders.CONTENT_ENCODING, "deflate");
+ response.addHeader(HttpHeaders.CONTENT_ENCODING, "deflate"); //$NON-NLS-1$
response.addHeader(HttpHeaders.VARY, HttpHeaders.ACCEPT_ENCODING);
}
}
@@ -268,7 +268,7 @@ public class ContentEncodingResponseFilt
}
private boolean containsAcceptEncoding(String value) {
- String[] str = value.split(",");
+ String[] str = value.split(","); //$NON-NLS-1$
for (String s : str) {
if (HttpHeaders.ACCEPT_ENCODING.equalsIgnoreCase(s.trim())) {
return true;
@@ -279,26 +279,26 @@ public class ContentEncodingResponseFilt
@Override
public void addHeader(String name, String value) {
- logger.debug("addHeader({}, {}) entry", name, value);
+ logger.debug("addHeader({}, {}) entry", name, value); //$NON-NLS-1$
/*
* this logic is added to append Accept-Encoding to the first Vary
* header value.
*/
if (HttpHeaders.VARY.equalsIgnoreCase(name)) {
++varyHeaderCount;
- logger.debug("Vary header count is now {}", varyHeaderCount);
+ logger.debug("Vary header count is now {}", varyHeaderCount); //$NON-NLS-1$
if (varyHeaderCount == 1) {
// add the Accept-Encoding value to the Vary header
- if (!"*".equals(value) && !containsAcceptEncoding(value)) {
+ if (!"*".equals(value) && !containsAcceptEncoding(value)) { //$NON-NLS-1$
logger
- .debug("Vary header did not contain Accept-Encoding so appending to Vary header value");
- super.addHeader(HttpHeaders.VARY, value + ", "
+ .debug("Vary header did not contain Accept-Encoding so appending to Vary header value"); //$NON-NLS-1$
+ super.addHeader(HttpHeaders.VARY, value + ", " //$NON-NLS-1$
+ HttpHeaders.ACCEPT_ENCODING);
return;
}
} else if (HttpHeaders.ACCEPT_ENCODING.equals(value)) {
logger
- .debug("Skipping Vary header that was only Accept-Encoding since it was already appended to a previous Vary header value");
+ .debug("Skipping Vary header that was only Accept-Encoding since it was already appended to a previous Vary header value"); //$NON-NLS-1$
// skip this addition since it has already been appended to
// the first Vary value by the "if true" block above
return;
@@ -309,40 +309,40 @@ public class ContentEncodingResponseFilt
@Override
public ServletOutputStream getOutputStream() throws IOException {
- logger.debug("getOutputStream() entry");
+ logger.debug("getOutputStream() entry"); //$NON-NLS-1$
if (outputStream == null) {
- logger.debug("output stream was null");
+ logger.debug("output stream was null"); //$NON-NLS-1$
this.outputStream = super.getOutputStream();
List<String> acceptableEncodings = acceptEncoding.getAcceptableEncodings();
- logger.debug("acceptableEncodings is {}", acceptableEncodings);
+ logger.debug("acceptableEncodings is {}", acceptableEncodings); //$NON-NLS-1$
for (String encoding : acceptableEncodings) {
- logger.debug("encoding under test is {}", encoding);
- if ("gzip".equalsIgnoreCase(encoding)) {
- logger.debug("going to use gzip encoding");
+ logger.debug("encoding under test is {}", encoding); //$NON-NLS-1$
+ if ("gzip".equalsIgnoreCase(encoding)) { //$NON-NLS-1$
+ logger.debug("going to use gzip encoding"); //$NON-NLS-1$
this.encodedOutputStream = new GzipEncoderOutputStream(outputStream, this);
this.outputStream = encodedOutputStream;
- logger.debug("getOutputStream() exit - returning gzipped encode stream");
+ logger.debug("getOutputStream() exit - returning gzipped encode stream"); //$NON-NLS-1$
return outputStream;
- } else if ("deflate".equalsIgnoreCase(encoding)) {
- logger.debug("going to use deflate encoding");
+ } else if ("deflate".equalsIgnoreCase(encoding)) { //$NON-NLS-1$
+ logger.debug("going to use deflate encoding"); //$NON-NLS-1$
this.encodedOutputStream =
new DeflaterContentEncodedOutputStream(outputStream, this);
this.outputStream = encodedOutputStream;
- logger.debug("getOutputStream() exit - returning deflate encode stream");
+ logger.debug("getOutputStream() exit - returning deflate encode stream"); //$NON-NLS-1$
return outputStream;
}
}
if (acceptEncoding.isAnyEncodingAllowed() && !acceptEncoding.getBannedEncodings()
- .contains("gzip")) {
- logger.debug("going to use gzip encoding because any encoding is allowed");
+ .contains("gzip")) { //$NON-NLS-1$
+ logger.debug("going to use gzip encoding because any encoding is allowed"); //$NON-NLS-1$
this.encodedOutputStream = new GzipEncoderOutputStream(outputStream, this);
this.outputStream = encodedOutputStream;
- logger.debug("getOutputStream() exit - returning gzipped encode stream");
+ logger.debug("getOutputStream() exit - returning gzipped encode stream"); //$NON-NLS-1$
return outputStream;
}
}
- logger.debug("getOutputStream() exit - returning output stream");
+ logger.debug("getOutputStream() exit - returning output stream"); //$NON-NLS-1$
return outputStream;
}
}
Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/utils/ServletFileLoader.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/utils/ServletFileLoader.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/utils/ServletFileLoader.java (original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/utils/ServletFileLoader.java Tue Jul 6 15:36:47 2010
@@ -34,14 +34,14 @@ public class ServletFileLoader extends F
public static InputStream loadFileAsStream(ServletContext servletContext, String fileName)
throws FileNotFoundException {
- if (fileName == null || fileName.trim().equals("")) {
- throw new NullPointerException("fileName");
+ if (fileName == null || fileName.trim().equals("")) { //$NON-NLS-1$
+ throw new NullPointerException("fileName"); //$NON-NLS-1$
}
if (servletContext != null) {
- logger.debug("Searching for {} using servlet context.", fileName);
+ logger.debug("Searching for {} using servlet context.", fileName); //$NON-NLS-1$
- if(fileName.startsWith("/")) { // protect against MalformedURLException
+ if (fileName.startsWith("/")) { // protect against MalformedURLException //$NON-NLS-1$
InputStream is = servletContext.getResourceAsStream(fileName);
if (is != null) {
return is;