1 4 package com.tc.object.config; 5 6 import com.tc.config.schema.builder.ConfigBuilderFactory; 7 import com.tc.config.schema.builder.DSOApplicationConfigBuilder; 8 import com.tc.config.schema.builder.InstrumentedClassConfigBuilder; 9 import com.tc.config.schema.builder.LockConfigBuilder; 10 import com.tc.config.schema.builder.RootConfigBuilder; 11 12 import java.util.LinkedList ; 13 import java.util.List ; 14 15 22 public class DSOApplicationConfigImpl implements DSOApplicationConfig { 23 24 private final ConfigBuilderFactory factory; 25 private final List roots = new LinkedList (); 26 private final List instrumentedClasses = new LinkedList (); 27 private final List locks = new LinkedList (); 28 29 public DSOApplicationConfigImpl(ConfigBuilderFactory factory) { 30 this.factory = factory; 31 } 32 33 public void writeTo(DSOApplicationConfigBuilder builder) { 34 if (!roots.isEmpty()) { 35 builder.setRoots((RootConfigBuilder[]) roots.toArray(new RootConfigBuilder[roots.size()])); 36 } 37 builder.setInstrumentedClasses((InstrumentedClassConfigBuilder[]) instrumentedClasses 38 .toArray(new InstrumentedClassConfigBuilder[instrumentedClasses.size()])); 39 builder.setLocks((LockConfigBuilder[]) locks.toArray(new LockConfigBuilder[locks.size()])); 40 } 41 42 public void addRoot(String rootName, String rootFieldName) { 43 RootConfigBuilder root = factory.newRootConfigBuilder(); 44 root.setRootName(rootName); 45 root.setFieldName(rootFieldName); 46 roots.add(root); 47 } 48 49 public void addIncludePattern(String classPattern) { 50 addIncludePattern(classPattern, false); 51 } 52 53 public void addIncludePattern(String classPattern, boolean honorTransient) { 54 InstrumentedClassConfigBuilder instrumentedClass = factory.newInstrumentedClassConfigBuilder(); 55 instrumentedClass.setClassExpression(classPattern); 56 instrumentedClass.setHonorTransient(honorTransient); 57 addInstrumentedClass(instrumentedClass); 58 } 59 60 private void addInstrumentedClass(InstrumentedClassConfigBuilder instrumentedClass) { 61 instrumentedClasses.add(instrumentedClass); 62 } 63 64 public void addWriteAutolock(String methodPattern) { 65 LockConfigBuilder lock = factory.newWriteAutoLockConfigBuilder(); 66 lock.setMethodExpression(methodPattern); 67 locks.add(lock); 68 } 69 70 public void addReadAutolock(String methodPattern) { 71 LockConfigBuilder lock = factory.newReadAutoLockConfigBuilder(); 72 lock.setMethodExpression(methodPattern); 73 locks.add(lock); 74 } 75 76 } 77 | Popular Tags |