This repository has been archived by the owner on Dec 15, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b062d5
commit 0199783
Showing
10 changed files
with
253 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.springframework.issues</groupId> | ||
<artifactId>SPR-9638</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context</artifactId> | ||
<version>3.2.0.BUILD-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>log4j</groupId> | ||
<artifactId>log4j</artifactId> | ||
<version>1.2.16</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.8</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<repositories> | ||
<repository> | ||
<id>spring-maven-snapshot</id> | ||
<name>Springframework Maven Snapshot Repository</name> | ||
<url>http://repo.springsource.org/snapshot</url> | ||
<snapshots><enabled>true</enabled></snapshots> | ||
</repository> | ||
</repositories> | ||
<properties> | ||
<project.build.sourceEncoding>UTF8</project.build.sourceEncoding> | ||
</properties> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.3.2</version> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.7.2</version> | ||
<configuration> | ||
<includes> | ||
<include>**/*Tests.java</include> | ||
</includes> | ||
<excludes> | ||
<exclude>**/*Abstract*.java</exclude> | ||
</excludes> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> | ||
|
37 changes: 37 additions & 0 deletions
37
SPR-9638/src/main/java/org/springframework/issues/ControllerAdvisor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2002-2012 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.issues; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
import org.springframework.aop.interceptor.SimpleTraceInterceptor; | ||
import org.springframework.aop.support.DefaultPointcutAdvisor; | ||
import org.springframework.aop.support.StaticMethodMatcherPointcut; | ||
import org.springframework.core.annotation.AnnotationUtils; | ||
import org.springframework.stereotype.Controller; | ||
|
||
@SuppressWarnings("serial") | ||
public class ControllerAdvisor extends DefaultPointcutAdvisor { | ||
|
||
public ControllerAdvisor() { | ||
super(new StaticMethodMatcherPointcut() { | ||
public boolean matches(Method method, Class<?> targetClass) { | ||
return (AnnotationUtils.findAnnotation(targetClass, Controller.class) != null); | ||
} | ||
}, new SimpleTraceInterceptor()); | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
SPR-9638/src/main/java/org/springframework/issues/DefaultTestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2002-2012 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.issues; | ||
|
||
import org.springframework.stereotype.Controller; | ||
|
||
@Controller | ||
public class DefaultTestController implements TestController { | ||
|
||
public void handle() { | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
SPR-9638/src/main/java/org/springframework/issues/TestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright 2002-2012 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.issues; | ||
|
||
public interface TestController { | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
SPR-9638/src/main/java/org/springframework/issues/TestInitializingBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2002-2012 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.issues; | ||
|
||
import org.springframework.beans.BeansException; | ||
import org.springframework.beans.factory.InitializingBean; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.ApplicationContextAware; | ||
|
||
public class TestInitializingBean implements InitializingBean, ApplicationContextAware { | ||
|
||
private ApplicationContext applicationContext; | ||
|
||
private Class<?> controllerType; | ||
|
||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | ||
this.applicationContext = applicationContext; | ||
} | ||
|
||
public Class<?> getControllerType() { | ||
return this.controllerType; | ||
} | ||
|
||
public void afterPropertiesSet() throws Exception { | ||
this.controllerType = this.applicationContext.getType("testController"); | ||
} | ||
|
||
} |
Empty file.
20 changes: 20 additions & 0 deletions
20
SPR-9638/src/main/resources/org/springframework/issues/config.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> | ||
|
||
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" /> | ||
|
||
<bean class="org.springframework.issues.ControllerAdvisor" /> | ||
|
||
<beans profile="success"> | ||
<bean id="testController" class="org.springframework.issues.DefaultTestController" /> | ||
<bean class="org.springframework.issues.TestInitializingBean" /> | ||
</beans> | ||
|
||
<beans profile="failure"> | ||
<bean class="org.springframework.issues.TestInitializingBean" /> | ||
<bean id="testController" class="org.springframework.issues.DefaultTestController" /> | ||
</beans> | ||
|
||
</beans> |
38 changes: 38 additions & 0 deletions
38
SPR-9638/src/test/java/org/springframework/issues/ReproTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.springframework.issues; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.lang.reflect.Proxy; | ||
|
||
import org.junit.Test; | ||
import org.springframework.context.support.ClassPathXmlApplicationContext; | ||
|
||
public class ReproTests { | ||
|
||
@Test | ||
public void success() { | ||
|
||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(); | ||
context.setConfigLocation("classpath:org/springframework/issues/config.xml"); | ||
context.getEnvironment().setActiveProfiles("success"); | ||
context.refresh(); | ||
|
||
TestInitializingBean bean = context.getBean(TestInitializingBean.class); | ||
|
||
assertTrue(Proxy.isProxyClass(bean.getControllerType())); | ||
} | ||
|
||
@Test | ||
public void failure() { | ||
|
||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(); | ||
context.setConfigLocation("classpath:org/springframework/issues/config.xml"); | ||
context.getEnvironment().setActiveProfiles("failure"); | ||
context.refresh(); | ||
|
||
TestInitializingBean bean = context.getBean(TestInitializingBean.class); | ||
|
||
assertTrue(Proxy.isProxyClass(bean.getControllerType())); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
log4j.rootCategory=ERROR, stdout | ||
|
||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender | ||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n | ||
|
||
log4j.category.org.springframework=WARN |