001/* 002 * Copyright 2002-2012 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.context.annotation; 018 019import org.springframework.beans.factory.config.BeanDefinition; 020import org.springframework.util.Assert; 021 022/** 023 * Describes scope characteristics for a Spring-managed bean including the scope 024 * name and the scoped-proxy behavior. 025 * 026 * <p>The default scope is "singleton", and the default is to <i>not</i> create 027 * scoped-proxies. 028 * 029 * @author Mark Fisher 030 * @author Juergen Hoeller 031 * @since 2.5 032 * @see ScopeMetadataResolver 033 * @see ScopedProxyMode 034 */ 035public class ScopeMetadata { 036 037 private String scopeName = BeanDefinition.SCOPE_SINGLETON; 038 039 private ScopedProxyMode scopedProxyMode = ScopedProxyMode.NO; 040 041 042 /** 043 * Set the name of the scope. 044 */ 045 public void setScopeName(String scopeName) { 046 Assert.notNull(scopeName, "'scopeName' must not be null"); 047 this.scopeName = scopeName; 048 } 049 050 /** 051 * Get the name of the scope. 052 */ 053 public String getScopeName() { 054 return this.scopeName; 055 } 056 057 /** 058 * Set the proxy-mode to be applied to the scoped instance. 059 */ 060 public void setScopedProxyMode(ScopedProxyMode scopedProxyMode) { 061 Assert.notNull(scopedProxyMode, "'scopedProxyMode' must not be null"); 062 this.scopedProxyMode = scopedProxyMode; 063 } 064 065 /** 066 * Get the proxy-mode to be applied to the scoped instance. 067 */ 068 public ScopedProxyMode getScopedProxyMode() { 069 return this.scopedProxyMode; 070 } 071 072}