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.
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.aop.microcontainer.integration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import org.jboss.aop.Advisor;
import org.jboss.aop.AspectManager;
import org.jboss.aop.ReflectiveAspectBinder;
import org.jboss.aop.advice.AspectDefinition;
import org.jboss.aop.microcontainer.beans.AspectManagerFactory;
import org.jboss.aop.microcontainer.beans.ManagedAspectDefinition;
import org.jboss.aop.microcontainer.lifecycle.LifecycleCallbackDefinition;
import org.jboss.aop.microcontainer.annotations.DisabledType;
import org.jboss.aop.proxy.container.ContainerCache;
import org.jboss.aop.util.Advisable;
import org.jboss.aop.util.ClassInfoMethodHashing;
import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.beans.metadata.api.annotations.Dependency;
import org.jboss.dependency.spi.ControllerState;
import org.jboss.kernel.spi.dependency.DependencyBuilderListItem;
import org.jboss.kernel.spi.dependency.helpers.AbstractDependencyBuilder;
import org.jboss.metadata.spi.MetaData;
import org.jboss.metadata.spi.signature.MethodSignature;
import org.jboss.reflect.plugins.AnnotationValueFactory;
import org.jboss.reflect.plugins.introspection.IntrospectionAnnotationHelper;
import org.jboss.reflect.spi.AnnotationInfo;
import org.jboss.reflect.spi.AnnotationValue;
import org.jboss.reflect.spi.ArrayInfo;
import org.jboss.reflect.spi.ArrayValue;
import org.jboss.reflect.spi.ClassInfo;
import org.jboss.reflect.spi.MethodInfo;
import org.jboss.reflect.spi.StringValue;
import org.jboss.reflect.spi.TypeInfo;
import org.jboss.reflect.spi.Value;
/**
* Finds all managed aspects that apply
* to the bean and includes their dependencies as dependencies of the bean
*
* @author Kabir Khan
* @author Adrian Brock
* @author Ales Justin
* @version $Revision: 89243 $
*/
public class AOPDependencyBuilder extends AbstractDependencyBuilder
{
private static final String DEPENDENCY_CLASS_NAME = Dependency.class.getName();
private static final String DEPENDENCY_NAME_ATTRIBUTE = "name";
private static final IntrospectionAnnotationHelper helper = new IntrospectionAnnotationHelper();
/**
* Should we bypass AOP.
*
* @param beanInfo the bean info
* @param metaData the metadata instance
* @param disabledType The type we want to check if is disabled
* @return true if we should bypass aop, false otherwise
*/
protected boolean bypassAOP(BeanInfo beanInfo, MetaData metaData, DisabledType disabledType)
{
return DisableAOPHelper.isAOPDisabled(metaData, disabledType);
}
@SuppressWarnings({"unchecked", "deprecation"})
@Override
public List getDependencies(BeanInfo beanInfo, MetaData metaData)
{
if (bypassAOP(beanInfo, metaData, DisabledType.ALL))
{
return super.getDependencies(beanInfo, metaData);
}
AspectManager manager = AspectManagerFactory.getAspectManager(metaData);
try
{
ClassInfo classInfo = beanInfo.getClassInfo();
String className = classInfo.getName();
if (className != null)
{
ClassLoader loader = classInfo.getType().getClassLoader();
if (loader == null)
{
loader = Thread.currentThread().getContextClassLoader();
}
Class> clazz = loader.loadClass(className);
Advisor advisor;
synchronized (ContainerCache.mapLock)
{
ContainerCache cache = ContainerCache.initialise(manager, clazz, metaData, true);
advisor = cache.getAdvisor();
}
ReflectiveAspectBinder binder = new ReflectiveAspectBinder(clazz, advisor);
ArrayList depends = new ArrayList();
if (bypassAOP(beanInfo, metaData, DisabledType.POINTCUTS) == false)
{
Set aspects = binder.getAspects();
if (aspects != null && aspects.size() > 0)
{
Iterator it = aspects.iterator();
while (it.hasNext())
{
AspectDefinition def = (AspectDefinition) it.next();
if (def instanceof ManagedAspectDefinition)
{
String name = ((ManagedAspectDefinition)def).getDependentAspectName();
if (name != null)
{
depends.add(new AspectDependencyBuilderListItem(name));
}
}
}
}
}
if (bypassAOP(beanInfo, metaData, DisabledType.LIFECYCLE) == false)
{
Map