Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.
*/
package org.springframework.ejb.interceptor;
import java.util.Map;
import java.util.WeakHashMap;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ejb.EJBException;
import javax.ejb.PostActivate;
import javax.ejb.PrePassivate;
import javax.interceptor.InvocationContext;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.access.BeanFactoryLocator;
import org.springframework.beans.factory.access.BeanFactoryReference;
import org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.access.ContextSingletonBeanFactoryLocator;
/**
* EJB3-compliant interceptor class that injects Spring beans into
* fields and methods which are annotated with {@code @Autowired}.
* Performs injection after construction as well as after activation
* of a passivated bean.
*
*
To be applied through an {@code @Interceptors} annotation in
* the EJB Session Bean or Message-Driven Bean class, or through an
* {@code interceptor-binding} XML element in the EJB deployment descriptor.
*
*
Delegates to Spring's {@link AutowiredAnnotationBeanPostProcessor}
* underneath, allowing for customization of its specific settings through
* overriding the {@link #configureBeanPostProcessor} template method.
*
*
The actual BeanFactory to obtain Spring beans from is determined
* by the {@link #getBeanFactory} template method. The default implementation
* obtains the Spring {@link ContextSingletonBeanFactoryLocator}, initialized
* from the default resource location classpath*:beanRefContext.xml,
* and obtains the single ApplicationContext defined there.
*
*
NOTE: If you have more than one shared ApplicationContext definition available
* in your EJB class loader, you need to override the {@link #getBeanFactoryLocatorKey}
* method and provide a specific locator key for each autowired EJB.
* Alternatively, override the {@link #getBeanFactory} template method and
* obtain the target factory explicitly.
*
*
WARNING: Do not define the same bean as Spring-managed bean and as
* EJB3 session bean in the same deployment unit. In particular, be
* careful when using the {@code } feature
* in combination with the deployment of Spring-based EJB3 session beans:
* Make sure that the EJB3 session beans are not autodetected as
* Spring-managed beans as well, using appropriate package restrictions.
*
* @author Juergen Hoeller
* @since 2.5.1
* @see org.springframework.beans.factory.annotation.Autowired
* @see org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor
* @see org.springframework.context.access.ContextSingletonBeanFactoryLocator
* @see #getBeanFactoryLocatorKey
*/
public class SpringBeanAutowiringInterceptor {
/*
* We're keeping the BeanFactoryReference per target object in order to
* allow for using a shared interceptor instance on pooled target beans.
* This is not strictly necessary for EJB3 Session Beans and Message-Driven
* Beans, where interceptor instances get created per target bean instance.
* It simply protects against future usage of the interceptor in a shared scenario.
*/
private final Map