Java Code Examples for org.aspectj.lang.reflect.PerClauseKind#SINGLETON
The following examples show how to use
org.aspectj.lang.reflect.PerClauseKind#SINGLETON .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AspectJProxyFactory.java From spring-analysis-note with MIT License | 6 votes |
/** * Create a {@link MetadataAwareAspectInstanceFactory} for the supplied aspect type. If the aspect type * has no per clause, then a {@link SingletonMetadataAwareAspectInstanceFactory} is returned, otherwise * a {@link PrototypeAspectInstanceFactory} is returned. */ private MetadataAwareAspectInstanceFactory createAspectInstanceFactory( AspectMetadata am, Class<?> aspectClass, String aspectName) { MetadataAwareAspectInstanceFactory instanceFactory; if (am.getAjType().getPerClause().getKind() == PerClauseKind.SINGLETON) { // Create a shared aspect instance. Object instance = getSingletonAspectInstance(aspectClass); instanceFactory = new SingletonMetadataAwareAspectInstanceFactory(instance, aspectName); } else { // Create a factory for independent aspect instances. instanceFactory = new SimpleMetadataAwareAspectInstanceFactory(aspectClass, aspectName); } return instanceFactory; }
Example 2
Source File: AspectJProxyFactory.java From java-technology-stack with MIT License | 6 votes |
/** * Create a {@link MetadataAwareAspectInstanceFactory} for the supplied aspect type. If the aspect type * has no per clause, then a {@link SingletonMetadataAwareAspectInstanceFactory} is returned, otherwise * a {@link PrototypeAspectInstanceFactory} is returned. */ private MetadataAwareAspectInstanceFactory createAspectInstanceFactory( AspectMetadata am, Class<?> aspectClass, String aspectName) { MetadataAwareAspectInstanceFactory instanceFactory; if (am.getAjType().getPerClause().getKind() == PerClauseKind.SINGLETON) { // Create a shared aspect instance. Object instance = getSingletonAspectInstance(aspectClass); instanceFactory = new SingletonMetadataAwareAspectInstanceFactory(instance, aspectName); } else { // Create a factory for independent aspect instances. instanceFactory = new SimpleMetadataAwareAspectInstanceFactory(aspectClass, aspectName); } return instanceFactory; }
Example 3
Source File: AspectJProxyFactory.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Create a {@link MetadataAwareAspectInstanceFactory} for the supplied aspect type. If the aspect type * has no per clause, then a {@link SingletonMetadataAwareAspectInstanceFactory} is returned, otherwise * a {@link PrototypeAspectInstanceFactory} is returned. */ private MetadataAwareAspectInstanceFactory createAspectInstanceFactory( AspectMetadata am, Class<?> aspectClass, String aspectName) { MetadataAwareAspectInstanceFactory instanceFactory; if (am.getAjType().getPerClause().getKind() == PerClauseKind.SINGLETON) { // Create a shared aspect instance. Object instance = getSingletonAspectInstance(aspectClass); instanceFactory = new SingletonMetadataAwareAspectInstanceFactory(instance, aspectName); } else { // Create a factory for independent aspect instances. instanceFactory = new SimpleMetadataAwareAspectInstanceFactory(aspectClass, aspectName); } return instanceFactory; }
Example 4
Source File: AspectJProxyFactory.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Create a {@link MetadataAwareAspectInstanceFactory} for the supplied aspect type. If the aspect type * has no per clause, then a {@link SingletonMetadataAwareAspectInstanceFactory} is returned, otherwise * a {@link PrototypeAspectInstanceFactory} is returned. */ private MetadataAwareAspectInstanceFactory createAspectInstanceFactory( AspectMetadata am, Class<?> aspectClass, String aspectName) { MetadataAwareAspectInstanceFactory instanceFactory = null; if (am.getAjType().getPerClause().getKind() == PerClauseKind.SINGLETON) { // Create a shared aspect instance. Object instance = getSingletonAspectInstance(aspectClass); instanceFactory = new SingletonMetadataAwareAspectInstanceFactory(instance, aspectName); } else { // Create a factory for independent aspect instances. instanceFactory = new SimpleMetadataAwareAspectInstanceFactory(aspectClass, aspectName); } return instanceFactory; }
Example 5
Source File: AspectJProxyFactory.java From spring-analysis-note with MIT License | 5 votes |
/** * Add the supplied aspect instance to the chain. The type of the aspect instance * supplied must be a singleton aspect. True singleton lifecycle is not honoured when * using this method - the caller is responsible for managing the lifecycle of any * aspects added in this way. * @param aspectInstance the AspectJ aspect instance */ public void addAspect(Object aspectInstance) { Class<?> aspectClass = aspectInstance.getClass(); String aspectName = aspectClass.getName(); AspectMetadata am = createAspectMetadata(aspectClass, aspectName); if (am.getAjType().getPerClause().getKind() != PerClauseKind.SINGLETON) { throw new IllegalArgumentException( "Aspect class [" + aspectClass.getName() + "] does not define a singleton aspect"); } addAdvisorsFromAspectInstanceFactory( new SingletonMetadataAwareAspectInstanceFactory(aspectInstance, aspectName)); }
Example 6
Source File: AspectJProxyFactory.java From java-technology-stack with MIT License | 5 votes |
/** * Add the supplied aspect instance to the chain. The type of the aspect instance * supplied must be a singleton aspect. True singleton lifecycle is not honoured when * using this method - the caller is responsible for managing the lifecycle of any * aspects added in this way. * @param aspectInstance the AspectJ aspect instance */ public void addAspect(Object aspectInstance) { Class<?> aspectClass = aspectInstance.getClass(); String aspectName = aspectClass.getName(); AspectMetadata am = createAspectMetadata(aspectClass, aspectName); if (am.getAjType().getPerClause().getKind() != PerClauseKind.SINGLETON) { throw new IllegalArgumentException( "Aspect class [" + aspectClass.getName() + "] does not define a singleton aspect"); } addAdvisorsFromAspectInstanceFactory( new SingletonMetadataAwareAspectInstanceFactory(aspectInstance, aspectName)); }
Example 7
Source File: AspectJProxyFactory.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Add the supplied aspect instance to the chain. The type of the aspect instance * supplied must be a singleton aspect. True singleton lifecycle is not honoured when * using this method - the caller is responsible for managing the lifecycle of any * aspects added in this way. * @param aspectInstance the AspectJ aspect instance */ public void addAspect(Object aspectInstance) { Class<?> aspectClass = aspectInstance.getClass(); String aspectName = aspectClass.getName(); AspectMetadata am = createAspectMetadata(aspectClass, aspectName); if (am.getAjType().getPerClause().getKind() != PerClauseKind.SINGLETON) { throw new IllegalArgumentException( "Aspect class [" + aspectClass.getName() + "] does not define a singleton aspect"); } addAdvisorsFromAspectInstanceFactory( new SingletonMetadataAwareAspectInstanceFactory(aspectInstance, aspectName)); }
Example 8
Source File: AspectJProxyFactory.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Add the supplied aspect instance to the chain. The type of the aspect instance * supplied must be a singleton aspect. True singleton lifecycle is not honoured when * using this method - the caller is responsible for managing the lifecycle of any * aspects added in this way. * @param aspectInstance the AspectJ aspect instance */ public void addAspect(Object aspectInstance) { Class<?> aspectClass = aspectInstance.getClass(); String aspectName = aspectClass.getName(); AspectMetadata am = createAspectMetadata(aspectClass, aspectName); if (am.getAjType().getPerClause().getKind() != PerClauseKind.SINGLETON) { throw new IllegalArgumentException( "Aspect class [" + aspectClass.getName() + "] does not define a singleton aspect"); } addAdvisorsFromAspectInstanceFactory( new SingletonMetadataAwareAspectInstanceFactory(aspectInstance, aspectName)); }
Example 9
Source File: InstantiationModelAwarePointcutAdvisorImpl.java From spring-analysis-note with MIT License | 2 votes |
/** * This is only of interest for Spring AOP: AspectJ instantiation semantics * are much richer. In AspectJ terminology, all a return of {@code true} * means here is that the aspect is not a SINGLETON. */ @Override public boolean isPerInstance() { return (getAspectMetadata().getAjType().getPerClause().getKind() != PerClauseKind.SINGLETON); }
Example 10
Source File: InstantiationModelAwarePointcutAdvisorImpl.java From java-technology-stack with MIT License | 2 votes |
/** * This is only of interest for Spring AOP: AspectJ instantiation semantics * are much richer. In AspectJ terminology, all a return of {@code true} * means here is that the aspect is not a SINGLETON. */ @Override public boolean isPerInstance() { return (getAspectMetadata().getAjType().getPerClause().getKind() != PerClauseKind.SINGLETON); }
Example 11
Source File: InstantiationModelAwarePointcutAdvisorImpl.java From lams with GNU General Public License v2.0 | 2 votes |
/** * This is only of interest for Spring AOP: AspectJ instantiation semantics * are much richer. In AspectJ terminology, all a return of {@code true} * means here is that the aspect is not a SINGLETON. */ @Override public boolean isPerInstance() { return (getAspectMetadata().getAjType().getPerClause().getKind() != PerClauseKind.SINGLETON); }
Example 12
Source File: InstantiationModelAwarePointcutAdvisorImpl.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * This is only of interest for Spring AOP: AspectJ instantiation semantics * are much richer. In AspectJ terminology, all a return of {@code true} * means here is that the aspect is not a SINGLETON. */ @Override public boolean isPerInstance() { return (getAspectMetadata().getAjType().getPerClause().getKind() != PerClauseKind.SINGLETON); }