01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.jca.context;
18:
19: import javax.resource.spi.BootstrapContext;
20:
21: import org.springframework.beans.BeansException;
22: import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
23: import org.springframework.context.support.GenericApplicationContext;
24:
25: /**
26: * {@link org.springframework.context.ApplicationContext} implementation
27: * for a JCA ResourceAdapter. Needs to be initialized with the JCA
28: * {@link javax.resource.spi.BootstrapContext}, passing it on to
29: * Spring-managed beans that implement {@link BootstrapContextAware}.
30: *
31: * @author Juergen Hoeller
32: * @since 2.5
33: * @see SpringContextResourceAdapter
34: * @see BootstrapContextAware
35: */
36: public class ResourceAdapterApplicationContext extends
37: GenericApplicationContext {
38:
39: private final BootstrapContext bootstrapContext;
40:
41: /**
42: * Create a new ResourceAdapterApplicationContext for the given BootstrapContext.
43: * @param bootstrapContext the JCA BootstrapContext that the ResourceAdapter
44: * has been started with
45: */
46: public ResourceAdapterApplicationContext(
47: BootstrapContext bootstrapContext) {
48: this .bootstrapContext = bootstrapContext;
49: }
50:
51: protected void postProcessBeanFactory(
52: ConfigurableListableBeanFactory beanFactory)
53: throws BeansException {
54: beanFactory
55: .addBeanPostProcessor(new BootstrapContextAwareProcessor(
56: this .bootstrapContext));
57: beanFactory
58: .ignoreDependencyInterface(BootstrapContextAware.class);
59: }
60:
61: }
|