KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > dispatcher > mapper > ActionMapperFactory


1 package com.opensymphony.webwork.dispatcher.mapper;
2
3 import com.opensymphony.webwork.config.Configuration;
4 import com.opensymphony.xwork.ObjectFactory;
5 import org.apache.commons.logging.Log;
6 import org.apache.commons.logging.LogFactory;
7
8 import java.util.HashMap JavaDoc;
9
10 /**
11  * User: plightbo
12  * Date: Jun 20, 2005
13  * Time: 6:56:45 PM
14  */

15 public class ActionMapperFactory {
16     protected static final Log LOG = LogFactory.getLog(ActionMapperFactory.class);
17
18     private static final HashMap JavaDoc classMap = new HashMap JavaDoc();
19
20     public static ActionMapper getMapper() {
21         synchronized (classMap) {
22             String JavaDoc clazz = (String JavaDoc) Configuration.get("webwork.mapper.class");
23             try {
24                 ActionMapper mapper = (ActionMapper) classMap.get(clazz);
25                 if (mapper == null) {
26                     mapper = (ActionMapper) ObjectFactory.getObjectFactory().buildBean(clazz);
27                     classMap.put(clazz, mapper);
28                 }
29
30                 return mapper;
31             } catch (Exception JavaDoc e) {
32                 String JavaDoc msg = "Could not creat ActionMapper: WebWork will *not* work!";
33                 LOG.fatal(msg, e);
34                 throw new RuntimeException JavaDoc(msg, e);
35             }
36         }
37     }
38 }
39
Popular Tags