|
|||||||||||||||||||
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 | |||||||||||||||
SpringLookupFactory.java | 100% | 100% | 100% | 100% |
|
1 |
// Copyright 2004, 2005 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.lib.impl;
|
|
16 |
|
|
17 |
import org.apache.hivemind.ServiceImplementationFactory;
|
|
18 |
import org.apache.hivemind.ServiceImplementationFactoryParameters;
|
|
19 |
import org.apache.hivemind.impl.BaseLocatable;
|
|
20 |
import org.springframework.beans.factory.BeanFactory;
|
|
21 |
|
|
22 |
/**
|
|
23 |
* Implementation of {@link org.apache.hivemind.ServiceImplementationFactory}that doesn't create
|
|
24 |
* beans, but instead it looks them up inside a Spring
|
|
25 |
* {@link org.springframework.beans.factory.BeanFactory}.
|
|
26 |
*
|
|
27 |
* @author Howard Lewis Ship
|
|
28 |
*/
|
|
29 |
public class SpringLookupFactory extends BaseLocatable implements ServiceImplementationFactory |
|
30 |
{ |
|
31 |
/** @since 1.1 */
|
|
32 |
private BeanFactory _defaultBeanFactory;
|
|
33 |
|
|
34 | 3 |
public Object createCoreServiceImplementation(
|
35 |
ServiceImplementationFactoryParameters factoryParameters) |
|
36 |
{ |
|
37 | 3 |
SpringBeanParameter p = (SpringBeanParameter) factoryParameters.getParameters().get(0); |
38 |
|
|
39 | 3 |
String beanName = p.getName(); |
40 |
|
|
41 | 3 |
BeanFactory f = p.getBeanFactory(); |
42 |
|
|
43 | 3 |
if (f == null) |
44 | 2 |
f = _defaultBeanFactory; |
45 |
|
|
46 | 3 |
return f.getBean(beanName, factoryParameters.getServiceInterface());
|
47 |
} |
|
48 |
|
|
49 |
/** @since 1.1 */
|
|
50 | 2 |
public void setDefaultBeanFactory(BeanFactory defaultBeanFactory) |
51 |
{ |
|
52 | 2 |
_defaultBeanFactory = defaultBeanFactory; |
53 |
} |
|
54 |
} |
|