/** * Accessor for the Java type being represented here. * @return The Java type */ public Class getJavaType() { return clr.classForName(typeName); }
/** * Method to validate an element against the accepted type. * @param clr The ClassLoaderResolver * @param element The element to validate * @return Whether it is valid. */ protected boolean validateElementType(ClassLoaderResolver clr, Object element) { if (element == null) { return true; } Class primitiveElementClass = ClassUtils.getPrimitiveTypeForType(element.getClass()); if (primitiveElementClass != null) { // Allow for the element type being primitive, and the user wanting to store its wrapper String elementTypeWrapper = elementType; Class elementTypeClass = clr.classForName(elementType); if (elementTypeClass.isPrimitive()) { elementTypeWrapper = ClassUtils.getWrapperTypeForPrimitiveType(elementTypeClass).getName(); } return clr.isAssignableFrom(elementTypeWrapper, element.getClass()); } return clr.isAssignableFrom(elementType, element.getClass()); } }
/** * Overwrite to have an opportunity to find resources from the delegate ClassLoaderResolver */ protected synchronized URL findResource(String name) { //avoid reentrant calls if (loadingResource) { return null; } loadingResource = true; try { URL url = super.findResource(name); if (url == null) { if (delegate != null) { url = delegate.getResource(name, null); } } return url; } finally { loadingResource = false; } } }
/** * Utility to validate the type of a value for storing in the Map. * @param clr The ClassLoaderResolver * @param value The value to check. */ protected void validateValueType(ClassLoaderResolver clr, Object value) { if (value == null && !allowNulls) { // Nulls not allowed and value is null throw new NullPointerException(Localiser.msg("056063")); } if (value != null && !clr.isAssignableFrom(valueType, value.getClass())) { throw new ClassCastException(Localiser.msg("056065", value.getClass().getName(), valueType)); } }
try resources = clr.getResources(location, null);
/** * Utility to validate the type of a key for storing in the Map. * @param clr The ClassLoaderResolver * @param key The key to check. */ protected void validateKeyType(ClassLoaderResolver clr, Object key) { if (key == null && !allowNulls) { // Nulls not allowed and key is null throw new NullPointerException(Localiser.msg("056062")); } if (key != null && !clr.isAssignableFrom(keyType, key.getClass())) { throw new ClassCastException(Localiser.msg("056064", key.getClass().getName(), keyType)); } }
try resources = clr.getResources(location, pc_class.getClassLoader());
private Class<?> classForName(ClassLoaderResolver clr, String typeStr) { // If typeStr is a primitive it is not a class we can look up using // Class.forName. Consult our map of primitive classnames to see // if this is the case. Class<?> clazz = PrimitiveUtils.PRIMITIVE_CLASSNAMES.get(typeStr); if (clazz == null) { clazz = clr.classForName(typeStr); } return clazz; }
Class elementTypeClass = clr.classForName(elementType); if (elementTypeClass.isPrimitive()) return clr.isAssignableFrom(elementTypeWrapper, element.getClass()); Class elementCls = clr.classForName(elementType); if (!storeMgr.getNucleusContext().getMetaDataManager().isPersistentInterface(elementType) && elementCls.isInterface()) return clr.isAssignableFrom(elementType, element.getClass());
/** * Utility to throw an exception if the object is not persistable. * @param op The ObjectProvider for the object */ void assertPCClass(ObjectProvider op) { Class c = op.getObject().getClass(); if (!op.getExecutionContext().getClassLoaderResolver().isAssignableFrom(cmd.getFullClassName(),c)) { throw new NucleusException(Localiser.msg("057013",cmd.getFullClassName(),c)).setFatal(); } }
classReaderInputStream = clr.getResource(inputResourceName,null).openStream(); cr = new ClassReader(classReaderInputStream);
try resources = clr.getResources(location, cls.getClassLoader()); try resources = clr.getResources(location, null);
/** * Parse comma separated string of class names and return a * corresponding array of classes * @param property the string with comma separated class names * @return */ private Class<?>[] getGroups(String property) { if (property==null || property.trim().length()==0) { return new Class<?>[] {javax.validation.groups.Default.class}; } else { String[] classNames = property.trim().split(","); Class<?>[] groups = new Class<?>[classNames.length]; for (int i=0; i<classNames.length; i++) { groups[i] = clr.classForName(classNames[i].trim()); } return groups; } } }
Class element_class = clr.classForName(elementType); !clr.isAssignableFrom(elementMemberMetaData.getType(), ownerMmd.getAbstractClassMetaData().getFullClassName())) { throw new NucleusUserException(LOCALISER.msg("056025", ownerMmd.getFullFieldName(), elementMemberMetaData.getFullFieldName(), elementMemberMetaData.getTypeName(), ownerMmd.getAbstractClassMetaData().getFullClassName()));
URL classURL = clr.getResource(baseName + ".class", null); URL convertedPath = metaDataMgr.getNucleusContext().getPluginManager().resolveURLAsFileURL(classURL); String classFilename = convertedPath.getFile();
/** * Constructor for an enhancer for the class. The class is assumed to be in the CLASSPATH. * @param cmd MetaData for the class to be enhanced * @param clr ClassLoader resolver * @param mmgr MetaData manager */ public ASMClassEnhancer(ClassMetaData cmd, ClassLoaderResolver clr, MetaDataManager mmgr) { super(cmd, clr, mmgr); cls = clr.classForName(cmd.getFullClassName()); asmClassName = cmd.getFullClassName().replace('.', '/'); classDescriptor = Type.getDescriptor(cls); inputResourceName = "/" + className.replace('.','/') + ".class"; }
Class element_class = clr.classForName(elementType); if (!clr.isAssignableFrom(eofmd.getType(), mmd.getAbstractClassMetaData().getFullClassName()))
classReaderInputStream = clr.getResource(inputResourceName, null).openStream(); cr = new ClassReader(classReaderInputStream);
/** * Convenience method to load the (JDBC) driver. * @param dbDriver Datastore driver * @param clr Class loader resolver */ protected void loadDriver(String dbDriver, ClassLoaderResolver clr) { // Load the database driver try { clr.classForName(dbDriver).newInstance(); } catch (Exception e) { try { Class.forName(dbDriver).newInstance(); } catch (Exception e2) { // JDBC driver not found throw new DatastoreDriverNotFoundException(dbDriver); } } }
Class element_class = clr.classForName(elementType); if (ClassUtils.isReferenceType(element_class)) if (!clr.isAssignableFrom(eofmd.getType(), mmd.getAbstractClassMetaData().getFullClassName()))