1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.services.impl; |
16 |
| |
17 |
| import org.apache.hivemind.ApplicationRuntimeException; |
18 |
| import org.apache.hivemind.ServiceImplementationFactory; |
19 |
| import org.apache.hivemind.ServiceImplementationFactoryParameters; |
20 |
| import org.apache.hivemind.lib.DefaultImplementationBuilder; |
21 |
| import org.apache.tapestry.spec.IApplicationSpecification; |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| public class ExtensionLookupFactory implements ServiceImplementationFactory |
36 |
| { |
37 |
| private IApplicationSpecification _specification; |
38 |
| |
39 |
| private DefaultImplementationBuilder _defaultBuilder; |
40 |
| |
41 |
87
| public Object createCoreServiceImplementation(
|
42 |
| ServiceImplementationFactoryParameters factorParameters) |
43 |
| { |
44 |
87
| ExtensionLookupParameter p = (ExtensionLookupParameter) factorParameters.getParameters()
|
45 |
| .get(0); |
46 |
| |
47 |
87
| String extensionName = p.getExtensionName();
|
48 |
| |
49 |
87
| Class serviceInterface = factorParameters.getServiceInterface();
|
50 |
| |
51 |
87
| try
|
52 |
| { |
53 |
87
| if (_specification.checkExtension(extensionName))
|
54 |
1
| return _specification.getExtension(extensionName, serviceInterface);
|
55 |
| |
56 |
85
| if (p.getDefault() != null)
|
57 |
42
| return p.getDefault();
|
58 |
| |
59 |
43
| return _defaultBuilder.buildDefaultImplementation(serviceInterface);
|
60 |
| } |
61 |
| catch (Exception ex) |
62 |
| { |
63 |
1
| throw new ApplicationRuntimeException(ex.getMessage(), p.getLocation(), ex);
|
64 |
| } |
65 |
| } |
66 |
| |
67 |
42
| public void setDefaultBuilder(DefaultImplementationBuilder builder)
|
68 |
| { |
69 |
42
| _defaultBuilder = builder;
|
70 |
| } |
71 |
| |
72 |
44
| public void setSpecification(IApplicationSpecification specification)
|
73 |
| { |
74 |
44
| _specification = specification;
|
75 |
| } |
76 |
| |
77 |
| } |