org.apache.commons.logging.impl
クラス LogFactoryImpl

java.lang.Object
  拡張org.apache.commons.logging.LogFactory
      拡張org.apache.commons.logging.impl.LogFactoryImpl

public class LogFactoryImpl
extends LogFactory

ログ実装のラッパを生成するため、次のアルゴリズムで動的にログ実装を選択する、 LogFactory の具象サブクラスです。

Concrete subclass of {@link LogFactory} that implements the following algorithm to dynamically select a logging implementation class to instantiate a wrapper for.

もし選択した Log 実装クラスが LogFactory を引数に取る setLogFactory() メソッドを持つ場合は、ファクトリと関連付けるために 新たに生成したインスタンスのこのメソッドを実行します。 これにより、 Log インスタンスはファクトリに設定された属性を利用可能になります。

If the selected {@link Log} implementation class has a setLogFactory() method that accepts a {@link LogFactory} parameter, this method will be called on each newly created instance to identify the associated factory. This makes factory configuration attributes available to the Log instance, if it so desires.

このファクトリは前に作成した Log インスタンスを記憶し、同じ名前で 再度 getInstance() メソッドが呼ばれた場合に(同じインスタンスを)返します。 この実装はいかなる設定された属性も無視します。

This factory will remember previously created Log instances for the same name, and will return them on repeated requests to the getInstance() method. This implementation ignores any configured attributes.

バージョン:
$Revision: 1.4 $ $Date: 2004/04/20 14:55:40 $
作成者:
Rod Waldhoff, Craig R. McClanahan, Richard A. Sitze
翻訳者:
日置 聡
校正者:
本間 宏崇
翻訳状況:
校了

フィールドの概要
protected  Hashtable attributes
          設定のための属性。
protected  Hashtable instances
          ロガーの名称をキーにして保持される、既に生成された Log インスタンス。
static String LOG_PROPERTY
          使用する Log 実装クラスを特定するシステムプロパティ名。
protected static String LOG_PROPERTY_OLD
          古い LogSource クラスとの 下位互換のための、推奨されないシステムプロパティ名。
private  String logClassName
          Log インターフェイスを実装するクラスの名称。
protected  Constructor logConstructor
          新規インスタンスの生成に使用される、引数が 1 つの Log 実装クラスのコンストラクタ。
protected  Class[] logConstructorSignature
          コンストラクタで使用される引数。
protected  Method logMethod
          選択された Log クラスの引数が 1 つの setLogFactory メソッド(もしあれば)。
protected  Class[] logMethodSignature
          setLogFactory メソッドで使用される引数。
 
クラス org.apache.commons.logging.LogFactory から継承したフィールド
factories, FACTORY_DEFAULT, FACTORY_PROPERTIES, FACTORY_PROPERTY, SERVICE_ID
 
コンストラクタの概要
LogFactoryImpl()
          ファクトリの検索機構が必要とする、引数なしの public コンストラクタ。
 
メソッドの概要
 Object getAttribute(String name)
          指定された名称の設定属性を返します(もしあれば)。
 String[] getAttributeNames()
          現在設定されている全属性の名称を配列で返します。
 Log getInstance(Class clazz)
          指定クラスから取得した名称を引数に getInstance(String) を呼ぶ、手順簡略化のためのメソッドです。
 Log getInstance(String name)
          現在ファクトリに設定されている属性を使用して Log インスタンスを(必要であれば)生成し返します。
protected  String getLogClassName()
          使用する Log 実装クラスの完全修飾クラス名を返します。
protected  Constructor getLogConstructor()
          新規 Log インスタンスの生成に使用するコンストラクタを返します。
protected  boolean isJdk14Available()
          JDK 1.4 以降のログ機能を利用可能か?
protected  boolean isLog4JAvailable()
          Log4J 実装を利用可能か?
private static Class loadClass(String name)
          このメソッドは PRIVATE のままでなくてはなりません。
protected  Log newInstance(String name)
          指定された名称の新規 Log インスタンスを生成し、返します。
 void release()
          このファクトリがこれまで生成・返却した全ての Log インスタンスへの内部参照を解放します。
 void removeAttribute(String name)
          指定された名称の設定属性を削除します。
 void setAttribute(String name, Object value)
          指定された名称の設定属性を設定します。
 
クラス org.apache.commons.logging.LogFactory から継承したメソッド
getContextClassLoader, getFactory, getLog, getLog, newFactory, release, releaseAll
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

LOG_PROPERTY

public static final String LOG_PROPERTY
使用する Log 実装クラスを特定するシステムプロパティ名。
The name of the system property identifying our {@link Log} implementation class.

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

LOG_PROPERTY_OLD

protected static final String LOG_PROPERTY_OLD
古い LogSource クラスとの 下位互換のための、推奨されないシステムプロパティ名。
The deprecated system property used for backwards compatibility with the old {@link org.apache.commons.logging.LogSource} class.

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

attributes

protected Hashtable attributes
設定のための属性。
Configuration attributes


instances

