本文整理匯總了Java中javax.annotation.Resource.lookup方法的典型用法代碼示例。如果您正苦於以下問題:Java Resource.lookup方法的具體用法?Java Resource.lookup怎麽用?Java Resource.lookup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.annotation.Resource
的用法示例。
在下文中一共展示了Resource.lookup方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: resolveResource
import javax.annotation.Resource; //導入方法依賴的package包/類
@Override
public Object resolveResource(InjectionPoint injectionPoint) {
Resource resource = getResourceAnnotation(injectionPoint);
if (resource == null) {
throw new IllegalArgumentException("No @Resource annotation found on " + injectionPoint);
}
if (injectionPoint.getMember() instanceof Method && ((Method) injectionPoint.getMember()).getParameterTypes().length != 1) {
throw new IllegalArgumentException(
"Injection point represents a method which doesn't follow JavaBean conventions (must have exactly one parameter) " + injectionPoint);
}
String name;
if (!resource.lookup().equals("")) {
name = resource.lookup();
} else {
name = getResourceName(injectionPoint);
}
return resources.get(name);
}