JavaTM 2 Platform
Standard Ed. 6

java.beans.beancontext
类 BeanContextServicesSupport

java.lang.Object
  继承者 java.beans.beancontext.BeanContextChildSupport
      继承者 java.beans.beancontext.BeanContextSupport
          继承者 java.beans.beancontext.BeanContextServicesSupport
所有已实现的接口:
BeanContext, BeanContextChild, BeanContextServiceRevokedListener, BeanContextServices, BeanContextServicesListener, DesignMode, PropertyChangeListener, VetoableChangeListener, Visibility, Serializable, Iterable, Collection, EventListener

public class BeanContextServicesSupport
extends BeanContextSupport
implements BeanContextServices

此帮助器类提供 java.beans.beancontext.BeanContextServices 接口的实用工具实现。

因为此类直接实现 BeanContextServices 接口,所以可以通过创建此实现的子类来使用该类,或者由通过 BeanContextProxy 接口的另一个实例对此类实例的委托来使用该类。

从以下版本开始:
1.2
另请参见:
序列化表格

嵌套类摘要
protected  class BeanContextServicesSupport.BCSSChild
           
protected  class BeanContextServicesSupport.BCSSProxyServiceProvider
           
protected static class BeanContextServicesSupport.BCSSServiceProvider
          子类可以为此嵌套类创建子类,以便为每个 BeanContextServicesProvider 添加行为。
 
从类 java.beans.beancontext.BeanContextSupport 继承的嵌套类/接口
BeanContextSupport.BCSChild, BeanContextSupport.BCSIterator
 
字段摘要
protected  ArrayList bcsListeners
          BeanContextServicesListener 对象的列表。
protected  BeanContextServicesSupport.BCSSProxyServiceProvider proxy
          BeanContextServiceProvider 的委托。
protected  int serializable
          可序列化 BeanContextServceProvider 的实例数。
protected  HashMap services
           protected transient HashMap services 字段的所有访问在该对象上都应该是同步的。
 
从类 java.beans.beancontext.BeanContextSupport 继承的字段
bcmListeners, children, designTime, locale, okToUseGui
 
从类 java.beans.beancontext.BeanContextChildSupport 继承的字段
beanContext, beanContextChildPeer, pcSupport, rejectedSetBCOnce, vcSupport
 
从接口 java.beans.beancontext.BeanContext 继承的字段
globalHierarchyLock
 
从接口 java.beans.DesignMode 继承的字段
PROPERTYNAME
 
构造方法摘要
BeanContextServicesSupport()
          创建不是另一个对象代理的实例。
BeanContextServicesSupport(BeanContextServices peer)
          创建一个具有同位体的实例
BeanContextServicesSupport(BeanContextServices peer, Locale lcle)
          使用指定语言环境创建一个实例。
BeanContextServicesSupport(BeanContextServices peer, Locale lcle, boolean dtime)
          使用指定 Locale 和设计模式创建一个实例。
BeanContextServicesSupport(BeanContextServices peer, Locale lcle, boolean dTime, boolean visible)
           构造一个 BeanContextServicesSupport 实例
 
方法摘要
 void addBeanContextServicesListener(BeanContextServicesListener bcsl)
          添加一个 BeanContextServicesListener。
 boolean addService(Class serviceClass, BeanContextServiceProvider bcsp)
          添加服务。
protected  boolean addService(Class serviceClass, BeanContextServiceProvider bcsp, boolean fireEvent)
          添加服务。
protected  void bcsPreDeserializationHook(ObjectInputStream ois)
          在反序列化子级之前,从 BeanContextSupport readObject 中调用。
protected  void bcsPreSerializationHook(ObjectOutputStream oos)
          在序列化子级之前,从 BeanContextSupport writeObject 中调用。
protected  void childJustRemovedHook(Object child, BeanContextSupport.BCSChild bcsc)
          在已成功移除子级之后,从超类的子级移除操作中调用。
protected  BeanContextSupport.BCSChild createBCSChild(Object targetChild, Object peer)
           子类可以重写此方法来插入自己的 Child 的子类,而不必重写 add() 或其他将子级添加到集合中的 Collection 方法。
