/* ======================================================================= *
* .:;tjfLLffji, *
* :,itLDKW#########Kj, *
* .:ijLGEW########KEEKKW###Kf, *
* .,ifLGEK###########KDLfjjjffGE###Ei *
* .:,;tLDEW#######WKEDGLfLK##KLjjjjjjjjjjjE###Wt *
* :;jLDEK#######WKEDGLffjjjjjD###DjjjjjjjjjjjjLW###L. *
* .;jGK#########WDGLffjjjjjjjjjjjD###DjjjjjjjjjjjjLW###G: *
* GW###WKDDDDEK#####KDLjjjjjjjjjjjfK##WGfjjjjjjjjjjK###Ei *
* i###WDLfjjjjjfLKW#####EGLfjjjjjjjjLK##WEGfjjjjjfLD###Kt. *
* ;E##KLjjjjjjjjjjjfGEW#####KEGfjjjjjjfW####WEDDEEK###WG; *
* f##WLjjjjjjjjjjjjjjjfLDW#####WGfjjjjjGW############Gi. *
* .f##KLjjjjjjjjjjjjjjjjjjjfLDEW####WW########KGLft;,. *
* iK##EfjjjjjjjjjjjjjjjjjjjjjjfGK#######WGjt;: *
* .j###KGfjjjjjjjjjjjjjjjjjjjjjjfLDKW###WELt, *
* jE#####DLfjjjjjjjjjjjjjjjjjjjjjjjfLEW#####Gj,. *
* ,jGK####KEGfjjjjjjjjjjjjjjjjjjjjjjjfGEK####WDj; *
* ,tLW####WKLfjjjjjjjjjjjjjjjjjjjjjjjfLDW####WL *
* ;jGK####KEGfjjjjjjjjjjjjjjjjjjjjjjjfGEW###i *
* .,;itLDEK#########WGLfjjjjjjjjjjjjjjjjjjjjjfD##Wt *
* ,fGEKW#######WWEEEW#####KDLfjjjjjjjjjjjjjjjjjjjfK##G: *
* .iGK############ELjjjfGDK#####KEfjjjjjjjjjjjjjjjjjfE##G: *
* .fW###EGLffjfLDK####LjjjjjjfLDKW####WEGLfjjjjjjjjjjLK##Ki *
* .jW###EjjjjjjjjjfGW##KfjjjjjjjjjfGE######KGfjjjjjfLDW###t. *
* ;E###EfjjjjjjjjjjjGW##DjjjjjjjjjjjjLDKW####WEEEEEK####WG *
* tW###DjjjjjjjjjjjjfK##KfjjjjjjjjjjjjjfGE############KGi. *
* ;E###EfjjjjjjjjjjjGW##DjjjjfLGDEEKW########KEGLfj,. *
* .jW###EjjjjjjjjjfDW##WDGEEKK#######WKEDLfj;,. *
* .jK###EGffjjfLDK############WEDGLj;,:. *
* .;LK#############WDLft;,: *
* ,fGEKKKKEGfjt;,. *
* ,jjjji, *
* *
* Shocks Servlet Framework� *
* Copyright (c) 2003, NRFX Technologies LLC (www.nrfx.com) *
* All Rights Reserved. *
* *
* Licensed under the Academic Free License version 2.0; you may not use *
* this file except in compliance with the License. You may obtain a *
* copy of the License at http://www.opensource.org/licenses/afl-2.0.php *
* *
* Software distributed under the License is distributed on an "AS IS" *
* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express *
* or implied. See the License for the specific language governing *
* permissions and limitations under the License. *
* ======================================================================= */
package shocks.framework.action.repository;
import java.util.*;
import shocks.client.*;
import shocks.dawp.Action;
import shocks.dawp.DataSource;
import shocks.framework.action.*;
import org.apache.log4j.*;
public class CentralActionRepository implements
ActionRepository,
CentralActionRepositoryMBean {
private Map pools = new HashMap();
private Logger log = Logger.getLogger("Shocks][CAR");
public Action leaseAction(DataSource metadata) {
String type = (String)metadata.getAttribute("type");
if(type == "action") {
String className = (String)metadata.getAttribute("className");
if(pools.containsKey(className)){
Action action = pool(className).lease();
return pool(className).lease();
} else {
log.debug("no pool for " + className);
}
} else {
log.error("Can't use " + type + " metadata.");
}
return null;
}
public void release(Action instance) {
String className = ((ActionSupport)instance).getClassName();
pool(className).release(instance);
}
public void addAction(Action instance) {
String className = ((ActionSupport)instance).getClassName();
if(pools.containsKey(className)){
log.warn("A pool for " + className + " already exists.");
} else {
ActionInstancePool pool = new ActionInstancePool(instance);
pools.put(className, pool);
log.info("Loaded action, className = " + className);
}
}
private ActionInstancePool pool(String className) {
return (ActionInstancePool)pools.get(className);
}
}