本文整理汇总了Java中org.apache.catalina.util.Introspection类的典型用法代码示例。如果您正苦于以下问题:Java Introspection类的具体用法?Java Introspection怎么用?Java Introspection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Introspection类属于org.apache.catalina.util包,在下文中一共展示了Introspection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loadApplicationListenerAnnotations
import org.apache.catalina.util.Introspection; //导入依赖的package包/类
/**
* Process the annotations for the listeners.
*/
protected static void loadApplicationListenerAnnotations(Context context) {
Class<?> classClass = null;
String[] applicationListeners =
context.findApplicationListeners();
for (int i = 0; i < applicationListeners.length; i++) {
classClass = Introspection.loadClass(context,
applicationListeners[i]);
if (classClass == null) {
continue;
}
loadClassAnnotation(context, classClass);
loadFieldsAnnotation(context, classClass);
loadMethodsAnnotation(context, classClass);
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:20,代码来源:WebAnnotationSet.java
示例2: loadApplicationFilterAnnotations
import org.apache.catalina.util.Introspection; //导入依赖的package包/类
/**
* Process the annotations for the filters.
*/
protected static void loadApplicationFilterAnnotations(Context context) {
Class<?> classClass = null;
FilterDef[] filterDefs = context.findFilterDefs();
for (int i = 0; i < filterDefs.length; i++) {
classClass = Introspection.loadClass(context,
(filterDefs[i]).getFilterClass());
if (classClass == null) {
continue;
}
loadClassAnnotation(context, classClass);
loadFieldsAnnotation(context, classClass);
loadMethodsAnnotation(context, classClass);
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:19,代码来源:WebAnnotationSet.java
示例3: loadMethodsAnnotation
import org.apache.catalina.util.Introspection; //导入依赖的package包/类
protected static void loadMethodsAnnotation(Context context,
Class<?> classClass) {
// Initialize the annotations
Method[] methods = Introspection.getDeclaredMethods(classClass);
if (methods != null && methods.length > 0) {
for (Method method : methods) {
Resource annotation = method.getAnnotation(Resource.class);
if (annotation != null) {
if (!Introspection.isValidSetter(method)) {
throw new IllegalArgumentException(sm.getString(
"webAnnotationSet.invalidInjection"));
}
String defaultName = classClass.getName() + SEPARATOR +
Introspection.getPropertyName(method);
Class<?> defaultType =
(method.getParameterTypes()[0]);
addResource(context, annotation, defaultName, defaultType);
}
}
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:24,代码来源:WebAnnotationSet.java
示例4: findLifecycleCallback
import org.apache.catalina.util.Introspection; //导入依赖的package包/类
private static Method findLifecycleCallback(Method currentMethod,
String methodNameFromXml, Method method,
Class<? extends Annotation> annotation) {
Method result = currentMethod;
if (methodNameFromXml != null) {
if (method.getName().equals(methodNameFromXml)) {
if (!Introspection.isValidLifecycleCallback(method)) {
throw new IllegalArgumentException(
"Invalid " + annotation.getName() + " annotation");
}
result = method;
}
} else {
if (method.isAnnotationPresent(annotation)) {
if (currentMethod != null ||
!Introspection.isValidLifecycleCallback(method)) {
throw new IllegalArgumentException(
"Invalid " + annotation.getName() + " annotation");
}
result = method;
}
}
return result;
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:25,代码来源:DefaultInstanceManager.java
示例5: loadMethodsAnnotation
import org.apache.catalina.util.Introspection; //导入依赖的package包/类
protected static void loadMethodsAnnotation(Context context, Class<?> classClass) {
// Initialize the annotations
Method[] methods = Introspection.getDeclaredMethods(classClass);
if (methods != null && methods.length > 0) {
for (Method method : methods) {
Resource annotation = method.getAnnotation(Resource.class);
if (annotation != null) {
if (!Introspection.isValidSetter(method)) {
throw new IllegalArgumentException(sm.getString("webAnnotationSet.invalidInjection"));
}
String defaultName = classClass.getName() + SEPARATOR + Introspection.getPropertyName(method);
Class<?> defaultType = (method.getParameterTypes()[0]);
addResource(context, annotation, defaultName, defaultType);
}
}
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:20,代码来源:WebAnnotationSet.java
示例6: lookupMethodResource
import org.apache.catalina.util.Introspection; //导入依赖的package包/类
/**
* Inject resources in specified method.
*
* @param context
* jndi context to extract value from
* @param instance
* object to inject into
* @param method
* field target for injection
* @param name
* jndi name value is bound under
* @param clazz
* class annotation is defined in
* @throws IllegalAccessException
* if method is inaccessible
* @throws javax.naming.NamingException
* if value is not accessible in naming context
* @throws java.lang.reflect.InvocationTargetException
* if setter call fails
*/
protected static void lookupMethodResource(Context context, Object instance, Method method, String name,
Class<?> clazz) throws NamingException, IllegalAccessException, InvocationTargetException {
if (!Introspection.isValidSetter(method)) {
throw new IllegalArgumentException(sm.getString("defaultInstanceManager.invalidInjection"));
}
Object lookedupResource;
boolean accessibility;
String normalizedName = normalize(name);
if ((normalizedName != null) && (normalizedName.length() > 0)) {
lookedupResource = context.lookup(normalizedName);
} else {
lookedupResource = context.lookup(clazz.getName() + "/" + Introspection.getPropertyName(method));
}
synchronized (method) {
accessibility = method.isAccessible();
method.setAccessible(true);
method.invoke(instance, lookedupResource);
method.setAccessible(accessibility);
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:46,代码来源:DefaultInstanceManager.java
示例7: findLifecycleCallback
import org.apache.catalina.util.Introspection; //导入依赖的package包/类
private static Method findLifecycleCallback(Method currentMethod, String methodNameFromXml, Method method,
Class<? extends Annotation> annotation) {
Method result = currentMethod;
if (methodNameFromXml != null) {
if (method.getName().equals(methodNameFromXml)) {
if (!Introspection.isValidLifecycleCallback(method)) {
throw new IllegalArgumentException("Invalid " + annotation.getName() + " annotation");
}
result = method;
}
} else {
if (method.isAnnotationPresent(annotation)) {
if (currentMethod != null || !Introspection.isValidLifecycleCallback(method)) {
throw new IllegalArgumentException("Invalid " + annotation.getName() + " annotation");
}
result = method;
}
}
return result;
}
开发者ID:how2j,项目名称:lazycat,代码行数:21,代码来源:DefaultInstanceManager.java
示例8: loadApplicationListenerAnnotations
import org.apache.catalina.util.Introspection; //导入依赖的package包/类
/**
* Process the annotations for the listeners.
*/
protected static void loadApplicationListenerAnnotations(Context context) {
Class<?> classClass = null;
@SuppressWarnings("deprecation")
String[] applicationListeners =
context.findApplicationListeners();
for (int i = 0; i < applicationListeners.length; i++) {
classClass = Introspection.loadClass(context,
applicationListeners[i]);
if (classClass == null) {
continue;
}
loadClassAnnotation(context, classClass);
loadFieldsAnnotation(context, classClass);
loadMethodsAnnotation(context, classClass);
}
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:21,代码来源:WebAnnotationSet.java
示例9: loadFieldsAnnotation
import org.apache.catalina.util.Introspection; //导入依赖的package包/类
protected static void loadFieldsAnnotation(Context context,
Class<?> classClass) {
// Initialize the annotations
Field[] fields = Introspection.getDeclaredFields(classClass);
if (fields != null && fields.length > 0) {
for (Field field : fields) {
if (field.isAnnotationPresent(Resource.class)) {
Resource annotation = field.getAnnotation(Resource.class);
String defaultName =
classClass.getName() + SEPARATOR + field.getName();
Class<?> defaultType = field.getType();
addResource(context, annotation, defaultName, defaultType);
}
}
}
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:17,代码来源:WebAnnotationSet.java
示例10: loadMethodsAnnotation
import org.apache.catalina.util.Introspection; //导入依赖的package包/类
protected static void loadMethodsAnnotation(Context context,
Class<?> classClass) {
// Initialize the annotations
Method[] methods = Introspection.getDeclaredMethods(classClass);
if (methods != null && methods.length > 0) {
for (Method method : methods) {
if (method.isAnnotationPresent(Resource.class)) {
Resource annotation = method.getAnnotation(Resource.class);
if (!Introspection.isValidSetter(method)) {
throw new IllegalArgumentException(sm.getString(
"webAnnotationSet.invalidInjection"));
}
String defaultName = classClass.getName() + SEPARATOR +
Introspection.getPropertyName(method);
Class<?> defaultType =
(method.getParameterTypes()[0]);
addResource(context, annotation, defaultName, defaultType);
}
}
}
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:25,代码来源:WebAnnotationSet.java
示例11: loadFieldsAnnotation
import org.apache.catalina.util.Introspection; //导入依赖的package包/类
protected static void loadFieldsAnnotation(Context context,
Class<?> classClass) {
// Initialize the annotations
Field[] fields = Introspection.getDeclaredFields(classClass);
if (fields != null && fields.length > 0) {
for (Field field : fields) {
Resource annotation = field.getAnnotation(Resource.class);
if (annotation != null) {
String defaultName = classClass.getName() + SEPARATOR + field.getName();
Class<?> defaultType = field.getType();
addResource(context, annotation, defaultName, defaultType);
}
}
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:16,代码来源:WebAnnotationSet.java
示例12: getType
import org.apache.catalina.util.Introspection; //导入依赖的package包/类
private static String getType(Resource annotation, Class<?> defaultType) {
Class<?> type = annotation.type();
if (type == null || type.equals(Object.class)) {
if (defaultType != null) {
type = defaultType;
}
}
return Introspection.convertPrimitiveType(type).getCanonicalName();
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:10,代码来源:WebAnnotationSet.java
示例13: checkResourceType
import org.apache.catalina.util.Introspection; //导入依赖的package包/类
/**
* Checks that the configuration of the type for the specified resource is
* consistent with any injection targets and if the type is not specified,
* tries to configure the type based on the injection targets
*
* @param resource The resource to check
*
* @return <code>true</code> if the type for the resource is now valid (if
* previously <code>null</code> this means it is now set) or
* <code>false</code> if the current resource type is inconsistent
* with the injection targets and/or cannot be determined
*/
private boolean checkResourceType(ResourceBase resource) {
if (!(container instanceof Context)) {
// Only Context's will have injection targets
return true;
}
if (resource.getInjectionTargets() == null ||
resource.getInjectionTargets().size() == 0) {
// No injection targets so use the defined type for the resource
return true;
}
Context context = (Context) container;
String typeName = resource.getType();
Class<?> typeClass = null;
if (typeName != null) {
typeClass = Introspection.loadClass(context, typeName);
if (typeClass == null) {
// Can't load the type - will trigger a failure later so don't
// fail here
return true;
}
}
Class<?> compatibleClass =
getCompatibleType(context, resource, typeClass);
if (compatibleClass == null) {
// Indicates that a compatible type could not be identified that
// worked for all injection targets
return false;
}
resource.setType(compatibleClass.getCanonicalName());
return true;
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:49,代码来源:NamingResources.java
示例14: getSetterType
import org.apache.catalina.util.Introspection; //导入依赖的package包/类
private Class<?> getSetterType(Class<?> clazz, String name) {
Method[] methods = Introspection.getDeclaredMethods(clazz);
if (methods != null && methods.length > 0) {
for (Method method : methods) {
if (Introspection.isValidSetter(method) &&
Introspection.getPropertyName(method).equals(name)) {
return method.getParameterTypes()[0];
}
}
}
return null;
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:13,代码来源:NamingResources.java
示例15: getFieldType
import org.apache.catalina.util.Introspection; //导入依赖的package包/类
private Class<?> getFieldType(Class<?> clazz, String name) {
Field[] fields = Introspection.getDeclaredFields(clazz);
if (fields != null && fields.length > 0) {
for (Field field : fields) {
if (field.getName().equals(name)) {
return field.getType();
}
}
}
return null;
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:12,代码来源:NamingResources.java
示例16: lookupMethodResource
import org.apache.catalina.util.Introspection; //导入依赖的package包/类
/**
* Inject resources in specified method.
*
* @param context jndi context to extract value from
* @param instance object to inject into
* @param method field target for injection
* @param name jndi name value is bound under
* @param clazz class annotation is defined in
* @throws IllegalAccessException if method is inaccessible
* @throws javax.naming.NamingException if value is not accessible in naming context
* @throws java.lang.reflect.InvocationTargetException
* if setter call fails
*/
protected static void lookupMethodResource(Context context,
Object instance, Method method, String name, Class<?> clazz)
throws NamingException, IllegalAccessException, InvocationTargetException {
if (!Introspection.isValidSetter(method)) {
throw new IllegalArgumentException(
sm.getString("defaultInstanceManager.invalidInjection"));
}
Object lookedupResource;
boolean accessibility;
String normalizedName = normalize(name);
if ((normalizedName != null) && (normalizedName.length() > 0)) {
lookedupResource = context.lookup(normalizedName);
} else {
lookedupResource = context.lookup(
clazz.getName() + "/" + Introspection.getPropertyName(method));
}
synchronized (method) {
accessibility = method.isAccessible();
method.setAccessible(true);
method.invoke(instance, lookedupResource);
method.setAccessible(accessibility);
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:42,代码来源:DefaultInstanceManager.java
示例17: loadApplicationListenerAnnotations
import org.apache.catalina.util.Introspection; //导入依赖的package包/类
/**
* Process the annotations for the listeners.
*/
protected static void loadApplicationListenerAnnotations(Context context) {
Class<?> classClass = null;
String[] applicationListeners = context.findApplicationListeners();
for (int i = 0; i < applicationListeners.length; i++) {
classClass = Introspection.loadClass(context, applicationListeners[i]);
if (classClass == null) {
continue;
}
loadClassAnnotation(context, classClass);
loadFieldsAnnotation(context, classClass);
loadMethodsAnnotation(context, classClass);
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:18,代码来源:WebAnnotationSet.java
示例18: loadApplicationFilterAnnotations
import org.apache.catalina.util.Introspection; //导入依赖的package包/类
/**
* Process the annotations for the filters.
*/
protected static void loadApplicationFilterAnnotations(Context context) {
Class<?> classClass = null;
FilterDef[] filterDefs = context.findFilterDefs();
for (int i = 0; i < filterDefs.length; i++) {
classClass = Introspection.loadClass(context, (filterDefs[i]).getFilterClass());
if (classClass == null) {
continue;
}
loadClassAnnotation(context, classClass);
loadFieldsAnnotation(context, classClass);
loadMethodsAnnotation(context, classClass);
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:18,代码来源:WebAnnotationSet.java
示例19: loadFieldsAnnotation
import org.apache.catalina.util.Introspection; //导入依赖的package包/类
protected static void loadFieldsAnnotation(Context context, Class<?> classClass) {
// Initialize the annotations
Field[] fields = Introspection.getDeclaredFields(classClass);
if (fields != null && fields.length > 0) {
for (Field field : fields) {
Resource annotation = field.getAnnotation(Resource.class);
if (annotation != null) {
String defaultName = classClass.getName() + SEPARATOR + field.getName();
Class<?> defaultType = field.getType();
addResource(context, annotation, defaultName, defaultType);
}
}
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:15,代码来源:WebAnnotationSet.java
示例20: getType
import org.apache.catalina.util.Introspection; //导入依赖的package包/类
private static String getType(Resource annotation, Class<?> defaultType) {
Class<?> type = annotation.type();
if (type == null || type.equals(Object.class)) {
if (defaultType != null) {
type = defaultType;
}
}
return Introspection.convertPrimitiveType(type).getCanonicalName();
}
开发者ID:how2j,项目名称:lazycat,代码行数:10,代码来源:WebAnnotationSet.java
注:本文中的org.apache.catalina.util.Introspection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论