protected  BeanContextServicesSupport.BCSSServiceProvider createBCSSServiceProvider(Class sc, BeanContextServiceProvider bcsp)
          子类可以重写此方法来创建 BCSSServiceProvider 的新子类,而不必为了实例化而重写 addService()。
protected  void fireServiceAdded(BeanContextServiceAvailableEvent bcssae)
          触发一个指示新服务已变得可用的 BeanContextServiceAvailableEvent
protected  void fireServiceAdded(Class serviceClass)
          触发一个通知新服务的 BeanContextServiceEvent
protected  void fireServiceRevoked(BeanContextServiceRevokedEvent bcsre)
          触发一个通知将被取消的服务的 BeanContextServiceEvent
protected  void fireServiceRevoked(Class serviceClass, boolean revokeNow)
          触发一个指示某一特定服务不再可用的 BeanContextServiceRevokedEvent
 BeanContextServices getBeanContextServicesPeer()
          获得与此 BeanContextServicesSupport 相关联的 BeanContextServices
protected static BeanContextServicesListener getChildBeanContextServicesListener(Object child)
          获得指定子级的 BeanContextServicesListener(如果有)。
 Iterator getCurrentServiceClasses()
          获得此上下文的当前可用服务。
 Iterator getCurrentServiceSelectors(Class serviceClass)
          通过在基础 BeanContextServiceProvider 上调用 getCurrentServiceSelectors() 获得指定服务的与服务有关的服务参数列表(服务选择器)。
 Object getService(BeanContextChild child, Object requestor, Class serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl)
          获得一个可被委托的服务。
 boolean hasService(Class serviceClass)
          具有一个可被委托的服务。
 void initialize()
          由 BeanContextSupport 超类在构造和反序列化期间调用,以初始化子类的瞬态。
protected  void initializeBeanContextResources()
          从 setBeanContext 中调用,以通知 BeanContextChild 分配从嵌套 BeanContext 中获得的资源。
protected  void releaseBeanContextResources()
          从 setBeanContext 中调用,以通知 BeanContextChild 释放从嵌套 BeanContext 中获得的资源。
 void releaseService(BeanContextChild child, Object requestor, Object service)
          释放服务。
 void removeBeanContextServicesListener(BeanContextServicesListener bcsl)
          移除一个 BeanContextServicesListener。
 void revokeService(Class serviceClass, BeanContextServiceProvider bcsp, boolean revokeCurrentServicesNow)
          移除服务。
 void serviceAvailable(BeanContextServiceAvailableEvent bcssae)
          BeanContextServicesListener 回调,如果此 BeanContextService 自己尚未实现此服务,则将事件传播到所有当前已注册侦听器和 BeanContextServices 子级。
 void serviceRevoked(BeanContextServiceRevokedEvent bcssre)
          BeanContextServicesListener 回调,如果此 BeanContextService 自己尚未实现此服务,则将事件传播到所有当前已注册侦听器和 BeanContextServices 子级。
 
从类 java.beans.beancontext.BeanContextSupport 继承的方法
add, addAll, addBeanContextMembershipListener, avoidingGui, bcsChildren, childDeserializedHook, childJustAddedHook, classEquals, clear, contains, containsAll, containsKey, copyChildren, deserialize, dontUseGui, fireChildrenAdded, fireChildrenRemoved, getBeanContextPeer, getChildBeanContextChild, getChildBeanContextMembershipListener, getChildPropertyChangeListener, getChildSerializable, getChildVetoableChangeListener, getChildVisibility, getLocale, getResource, getResourceAsStream, instantiateChild, isDesignTime, isEmpty, isSerializing, iterator, needsGui, okToUseGui, propertyChange, readChildren, remove, remove, removeAll, removeBeanContextMembershipListener, retainAll, serialize, setDesignTime, setLocale, size, toArray, toArray, validatePendingAdd, validatePendingRemove, vetoableChange, writeChildren
 
