001: /*
002: * Created on 08-Apr-2005
003: *
004: */
005: package com.jofti.config;
006:
007: import java.util.List;
008: import java.util.Map;
009: import java.util.Properties;
010:
011: import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
012:
013: /**
014:
015: *
016: * A convenience class for use in the addIndex method. The default config already has the default entries
017: * in each of the configuration properties. The only thing not present are any class mappings - so
018: * no changes to this object will result in only the built-in types being indexed.<p>
019: *
020: The settings are:
021: <ul>
022: <li>name: default
023: <li>adapter: com.jofti.cache.adapter.MapAdapter
024: <li>parserType: com.jofti.introspect.JavaBeanClassIntrospector
025: <li>indexType: com.jofti.tree.TreeIndex
026: <li>ClassMappings: [ ]
027: <li>queryMappings: [ ]
028: <li>adapterProperties: [ ]
029: </ul>
030: *
031: *
032: *
033: * @author Steve Woodcock (steve@jofti.com)<p>
034: * @version 1.0
035: */
036: public class DefaultIndexConfig implements IndexConfig {
037:
038: //set up the default values
039:
040: private String name = "default";
041:
042: private String cacheAdapter = "com.jofti.cache.adapter.MapAdapter";
043:
044: private String indexType = "com.jofti.tree.TreeIndex";
045:
046: private String parserType = "com.jofti.introspect.JavaBeanClassIntrospector";
047:
048: private Map classMappings = new ConcurrentHashMap();
049:
050: private Map queryMappings = new ConcurrentHashMap();
051:
052: private boolean lazyLoaded = false;
053:
054: private Properties adapterProperties;
055:
056: private Properties indexProperties = new Properties();
057:
058: public DefaultIndexConfig() {
059:
060: }
061:
062: /* (non-Javadoc)
063: * @see com.jofti.config.IndexConfig#getName()
064: */
065: public String getName() {
066: return name;
067: }
068:
069: /* (non-Javadoc)
070: * @see com.jofti.conf.CacheConfig#getCacheAdapter()
071: */
072: public String getCacheAdapter() {
073: return cacheAdapter;
074: }
075:
076: /* (non-Javadoc)
077: * @see com.jofti.conf.CacheConfig#getIndexMappings()
078: */
079: public Map getIndexMappings() {
080: return classMappings;
081: }
082:
083: /* (non-Javadoc)
084: * @see com.jofti.config.IndexConfig#addMapping(java.lang.String, java.util.List)
085: */
086: public void addMapping(String clazz, List propertyList) {
087:
088: classMappings.put(clazz, propertyList);
089: }
090:
091: /* (non-Javadoc)
092: * @see com.jofti.config.IndexConfig#addQuery(java.lang.String, java.lang.String)
093: */
094: public void addQuery(String name, String query) {
095:
096: queryMappings.put(name, query);
097: }
098:
099: /**
100: * @param cacheAdapter The cacheAdapter to set.
101: */
102: public void setCacheAdapter(String cacheAdapter) {
103: this .cacheAdapter = cacheAdapter;
104: }
105:
106: /**
107: * @param indexType The indexType to set.
108: */
109: public void setIndexType(String indexType) {
110: this .indexType = indexType;
111: }
112:
113: /**
114: * @param name The name to set.
115: */
116: public void setName(String name) {
117: this .name = name;
118: }
119:
120: /**
121: * @return Returns the classMappings.
122: */
123: public Map getClassMappings() {
124: return classMappings;
125: }
126:
127: /**
128: * @return Returns the queryMappings.
129: */
130: public Map getQueryMappings() {
131: return queryMappings;
132: }
133:
134: /**
135: * @return Returns the indexType.
136: */
137: public String getIndexType() {
138: return indexType;
139: }
140:
141: /**
142: * @return Returns the lazyLoaded.
143: */
144: public boolean isLazyLoaded() {
145: return lazyLoaded;
146: }
147:
148: /**
149: * @param lazyLoaded The lazyLoaded to set.
150: */
151: public void setLazyLoaded(boolean lazyLoaded) {
152: this .lazyLoaded = lazyLoaded;
153: }
154:
155: /**
156: * @return Returns the adapterProperties.
157: */
158: public Properties getAdapterProperties() {
159: return adapterProperties;
160: }
161:
162: /**
163: * @param adapterProperties The adapterProperties to set.
164: */
165: public void setAdapterProperties(Properties adapterProperties) {
166: this .adapterProperties = adapterProperties;
167: }
168:
169: /* (non-Javadoc)
170: * @see com.jofti.config.IndexConfig#getParserType()
171: */
172: public String getParserType() {
173: return parserType;
174: }
175:
176: /**
177: * @param parserType The parserType to set.
178: */
179: public void setParserType(String parserType) {
180: this .parserType = parserType;
181: }
182:
183: /* (non-Javadoc)
184: * @see com.jofti.config.IndexConfig#getPersistenceProperties()
185: */
186: public Properties getIndexProperties() {
187:
188: return indexProperties;
189: }
190:
191: public synchronized void setIndexProperties(
192: Properties indexProperties) {
193: this.indexProperties = indexProperties;
194: }
195:
196: }
|