Skip to content

Commit 7d62aab

Browse files
committed
Initial import of the aspects module
1 parent 827916b commit 7d62aab

15 files changed

Lines changed: 756 additions & 0 deletions

File tree

build-spring-framework/build.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<pathelement location="../org.springframework.aop"/>
1010
<pathelement location="../org.springframework.context"/>
1111
<pathelement location="../org.springframework.transaction"/>
12+
<pathelement location="../org.springframework.aspects"/>
1213
<pathelement location="../org.springframework.jdbc"/>
1314
<pathelement location="../org.springframework.web"/>
1415
<pathelement location="../org.springframework.orm"/>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project name="org.springframework.aspects">
3+
<property file="${basedir}/../build.properties"/>
4+
<import file="${basedir}/../build-spring-framework/package-bundle.xml"/>
5+
<import file="${basedir}/../spring-build/aspect/default.xml"/>
6+
</project>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<?xml-stylesheet type="text/xsl" href="http://ivyrep.jayasoft.org/ivy-doc.xsl"?>
3+
<ivy-module
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="http://incubator.apache.org/ivy/schemas/ivy.xsd"
6+
version="1.3">
7+
8+
<info organisation="org.springframework" module="${ant.project.name}">
9+
<license name="Apache 2.0" url="http://www.apache.org/licenses/LICENSE-2.0"/>
10+
</info>
11+
12+
<configurations>
13+
<include file="${spring.build.dir}/common/default-ivy-configurations.xml"/>
14+
<conf name="aspectj" extends="runtime" description="JARs needed to run with AspectJ"/>
15+
<conf name="tx" extends="runtime" description="JARs needed to run transactional aspects"/>
16+
</configurations>
17+
18+
<publications>
19+
<artifact name="${ant.project.name}"/>
20+
<artifact name="${ant.project.name}-sources" type="src" ext="jar"/>
21+
</publications>
22+
23+
<dependencies>
24+
<dependency org="org.apache.commons" name="com.springsource.org.apache.commons.logging" rev="1.1.1" conf="compile->compile"/>
25+
<dependency org="org.aspectj" name="com.springsource.org.aspectj.weaver" rev="1.5.4" conf="optional, aspectj->compile"/>
26+
<dependency org="org.springframework" name="org.springframework.beans" rev="latest.integration" conf="compile->compile"/>
27+
<dependency org="org.springframework" name="org.springframework.transaction" rev="latest.integration" conf="optional, tx->compile"/>
28+
</dependencies>
29+
30+
</ivy-module>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>org.springframework</groupId>
5+
<artifactId>org.springframework.core</artifactId>
6+
<packaging>jar</packaging>
7+
<name>Spring Core Abstractions and Utilities</name>
8+
<version>3.0.0.M1</version>
9+
<repositories>
10+
<repository>
11+
<id>com.springsource.repository.bundles.external</id>
12+
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
13+
<url>http://repository.springsource.com/maven/bundles/external</url>
14+
</repository>
15+
</repositories>
16+
<build>
17+
<plugins>
18+
<plugin>
19+
<groupId>org.apache.maven.plugins</groupId>
20+
<artifactId>maven-compiler-plugin</artifactId>
21+
<configuration>
22+
<source>1.5</source>
23+
<target>1.5</target>
24+
</configuration>
25+
</plugin>
26+
</plugins>
27+
</build>
28+
<dependencies>
29+
<dependency>
30+
<groupId>org.apache.commons</groupId>
31+
<artifactId>com.springsource.org.apache.commons.logging</artifactId>
32+
<version>1.1.1</version>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.apache.log4j</groupId>
36+
<artifactId>com.springsource.org.apache.log4j</artifactId>
37+
<version>1.2.15</version>
38+
<optional>true</optional>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.apache.commons</groupId>
42+
<artifactId>com.springsource.org.apache.commons.collections</artifactId>
43+
<version>3.2.0</version>
44+
<optional>true</optional>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.aspectj</groupId>
48+
<artifactId>com.springsource.org.aspectj.weaver</artifactId>
49+
<version>1.6.2.RELEASE</version>
50+
<optional>true</optional>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.objectweb.asm</groupId>
54+
<artifactId>com.springsource.org.objectweb.asm.commons</artifactId>
55+
<version>2.2.3</version>
56+
<optional>true</optional>
57+
</dependency>
58+
</dependencies>
59+
</project>
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Copyright 2002-2008 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
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.beans.factory.aspectj;
18+
19+
import org.aspectj.lang.annotation.SuppressAjWarnings;
20+
import org.springframework.beans.factory.wiring.BeanConfigurerSupport;
21+
22+
/**
23+
* Abstract superaspect for AspectJ aspects that can perform Dependency
24+
* Injection on objects, however they may be created. Define the beanCreation()
25+
* pointcut in subaspects.
26+
*
27+
* <p>Subaspects may also need a metadata resolution strategy, in the
28+
* <code>BeanWiringInfoResolver</code> interface. The default implementation
29+
* looks for a bean with the same name as the FQN. This is the default name
30+
* of a bean in a Spring container if the id value is not supplied explicitly.
31+
*
32+
* @author Rob Harrop
33+
* @author Rod Johnson
34+
* @author Adrian Colyer
35+
* @author Ramnivas Laddad
36+
* @since 2.0
37+
* @deprecated as of Spring 2.5.2.
38+
* Use AbstractDependencyInjectionAspect or its subaspects instead.
39+
*/
40+
public abstract aspect AbstractBeanConfigurerAspect extends BeanConfigurerSupport {
41+
42+
/**
43+
* Configured bean before initialization.
44+
*/
45+
@SuppressAjWarnings("adviceDidNotMatch")
46+
before(Object beanInstance) : beanInitialization(beanInstance) {
47+
if (preConstructionConfiguration(beanInstance)) {
48+
configureBean(beanInstance);
49+
}
50+
}
51+
52+
/**
53+
* Configured bean after construction.
54+
*/
55+
@SuppressAjWarnings("adviceDidNotMatch")
56+
after(Object beanInstance) returning : beanCreation(beanInstance) {
57+
if (!preConstructionConfiguration(beanInstance)) {
58+
configureBean(beanInstance);
59+
}
60+
}
61+
62+
63+
/**
64+
* The initialization of a new object.
65+
*
66+
* <p>WARNING: Although this pointcut is non-abstract for backwards
67+
* compatibility reasons, it is meant to be overridden to select
68+
* initialization of any configurable bean.
69+
*/
70+
protected pointcut beanInitialization(Object beanInstance);
71+
72+
/**
73+
* The creation of a new object.
74+
*/
75+
protected abstract pointcut beanCreation(Object beanInstance);
76+
77+
78+
/**
79+
* Are dependencies to be injected prior to the construction of an object?
80+
*/
81+
protected boolean preConstructionConfiguration(Object beanInstance) {
82+
return false; // matches the default in the @Configurable annotation
83+
}
84+
85+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
* Copyright 2002-2008 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
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.beans.factory.aspectj;
18+
19+
import org.aspectj.lang.annotation.SuppressAjWarnings;
20+
21+
/**
22+
* Abstract base aspect that can perform Dependency
23+
* Injection on objects, however they may be created.
24+
*
25+
* @author Ramnivas Laddad
26+
* @since 2.5.2
27+
*/
28+
public abstract aspect AbstractDependencyInjectionAspect {
29+
/**
30+
* Select construction join points for objects to inject dependencies
31+
*/
32+
public abstract pointcut beanConstruction(Object bean);
33+
34+
/**
35+
* Select deserialization join points for objects to inject dependencies
36+
*/
37+
public abstract pointcut beanDeserialization(Object bean);
38+
39+
/**
40+
* Select join points in a configurable bean
41+
*/
42+
public abstract pointcut inConfigurableBean();
43+
44+
/**
45+
* Select join points in beans to be configured prior to construction?
46+
* By default, use post-construction injection matching the default in the Configurable annotation.
47+
*/
48+
public pointcut preConstructionConfiguration() : if(false);
49+
50+
/**
51+
* Select the most-specific initialization join point
52+
* (most concrete class) for the initialization of an instance.
53+
*/
54+
public pointcut mostSpecificSubTypeConstruction() :
55+
if(thisJoinPoint.getSignature().getDeclaringType() == thisJoinPoint.getThis().getClass());
56+
57+
/**
58+
* Select least specific super type that is marked for DI (so that injection occurs only once with pre-construction inejection
59+
*/
60+
public abstract pointcut leastSpecificSuperTypeConstruction();
61+
62+
/**
63+
* Configure the bean
64+
*/
65+
public abstract void configureBean(Object bean);
66+
67+
68+
private pointcut preConstructionCondition() :
69+
leastSpecificSuperTypeConstruction() && preConstructionConfiguration();
70+
71+
private pointcut postConstructionCondition() :
72+
mostSpecificSubTypeConstruction() && !preConstructionConfiguration();
73+
74+
/**
75+
* Pre-construction configuration.
76+
*/
77+
@SuppressAjWarnings("adviceDidNotMatch")
78+
before(Object bean) :
79+
beanConstruction(bean) && preConstructionCondition() && inConfigurableBean() {
80+
configureBean(bean);
81+
}
82+
83+
/**
84+
* Post-construction configuration.
85+
*/
86+
@SuppressAjWarnings("adviceDidNotMatch")
87+
after(Object bean) returning :
88+
beanConstruction(bean) && postConstructionCondition() && inConfigurableBean() {
89+
configureBean(bean);
90+
}
91+
92+
/**
93+
* Post-deserialization configuration.
94+
*/
95+
@SuppressAjWarnings("adviceDidNotMatch")
96+
after(Object bean) returning :
97+
beanDeserialization(bean) && inConfigurableBean() {
98+
configureBean(bean);
99+
}
100+
101+
}

0 commit comments

Comments
 (0)