KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > config > schema > test > LockConfigBuilderImpl


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.config.schema.test;
5
6 import com.tc.config.schema.builder.LockConfigBuilder;
7 import com.tc.util.Assert;
8
9 /**
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 LockConfigBuilder {
14
15   private final String JavaDoc tag;
16
17   public LockConfigBuilderImpl(String JavaDoc tag, Class JavaDoc clazz, String JavaDoc lockLevel) {
18     this(tag);
19     setMethodExpression("* " + clazz.getName() + ".*(..)");
20     setLockLevel(lockLevel);
21   }
22   
23   public LockConfigBuilderImpl(String JavaDoc tag) {
24     super(4, ALL_PROPERTIES);
25
26     Assert.assertNotBlank(tag);
27     this.tag = tag;
28   }
29
30   public void setLockName(String JavaDoc value) {
31     setProperty("lock-name", value);
32   }
33
34   public void setMethodExpression(String JavaDoc value) {
35     setProperty("method-expression", value);
36   }
37
38   public void setLockLevel(String JavaDoc value) {
39     setProperty("lock-level", value);
40   }
41
42   public void setLockName(int value) {
43     setProperty("lock-name", value);
44   }
45
46   private static final String JavaDoc[] ALL_PROPERTIES = new String JavaDoc[] { "lock-name", "method-expression", "lock-level" };
47
48   public String JavaDoc toString() {
49     return openElement(this.tag) + elements(ALL_PROPERTIES) + closeElement(this.tag);
50   }
51
52 }
53
Popular Tags