1 package rydeen.spi;
2
3 import rydeen.Arguments;
4 import rydeen.Processor;
5 import rydeen.ProcessorBuildException;
6 import rydeen.utils.Author;
7 import rydeen.utils.Organization;
8 import rydeen.utils.Provider;
9
10
11
12
13
14
15 public abstract class AbstractProcessorService implements ProcessorService{
16 private Arguments args;
17 private Provider provider;
18
19
20
21
22 protected AbstractProcessorService(){
23 args = createDefaultArguments();
24 provider = createProvider();
25 }
26
27
28
29
30
31
32
33 protected abstract Arguments createDefaultArguments();
34
35
36
37
38
39
40
41 protected abstract Provider createProvider();
42
43
44
45
46
47 protected abstract Processor createProcessor() throws ProcessorBuildException;
48
49 @Override
50 public final Author[] getAuthors(){
51 Provider provider = getProvider();
52 if(provider != null){
53 return provider.getAuthors();
54 }
55 return new Author[0];
56 }
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74 @Override
75 public final Arguments getDefaultArguments(){
76 return new Arguments(args);
77 }
78
79
80
81
82 @Override
83 public abstract String getDescription();
84
85
86
87
88
89
90 @Override
91 public final Organization getOrganization(){
92 Provider provider = getProvider();
93 if(provider != null){
94 return provider.getOrganization();
95 }
96 return null;
97 }
98
99
100
101
102
103 @Override
104 public final Processor getProcessor() throws ProcessorBuildException{
105 Processor processor = createProcessor();
106 if(processor == null){
107 throw new ProcessorBuildException();
108 }
109
110 return processor;
111 }
112
113
114
115
116 @Override
117 public abstract String getProcessorName();
118
119
120
121
122
123 @Override
124 public final Provider getProvider(){
125 return provider;
126 }
127 }