Skip to content
This repository was archived by the owner on Dec 15, 2021. It is now read-only.

Commit 7a10945

Browse files
committed
Add repro project for SPR-9243
1 parent f6d1a29 commit 7a10945

File tree

9 files changed

+262
-0
lines changed

9 files changed

+262
-0
lines changed

SPR-9243/pom.xml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
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>SPR-9243</artifactId>
6+
<name>SPR-9243</name>
7+
<packaging>jar</packaging>
8+
<version>1.0-SNAPSHOT</version>
9+
<properties>
10+
<java-version>1.6</java-version>
11+
<!-- FIXME change to this version to pass the test
12+
<org.springframework-version>3.1.0.RELEASE</org.springframework-version>
13+
-->
14+
<org.springframework-version>3.1.1.RELEASE</org.springframework-version>
15+
<org.slf4j-version>1.5.10</org.slf4j-version>
16+
</properties>
17+
<dependencies>
18+
19+
20+
<!-- Spring -->
21+
<dependency>
22+
<groupId>org.springframework</groupId>
23+
<artifactId>spring-context</artifactId>
24+
<version>${org.springframework-version}</version>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.springframework</groupId>
28+
<artifactId>org.springframework.web</artifactId>
29+
<version>${org.springframework-version}</version>
30+
</dependency>
31+
32+
<dependency>
33+
<groupId>org.aspectj</groupId>
34+
<artifactId>aspectjweaver</artifactId>
35+
<version>1.6.8</version>
36+
</dependency>
37+
<dependency>
38+
<groupId>aopalliance</groupId>
39+
<artifactId>aopalliance</artifactId>
40+
<version>1.0</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>cglib</groupId>
44+
<artifactId>cglib</artifactId>
45+
<version>2.2</version>
46+
</dependency>
47+
48+
<!-- Servlet -->
49+
<dependency>
50+
<groupId>javax.servlet</groupId>
51+
<artifactId>servlet-api</artifactId>
52+
<version>2.5</version>
53+
<scope>provided</scope>
54+
</dependency>
55+
56+
<!-- Test -->
57+
<dependency>
58+
<groupId>junit</groupId>
59+
<artifactId>junit</artifactId>
60+
<version>4.9</version>
61+
<scope>test</scope>
62+
</dependency>
63+
64+
</dependencies>
65+
<repositories>
66+
67+
<repository>
68+
<id>spring.maven.milestone</id>
69+
<name>Spring Milestone Maven Repo</name>
70+
<url>http://repository.springsource.com/maven/bundles/milestone</url>
71+
</repository>
72+
<repository>
73+
<id>spring.maven.release</id>
74+
<name>Spring Release Maven Repo</name>
75+
<url>http://repository.springsource.com/maven/bundles/release</url>
76+
</repository>
77+
<repository>
78+
<id>com.springsource.repository.bundles.external</id>
79+
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
80+
<url>http://repository.springsource.com/maven/bundles/external</url>
81+
</repository>
82+
83+
</repositories>
84+
<build>
85+
<plugins>
86+
<plugin>
87+
<groupId>org.apache.maven.plugins</groupId>
88+
<artifactId>maven-compiler-plugin</artifactId>
89+
<version>2.3.2</version>
90+
<configuration>
91+
<source>${java-version}</source>
92+
<target>${java-version}</target>
93+
</configuration>
94+
</plugin>
95+
<plugin>
96+
<groupId>org.apache.maven.plugins</groupId>
97+
<artifactId>maven-dependency-plugin</artifactId>
98+
<executions>
99+
<execution>
100+
<id>install</id>
101+
<phase>install</phase>
102+
<goals>
103+
<goal>sources</goal>
104+
</goals>
105+
</execution>
106+
</executions>
107+
</plugin>
108+
<plugin>
109+
<groupId>org.apache.maven.plugins</groupId>
110+
<artifactId>maven-surefire-plugin</artifactId>
111+
<version>2.7.2</version>
112+
<configuration>
113+
<junitArtifactName>junit:junit</junitArtifactName>
114+
</configuration>
115+
</plugin>
116+
</plugins>
117+
</build>
118+
</project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.chare;
2+
3+
import org.springframework.context.annotation.Configuration;
4+
import org.springframework.context.annotation.EnableAspectJAutoProxy;
5+
import org.springframework.context.annotation.Import;
6+
7+
@Configuration
8+
@EnableAspectJAutoProxy
9+
@Import({
10+
org.chare.service.Config.class,
11+
org.chare.otherService.Config.class
12+
}
13+
)
14+
15+
public class Config {
16+
17+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package org.chare.entity;
2+
3+
import java.io.Serializable;
4+
5+
public class User implements Serializable {
6+
7+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.chare.otherService;
2+
3+
import org.chare.service.Service;
4+
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.context.annotation.Configuration;
7+
8+
@Configuration
9+
public class Config {
10+
@Autowired
11+
private Service service;
12+
13+
@Bean
14+
public OtherService service() {
15+
return new OtherService(service);
16+
}
17+
18+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.chare.otherService;
2+
3+
import org.chare.service.Service;
4+
5+
public class OtherService {
6+
7+
public final Service service;
8+
9+
public OtherService(Service service) {
10+
this.service = service;
11+
}
12+
13+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.chare.service;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.context.annotation.Scope;
6+
import org.springframework.context.annotation.ScopedProxyMode;
7+
8+
@Configuration
9+
public class Config {
10+
@Bean
11+
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
12+
public UserPreferences userPreferences() {
13+
return new UserPreferences();
14+
}
15+
16+
@Bean
17+
public Service Service() {
18+
return new Service();
19+
}
20+
21+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package org.chare.service;
2+
3+
public class Service {
4+
5+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.chare.service;
2+
3+
import org.chare.entity.User;
4+
5+
public class UserPreferences {
6+
7+
public User user;
8+
9+
public UserPreferences() {
10+
this(new User());
11+
}
12+
13+
public UserPreferences(User user) {
14+
this.user = user;
15+
}
16+
17+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package org.chare;
2+
3+
import static org.junit.Assert.*;
4+
5+
import java.util.ArrayList;
6+
import java.util.List;
7+
8+
import org.chare.service.Service;
9+
import org.junit.Test;
10+
import org.springframework.context.annotation.Configuration;
11+
import org.springframework.context.support.AbstractApplicationContext;
12+
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
13+
14+
public class ConfigTest {
15+
16+
@Test
17+
public void testConfig() throws Exception {
18+
AbstractApplicationContext context = createContext(Config.class, DependencyConfig.class);
19+
assertNotNull(context.getBean(Service.class));
20+
context.close();
21+
}
22+
23+
@Configuration
24+
static class DependencyConfig {
25+
26+
}
27+
28+
29+
public static AnnotationConfigWebApplicationContext createContext(final Class<?> ... configClasses) {
30+
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext() {
31+
@Override
32+
public String[] getConfigLocations() {
33+
return convertToConfigLocations(configClasses);
34+
}
35+
};
36+
context.refresh();
37+
return context;
38+
}
39+
40+
public static String[] convertToConfigLocations(Class<?>... configClasses) {
41+
List<String> names = new ArrayList<String>();
42+
for (Class<?> configClass : configClasses)
43+
names.add(configClass.getName());
44+
return names.toArray(new String [] {});
45+
}
46+
}

0 commit comments

Comments
 (0)