*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
import org.springframework.context.access.ContextSingletonBeanFactoryLocator;
import org.wamblee.general.BeanFactory;
import org.wamblee.general.BeanFactoryException;
import org.springframework.context.access.ContextSingletonBeanFactoryLocator;
import org.wamblee.general.BeanFactory;
import org.wamblee.general.BeanFactoryException;
* it must tbe subclassed to provide a default constructor.
*/
public class SpringBeanFactory implements BeanFactory {
* it must tbe subclassed to provide a default constructor.
*/
public class SpringBeanFactory implements BeanFactory {
public SpringBeanFactory(String aSelector, String aFactoryName) {
try {
BeanFactoryLocator locator = ContextSingletonBeanFactoryLocator
public SpringBeanFactory(String aSelector, String aFactoryName) {
try {
BeanFactoryLocator locator = ContextSingletonBeanFactoryLocator
factoryReference = locator.useBeanFactory(aFactoryName);
} catch (BeansException e) {
throw new BeanFactoryException(
factoryReference = locator.useBeanFactory(aFactoryName);
} catch (BeansException e) {
throw new BeanFactoryException(
- "Could not load bean factory: selector = '" + aSelector
- + "', factory = '" + aFactoryName + "'", e);
+ "Could not load bean factory: selector = '" + aSelector +
+ "', factory = '" + aFactoryName + "'", e);
*/
public <T> T find(String aId, Class<T> aClass) {
try {
Object obj = factoryReference.getFactory().getBean(aId, aClass);
assert obj != null;
*/
public <T> T find(String aId, Class<T> aClass) {
try {
Object obj = factoryReference.getFactory().getBean(aId, aClass);
assert obj != null;
return aClass.cast(obj);
} catch (BeansException e) {
throw new BeanFactoryException(e.getMessage(), e);
}
}
return aClass.cast(obj);
} catch (BeansException e) {
throw new BeanFactoryException(e.getMessage(), e);
}
}
- public org.springframework.beans.factory.BeanFactory getSpringBeanFactory() {
- return factoryReference.getFactory();
+ public org.springframework.beans.factory.BeanFactory getSpringBeanFactory() {
+ return factoryReference.getFactory();