org.apache.commons.logging
クラス LogFactory

java.lang.Object
  拡張org.apache.commons.logging.LogFactory
直系の既知のサブクラス:
Log4jFactory, LogFactoryImpl

public abstract class LogFactory
extends Object

Log インスタンスを生成するファクトリです。(ログ処理の)製品の発見・設定を行う機能は、 JAXP のような標準的な Java API で使われている機能に類似しています。

Factory for creating {@link Log} instances, with discovery and configuration features similar to that employed by standard Java APIs such as JAXP.

実装に関する注記 - この実装の多くは Apache Xerces 内の (JAXP のプラグイン的機能のAPIに相当する) SAXParserFactory と DocumentBuilderFactory の実装をベースとしています。

IMPLEMENTATION NOTE - This implementation is heavily based on the SAXParserFactory and DocumentBuilderFactory implementations (corresponding to the JAXP pluggability APIs) found in Apache Xerces.

バージョン:
$Revision: 1.3 $ $Date: 2004/04/08 12:23:54 $
作成者:
Craig R. McClanahan, Costin Manolache, Richard A. Sitze
翻訳者:
日置 聡
校正者:
高橋 達男
翻訳状況:
校了

フィールドの概要
protected static Hashtable factories
          生成時に使用された ClassLoader をキーとして格納される 生成済みの LogFactory インスタンス。
static String FACTORY_DEFAULT
          他に設定が見つからなかった場合に使用するデフォルトの LogFactory 実装クラスの完全修飾名。
static String FACTORY_PROPERTIES
          検索対象となるプロパティファイルの名称。
static String FACTORY_PROPERTY
          LogFactory 実装クラス名を特定するために使用するプロパティの名称。
protected static String SERVICE_ID
          JDK1.3 以降で適用される 'サービスプロバイダ' の識別情報。
 
コンストラクタの概要
protected LogFactory()
          public で利用できないようにするための protected コンストラクタ。
 
メソッドの概要
private static void cacheFactory(ClassLoader classLoader, LogFactory factory)
           
abstract  Object getAttribute(String name)
          指定された名称の設定のための属性を返します(もしあれば)。
abstract  String[] getAttributeNames()
          現在設定されている全ての属性の名称を配列に格納して返します。
private static LogFactory getCachedFactory(ClassLoader contextClassLoader)
          キャッシュしているファクトリをチェックします(クラスローダをキーとして)。
protected static ClassLoader getContextClassLoader()
          利用できる場合にはスレッドコンテキストクラスローダを返します。
static LogFactory getFactory()
          以下の順番でロードする実装クラスの名称を検索し、 LogFactory インスタンスを (必要ならば生成して) 返します。
abstract  Log getInstance(Class clazz)
          指定されたクラスから名称を取得して自身の getInstance(String) を呼ぶ、手順簡略化のためのメソッドです。
abstract  Log getInstance(String name)
          現在のファクトリに設定されている属性を使用して Log インスタンスを(必要ならば生成して)返します。
static Log getLog(Class clazz)
          アプリケーションがファクトリを意識せずに指定した名称のロガーを取得できる 手順簡略化のためのメソッドです。
static Log getLog(String name)
          アプリケーションがファクトリを意識せずに指定した名称のロガーを取得できる 手順簡略化のためのメソッドです。
private static InputStream getResourceAsStream(ClassLoader loader, String name)
           
protected static LogFactory newFactory(String factoryClass, ClassLoader classLoader)
          指定した LogFactory 実装クラスの新しいインスタンスを、 指定したクラスローダからロードして返します。
abstract  void release()
          その時点までにこのファクトリが生成して返した全ての Log インスタンスへの内部参照を解放します。
static void release(ClassLoader classLoader)
          指定したクラスローダに関連し、その時点までに生成された各 LogFactory インスタンスの release() メソッドを呼んだ後、 各インスタンスへの内部参照を (もしあれば) すべて解放します。
static void releaseAll()
          その時点までにこのファクトリが生成して返した全ての LogFactory インスタンスで release() を呼び出した後、各インスタンスへの内部参照を解放します。
abstract  void removeAttribute(String name)
          指定された名称の設定属性を削除します。
abstract  void setAttribute(String name, Object value)
          指定された名称の設定属性をセットします。
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

FACTORY_PROPERTY

public static final String FACTORY_PROPERTY
LogFactory 実装クラス名を特定するために使用するプロパティの名称。
The name of the property used to identify the LogFactory implementation class name.

関連項目:
定数フィールド値

FACTORY_DEFAULT

public static final String FACTORY_DEFAULT
他に設定が見つからなかった場合に使用するデフォルトの LogFactory 実装クラスの完全修飾名。
The fully qualified class name of the fallback LogFactory implementation class to use, if no other can be found.

関連項目:
定数フィールド値

FACTORY_PROPERTIES

public static final String FACTORY_PROPERTIES
検索対象となるプロパティファイルの名称。
The name of the properties file to search for.

関連項目:
定数フィールド値