从类 java.beans.beancontext.BeanContextChildSupport 继承的方法
addPropertyChangeListener, addVetoableChangeListener, firePropertyChange, fireVetoableChange, getBeanContext, getBeanContextChildPeer, isDelegated, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext, validatePendingSetBeanContext
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
从接口 java.beans.beancontext.BeanContext 继承的方法
addBeanContextMembershipListener, getResource, getResourceAsStream, instantiateChild, removeBeanContextMembershipListener
 
从接口 java.beans.beancontext.BeanContextChild 继承的方法
addPropertyChangeListener, addVetoableChangeListener, getBeanContext, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext
 
从接口 java.util.Collection 继承的方法
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
从接口 java.beans.DesignMode 继承的方法
isDesignTime, setDesignTime
 
从接口 java.beans.Visibility 继承的方法
avoidingGui, dontUseGui, needsGui, okToUseGui
 

字段详细信息

services

protected transient HashMap services
protected transient HashMap services 字段的所有访问在该对象上都应该是同步的。


serializable

protected transient int serializable
可序列化 BeanContextServceProvider 的实例数。


proxy

protected transient BeanContextServicesSupport.BCSSProxyServiceProvider proxy
BeanContextServiceProvider 的委托。


bcsListeners

protected transient ArrayList bcsListeners
BeanContextServicesListener 对象的列表。

构造方法详细信息

BeanContextServicesSupport

public BeanContextServicesSupport(BeanContextServices peer,
                                  Locale lcle,
                                  boolean dTime,
                                  boolean visible)

构造一个 BeanContextServicesSupport 实例

参数:
peer - 将为其提供实现的同位体 BeanContext,如果该参数为 null,则此对象是它自己的同位体
lcle - 此 BeanContext 的当前 Locale。
dtime - 初始状态,如果在设计模式下,则该参数为 true,如果在运行状态下,则该参数为 false。
visible - 初始可见性。

BeanContextServicesSupport

public BeanContextServicesSupport(BeanContextServices peer,
                                  Locale lcle,
                                  boolean dtime)
使用指定 Locale 和设计模式创建一个实例。

参数:
peer - 将为其提供实现的同位体 BeanContext,如果该参数为 null,则此对象是它自己的同位体
lcle - 此 BeanContext 的当前 Locale。
dtime - 初始状态,如果在设计模式下,则该参数为 true,如果在运行状态下,则该参数为 false。

BeanContextServicesSupport

public BeanContextServicesSupport(BeanContextServices peer,
                                  Locale lcle)
使用指定语言环境创建一个实例。

参数:
peer - 将为其提供实现的同位体 BeanContext,如果该参数为 null,则此对象是它自己的同位体
lcle - 此 BeanContext 的当前 Locale。

BeanContextServicesSupport

public BeanContextServicesSupport(BeanContextServices peer)
创建一个具有同位体的实例

参数:
peer - 将为其提供实现的同位体 BeanContext,如果该参数为 null,则此对象是它自己的同位体。

BeanContextServicesSupport

public BeanContextServicesSupport()
创建不是另一个对象代理的实例。

方法详细信息

initialize

public void initialize()
由 BeanContextSupport 超类在构造和反序列化期间调用,以初始化子类的瞬态。 子类可以封装此方法,但不应该重写或直接调用它。

覆盖:
BeanContextSupport 中的 initialize

getBeanContextServicesPeer

public BeanContextServices getBeanContextServicesPeer()
获得与此 BeanContextServicesSupport 相关联的 BeanContextServices

返回:
BeanContext 的实例,此对象将为其提供实现。

createBCSChild

protected BeanContextSupport.BCSChild createBCSChild(Object targetChild,
                                                     Object peer)

子类可以重写此方法来插入自己的 Child 的子类,而不必重写 add() 或其他将子级添加到集合中的 Collection 方法。

覆盖:
BeanContextSupport 中的 createBCSChild
参数:
targetChild - 要创建自己的 Child 的子级
peer - 同位体,如果 targetChild 和同位体通过 BeanContextProxy 建立联系

createBCSSServiceProvider

protected BeanContextServicesSupport.BCSSServiceProvider createBCSSServiceProvider(Class sc,
                                                                                   BeanContextServiceProvider bcsp)
