LifecycleFactory (Java EE 5)

Java EE API


javax.faces.lifecycle Class LifecycleFactory

java.lang.Object
  extended by javax.faces.lifecycle.LifecycleFactory

public abstract class LifecycleFactory
extends Object


LifecycleFactory 是创建(如有需要)和返回 Lifecycle 实例的工厂对象。JavaServer Faces 实现必须至少提供一个默认的 Lifecycle 实现。高级实现(或外部第三方库)可以提供附加的 Lifecycle 实现(以生命周期标识符作为关键字),用于根据每个请求执行不同类型的请求处理。

每个利用 JavaServer Faces 的 Web 应用程序都必须有一个 LifecycleFactory 实例。可以通过可移植的方式获取此实例,即调用:

LifecycleFactory factory = (LifecycleFactory)
FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
 
英文文档:

LifecycleFactory is a factory object that creates (if needed) and returns Lifecycle instances. Implementations of JavaServer Faces must provide at least a default implementation of Lifecycle. Advanced implementations (or external third party libraries) MAY provide additional Lifecycle implementations (keyed by lifecycle identifiers) for performing different types of request processing on a per-request basis.

There must be one LifecycleFactory instance per web application that is utilizing JavaServer Faces. This instance can be acquired, in a portable manner, by calling:

   LifecycleFactory factory = (LifecycleFactory)
    FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
 


Field Summary
static String
 
Constructor Summary
 
Method Summary
abstract  void
abstract  Lifecycle
abstract  Iterator<String>
 
Methods inherited from class java.lang.Object
 

Field Detail

英文文档:

DEFAULT_LIFECYCLE

public static final String DEFAULT_LIFECYCLE

The lifecycle identifier for the default Lifecycle instance for this JavaServer Faces implementation.

See Also:
Constant Field Values

Constructor Detail

public LifecycleFactory()
英文文档:

LifecycleFactory

public LifecycleFactory()
Method Detail

abstract public void addLifecycle(String lifecycleId, Lifecycle lifecycle)

注册与指定 lifecycleId 关联的新 Lifecycle 实例,以便此 LifecycleFactory 为其提供支持。此方法可以在任意时间调用,并使相应的 Lifecycle 实例在此 Web 应用程序剩余的生命周期内一直可用。

lifecycleIdLifecycle 的标识符
lifecycle 要注册的 Lifecycle 实例
ThrowsIllegalArgumentException: 如果已经注册了带有指定 lifecycleIdLifecycle
ThrowsNullPointerException: 如果 lifecycleIdlifecyclenull
英文文档:

addLifecycle

public abstract void addLifecycle(String lifecycleId,
                                  Lifecycle lifecycle)

Register a new Lifecycle instance, associated with the specified lifecycleId, to be supported by this LifecycleFactory. This method may be called at any time, and makes the corresponding Lifecycle instance available throughout the remaining lifetime of this web application.

Parameters:
lifecycleId - Identifier of the new Lifecycle
lifecycle - Lifecycle instance that we are registering
Throws:
IllegalArgumentException - if a Lifecycle with the specified lifecycleId has already been registered
NullPointerException - if lifecycleId or lifecycle is null

abstract public Lifecycle getLifecycle(String lifecycleId)

为指定的生命周期标识符创建(如有需要)并返回 Lifecycle 实例。通过 getLifecycleIds() 方法可以获得可用生命周期标识符集合。

每次对同一个 Web 应用程序中的相同 lifecycleId 调用 getLifecycle() 都必须返回相同的 Lifecycle 实例。

lifecycleId 请求的 Lifecycle 实例的生命周期标识符
ThrowsIllegalArgumentException: 如果对于指定的标识符没有任何可以返回的 Lifecycle 实例
ThrowsNullPointerException: 如果 lifecycleIdnull
英文文档:

getLifecycle

public abstract Lifecycle getLifecycle(String lifecycleId)

Create (if needed) and return a Lifecycle instance for the specified lifecycle identifier. The set of available lifecycle identifiers is available via the getLifecycleIds() method.

Each call to getLifecycle() for the same lifecycleId, from within the same web application, must return the same Lifecycle instance.

Parameters:
lifecycleId - Lifecycle identifier of the requested Lifecycle instance
Throws:
IllegalArgumentException - if no Lifecycle instance can be returned for the specified identifier
NullPointerException - if lifecycleId is null

abstract public java.util.Iterator<E> getLifecycleIds()

返回一个对此工厂支持的生命周期标识符集合进行迭代的 Iterator。此集合必须包括 LifecycleFactory.DEFAULT_LIFECYCLE 指定的值。

英文文档:

getLifecycleIds

public abstract Iterator<String> getLifecycleIds()

Return an Iterator over the set of lifecycle identifiers supported by this factory. This set must include the value specified by LifecycleFactory.DEFAULT_LIFECYCLE.



Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!