| Method from org.jboss.deployment.cache.DeploymentCache Detail: |
protected void createService() throws Exception {
// create stale deployemnt timer/scanner/whatever
}
|
public void deploy(URL url) throws DeploymentException {
boolean debug = log.isDebugEnabled();
try {
URL storedURL = store.get(url);
if (storedURL != null) {
// it's in the cache, is it still valid ?
if (isInvalid(url, storedURL)) {
// the stored version is old, get the new version
log.info("Cached deployment is invalid; refreshing store for URL: " + url);
storedURL = store.put(url);
}
else {
if (debug) {
log.debug("Using cached deployment URL: " + storedURL);
}
}
}
else {
// not in the cache, put it there
log.info("Deployment not in cache; adding URL to store: " + url);
storedURL = store.put(url);
}
// invoke the chained deployer with the stored URL
deployer.deploy(storedURL);
}
catch (Exception e) {
throw new DeploymentException(e);
}
}
|
protected void destroyService() throws Exception {
deployer = null;
store = null;
}
|
public ObjectName getDeployer() {
return ((MBeanProxyInstance)deployer).getMBeanProxyObjectName();
}
|
public ObjectName getStore() {
return ((MBeanProxyInstance)store).getMBeanProxyObjectName();
}
|
public boolean isDeployed(URL url) {
try {
URL storedURL = store.get(url);
// if the stored url is not null then ask the target deployer
// else it is not deployed
return storedURL != null && deployer.isDeployed(url);
}
catch (Exception e) {
return false;
}
}
|
protected boolean isInvalid(URL orig,
URL stored) throws Exception {
boolean trace = log.isTraceEnabled();
long omod = orig.openConnection().getLastModified();
long smod = stored.openConnection().getLastModified();
if (trace) {
log.trace("Modfication times (orig, stored): " + omod + ", " + smod);
}
return omod > smod;
}
|
public void setDeployer(ObjectName deployerName) {
if (deployerName == null)
throw new NullArgumentException("deployerName");
deployer = (Deployer)
MBeanProxyExt.create(Deployer.class, deployerName, server);
}
|
public void setStore(ObjectName storeName) {
if (storeName == null)
throw new NullArgumentException("storeName");
store = (DeploymentStore)
MBeanProxyExt.create(DeploymentStore.class, storeName, server);
}
|
protected void startService() throws Exception {
if (deployer == null)
throw new MissingAttributeException("Deployer");
if (store == null)
throw new MissingAttributeException("Store");
// start stale deployemnt timer/scanner/whatever
}
|
protected void stopService() throws Exception {
// stop stale deployemnt timer/scanner/whatever
}
|
public void undeploy(URL url) throws DeploymentException {
boolean debug = log.isDebugEnabled();
try {
URL storedURL = store.get(url);
if (storedURL != null) {
// invoke undeploy on target deployer using local cache url
deployer.undeploy(storedURL);
}
else {
if (debug) {
log.debug("Not found in store; ignoring URL: " + url);
}
}
}
catch (Exception e) {
throw new DeploymentException(e);
}
}
|