protected Hashtable instances
ロガーの名称をキーにして保持される、既に生成された Log インスタンス。
The {@link org.apache.commons.logging.Log} instances that have already been created, keyed by logger name.


logClassName

private String logClassName
Log インターフェイスを実装するクラスの名称。
Name of the class implementing the Log interface.


logConstructor

protected Constructor logConstructor
新規インスタンスの生成に使用される、引数が 1 つの Log 実装クラスのコンストラクタ。 この値は getLogConstructor() で初期化され、繰り返し使用されます。
The one-argument constructor of the {@link org.apache.commons.logging.Log} implementation class that will be used to create new instances. This value is initialized by getLogConstructor(), and then returned repeatedly.


logConstructorSignature

protected Class[] logConstructorSignature
コンストラクタで使用される引数。
The signature of the Constructor to be used.


logMethod

protected Method logMethod
選択された Log クラスの引数が 1 つの setLogFactory メソッド(もしあれば)。
The one-argument setLogFactory method of the selected {@link org.apache.commons.logging.Log} method, if it exists.


logMethodSignature

protected Class[] logMethodSignature
setLogFactory メソッドで使用される引数。
The signature of the setLogFactory method to be used.

コンストラクタの詳細

LogFactoryImpl

public LogFactoryImpl()
ファクトリの検索機構が必要とする、引数なしの public コンストラクタ。
Public no-arguments constructor required by the lookup mechanism.

メソッドの詳細

getAttribute

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

定義:
クラス LogFactory 内の getAttribute
パラメータ:
name - 取得する属性の名称
Name of the attribute to return

getAttributeNames

public String[] getAttributeNames()
現在設定されている全属性の名称を配列で返します。 属性が 1 つも設定されていない場合は、サイズ 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.

定義:
クラス LogFactory 内の getAttributeNames

getInstance

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

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

getInstance

public 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.

定義:
クラス LogFactory 内の getInstance
パラメータ:
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 void release()
このファクトリがこれまで生成・返却した全ての Log インスタンスへの内部参照を解放します。 これはサーブレットコンテナのような環境で、実装されたアプリケーションに対して クラスローダからリロードが指示された場合に有用です。 そのクラスローダの配下で参照され続けるオブジェクトはガベージコレクションを妨げます。
Release any internal references to previously created {@link org.apache.commons.logging.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.

定義:
クラス LogFactory 内の release

removeAttribute

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

定義:
クラス LogFactory 内の removeAttribute
パラメータ:
name - 削除する属性の名称
Name of the attribute to remove

setAttribute

public void setAttribute(String name,
                         Object value)
指定された名称の設定属性を設定します。 引数 value への null 指定は removeAttribute(name) と同等です。
Set the configuration attribute with the specified name. Calling this with a null value is equivalent to calling removeAttribute(name).

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

getLogClassName

protected String getLogClassName()
使用する Log 実装クラスの完全修飾クラス名を返します。
Return the fully qualified Java classname of the {@link Log} implementation we will be using.


getLogConstructor

protected Constructor getLogConstructor()
                                 throws LogConfigurationException

新規 Log インスタンスの生成に使用するコンストラクタを返します。

Return the Constructor that can be called to instantiate new {@link org.apache.commons.logging.Log} instances.

実装の注 - 結局いかなる状況でも同じ Constructor インスタンスが取得されるため、 複数のスレッドがこのメソッドを呼ぶことにより起こる競合状況は無視されます。

IMPLEMENTATION NOTE - Race conditions caused by calling this method from more than one thread are ignored, because the same Constructor instance will ultimately be derived in all circumstances.

例外:
LogConfigurationException - 適切なコンストラクタを返せない場合
if a suitable constructor cannot be returned

loadClass

private static Class loadClass(String name)
                        throws ClassNotFoundException
このメソッドは PRIVATE のままでなくてはなりません。
MUST KEEP THIS METHOD PRIVATE.

このメソッドは AccessController.doPrivileged() を使用しているため、 org.apache.commons.logging.LogFactoryImpl の外部へ公開すると セキュリティ侵害につながります。

Exposing this method outside of org.apache.commons.logging.LogFactoryImpl will create a security violation: This method uses AccessController.doPrivileged().

クラスをロードします。まずスレッドクラスローダからロードを試み、 ロードできなかった場合にはこのクラスをロードしたクラスローダを使用します。
Load a class, try first the thread class loader, and if it fails use the loader that loaded this class.

例外:
ClassNotFoundException

isJdk14Available

protected boolean isJdk14Available()
JDK 1.4 以降のログ機能を利用可能か?
Is JDK 1.4 or later logging available?


isLog4JAvailable

protected boolean isLog4JAvailable()
Log4J 実装を利用可能か?
Is a Log4J implementation available?


newInstance

protected Log newInstance(String name)
                   throws LogConfigurationException
指定された名称の新規 Log インスタンスを生成し、返します。
Create and return a new {@link org.apache.commons.logging.Log} instance for the specified name.

パラメータ:
name - 新規ロガーの名称
Name of the new logger
例外:
LogConfigurationException - 新規インスタンスを生成できなかった場合
if a new instance cannot be created


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