01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.config.schema.test;
05:
06: import com.tc.config.schema.builder.LockConfigBuilder;
07: import com.tc.util.Assert;
08:
09: /**
10: * Allows you to build valid config for a lock. This class <strong>MUST NOT</strong> invoke the actual XML beans to do
11: * its work; one of its purposes is, in fact, to test that those beans are set up correctly.
12: */
13: public class LockConfigBuilderImpl extends BaseConfigBuilder implements
14: LockConfigBuilder {
15:
16: private final String tag;
17:
18: public LockConfigBuilderImpl(String tag, Class clazz,
19: String lockLevel) {
20: this (tag);
21: setMethodExpression("* " + clazz.getName() + ".*(..)");
22: setLockLevel(lockLevel);
23: }
24:
25: public LockConfigBuilderImpl(String tag) {
26: super (4, ALL_PROPERTIES);
27:
28: Assert.assertNotBlank(tag);
29: this .tag = tag;
30: }
31:
32: public void setLockName(String value) {
33: setProperty("lock-name", value);
34: }
35:
36: public void setMethodExpression(String value) {
37: setProperty("method-expression", value);
38: }
39:
40: public void setLockLevel(String value) {
41: setProperty("lock-level", value);
42: }
43:
44: public void setLockName(int value) {
45: setProperty("lock-name", value);
46: }
47:
48: private static final String[] ALL_PROPERTIES = new String[] {
49: "lock-name", "method-expression", "lock-level" };
50:
51: public String toString() {
52: return openElement(this.tag) + elements(ALL_PROPERTIES)
53: + closeElement(this.tag);
54: }
55:
56: }
|