子类可以重写此方法来创建 BCSSServiceProvider 的新子类,而不必为了实例化而重写 addService()。


addBeanContextServicesListener

public void addBeanContextServicesListener(BeanContextServicesListener bcsl)
添加一个 BeanContextServicesListener。

指定者:
接口 BeanContextServices 中的 addBeanContextServicesListener
参数:
bcsl - 要添加的 BeanContextServicesListener

removeBeanContextServicesListener

public void removeBeanContextServicesListener(BeanContextServicesListener bcsl)
移除一个 BeanContextServicesListener。

指定者:
接口 BeanContextServices 中的 removeBeanContextServicesListener
参数:
bcsl - 要从此上下文移除的 BeanContextServicesListener

addService

public boolean addService(Class serviceClass,
                          BeanContextServiceProvider bcsp)
添加服务。

指定者:
接口 BeanContextServices 中的 addService
参数:
serviceClass - 要添加的服务
bcsp - 与该服务相关联的 BeanContextServiceProvider

addService

protected boolean addService(Class serviceClass,
                             BeanContextServiceProvider bcsp,
                             boolean fireEvent)
添加服务。


revokeService

public void revokeService(Class serviceClass,
                          BeanContextServiceProvider bcsp,
                          boolean revokeCurrentServicesNow)
移除服务。

指定者:
接口 BeanContextServices 中的 revokeService
参数:
serviceClass - 要从此 BeanContextServices 中取消的服务
bcsp - 与将取消的特定服务有关联的 BeanContextServiceProvider
revokeCurrentServicesNow - 值为 true 指示一个异常环境,在该环境中,BeanContextServiceProviderBeanContextServices 希望立即终止为指定服务的所有当前突出引用提供服务。

hasService

public boolean hasService(Class serviceClass)
具有一个可被委托的服务。

指定者:
接口 BeanContextServices 中的 hasService
参数:
serviceClass - 相关服务
返回:
如果可得到服务,则返回 true

getService

public Object getService(BeanContextChild child,
                         Object requestor,
                         Class serviceClass,
                         Object serviceSelector,
                         BeanContextServiceRevokedListener bcsrl)
                  throws TooManyListenersException
获得一个可被委托的服务。

指定者:
接口 BeanContextServices 中的 getService
参数:
child - 与此请求相关联的 BeanContextChild
requestor - 请求服务的对象
serviceClass - 所请求服务的类
serviceSelector - 与服务有关的参数
bcsrl - 通知稍后是否应该取消服务的 BeanContextServiceRevokedListener
返回:
所请求的此上下文的指定 Service 的引用,或 null
抛出:
TooManyListenersException

releaseService

public void releaseService(BeanContextChild child,
                           Object requestor,
                           Object service)
释放服务。

指定者:
接口 BeanContextServices 中的 releaseService
参数:
child - BeanContextChild
requestor - 请求者
service - 服务

getCurrentServiceClasses

public Iterator getCurrentServiceClasses()
从接口 BeanContextServices 复制的描述
获得此上下文的当前可用服务。

指定者:
接口 BeanContextServices 中的 getCurrentServiceClasses
返回:
所有当前已注册服务类的迭代器。

getCurrentServiceSelectors

public Iterator getCurrentServiceSelectors(Class serviceClass)
从接口 BeanContextServices 复制的描述
通过在基础 BeanContextServiceProvider 上调用 getCurrentServiceSelectors() 获得指定服务的与服务有关的服务参数列表(服务选择器)。

指定者:
接口 BeanContextServices 中的 getCurrentServiceSelectors
参数:
serviceClass - 指定服务
返回:
所有可用于指定服务的当前可用服务选择器(如果有)的迭代器。

serviceAvailable

public void serviceAvailable(BeanContextServiceAvailableEvent bcssae)
BeanContextServicesListener 回调,如果此 BeanContextService 自己尚未实现此服务,则将事件传播到所有当前已注册侦听器和 BeanContextServices 子级。 子类可重写或封装此方法来实现自己的传播语义。

