public class ComboContext extends Object implements IocContext
每当获取时 按照构造Context的顺序,依次获取。 只要有一个 Context 返回了非 null 对象,就立即返回
Constructor and Description |
---|
ComboContext(IocContext... contexts)
Context 的获取优先级,以数组的顺序来决定
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
清空缓存,注销资源,执行完后,当前上下文对象恢复到初始状态
|
void |
depose()
销毁当前上下文对象,清空资源,执行完后,当前上下文对象将不再可用
|
ObjectProxy |
fetch(String key)
根据对象的名称获取上下文环境中的一个对象
|
IocContext[] |
getContexts() |
Set<String> |
names() |
boolean |
remove(String scope,
String name)
从上下文环境中删一个对象。实现类根据 scope 信息来决定是否删除
|
boolean |
save(String scope,
String name,
ObjectProxy obj)
存储一个对象,根据对象的级别,各个实现类可以决定是否真的存储
|
public ComboContext(IocContext... contexts)
contexts
- public ObjectProxy fetch(String key)
IocContext
fetch
in interface IocContext
key
- 对象的名称public boolean save(String scope, String name, ObjectProxy obj)
IocContext
save
in interface IocContext
scope
- 对象范围name
- 对象的名称obj
- 对象本身public boolean remove(String scope, String name)
IocContext
remove
in interface IocContext
scope
- 对象范围name
- 对象的名称public void clear()
IocContext
clear
in interface IocContext
public void depose()
IocContext
depose
in interface IocContext
public IocContext[] getContexts()
public Set<String> names()
names
in interface IocContext
Copyright © 2017. All rights reserved.