|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
BuilderFactory.java | - | 100% | 100% | 100% |
|
1 |
// Copyright 2004 The Apache Software Foundation
|
|
2 |
//
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
5 |
// You may obtain a copy of the License at
|
|
6 |
//
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8 |
//
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12 |
// See the License for the specific language governing permissions and
|
|
13 |
// limitations under the License.
|
|
14 |
|
|
15 |
package org.apache.hivemind.service.impl;
|
|
16 |
|
|
17 |
import java.util.List;
|
|
18 |
|
|
19 |
import org.apache.commons.logging.LogFactory;
|
|
20 |
import org.apache.hivemind.HiveMind;
|
|
21 |
import org.apache.hivemind.ServiceImplementationFactory;
|
|
22 |
import org.apache.hivemind.internal.Module;
|
|
23 |
|
|
24 |
/**
|
|
25 |
* Implementation of {@link org.apache.hivemind.ServiceImplementationFactory}
|
|
26 |
* that can instantiate an object and then configure its properties.
|
|
27 |
*
|
|
28 |
* <p>
|
|
29 |
* Some thought has been given to using bytecode generation to create properties
|
|
30 |
* for messages, extension point id, and so forth. This is being avoided because it
|
|
31 |
* undermines the ability to test service implemenations as POJOs, outside the
|
|
32 |
* framework of HiveMind.
|
|
33 |
*
|
|
34 |
* <p>
|
|
35 |
* Instead the service is configured by means of the implementation's
|
|
36 |
* constructor and setter methods.
|
|
37 |
*
|
|
38 |
* @author Howard Lewis Ship
|
|
39 |
*/
|
|
40 |
public class BuilderFactory implements ServiceImplementationFactory |
|
41 |
{ |
|
42 |
private static final String POINT_ID = "hivemind.BuilderFactory"; |
|
43 |
|
|
44 | 233 |
public Object createCoreServiceImplementation(
|
45 |
String serviceId, |
|
46 |
Class serviceInterface, |
|
47 |
Module invokingModule, |
|
48 |
List parameters) |
|
49 |
{ |
|
50 | 233 |
HiveMind.checkFactoryParameterCount(POINT_ID, parameters, 1); |
51 |
|
|
52 | 233 |
BuilderParameter parameter = (BuilderParameter) parameters.get(0); |
53 |
|
|
54 |
// Hm. Ideally, either the ServicePoint should pass in the Log instance, or
|
|
55 |
// the ServicePoint itself should be passed in --- this duplicates (trivial)
|
|
56 |
// logic inside AbstractServicePoint.
|
|
57 |
|
|
58 | 233 |
BuilderFactoryLogic logic = |
59 |
new BuilderFactoryLogic(
|
|
60 |
invokingModule, |
|
61 |
LogFactory.getLog(serviceId), |
|
62 |
serviceId, |
|
63 |
parameter); |
|
64 |
|
|
65 | 233 |
return logic.createService();
|
66 |
} |
|
67 |
} |
|
68 |
|
|