指定者:
接口 BeanContextServicesListener 中的 serviceAvailable
覆盖:
BeanContextChildSupport 中的 serviceAvailable
参数:
bcssae - 由于服务变得可用而触发的 BeanContextServiceAvailableEvent

serviceRevoked

public void serviceRevoked(BeanContextServiceRevokedEvent bcssre)
BeanContextServicesListener 回调,如果此 BeanContextService 自己尚未实现此服务,则将事件传播到所有当前已注册侦听器和 BeanContextServices 子级。 子类可重写或封装此方法来实现自己的传播语义。

指定者:
接口 BeanContextServiceRevokedListener 中的 serviceRevoked
覆盖:
BeanContextChildSupport 中的 serviceRevoked
参数:
bcssre - 由于取消服务而触发的 BeanContextServiceRevokedEvent

getChildBeanContextServicesListener

protected static final BeanContextServicesListener getChildBeanContextServicesListener(Object child)
获得指定子级的 BeanContextServicesListener(如果有)。

参数:
child - 指定子级
返回:
指定子级的 BeanContextServicesListener(如果有)

childJustRemovedHook

protected void childJustRemovedHook(Object child,
                                    BeanContextSupport.BCSChild bcsc)
在已成功移除子级之后,从超类的子级移除操作中调用。使用同步的子级调用。 如果此子级是一个 BeanContextChild,则该子类使用此钩子 (hook) 立即取消正由此子级使用的所有服务。 为了实现自己的子级移除副作用,子类可以封装此方法。

覆盖:
BeanContextSupport 中的 childJustRemovedHook

releaseBeanContextResources

protected void releaseBeanContextResources()
从 setBeanContext 中调用,以通知 BeanContextChild 释放从嵌套 BeanContext 中获得的资源。 此方法取消从其父级中获得的所有服务。 子类可以封装此方法来实现自己的语义。

覆盖:
BeanContextChildSupport 中的 releaseBeanContextResources

initializeBeanContextResources

protected void initializeBeanContextResources()
从 setBeanContext 中调用,以通知 BeanContextChild 分配从嵌套 BeanContext 中获得的资源。 子类可以封装此方法来实现自己的语义。

覆盖:
BeanContextChildSupport 中的 initializeBeanContextResources

fireServiceAdded

protected final void fireServiceAdded(Class serviceClass)
触发一个通知新服务的 BeanContextServiceEvent


fireServiceAdded

protected final void fireServiceAdded(BeanContextServiceAvailableEvent bcssae)
触发一个指示新服务已变得可用的 BeanContextServiceAvailableEvent

参数:
bcssae - BeanContextServiceAvailableEvent

fireServiceRevoked

protected final void fireServiceRevoked(BeanContextServiceRevokedEvent bcsre)
触发一个通知将被取消的服务的 BeanContextServiceEvent

参数:
bcsre - BeanContextServiceRevokedEvent

fireServiceRevoked

protected final void fireServiceRevoked(Class serviceClass,
                                        boolean revokeNow)
触发一个指示某一特定服务不再可用的 BeanContextServiceRevokedEvent


bcsPreSerializationHook

protected void bcsPreSerializationHook(ObjectOutputStream oos)
                                throws IOException
在序列化子级之前,从 BeanContextSupport writeObject 中调用。 此类将序列化这里的所有 Serializable BeanContextServiceProviders。 子类可以封装此方法来插入自己的序列化处理,该处理操作必须发生在序列化子级之前。

覆盖:
BeanContextSupport 中的 bcsPreSerializationHook
抛出:
IOException

bcsPreDeserializationHook

protected void bcsPreDeserializationHook(ObjectInputStream ois)
                                  throws IOException,
                                         ClassNotFoundException
在反序列化子级之前,从 BeanContextSupport readObject 中调用。 此类将反序列化以前已序列化的所有 Serializable BeanContextServiceProviders,这样可以使它们在反序列化时用于子级。 子类可以封装此方法来插入自己的序列化处理,该处理操作必须发生在序列化子级之前。

覆盖:
BeanContextSupport 中的 bcsPreDeserializationHook
抛出:
IOException
ClassNotFoundException

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only