1 15 package org.apache.examples.setters; 16 17 import java.io.IOException ; 18 import java.util.Collection ; 19 import java.util.List ; 20 import java.util.Properties ; 21 22 import org.apache.examples.Adder; 23 import org.apache.hivemind.Resource; 24 25 30 public class SetterService implements Runnable 31 { 32 private String _stringValue; 33 34 private int _intValue; 35 36 private double _doubleValue; 37 38 private Adder _adderService; 39 40 private List _configuration; 41 42 private Collection _container; 43 44 private Resource _textResource; 45 46 public void setAdderService(Adder adderService) 47 { 48 _adderService = adderService; 49 } 50 51 public void setConfiguration(List configuration) 52 { 53 _configuration = configuration; 54 } 55 56 public void setContainer(Collection container) 57 { 58 _container = container; 59 } 60 61 public void setDoubleValue(double doubleValue) 62 { 63 _doubleValue = doubleValue; 64 } 65 66 public void setIntValue(int intValue) 67 { 68 _intValue = intValue; 69 } 70 71 public void setStringValue(String stringValue) 72 { 73 _stringValue = stringValue; 74 } 75 76 public void setTextResource(Resource textResource) 77 { 78 _textResource = textResource; 79 } 80 81 public void run() 82 { 83 System.out.println("StringValue: " + _stringValue); 84 System.out.println("IntValue: " + _intValue); 85 System.out.println("DoubleValue: " + _doubleValue); 86 System.out.println("AdderService result: " + _adderService.add(10, 20)); 87 System.out.println("Configuration size: " + _configuration.size()); 88 System.out.println("Container type: " + _container.getClass().getName()); 89 Properties properties = loadResource(); 90 System.out.println("Text resource content: " + properties.toString()); 91 } 92 93 96 private Properties loadResource() 97 { 98 Properties properties = new Properties (); 99 try 100 { 101 properties.load(_textResource.getResourceURL().openStream()); 102 } 103 catch (IOException ignore) 104 { 105 } 106 return properties; 107 } 108 } 109 | Popular Tags |