/** * * This method calls getClass(Class, ClassLoader) with this class' * ClassLoader. * * @param className * The name of the class to load. * * @return The Class representing the given class name. A RuntimeException * is thrown if the class is not found. * * @see #exists(String) * */ public static Class getClass(String className) { if (_helper != null) { Class clazz = _helper.getClass(className); if (clazz != null) return clazz; } return getClass(className, _DEFAULT_CLASS_LOADER); }
/** * * @param type * * @return The unqualified (local) name of the class/interface. If the type * is an array, the [] characters will be appended. * */ public static String getShortName(Class type) { if (type.isArray()) { Class base = getClassFromArrayClass(type); String name = getShortName(base); return name + "[]"; } return getShortName(type.getName()); }
protected MessageHandler createGetCurrentMessageHandler() { MessageHandler handler = new GetCurrentMessageHandler(); Method method = ReflectUtils.getFirstMethod(getClass(), "getCurrentMessage"); handler.setMethod(method); return handler; }
/** * * This is a convenience method that invokes newInstance(Class) with a Class * object representing the given type. * * @see #getClass(String, ClassLoader) * @see #newInstance(Class) * */ public static Object newInstance(String className) { return newInstance(getClass(className)); }
ReflectUtils instance = new ReflectUtils(); _DEFAULT_CLASS_LOADER = instance.getClass().getClassLoader(); _helper = null; theClass = getClassFromArrayClass(theClass); return getPackageName(theClass.getName());
Class type = ReflectUtils.getClassFromArrayClass(getArrayClass()); Object array = Array.newInstance(type, children.length); Serializer serializer = getClassSerializer();
public Serializer create() { return (Serializer)ReflectUtils.newInstance(getSerializerClass()); }
/** * * Associates the given serializer with the type and any of its sub-types. * An ArraySerializer is also created for arrays of the type. * * @param type * @param ser * */ public void registerSerializer(Class type, Serializer ser) { if (type == null) throw new NullPointerException(_MESSAGES.get("NullClass")); if (ser == null) throw new NullPointerException(_MESSAGES.get("NullSerializer")); // // make an array version of the serializer // Class arrayType = ReflectUtils.getArrayClassFromClass(type); Serializer array = new ArraySerializer(arrayType, ser); _serializers.put(type, ser); _serializers.put(arrayType, array); }
/** * * This is a convenience method that invokes newInstance(Class) with a Class * object loaded by the given ClassLoader * * @see #getClass(String, ClassLoader) * @see #newInstance(Class) * */ public static Object newInstance(String className, ClassLoader classLoader) { return newInstance(getClass(className, classLoader)); }
Class theClass = ReflectUtils.getClassFromArrayClass(paramTypes[0]); Serializer ser = registry.getSerializer(theClass);
values = (Collection)ReflectUtils.newInstance(_collectionClass); super.put(key, values); ++_keySize;
Class type = ser.getSerializableType(); Class arrayType = ReflectUtils.getArrayClassFromClass(type); Serializer arraySer = new ArraySerializer(arrayType, ser);
protected MessageHandler createSetHandler() { MessageHandler handler = new SetHandler(); Method method = ReflectUtils.getFirstMethod(getClass(), "setResourceProperties"); handler.setMethod(method); return handler; }
protected Class createImplementationClass(Element xml, Environment env) { String className = XmlUtils.getElementText(xml, DescriptorConstants.JAVA_CAPABILITY_QNAME); // // null return value necessary to support default/required capability // implementations for some vendors // if (className == null) return null; return ReflectUtils.getClass(className, env.getClassLoader()); }
protected ResourceIdFactory createResourceIdFactory(Element xml, Environment env) { QName qname = DescriptorConstants.JAVA_ID_FACTORY_QNAME; String className = XmlUtils.getElementText(xml, qname); if (className == null) return null; Class theClass = null; ClassLoader loader = env.getClassLoader(); theClass = ReflectUtils.getClass(className, loader); if (!ResourceIdFactory.class.isAssignableFrom(theClass)) { Object[] filler = { className, ResourceIdFactory.class.getName() }; throw new RuntimeException(_MESSAGES.get("NotResourceIdFactory", filler)); } return (ResourceIdFactory)ReflectUtils.newInstance(theClass); }
type = ReflectUtils.getClassFromArrayClass(value.getClass());
public Persistence newInstance() { Persistence persistence = (Persistence)ReflectUtils.newInstance(getPersistenceClass()); persistence.setPersistenceLocation(getPersistenceLocation()); return persistence; }
protected MessageHandler createGetDocumentHandler() { MessageHandler handler = new GetDocumentHandler(); Method method = ReflectUtils.getFirstMethod(getClass(), "getResourcePropertyDocument"); handler.setMethod(method); return handler; }
protected Class createPersistenceClass(Element persistenceXML, Environment env) { String className = XmlUtils.getElementText(persistenceXML, DescriptorConstants.JAVA_PERSISTENCE_QNAME); ClassLoader loader = env.getClassLoader(); Class theClass = ReflectUtils.getClass(className, loader); // // make sure this class is an instance of RouterPersistence // if (!Persistence.class.isAssignableFrom(theClass)) { Object[] filler = { className, RouterPersistence.class.getName() }; String message = _MESSAGES.get("IncorrectPersistenceRoot", filler); throw new RuntimeException(message); } return theClass; }
public Capability newInstance() { Class theClass = getImplementationClass(); Capability capability = (Capability)ReflectUtils.newInstance(theClass); capability.setCapabilityURI(getURI()); capability.setMessageHandlers(getMessageHandlers()); capability.setInitializationParameters(getInitializationParameters()); PersistenceDefinition persistenceDef = getPersistenceDefinition(); if (persistenceDef != null) { Persistence persistence = persistenceDef.newInstance(); capability.setPersistence(persistence); } return capability; }