implemented dependsOn() and digestDependencies() methods
This commit is contained in:
parent
fed6c39ef3
commit
24dece80bb
2 changed files with 45 additions and 0 deletions
|
@ -160,6 +160,14 @@ public class ResponseBean implements Serializable {
|
||||||
res.setETag (etag);
|
res.setETag (etag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void dependsOn (Object what) {
|
||||||
|
res.dependsOn (what);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void digestDependencies () {
|
||||||
|
res.digestDependencies ();
|
||||||
|
}
|
||||||
|
|
||||||
/* public void notModified () throws RedirectException {
|
/* public void notModified () throws RedirectException {
|
||||||
res.setNotModified (true);
|
res.setNotModified (true);
|
||||||
} */
|
} */
|
||||||
|
|
|
@ -8,6 +8,7 @@ import java.util.*;
|
||||||
import helma.framework.core.Skin;
|
import helma.framework.core.Skin;
|
||||||
import helma.objectmodel.*;
|
import helma.objectmodel.*;
|
||||||
import helma.util.*;
|
import helma.util.*;
|
||||||
|
import java.security.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Transmitter for a response to the servlet client. Objects of this
|
* A Transmitter for a response to the servlet client. Objects of this
|
||||||
|
@ -95,6 +96,7 @@ public final class ResponseTrans implements Externalizable {
|
||||||
// the request trans for this response
|
// the request trans for this response
|
||||||
private transient RequestTrans reqtrans;
|
private transient RequestTrans reqtrans;
|
||||||
|
|
||||||
|
private transient MessageDigest digest;
|
||||||
|
|
||||||
public ResponseTrans () {
|
public ResponseTrans () {
|
||||||
super ();
|
super ();
|
||||||
|
@ -141,6 +143,9 @@ public final class ResponseTrans implements Externalizable {
|
||||||
values.clear ();
|
values.clear ();
|
||||||
lastModified = -1;
|
lastModified = -1;
|
||||||
notModified = false;
|
notModified = false;
|
||||||
|
etag = null;
|
||||||
|
if (digest != null)
|
||||||
|
digest.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -410,6 +415,38 @@ public final class ResponseTrans implements Externalizable {
|
||||||
return notModified;
|
return notModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void dependsOn (Object what) {
|
||||||
|
if (digest == null) try {
|
||||||
|
digest = MessageDigest.getInstance ("MD5");
|
||||||
|
} catch (NoSuchAlgorithmException nsa) {
|
||||||
|
// MD5 should always be available
|
||||||
|
}
|
||||||
|
if (what == null) {
|
||||||
|
digest.update (new byte[0]);
|
||||||
|
} else if (what instanceof byte[]) {
|
||||||
|
digest.update ((byte[]) what);
|
||||||
|
} else {
|
||||||
|
String str = what.toString();
|
||||||
|
if (str != null)
|
||||||
|
digest.update (str.getBytes ());
|
||||||
|
else
|
||||||
|
digest.update (new byte[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void digestDependencies () {
|
||||||
|
if (digest == null)
|
||||||
|
return;
|
||||||
|
byte[] b = digest.digest();
|
||||||
|
/* StringBuffer buf = new StringBuffer(b.length*2);
|
||||||
|
for ( int i=0; i<b.length; i++ ) {
|
||||||
|
int j = (b[i]<0) ? 256+b[i] : b[i];
|
||||||
|
if ( j<16 ) buf.append("0");
|
||||||
|
buf.append(Integer.toHexString(j));
|
||||||
|
} */
|
||||||
|
setETag (new String (Base64.encode(b)));
|
||||||
|
}
|
||||||
|
|
||||||
public void setSkinpath (Object[] arr) {
|
public void setSkinpath (Object[] arr) {
|
||||||
this.skinpath = arr;
|
this.skinpath = arr;
|
||||||
skincache = null;
|
skincache = null;
|
||||||
|
|
Loading…
Add table
Reference in a new issue