unico 2004/01/13 03:32:54
Modified: src/blocks/slide/java/org/apache/cocoon/components/source/impl
SlideSourceFactory.java SlideSource.java
Log:
add ability to use event caching
Revision Changes Path
1.13 +7 -5
cocoon-2.1/src/blocks/slide/java/org/apache/cocoon/components/source/impl/SlideSourceFactory.java
Index: SlideSourceFactory.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/slide/java/org/apache/cocoon/components/source/impl/SlideSourceFactory.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- SlideSourceFactory.java 23 Dec 2003 15:28:32 -0000 1.12
+++ SlideSourceFactory.java 13 Jan 2004 11:32:54 -0000 1.13
@@ -79,18 +79,17 @@
* @version CVS $Id$
*
* @avalon.component
- * @avalon.service type="SourceFactory"
+ * @avalon.service type=SourceFactory
* @x-avalon.lifestyle type=singleton
* @x-avalon.info name=slide
*/
public class SlideSourceFactory extends AbstractLogEnabled
-implements SourceFactory, ThreadSafe, Serviceable, Contextualizable {
+implements SourceFactory, Contextualizable, Serviceable, ThreadSafe {
private ServiceManager m_manager;
private SlideRepository m_repository;
private Context m_context;
-
public SlideSourceFactory() {
}
@@ -115,6 +114,7 @@
m_manager = manager;
}
+
/**
* Get a <code>Source</code> object.
*
@@ -170,6 +170,7 @@
String version = queryParameters.getParameter("version",null);
String scope = queryParameters.getParameter("scope",
nat.getNamespaceConfig().getFilesPath());
+ boolean eventCaching =
queryParameters.getParameterAsBoolean("event-caching",false);
if (getLogger().isDebugEnabled()) {
getLogger().debug("scheme: " + scheme);
@@ -178,9 +179,10 @@
getLogger().debug("path: " + path);
getLogger().debug("version: " + version);
getLogger().debug("scope: " + scope);
+ getLogger().debug("event-caching: " + eventCaching);
}
- SlideSource source = new
SlideSource(nat,scheme,scope,path,principal,version);
+ SlideSource source = new
SlideSource(nat,scheme,scope,path,principal,version,eventCaching);
source.enableLogging(getLogger());
source.contextualize(m_context);
1.16 +21 -9
cocoon-2.1/src/blocks/slide/java/org/apache/cocoon/components/source/impl/SlideSource.java
Index: SlideSource.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/slide/java/org/apache/cocoon/components/source/impl/SlideSource.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- SlideSource.java 23 Dec 2003 15:28:32 -0000 1.15
+++ SlideSource.java 13 Jan 2004 11:32:54 -0000 1.16
@@ -74,6 +74,8 @@
import org.apache.avalon.framework.service.Serviceable;
import org.apache.cocoon.CascadingIOException;
import org.apache.cocoon.Constants;
+import org.apache.cocoon.caching.validity.EventValidity;
+import org.apache.cocoon.caching.validity.NamedEvent;
import org.apache.cocoon.components.source.InspectableSource;
import org.apache.cocoon.components.source.LockableSource;
import org.apache.cocoon.components.source.VersionableSource;
@@ -149,6 +151,7 @@
private String m_principal;
private SourceValidity m_validity;
+ private boolean m_useEventCaching;
private SlideSourceOutputStream m_outputStream;
@@ -164,7 +167,8 @@
String scope,
String path,
String principal,
- String version) {
+ String version,
+ boolean useEventCaching) {
m_nat = nat;
m_scheme = scheme;
@@ -183,7 +187,7 @@
if (version != null) {
m_version = new NodeRevisionNumber(version);
}
-
+ m_useEventCaching = useEventCaching;
}
/**
@@ -300,9 +304,15 @@
*/
public SourceValidity getValidity() {
try {
- if (m_validity == null && m_descriptor != null) {
- m_validity = new TimeStampValidity(
- m_descriptor.getLastModifiedAsDate().getTime());
+ if (m_validity == null) {
+ if (m_useEventCaching) {
+ m_validity = new EventValidity(
+ new NamedEvent(m_nat.getName() + m_uri));
+ }
+ else if (m_descriptor != null) {
+ m_validity = new TimeStampValidity(
+ m_descriptor.getLastModifiedAsDate().getTime());
+ }
}
} catch (Exception e) {
getLogger().debug("Could not create SourceValidity", e);
@@ -316,7 +326,9 @@
* content has changed.
*/
public void refresh() {
- m_validity = null;
+ if (!m_useEventCaching) {
+ m_validity = null;
+ }
}
/**
@@ -469,7 +481,7 @@
}
private Source getChildByPath(String path) throws SourceException {
- SlideSource child = new
SlideSource(m_nat,m_scheme,m_scope,path,m_principal,null);
+ SlideSource child = new
SlideSource(m_nat,m_scheme,m_scope,path,m_principal,null,m_useEventCaching);
child.enableLogging(getLogger());
child.contextualize(m_context);
child.service(m_manager);
@@ -519,7 +531,7 @@
else {
parentPath = m_path.substring(0,index);
}
- SlideSource parent = new
SlideSource(m_nat,m_scheme,m_scope,parentPath,m_principal,null);
+ SlideSource parent = new
SlideSource(m_nat,m_scheme,m_scope,parentPath,m_principal,null,m_useEventCaching);
parent.enableLogging(getLogger());
parent.contextualize(m_context);
parent.service(m_manager);