1 16 package org.apache.commons.attributes.test; 17 18 import org.apache.commons.attributes.Attributes; 19 import org.apache.commons.attributes.RuntimeAttributeRepository; 20 21 public class RuntimeSample extends SuperSample implements SampleIFJoin { 22 23 static { 24 try { 25 RuntimeAttributeRepository rar = new RuntimeAttributeRepository (RuntimeSample.class); 26 rar.addClassAttribute (new ThreadSafe ()); 27 rar.addClassAttribute (new Dependency ( SampleService.class, "sample" )); 28 29 rar.addFieldAttribute ("field", new ThreadSafe ()); 30 31 rar.addMethodAttribute ("someMethod", new Class []{}, new Dependency ( SampleService.class, "sample-some-method1" )); 32 33 rar.addParameterAttribute ("methodWithAttributes", new Class []{ Integer.TYPE, Integer.TYPE }, 1, new ThreadSafe ()); 34 rar.addReturnAttribute ("methodWithAttributes", new Class []{ Integer.TYPE, Integer.TYPE }, new Dependency ( SampleService.class, "sample-return" )); 35 36 rar.addMethodAttribute ("someMethod", new Class []{ Integer.TYPE }, new Dependency ( SampleService.class, "sample-some-method2" )); 37 38 BeanAttribute ba = new BeanAttribute (1, "a"); 39 ba.setAnotherNumber (56 - 14); 40 ba.setName ("Smith, John \"Agent\""); 41 rar.addMethodAttribute ("methodWithNamedParameters", new Class []{}, ba); 42 43 rar.addMethodAttribute ("privateMethod", new Class []{}, new Dependency ( SampleService.class, "sample-privateMethod" )); 44 45 Attributes.setAttributes (rar); 46 } catch (Exception e) { 47 throw new Error ("Unable to set attribute information: " + e.toString ()); 48 } 49 } 50 51 public Object field; 52 53 public Object noAttributesInSubClass; 54 55 public void someMethod () { 56 57 } 58 59 public Integer methodWithAttributes (int param1, int param2) { 60 return null; 61 } 62 63 public void someMethod (int parameter) { 64 65 } 66 67 public void methodWithNamedParameters () { 68 69 } 70 71 public void methodWithNoAttributes () { 72 } 73 74 private void privateMethod () { 75 } 76 77 public static class InnerSample { 78 static { 79 try { 80 RuntimeAttributeRepository rar = new RuntimeAttributeRepository (RuntimeSample.InnerSample.class); 81 rar.addClassAttribute (new Dependency ( SampleService.class, "inner-sample" )); 82 Attributes.setAttributes (rar); 83 } catch (Exception e) { 84 throw new Error ("Unable to set attribute information: " + e.toString ()); 85 } 86 } 87 } 88 } | Popular Tags |