@Primary/@Lazy/@DependsOn supported as meta-annotations; @Bean supported as meta-annotation on factory methods as well

This commit is contained in:
Juergen Hoeller
2009-07-22 15:23:22 +00:00
parent a4bbd9abda
commit f519406c37
17 changed files with 156 additions and 123 deletions

View File

@@ -66,7 +66,9 @@ public class ScopingTests {
@After
public void tearDown() throws Exception {
ctx.close();
if (ctx != null) {
ctx.close();
}
ctx = null;
customScope = null;
}
@@ -328,7 +330,6 @@ public class ScopingTests {
return tb;
}
@Bean
@MyProxiedScope
public TestBean scopedProxyClass() {
TestBean tb = new TestBean();
@@ -361,6 +362,7 @@ public class ScopingTests {
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Bean
@Scope(value=SCOPE, proxyMode=ScopedProxyMode.TARGET_CLASS)
@interface MyProxiedScope {
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright 2002-2009 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.context.annotation5;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;
/**
* @author Juergen Hoeller
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Repository
@Primary
@Lazy
public @interface MyRepository {
}

View File

@@ -25,8 +25,7 @@ import org.springframework.stereotype.Repository;
/**
* @author Juergen Hoeller
*/
@Repository
@Primary @Lazy
@MyRepository
public class OtherFooDao implements FooDao {
public String findFoo(int id) {