SERVICE_ID

protected static final String SERVICE_ID
JDK1.3 以降で適用される 'サービスプロバイダ' の識別情報。 ( http://java.sun.com/j2se/1.3/ja/docs/ja/guide/jar/jar.html )
JDK1.3+ 'Service Provider' specification ( http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html )

関連項目:
定数フィールド値

factories

protected static Hashtable factories
生成時に使用された ClassLoader をキーとして格納される 生成済みの LogFactory インスタンス。
The previously constructed LogFactory instances, keyed by the ClassLoader with which it was created.

コンストラクタの詳細

LogFactory

protected LogFactory()
public で利用できないようにするための protected コンストラクタ。
Protected constructor that is not available for public use.

メソッドの詳細

getAttribute

public abstract Object getAttribute(String name)
指定された名称の設定のための属性を返します(もしあれば)。 指定された属性がない場合には null を返します。
Return the configuration attribute with the specified name (if any), or null if there is no such attribute.

パラメータ:
name - 取得する属性の名称
Name of the attribute to return

getAttributeNames

public abstract String[] getAttributeNames()
現在設定されている全ての属性の名称を配列に格納して返します。 属性が一つも存在しない場合には長さが0の配列を返します。
Return an array containing the names of all currently defined configuration attributes. If there are no such attributes, a zero length array is returned.


getInstance

public abstract Log getInstance(Class clazz)
                         throws LogConfigurationException
指定されたクラスから名称を取得して自身の getInstance(String) を呼ぶ、手順簡略化のためのメソッドです。
Convenience method to derive a name from the specified class and call getInstance(String) with it.

パラメータ:
clazz - 適切な Log 名称の取得元のクラス
Class for which a suitable Log name will be derived
例外:
LogConfigurationException - 適切な Log インスタンスを返せなかった場合
if a suitable Log instance cannot be returned

getInstance

public abstract Log getInstance(String name)
                         throws LogConfigurationException

現在のファクトリに設定されている属性を使用して Log インスタンスを(必要ならば生成して)返します。

Construct (if necessary) and return a Log instance, using the factory's current set of configuration attributes.

- 返される Log インスタンスが現在のアプリケーション固有のものであるかどうか、 また同じ名称を引数にこのメソッドを複数回呼んだ場合に同じインスタンスが返されるかどうかは使用している LogFactory に依存します。

NOTE - Depending upon the implementation of the LogFactory you are using, the Log instance you are returned may or may not be local to the current application, and may or may not be returned again on a subsequent call with the same name argument.

パラメータ:
name - 返される Log インスタンスの論理名 (名称の意味はラップされる内部のログ処理実装だけが知っています)
Logical name of the Log instance to be returned (the meaning of this name is only known to the underlying logging implementation that is being wrapped)
例外:
LogConfigurationException - 適切な Log インスタンスを返せなかった場合
if a suitable Log instance cannot be returned

release

public abstract void release()
その時点までにこのファクトリが生成して返した全ての Log インスタンスへの内部参照を解放します。 これはサーブレットコンテナのように、クラスローダを捨てるという方法で アプリケーションのリロードを実装している場合に役立ちます。 (捨てられた) クラスローダの配下のオブジェクトへの参照が宙ぶらりんになる (ダングリング) ため、 (このメソッドを呼び出さないと) ガベージコレクションが行なわれないからです。
Release any internal references to previously created {@link Log} instances returned by this factory. This is useful environments like servlet containers, which implement application reloading by throwing away a ClassLoader. Dangling references to objects in that class loader would prevent garbage collection.


removeAttribute

public abstract void removeAttribute(String name)
指定された名称の設定属性を削除します。 該当する属性がない場合には何も行いません。
Remove any configuration attribute associated with the specified name. If there is no such attribute, no action is taken.

パラメータ:
name - 削除する属性の名称
Name of the attribute to remove

setAttribute

public abstract void setAttribute(String name,
                                  Object value)
指定された名称の設定属性をセットします。 値に null が設定された場合には removeAttribute(name) を呼びます。
Set the configuration attribute with the specified name. Calling this with a null value is equivalent to calling removeAttribute(name).

パラメータ:
name - 設定する属性の名称
Name of the attribute to set
value - 設定する属性の値。 null の場合にはこの属性を削除
Value of the attribute to set, or null to remove any setting for this attribute

getFactory

public static LogFactory getFactory()
                             throws LogConfigurationException

以下の順番でロードする実装クラスの名称を検索し、 LogFactory インスタンスを (必要ならば生成して) 返します。

Construct (if necessary) and return a LogFactory instance, using the following ordered lookup procedure to determine the name of the implementation class to be loaded.

  • The org.apache.commons.logging.LogFactory system property.
  • The JDK 1.3 Service Discovery mechanism
  • Use the properties file commons-logging.properties file, if found in the class path of this class. The configuration file is in standard java.util.Properties format and contains the fully qualified name of the implementation class with the key being the system property defined above.
  • Fall back to a default implementation class (org.apache.commons.logging.impl.LogFactoryImpl).

- LogFactory 実装クラスを見つけるのにプロパティファイルを使った場合、 このファイル内に記述された全てのプロパティが、該当する LogFactory インスタンスの設定属性にセットされます。

NOTE - If the properties file method of identifying the LogFactory implementation class is utilized, all of the properties defined in this file will be set as configuration attributes on the corresponding LogFactory instance.

例外:
LogConfigurationException - 実装クラスが見つからない、またはインスタンス化できない場合
if the implementation class is not available or cannot be instantiated.

getLog

public static Log getLog(Class clazz)
                  throws LogConfigurationException
アプリケーションがファクトリを意識せずに指定した名称のロガーを取得できる 手順簡略化のためのメソッドです。
Convenience method to return a named logger, without the application having to care about factories.

パラメータ:
clazz - ログ名称の取得元のクラス
Class for which a log name will be derived
例外:
LogConfigurationException - 適切な Log インスタンスを返せなかった場合
if a suitable Log instance cannot be returned

getLog

public static Log getLog(String name)
                  throws LogConfigurationException
アプリケーションがファクトリを意識せずに指定した名称のロガーを取得できる 手順簡略化のためのメソッドです。
Convenience method to return a named logger, without the application having to care about factories.

パラメータ:
name - 返される Log インスタンスの論理名 (名称の意味はラップされる内部のログ処理実装だけが知っています)
Logical name of the Log instance to be returned (the meaning of this name is only known to the underlying logging implementation that is being wrapped)
例外:
LogConfigurationException - 適切な Log インスタンスを返せなかった場合
if a suitable Log instance cannot be returned

release

public static void release(ClassLoader classLoader)
指定したクラスローダに関連し、その時点までに生成された各 LogFactory インスタンスの release() メソッドを呼んだ後、 各インスタンスへの内部参照を (もしあれば) すべて解放します。
Release any internal references to previously created {@link LogFactory} instances that have been associated with the specified class loader (if any), after calling the instance method release() on each of them.

パラメータ:
classLoader - 解放対象の LogFactory が属するクラスローダ
ClassLoader for which to release the LogFactory

releaseAll

public static void releaseAll()
その時点までにこのファクトリが生成して返した全ての LogFactory インスタンスで release() を呼び出した後、各インスタンスへの内部参照を解放します。 これはサーブレットコンテナのように、クラスローダを捨てるという方法で アプリケーションのリロードを実装している場合に役立ちます。 (捨てられた) クラスローダの配下のオブジェクトへの参照が宙ぶらりんになる (ダングリング) ため、 (このメソッドを呼び出さないと) ガベージコレクションが行なわれないからです。
Release any internal references to previously created {@link LogFactory} instances, after calling the instance method release() on each of them. This is useful environments like servlet containers, which implement application reloading by throwing away a ClassLoader. Dangling references to objects in that class loader would prevent garbage collection.


getContextClassLoader

protected static ClassLoader getContextClassLoader()
                                            throws LogConfigurationException
利用できる場合にはスレッドコンテキストクラスローダを返します。 利用できない場合には null を返します。 セキュリティが信頼できる状態であれば スレッドコンテキストクラスローダは JDK 1.2 以降で利用することができます。
Return the thread context class loader if available. Otherwise return null. The thread context class loader is available for JDK 1.2 or later, if certain security conditions are met.

例外:
LogConfigurationException - 適切なクラスローダを認識できなかった場合。
if a suitable class loader cannot be identified.

getCachedFactory

private static LogFactory getCachedFactory(ClassLoader contextClassLoader)
キャッシュしているファクトリをチェックします(クラスローダをキーとして)。
Check cached factories (keyed by classLoader)


cacheFactory

private static void cacheFactory(ClassLoader classLoader,
                                 LogFactory factory)

newFactory

protected static LogFactory newFactory(String factoryClass,
                                       ClassLoader classLoader)
                                throws LogConfigurationException
指定した LogFactory 実装クラスの新しいインスタンスを、 指定したクラスローダからロードして返します。 失敗した場合にはこの (abstract の) LogFactory をロードする際に使用したクラスローダでロードを試みます。
Return a new instance of the specified LogFactory implementation class, loaded by the specified class loader. If that fails, try the class loader used to load this (abstract) LogFactory.

パラメータ:
factoryClass - LogFactory 実装クラスの完全修飾名
Fully qualified name of the LogFactory implementation class
classLoader - ファクトリクラスをロードする際に使用するクラスローダ
ClassLoader from which to load this class
例外:
LogConfigurationException - 適切なクラスローダを認識できなかった場合。
if a suitable class loader cannot be identified.

getResourceAsStream

private static InputStream getResourceAsStream(ClassLoader loader,
                                               String name)


このドキュメントは、Ja-Jakartaにより訳されました。 コメントがある場合は report@jajakarta.orgまでお願いします。
Translated into Japanese by jajakarta.org. The original page is here.
Copyright (c) 2002-2003 - Apache Software Foundation