1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
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 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
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 |
1
| public void setAdderService(Adder adderService)
|
47 |
| { |
48 |
1
| _adderService = adderService;
|
49 |
| } |
50 |
| |
51 |
1
| public void setConfiguration(List configuration)
|
52 |
| { |
53 |
1
| _configuration = configuration;
|
54 |
| } |
55 |
| |
56 |
1
| public void setContainer(Collection container)
|
57 |
| { |
58 |
1
| _container = container;
|
59 |
| } |
60 |
| |
61 |
1
| public void setDoubleValue(double doubleValue)
|
62 |
| { |
63 |
1
| _doubleValue = doubleValue;
|
64 |
| } |
65 |
| |
66 |
1
| public void setIntValue(int intValue)
|
67 |
| { |
68 |
1
| _intValue = intValue;
|
69 |
| } |
70 |
| |
71 |
1
| public void setStringValue(String stringValue)
|
72 |
| { |
73 |
1
| _stringValue = stringValue;
|
74 |
| } |
75 |
| |
76 |
1
| public void setTextResource(Resource textResource)
|
77 |
| { |
78 |
1
| _textResource = textResource;
|
79 |
| } |
80 |
| |
81 |
1
| public void run()
|
82 |
| { |
83 |
1
| System.out.println("StringValue: " + _stringValue);
|
84 |
1
| System.out.println("IntValue: " + _intValue);
|
85 |
1
| System.out.println("DoubleValue: " + _doubleValue);
|
86 |
1
| System.out.println("AdderService result: " + _adderService.add(10, 20));
|
87 |
1
| System.out.println("Configuration size: " + _configuration.size());
|
88 |
1
| System.out.println("Container type: " + _container.getClass().getName());
|
89 |
1
| Properties properties = loadResource();
|
90 |
1
| System.out.println("Text resource content: " + properties.toString());
|
91 |
| } |
92 |
| |
93 |
| |
94 |
| |
95 |
| |
96 |
1
| private Properties loadResource()
|
97 |
| { |
98 |
1
| Properties properties = new Properties();
|
99 |
1
| try
|
100 |
| { |
101 |
1
| properties.load(_textResource.getResourceURL().openStream());
|
102 |
| } |
103 |
| catch (IOException ignore) |
104 |
| { |
105 |
| } |
106 |
1
| return properties;
|
107 |
| } |
108 |
| } |