You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by st...@apache.org on 2009/01/13 17:59:19 UTC
svn commit: r734179 - in /cocoon/cocoon3/trunk:
cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/
cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/util/
cocoon-sample/src/main/java/org/apache/cocoon/sample/generation/
cocoon-sax/s...
Author: stevendolg
Date: Tue Jan 13 08:59:09 2009
New Revision: 734179
URL: http://svn.apache.org/viewvc?rev=734179&view=rev
Log:
Fixed some warnings.
Modified:
cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/MethodDelegator.java
cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/util/AnnotationCollector.java
cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/generation/CachingTimestampGenerator.java
cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/pipeline/component/sax/IncludeTransformer.java
cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/pipeline/util/XMLUtils.java
cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/XMLSitemapServlet.java
cocoon/cocoon3/trunk/cocoon-stax/src/main/java/org/apache/cocoon/stax/StAXCleaningTransformer.java
cocoon/cocoon3/trunk/cocoon-stax/src/main/java/org/apache/cocoon/stax/navigation/FindCorrespondingStartEndElementPairNavigator.java
Modified: cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/MethodDelegator.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/MethodDelegator.java?rev=734179&r1=734178&r2=734179&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/MethodDelegator.java (original)
+++ cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/MethodDelegator.java Tue Jan 13 08:59:09 2009
@@ -74,6 +74,10 @@
private class DeleteDelegate extends MethodDelegate {
+ public DeleteDelegate() {
+ super();
+ }
+
@Override
public RestResponse execute(Object controller) throws Exception {
if (controller instanceof Delete) {
@@ -86,6 +90,10 @@
private class GetDelegate extends MethodDelegate {
+ public GetDelegate() {
+ super();
+ }
+
@Override
public RestResponse execute(Object controller) throws Exception {
if (controller instanceof Get) {
@@ -98,6 +106,10 @@
private class HeadDelegate extends MethodDelegate {
+ public HeadDelegate() {
+ super();
+ }
+
@Override
public RestResponse execute(Object controller) throws Exception {
if (controller instanceof Head) {
@@ -110,6 +122,10 @@
private abstract class MethodDelegate {
+ public MethodDelegate() {
+ super();
+ }
+
public RestResponse execute(Object controller) throws Exception {
return new Status(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
}
@@ -117,6 +133,10 @@
private class OptionsDelegate extends MethodDelegate {
+ public OptionsDelegate() {
+ super();
+ }
+
@Override
public RestResponse execute(Object controller) throws Exception {
if (controller instanceof Options) {
@@ -129,6 +149,10 @@
private class PostDelegate extends MethodDelegate {
+ public PostDelegate() {
+ super();
+ }
+
@Override
public RestResponse execute(Object controller) throws Exception {
if (controller instanceof Post) {
@@ -142,6 +166,10 @@
private class PutDelegate extends MethodDelegate {
+ public PutDelegate() {
+ super();
+ }
+
@Override
public RestResponse execute(Object controller) throws Exception {
if (controller instanceof Put) {
Modified: cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/util/AnnotationCollector.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/util/AnnotationCollector.java?rev=734179&r1=734178&r2=734179&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/util/AnnotationCollector.java (original)
+++ cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/util/AnnotationCollector.java Tue Jan 13 08:59:09 2009
@@ -38,7 +38,7 @@
private static final Log LOG = LogFactory.getLog(AnnotationCollector.class);
- private Map<Class<?>, Map<Class<? extends Annotation>, List<Field>>> annotatedFields = new HashMap<Class<?>, Map<Class<? extends Annotation>, List<Field>>>();
+ private Map<Class<?>, Map<Class<? extends Annotation>, List<Field>>> annotatedFieldsCache = new HashMap<Class<?>, Map<Class<? extends Annotation>, List<Field>>>();
private Set<Class<? extends Annotation>> relevantAnnotations;
public AnnotationCollector() {
@@ -52,17 +52,15 @@
this.relevantAnnotations.add(SitemapParameter.class);
}
- public Map<Class<? extends Annotation>, List<Field>> getAnnotatedFields(Class<?> type) {
- synchronized (type) {
- Map<Class<? extends Annotation>, List<Field>> result = this.annotatedFields.get(type);
-
- if (result == null) {
- result = this.collectAnnotatedFields(type);
- this.annotatedFields.put(type, result);
- }
+ public synchronized Map<Class<? extends Annotation>, List<Field>> getAnnotatedFields(Class<?> type) {
+ Map<Class<? extends Annotation>, List<Field>> result = this.annotatedFieldsCache.get(type);
- return result;
+ if (result == null) {
+ result = this.collectAnnotatedFields(type);
+ this.annotatedFieldsCache.put(type, result);
}
+
+ return result;
}
private Map<Class<? extends Annotation>, List<Field>> collectAnnotatedFields(Class<?> type) {
Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/generation/CachingTimestampGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/generation/CachingTimestampGenerator.java?rev=734179&r1=734178&r2=734179&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/generation/CachingTimestampGenerator.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/generation/CachingTimestampGenerator.java Tue Jan 13 08:59:09 2009
@@ -32,7 +32,7 @@
private static final long serialVersionUID = 1L;
private final long timestamp;
- private CacheKeyImplementation(long timestamp) {
+ public CacheKeyImplementation(long timestamp) {
this.timestamp = timestamp;
}
Modified: cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/pipeline/component/sax/IncludeTransformer.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/pipeline/component/sax/IncludeTransformer.java?rev=734179&r1=734178&r2=734179&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/pipeline/component/sax/IncludeTransformer.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/pipeline/component/sax/IncludeTransformer.java Tue Jan 13 08:59:09 2009
@@ -47,34 +47,34 @@
@Override
public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException {
- if (INCLUDE_NS.equals(uri) && INCLUDE_EL.equals(localName)) {
- String sourceAtt = atts.getValue(SRC_ATTR);
-
- if (null != sourceAtt && !"".equals(sourceAtt)) {
- try {
- URL source = this.createSource(sourceAtt);
-
- XMLReader xmlReader = XMLReaderFactory.createXMLReader();
- xmlReader.setContentHandler(this.getXMLConsumer());
- IncludeXMLConsumer includeXMLConsumer = new IncludeXMLConsumer(this.getXMLConsumer());
- xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", includeXMLConsumer);
-
- BufferedInputStream inputStream = new BufferedInputStream(source.openStream());
- xmlReader.parse(new InputSource(inputStream));
-
- return;
- } catch (IOException e) {
- String message = "Can't read from URL " + sourceAtt;
- this.logger.error(message, e);
- throw new ProcessingException(message, e);
- }
- } else {
- String message = "The <include> element must contain a 'src' attribute that contains a URL.";
- this.logger.error(message);
- throw new ProcessingException(message);
- }
- } else {
+ if (!INCLUDE_NS.equals(uri) || !INCLUDE_EL.equals(localName)) {
super.startElement(uri, localName, name, atts);
+ return;
+ }
+
+ String sourceAtt = atts.getValue(SRC_ATTR);
+ if (null == sourceAtt || "".equals(sourceAtt)) {
+ String message = "The <include> element must contain a 'src' attribute that contains a URL.";
+ this.logger.error(message);
+ throw new ProcessingException(message);
+ }
+
+ try {
+ URL source = this.createSource(sourceAtt);
+
+ XMLReader xmlReader = XMLReaderFactory.createXMLReader();
+ xmlReader.setContentHandler(this.getXMLConsumer());
+ IncludeXMLConsumer includeXMLConsumer = new IncludeXMLConsumer(this.getXMLConsumer());
+ xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", includeXMLConsumer);
+
+ BufferedInputStream inputStream = new BufferedInputStream(source.openStream());
+ xmlReader.parse(new InputSource(inputStream));
+
+ return;
+ } catch (IOException e) {
+ String message = "Can't read from URL " + sourceAtt;
+ this.logger.error(message, e);
+ throw new ProcessingException(message, e);
}
}
Modified: cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/pipeline/util/XMLUtils.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/pipeline/util/XMLUtils.java?rev=734179&r1=734178&r2=734179&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/pipeline/util/XMLUtils.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/pipeline/util/XMLUtils.java Tue Jan 13 08:59:09 2009
@@ -122,7 +122,7 @@
xmlReader.setEntityResolver(new EntityResolver() {
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
- return new InputSource(new ByteArrayInputStream(new String("").getBytes()));
+ return new InputSource(new ByteArrayInputStream("".getBytes()));
}
});
} catch (SAXException e) {
Modified: cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/XMLSitemapServlet.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/XMLSitemapServlet.java?rev=734179&r1=734178&r2=734179&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/XMLSitemapServlet.java (original)
+++ cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/XMLSitemapServlet.java Tue Jan 13 08:59:09 2009
@@ -64,14 +64,13 @@
private String version = "";
@Override
- public void init(ServletConfig servletConfig) throws ServletException {
- this.servletConfig = servletConfig;
+ public void init(ServletConfig config) throws ServletException {
+ this.servletConfig = config;
super.init(this.servletConfig);
this.initVersionNumber();
}
- public void invoke(String requestURI, Map<String, Object> parameters, OutputStream outputStream)
- throws ServletException {
+ public void invoke(String requestURI, Map<String, Object> parameters, OutputStream outputStream) throws ServletException {
InvocationImpl invocation = (InvocationImpl) this.beanFactory.getBean(Invocation.class.getName());
invocation.setBaseURL(this.getBaseURL());
@@ -88,12 +87,11 @@
}
@Override
- protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException,
- IOException {
+ protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
long start = System.nanoTime();
this.logRequest(request);
- this.lazyInitialize(this.servletConfig);
+ this.lazyInitialize();
try {
Settings settings = (Settings) this.beanFactory.getBean(Settings.class.getName());
@@ -135,9 +133,9 @@
if (ifLastModifiedSince > 0 && ifLastModifiedSince / 1000 >= lastModified / 1000 && lastModified > 0) {
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
if (this.logger.isInfoEnabled()) {
- this.logger.info("The requested resource " + request.getRequestURI()
- + " hasn't changed: ifLastModifiedSince=" + ifLastModifiedSince + ", lastModified="
- + lastModified + ". Hence 304 (NOT_MODIFIED) was sent as status code.");
+ this.logger.info("The requested resource " + request.getRequestURI() + " hasn't changed: ifLastModifiedSince="
+ + ifLastModifiedSince + ", lastModified=" + lastModified
+ + ". Hence 304 (NOT_MODIFIED) was sent as status code.");
}
return;
@@ -180,8 +178,7 @@
try {
return this.servletConfig.getServletContext().getResource("/");
} catch (MalformedURLException e) {
- throw this.wrapException(e, "An exception occurred while retrieving the base "
- + "URL from the servlet context.");
+ throw this.wrapException(e, "An exception occurred while retrieving the base " + "URL from the servlet context.");
}
}
@@ -214,8 +211,8 @@
* Read versioning information from the Cocoon 3 Servlet module
*/
private void initVersionNumber() {
- String servletModuleVersion = ResourceUtils.getPOMProperties("org.apache.cocoon.servlet", "cocoon-servlet")
- .getProperty("version");
+ String servletModuleVersion = ResourceUtils.getPOMProperties("org.apache.cocoon.servlet", "cocoon-servlet").getProperty(
+ "version");
if (servletModuleVersion != null) {
this.version = servletModuleVersion;
}
@@ -236,12 +233,11 @@
}
}
- private synchronized void lazyInitialize(ServletConfig servletConfig) throws ServletException {
+ private synchronized void lazyInitialize() throws ServletException {
if (!this.initialized) {
try {
- SitemapBuilder sitemapBuilder = (SitemapBuilder) this.beanFactory.getBean(SitemapBuilder.class
- .getName());
- URL url = servletConfig.getServletContext().getResource(this.getSitemapPath());
+ SitemapBuilder sitemapBuilder = (SitemapBuilder) this.beanFactory.getBean(SitemapBuilder.class.getName());
+ URL url = this.servletConfig.getServletContext().getResource(this.getSitemapPath());
this.sitemap = sitemapBuilder.build(url);
} catch (Exception e) {
throw this.wrapException(e, "An exception occurred while building the sitemap.");
@@ -252,15 +248,14 @@
private void logRequest(HttpServletRequest request) throws ServletException {
if (this.logger.isInfoEnabled()) {
- this.logger.info("Performing " + request.getMethod().toUpperCase() + " request at "
- + request.getRequestURI());
+ this.logger.info("Performing " + request.getMethod().toUpperCase() + " request at " + request.getRequestURI());
}
if (this.logger.isDebugEnabled()) {
this.logger.debug("The base URL for this request is " + this.getBaseURL());
}
}
- private ServletException wrapException(Exception e, String msg) throws ServletException {
+ private ServletException wrapException(Exception e, String msg) {
this.logger.error(msg, e);
ServletException servletException = new ServletException(msg, e);
Modified: cocoon/cocoon3/trunk/cocoon-stax/src/main/java/org/apache/cocoon/stax/StAXCleaningTransformer.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-stax/src/main/java/org/apache/cocoon/stax/StAXCleaningTransformer.java?rev=734179&r1=734178&r2=734179&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-stax/src/main/java/org/apache/cocoon/stax/StAXCleaningTransformer.java (original)
+++ cocoon/cocoon3/trunk/cocoon-stax/src/main/java/org/apache/cocoon/stax/StAXCleaningTransformer.java Tue Jan 13 08:59:09 2009
@@ -17,13 +17,14 @@
package org.apache.cocoon.stax;
import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
/**
* Transformer which is used to clean an xml document from all whitespaces, comments and namespace
- * start prefixes and end prefixes as its SAX counterpart the {@link CleaningTransformer}.
+ * start prefixes and end prefixes as its SAX counterpart the CleaningTransformer.
*/
public class StAXCleaningTransformer extends AbstractStAXTransformer {
@@ -49,7 +50,7 @@
}
}
continue;
- } else if (event.getEventType() == XMLEvent.COMMENT) {
+ } else if (event.getEventType() == XMLStreamConstants.COMMENT) {
// remove comments
continue;
} else if (event.isStartElement()) {
Modified: cocoon/cocoon3/trunk/cocoon-stax/src/main/java/org/apache/cocoon/stax/navigation/FindCorrespondingStartEndElementPairNavigator.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-stax/src/main/java/org/apache/cocoon/stax/navigation/FindCorrespondingStartEndElementPairNavigator.java?rev=734179&r1=734178&r2=734179&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-stax/src/main/java/org/apache/cocoon/stax/navigation/FindCorrespondingStartEndElementPairNavigator.java (original)
+++ cocoon/cocoon3/trunk/cocoon-stax/src/main/java/org/apache/cocoon/stax/navigation/FindCorrespondingStartEndElementPairNavigator.java Tue Jan 13 08:59:09 2009
@@ -28,15 +28,13 @@
import org.apache.cocoon.pipeline.Pipeline;
/**
- * This implementation of the {@link Navigator} returns true every time a
- * {@link StartElement} is entered to
- * {@link Navigator#fulfillsCriteria(XMLEvent)} and matches all other conditions
- * entered to the {@link Navigator} during its creation. Also true is returned
- * if the corresponding {@link EndElement} is found. This {@link Navigator} is
- * quite similar to the {@link InSubtreeNavigator} with the difference that
- * false is returned for all elements between the found {@link StartElement} and
- * {@link EndElement} except another {@link StartElement} matching all
- * conditions.
+ * This implementation of the {@link Navigator} returns true every time a {@link StartElement} is
+ * entered to {@link Navigator#fulfillsCriteria(XMLEvent)} and matches all other conditions entered
+ * to the {@link Navigator} during its creation. Also true is returned if the corresponding
+ * {@link EndElement} is found. This {@link Navigator} is quite similar to the
+ * {@link InSubtreeNavigator} with the difference that false is returned for all elements between
+ * the found {@link StartElement} and {@link EndElement} except another {@link StartElement}
+ * matching all conditions.
*
* <pre>
* <anyElement> -> false
@@ -52,7 +50,7 @@
public class FindCorrespondingStartEndElementPairNavigator implements Navigator {
private String name;
- private List<Attribute> attributes = new ArrayList<Attribute>();;
+ private List<Attribute> attributes = new ArrayList<Attribute>();
private List<String> levelRememberer = new ArrayList<String>();
private int count = 0;
private boolean active;