|
1 |
| package com.agical.rdoc.core.service.impl; |
|
2 |
| |
|
3 |
| import com.agical.rdoc.core.TDDocService; |
|
4 |
| import com.agical.rdoc.core.model.SourceModelProvider; |
|
5 |
| import com.agical.rdoc.core.model.TextFormatter; |
|
6 |
| import com.agical.rdoc.core.model.impl.XmlCodeFormatter; |
|
7 |
| import com.agical.rdoc.core.service.code.Type; |
|
8 |
| import com.agical.rdoc.core.service.code.TypeFactory; |
|
9 |
| import com.agical.rdoc.core.service.code.impl.FlyweightTypeFactory; |
|
10 |
| import com.agical.rmock.core.util.ReflectionUtils; |
|
11 |
| |
|
12 |
| public class Code extends TDDocService { |
|
13 |
| private ReflectionUtils reflectionUtils = new ReflectionUtils(); |
|
14 |
| private TypeFactory typeFactory = TypeFactory.NULL; |
|
15 |
| private TextFormatter textFormatter; |
|
16 |
| private SourceModelProvider sourceModelProvider; |
|
17 |
| |
|
18 |
3
| public Type byName(String type) {
|
|
19 |
3
| return getTypeFactory().create(reflectionUtils.classForName(type));
|
|
20 |
| } |
|
21 |
| |
|
22 |
3
| private synchronized TypeFactory getTypeFactory() {
|
|
23 |
3
| if (typeFactory == TypeFactory.NULL) {
|
|
24 |
3
| typeFactory = new FlyweightTypeFactory(new XmlCodeFormatter(textFormatter), sourceModelProvider);
|
|
25 |
| } |
|
26 |
3
| return typeFactory;
|
|
27 |
| } |
|
28 |
| |
|
29 |
20
| public void setTextFormatter(TextFormatter textFormatter) {
|
|
30 |
20
| this.textFormatter = textFormatter;
|
|
31 |
| } |
|
32 |
| |
|
33 |
1
| public void setSourceModelProvider(SourceModelProvider sourceModelProvider) {
|
|
34 |
1
| this.sourceModelProvider = sourceModelProvider;
|
|
35 |
| } |
|
36 |
| |
|
37 |
| } |