bloritsch 01/11/13 08:50:38
Modified: src/org/apache/cocoon/components/language/markup/sitemap
SitemapMarkupLanguage.java
src/org/apache/cocoon/components/language/markup/xsp
XSPMarkupLanguage.java
src/org/apache/cocoon/reading DatabaseReader.java
ResourceReader.java
src/org/apache/cocoon/servlet CocoonServlet.java
src/org/apache/cocoon/util/log CocoonLogFormatter.java
Log:
Small resource improvement by avoiding new Date() where possible
Revision Changes Path
1.7 +2 -2
xml-cocoon2/src/org/apache/cocoon/components/language/markup/sitemap/SitemapMarkupLanguage.java
Index: SitemapMarkupLanguage.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/language/markup/sitemap/SitemapMarkupLanguage.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SitemapMarkupLanguage.java 2001/10/11 07:20:26 1.6
+++ SitemapMarkupLanguage.java 2001/11/13 16:50:38 1.7
@@ -30,7 +30,7 @@
* <a href="http://xml.apache.org/cocoon/sitemap.html">Sitemap</a>.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.6 $ $Date: 2001/10/11 07:20:26 $
+ * @version CVS $Revision: 1.7 $ $Date: 2001/11/13 16:50:38 $
*/
public class SitemapMarkupLanguage extends AbstractMarkupLanguage {
@@ -203,7 +203,7 @@
newAtts.addAttribute("", "file-name", "file-name", "CDATA", name);
newAtts.addAttribute("", "file-path", "file-path", "CDATA", path);
newAtts.addAttribute("", "creation-date", "creation-date",
- "CDATA", String.valueOf(new Date().getTime())
+ "CDATA", String.valueOf(System.currentTimeMillis())
);
// forward element with the modified attribute
super.startElement(namespaceURI, localName, qName, newAtts);
1.7 +2 -2
xml-cocoon2/src/org/apache/cocoon/components/language/markup/xsp/XSPMarkupLanguage.java
Index: XSPMarkupLanguage.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/language/markup/xsp/XSPMarkupLanguage.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XSPMarkupLanguage.java 2001/10/11 07:20:26 1.6
+++ XSPMarkupLanguage.java 2001/11/13 16:50:38 1.7
@@ -31,7 +31,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Sahuc</a>
- * @version CVS $Revision: 1.6 $ $Date: 2001/10/11 07:20:26 $
+ * @version CVS $Revision: 1.7 $ $Date: 2001/11/13 16:50:38 $
*/
public class XSPMarkupLanguage extends AbstractMarkupLanguage {
@@ -239,7 +239,7 @@
newAtts.addAttribute("", "file-name", "file-name", "CDATA", name);
newAtts.addAttribute("", "file-path", "file-path", "CDATA", path);
newAtts.addAttribute("", "creation-date", "creation-date", "CDATA",
- String.valueOf(new Date().getTime())
+ String.valueOf(System.currentTimeMillis())
);
// forward element with the modified attribute
super.startElement(namespaceURI, localName, qName, newAtts);
1.11 +2 -2 xml-cocoon2/src/org/apache/cocoon/reading/DatabaseReader.java
Index: DatabaseReader.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/reading/DatabaseReader.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- DatabaseReader.java 2001/10/15 13:40:55 1.10
+++ DatabaseReader.java 2001/11/13 16:50:38 1.11
@@ -45,7 +45,7 @@
public class DatabaseReader extends AbstractReader implements Composable,
Configurable, Disposable, Cacheable, Poolable {
private ComponentSelector dbselector;
private String dsn;
- private long lastModified = new Date().getTime();
+ private long lastModified = System.currentTimeMillis();
private Blob resource = null;
private Connection con = null;
private DataSourceComponent datasource = null;
@@ -256,7 +256,7 @@
long expires = parameters.getParameterAsInteger("expires", -1);
if (expires > 0) {
- response.setDateHeader("Expires", new Date().getTime() + expires);
+ response.setDateHeader("Expires", System.currentTimeMillis() + expires);
}
response.setHeader("Accept-Ranges", "bytes");
1.13 +2 -2 xml-cocoon2/src/org/apache/cocoon/reading/ResourceReader.java
Index: ResourceReader.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/reading/ResourceReader.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ResourceReader.java 2001/11/05 11:36:03 1.12
+++ ResourceReader.java 2001/11/13 16:50:38 1.13
@@ -31,7 +31,7 @@
/**
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.12 $ $Date: 2001/11/05 11:36:03 $
+ * @version CVS $Revision: 1.13 $ $Date: 2001/11/13 16:50:38 $
*
* The <code>ResourceReader</code> component is used to serve binary data
* in a sitemap pipeline. It makes use of HTTP Headers to determine if
@@ -123,7 +123,7 @@
long expires = parameters.getParameterAsInteger("expires", -1);
if (expires > 0) {
- response.setDateHeader("Expires", new Date().getTime() + expires);
+ response.setDateHeader("Expires", System.currentTimeMillis() +
expires);
}
response.setHeader("Accept-Ranges", "bytes");
1.52 +4 -4 xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java
Index: CocoonServlet.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- CocoonServlet.java 2001/10/31 16:16:28 1.51
+++ CocoonServlet.java 2001/11/13 16:50:38 1.52
@@ -59,7 +59,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Leo Sutic</a>
- * @version CVS $Revision: 1.51 $ $Date: 2001/10/31 16:16:28 $
+ * @version CVS $Revision: 1.52 $ $Date: 2001/11/13 16:50:38 $
*/
public class CocoonServlet extends HttpServlet {
@@ -636,7 +636,7 @@
} catch (Exception e){}
// This is more scalable
- long start = new Date().getTime();
+ long start = System.currentTimeMillis();
HttpServletRequest request = RequestWrapper.getServletRequest(req,
CocoonServlet.SAVE_UPLOADED_FILES_TO_DISK,
this.uploadDir,
@@ -768,7 +768,7 @@
res.setContentType(contentType = Notifier.notify(n,
res.getOutputStream()));
}
- long end = new Date().getTime();
+ long end = System.currentTimeMillis();
String timeString = processTime(end - start);
log.info("'" + uri + "' " + timeString);
@@ -881,7 +881,7 @@
c.compose(getParentComponentManager ());
c.setLogKitManager(this.logKitManager);
c.initialize();
- this.creationTime = new Date().getTime();
+ this.creationTime = System.currentTimeMillis();
if (this.cocoon != null) {
this.cocoon.dispose();
1.9 +23 -23
xml-cocoon2/src/org/apache/cocoon/util/log/CocoonLogFormatter.java
Index: CocoonLogFormatter.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/util/log/CocoonLogFormatter.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- CocoonLogFormatter.java 2001/10/11 07:28:25 1.8
+++ CocoonLogFormatter.java 2001/11/13 16:50:38 1.9
@@ -32,7 +32,7 @@
* </ul>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
- * @version CVS $Revision: 1.8 $ $Date: 2001/10/11 07:28:25 $
+ * @version CVS $Revision: 1.9 $ $Date: 2001/11/13 16:50:38 $
*/
public class CocoonLogFormatter extends ExtensiblePatternFormatter
@@ -40,16 +40,16 @@
protected final static int TYPE_CLASS = MAX_TYPE + 1;
protected final static int TYPE_URI = MAX_TYPE + 2;
protected final static int TYPE_THREAD = MAX_TYPE + 3;
-
+
protected final static String TYPE_CLASS_STR = "class";
protected final static String TYPE_CLASS_SHORT_STR = "short";
protected final static String TYPE_URI_STR = "uri";
protected final static String TYPE_THREAD_STR = "thread";
-
+
protected final SimpleDateFormat dateFormatter = new
SimpleDateFormat("(yyyy-MM-dd) HH:mm.ss:SSS");
-
- /**
+
+ /**
* Hack to get the call stack as an array of classes. The
* SecurityManager class provides it as a protected method, so
* change it to public through a new method !
@@ -72,12 +72,12 @@
/** The class that we will search for in the call stack */
private Class loggerClass = org.apache.log.Logger.class;
-
+
private CallStack callStack = new CallStack();
-
+
protected int getTypeIdFor(String type) {
-
+
// Search for new patterns defined here, or else delegate
// to the parent class
if (type.equalsIgnoreCase(TYPE_CLASS_STR))
@@ -97,31 +97,31 @@
switch (run.m_type) {
case TYPE_CLASS :
return getClass(run.m_format);
-
+
case TYPE_URI :
return getURI(event.getContextMap());
-
+
case TYPE_THREAD :
return getThread(event.getContextMap());
}
-
+
return super.formatPatternRun(event, run);
}
-
+
/**
* Finds the class that has called Logger.
*/
private String getClass(String format) {
-
+
Class[] stack = this.callStack.get();
-
+
// Traverse the call stack in reverse order until we find a Logger
for (int i = stack.length-1; i >= 0; i--) {
if (this.loggerClass.isAssignableFrom(stack[i])) {
-
+
// Found : the caller is the previous stack element
String className = stack[i+1].getName();
-
+
// Handle optional format
if (TYPE_CLASS_SHORT_STR.equalsIgnoreCase(format))
{
@@ -129,22 +129,22 @@
if (pos >= 0)
className = className.substring(pos + 1);
}
-
+
return className;
}
}
-
+
// No Logger found in call stack : can occur with AsyncLogTarget
// where formatting takes place in a different thread.
return "Unknown-class";
}
-
+
/**
* Find the URI that is being processed.
*/
private String getURI(ContextMap ctxMap) {
String result = "Unknown-URI";
-
+
// Get URI from the the object model.
if (ctxMap != null) {
Object context = ctxMap.get("objectModel");
@@ -156,11 +156,11 @@
}
}
}
-
+
return result;
}
-
+
/**
* Find the thread that is logged this event.
*/
@@ -170,7 +170,7 @@
else
return "Unknown-thread";
}
-
+
/**
* Utility method to format stack trace so that CascadingExceptions are
* formatted with all nested exceptions.
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]