本文整理匯總了Java中com.google.inject.Key.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java Key.toString方法的具體用法?Java Key.toString怎麽用?Java Key.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.inject.Key
的用法示例。
在下文中一共展示了Key.toString方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: scope
import com.google.inject.Key; //導入方法依賴的package包/類
public <T> Provider<T> scope(final Key<T> key, final Provider<T> creator)
{
if (log.isDebugEnabled())
{
log.debug(String.format(
"scope %s: adding key %s with creator %s",
scopeName, key, creator
));
}
scopedKeys.add(key);
final String name = key.toString();
return new Provider<T>()
{
public T get()
{
if (log.isDebugEnabled())
{
log.debug(String.format(
"scope %s: getting key %s with creator %s",
scopeName, key, creator
));
}
C context = getContext(key);
R registry = registryFor(context);
InstanceProvider<T> future =
AbstractContextScope.this.get(registry, key, name);
if (future == null)
{
InstanceProvider<T> futureTask = new FutureTaskProvider<T>(creator);
future = putIfAbsent(registry, key, name, futureTask);
if (future == null)
{
future = futureTask;
futureTask.run();
if (Thread.currentThread().isInterrupted())
{
remove(registry, key, name, futureTask);
}
}
}
return future.get();
}
public String toString()
{
return new ToStringBuilder(this.getClass())
.add("scopeName", scopeName)
.add("type", type)
.add("key", key)
.add("creator", creator)
.toString();
}
};
}