01: /*******************************************************************************
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: *******************************************************************************/package org.ofbiz.entity.config;
19:
20: import java.util.HashMap;
21: import java.util.Iterator;
22: import java.util.List;
23: import java.util.Map;
24:
25: import org.ofbiz.base.util.UtilValidate;
26: import org.ofbiz.base.util.UtilXml;
27: import org.w3c.dom.Element;
28:
29: /**
30: * Misc. utility method for dealing with the entityengine.xml file
31: *
32: */
33: public class DelegatorInfo extends NamedInfo {
34:
35: public String entityModelReader;
36: public String entityGroupReader;
37: public String entityEcaReader;
38: public boolean useEntityEca;
39: public String entityEcaHandlerClassName;
40: public boolean useDistributedCacheClear;
41: public String distributedCacheClearClassName;
42: public String distributedCacheClearUserLoginId;
43: public String sequencedIdPrefix;
44: public Map groupMap = new HashMap();
45:
46: public DelegatorInfo(Element element) {
47: super (element);
48: this .entityModelReader = element
49: .getAttribute("entity-model-reader");
50: this .entityGroupReader = element
51: .getAttribute("entity-group-reader");
52: this .entityEcaReader = element
53: .getAttribute("entity-eca-reader");
54:
55: // this defaults to true, ie anything but false is true
56: this .useEntityEca = !"false".equalsIgnoreCase(element
57: .getAttribute("entity-eca-enabled"));
58: this .entityEcaHandlerClassName = element
59: .getAttribute("entity-eca-handler-class-name");
60:
61: // this defaults to false, ie anything but true is false
62: this .useDistributedCacheClear = "true".equalsIgnoreCase(element
63: .getAttribute("distributed-cache-clear-enabled"));
64: this .distributedCacheClearClassName = element
65: .getAttribute("distributed-cache-clear-class-name");
66: if (UtilValidate.isEmpty(this .distributedCacheClearClassName))
67: this .distributedCacheClearClassName = "org.ofbiz.entityext.cache.EntityCacheServices";
68:
69: this .distributedCacheClearUserLoginId = element
70: .getAttribute("distributed-cache-clear-user-login-id");
71: if (UtilValidate.isEmpty(this .distributedCacheClearUserLoginId))
72: this .distributedCacheClearUserLoginId = "admin";
73:
74: this .sequencedIdPrefix = element
75: .getAttribute("sequenced-id-prefix");
76:
77: List groupMapList = UtilXml.childElementList(element,
78: "group-map");
79: Iterator groupMapIter = groupMapList.iterator();
80:
81: while (groupMapIter.hasNext()) {
82: Element groupMapElement = (Element) groupMapIter.next();
83: groupMap.put(groupMapElement.getAttribute("group-name"),
84: groupMapElement.getAttribute("datasource-name"));
85: }
86: }
87: }
|