Java 类org.hibernate.internal.util.ReflectHelper 实例源码

项目:lams    文件:JPAOverriddenAnnotationReader.java   
private void addTargetClass(Element element, AnnotationDescriptor ad, String nodeName, XMLContext.Default defaults) {
    String className = element.attributeValue( nodeName );
    if ( className != null ) {
        Class clazz;
        try {
            clazz = ReflectHelper.classForName(
                    XMLContext.buildSafeClassName( className, defaults ), this.getClass()
            );
        }
        catch ( ClassNotFoundException e ) {
            throw new AnnotationException(
                    "Unable to find " + element.getPath() + " " + nodeName + ": " + className, e
            );
        }
        ad.setValue( getJavaAttributeNameFromXMLOne( nodeName ), clazz );
    }
}
项目:lams    文件:JPAOverriddenAnnotationReader.java   
private void getMapKeyClass(List<Annotation> annotationList, Element element, XMLContext.Default defaults) {
    String nodeName = "map-key-class";
    Element subelement = element != null ? element.element( nodeName ) : null;
    if ( subelement != null ) {
        String mapKeyClassName = subelement.attributeValue( "class" );
        AnnotationDescriptor ad = new AnnotationDescriptor( MapKeyClass.class );
        if ( StringHelper.isNotEmpty( mapKeyClassName ) ) {
            Class clazz;
            try {
                clazz = ReflectHelper.classForName(
                        XMLContext.buildSafeClassName( mapKeyClassName, defaults ),
                        this.getClass()
                );
            }
            catch ( ClassNotFoundException e ) {
                throw new AnnotationException(
                        "Unable to find " + element.getPath() + " " + nodeName + ": " + mapKeyClassName, e
                );
            }
            ad.setValue( "value", clazz );
        }
        annotationList.add( AnnotationFactory.create( ad ) );
    }
}
项目:lams    文件:JPAOverriddenAnnotationReader.java   
private static void bindNamedSubgraph(XMLContext.Default defaults, AnnotationDescriptor ann, List<Element> subgraphNodes) {
    List<NamedSubgraph> annSubgraphNodes = new ArrayList<NamedSubgraph>(  );
    for(Element subgraphNode : subgraphNodes){
        AnnotationDescriptor annSubgraphNode = new AnnotationDescriptor( NamedSubgraph.class );
        copyStringAttribute( annSubgraphNode, subgraphNode, "name", true );
        String clazzName = subgraphNode.attributeValue( "class" );
        Class clazz;
        try {
            clazz = ReflectHelper.classForName(
                    XMLContext.buildSafeClassName( clazzName, defaults ),
                    JPAOverriddenAnnotationReader.class
            );
        }
        catch ( ClassNotFoundException e ) {
            throw new AnnotationException( "Unable to find entity-class: " + clazzName, e );
        }
        annSubgraphNode.setValue( "type", clazz );
        bindNamedAttributeNodes(subgraphNode, annSubgraphNode);
        annSubgraphNodes.add( (NamedSubgraph) AnnotationFactory.create( annSubgraphNode ) );
    }
    ann.setValue( "subgraphs", annSubgraphNodes.toArray( new NamedSubgraph[annSubgraphNodes.size()] ) );
}
项目:lams    文件:Array.java   
public Class getElementClass() throws MappingException {
    if (elementClassName==null) {
        org.hibernate.type.Type elementType = getElement().getType();
        return isPrimitiveArray() ?
            ( (PrimitiveType) elementType ).getPrimitiveClass() :
            elementType.getReturnedClass();
    }
    else {
        try {
            return ReflectHelper.classForName(elementClassName);
        }
        catch (ClassNotFoundException cnfe) {
            throw new MappingException(cnfe);
        }
    }
}
项目:lams    文件:SchemaExportTask.java   
private Configuration getConfiguration() throws Exception {
    Configuration cfg = new Configuration();
    if (namingStrategy!=null) {
        cfg.setNamingStrategy(
                (NamingStrategy) ReflectHelper.classForName(namingStrategy).newInstance()
            );
    }
    if (configurationFile != null) {
        cfg.configure( configurationFile );
    }

    String[] files = getFiles();
    for (int i = 0; i < files.length; i++) {
        String filename = files[i];
        if ( filename.endsWith(".jar") ) {
            cfg.addJar( new File(filename) );
        }
        else {
            cfg.addFile(filename);
        }
    }
    return cfg;
}
项目:lams    文件:SchemaUpdateTask.java   
private Configuration getConfiguration() throws Exception {
    Configuration cfg = new Configuration();
    if (namingStrategy!=null) {
        cfg.setNamingStrategy(
                (NamingStrategy) ReflectHelper.classForName( namingStrategy ).newInstance()
            );
    }
    if (configurationFile!=null) {
        cfg.configure( configurationFile );
    }

    String[] files = getFiles();
    for (int i = 0; i < files.length; i++) {
        String filename = files[i];
        if ( filename.endsWith(".jar") ) {
            cfg.addJar( new File(filename) );
        }
        else {
            cfg.addFile(filename);
        }
    }
    return cfg;
}
项目:lams    文件:SchemaValidatorTask.java   
private Configuration getConfiguration() throws Exception {
    Configuration cfg = new Configuration();
    if (namingStrategy!=null) {
        cfg.setNamingStrategy(
                (NamingStrategy) ReflectHelper.classForName(namingStrategy).newInstance()
            );
    }
    if (configurationFile!=null) {
        cfg.configure( configurationFile );
    }

    String[] files = getFiles();
    for (int i = 0; i < files.length; i++) {
        String filename = files[i];
        if ( filename.endsWith(".jar") ) {
            cfg.addJar( new File(filename) );
        }
        else {
            cfg.addFile(filename);
        }
    }
    return cfg;
}
项目:lams    文件:PojoInstantiator.java   
public PojoInstantiator(Component component, ReflectionOptimizer.InstantiationOptimizer optimizer) {
    this.mappedClass = component.getComponentClass();
    this.isAbstract = ReflectHelper.isAbstractClass( mappedClass );
    this.optimizer = optimizer;

    this.proxyInterface = null;
    this.embeddedIdentifier = false;

    try {
        constructor = ReflectHelper.getDefaultConstructor(mappedClass);
    }
    catch ( PropertyNotFoundException pnfe ) {
        LOG.noDefaultConstructor(mappedClass.getName());
        constructor = null;
    }
}
项目:lams    文件:JavassistProxyFactory.java   
@Override
public void postInstantiate(
        final String entityName,
        final Class persistentClass,
        final Set interfaces,
        final Method getIdentifierMethod,
        final Method setIdentifierMethod,
        CompositeType componentIdType) throws HibernateException {
    this.entityName = entityName;
    this.persistentClass = persistentClass;
    this.interfaces = (Class[]) interfaces.toArray(NO_CLASSES);
    this.getIdentifierMethod = getIdentifierMethod;
    this.setIdentifierMethod = setIdentifierMethod;
    this.componentIdType = componentIdType;
    this.factory = JavassistLazyInitializer.getProxyFactory( persistentClass, this.interfaces );
    this.overridesEquals = ReflectHelper.overridesEquals(persistentClass);
}
项目:lams    文件:DefaultIdentifierGeneratorFactory.java   
@Override
public Class getIdentifierGeneratorClass(String strategy) {
    if ( "native".equals( strategy ) ) {
        return dialect.getNativeIdentifierGeneratorClass();
    }

    Class generatorClass = generatorStrategyToClassNameMap.get( strategy );
    try {
        if ( generatorClass == null ) {
            generatorClass = ReflectHelper.classForName( strategy );
        }
    }
    catch ( ClassNotFoundException e ) {
        throw new MappingException( String.format( "Could not interpret id generator strategy [%s]", strategy ) );
    }
    return generatorClass;
}
项目:lams    文件:AbstractQueryImpl.java   
public Query setProperties(Object bean) throws HibernateException {
    Class clazz = bean.getClass();
    String[] params = getNamedParameters();
    for (int i = 0; i < params.length; i++) {
        String namedParam = params[i];
        try {
            Getter getter = ReflectHelper.getGetter( clazz, namedParam );
            Class retType = getter.getReturnType();
            final Object object = getter.get( bean );
            if ( Collection.class.isAssignableFrom( retType ) ) {
                setParameterList( namedParam, ( Collection ) object );
            }
            else if ( retType.isArray() ) {
                setParameterList( namedParam, ( Object[] ) object );
            }
            else {
                setParameter( namedParam, object, determineType( namedParam, retType ) );
            }
        }
        catch (PropertyNotFoundException pnfe) {
            // ignore
        }
    }
    return this;
}
项目:lams    文件:OracleTypesHelper.java   
private Class locateOracleTypesClass() {
    try {
        return ReflectHelper.classForName( ORACLE_TYPES_CLASS_NAME );
    }
    catch (ClassNotFoundException e) {
        try {
            return ReflectHelper.classForName( DEPRECATED_ORACLE_TYPES_CLASS_NAME );
        }
        catch (ClassNotFoundException e2) {
            throw new HibernateException(
                    String.format(
                            "Unable to locate OracleTypes class using either known FQN [%s, %s]",
                            ORACLE_TYPES_CLASS_NAME,
                            DEPRECATED_ORACLE_TYPES_CLASS_NAME
                    ),
                    e
            );
        }
    }
}
项目:lams    文件:LiteralProcessor.java   
public void lookupConstant(DotNode node) throws SemanticException {
    String text = ASTUtil.getPathText( node );
    Queryable persister = walker.getSessionFactoryHelper().findQueryableUsingImports( text );
    if ( persister != null ) {
        // the name of an entity class
        final String discrim = persister.getDiscriminatorSQLValue();
        node.setDataType( persister.getDiscriminatorType() );
        if ( InFragment.NULL.equals( discrim ) || InFragment.NOT_NULL.equals( discrim ) ) {
            throw new InvalidPathException(
                    "subclass test not allowed for null or not null discriminator: '" + text + "'"
            );
        }
        // the class discriminator value
        setSQLValue( node, text, discrim );
    }
    else {
        Object value = ReflectHelper.getConstantValue( text );
        if ( value == null ) {
            throw new InvalidPathException( "Invalid path: '" + text + "'" );
        }
        setConstantValue( node, text, value );
    }
}
项目:lams    文件:TypeFactory.java   
/**
 * @deprecated Use {@link #customCollection(String, java.util.Properties, String, String)}
 * instead.
 * See Jira issue: <a href="https://hibernate.onjira.com/browse/HHH-7771">HHH-7771</a>
 */
@Deprecated
public CollectionType customCollection(
        String typeName,
        Properties typeParameters,
        String role,
        String propertyRef,
        boolean embedded) {
    Class typeClass;
    try {
        typeClass = ReflectHelper.classForName( typeName );
    }
    catch ( ClassNotFoundException cnfe ) {
        throw new MappingException( "user collection type class not found: " + typeName, cnfe );
    }
    CustomCollectionType result = new CustomCollectionType( typeScope, typeClass, role, propertyRef, embedded );
    if ( typeParameters != null ) {
        injectParameters( result.getUserType(), typeParameters );
    }
    return result;
}
项目:lams    文件:TypeFactory.java   
public CollectionType customCollection(
        String typeName,
        Properties typeParameters,
        String role,
        String propertyRef) {
    Class typeClass;
    try {
        typeClass = ReflectHelper.classForName( typeName );
    }
    catch ( ClassNotFoundException cnfe ) {
        throw new MappingException( "user collection type class not found: " + typeName, cnfe );
    }
    CustomCollectionType result = new CustomCollectionType( typeScope, typeClass, role, propertyRef );
    if ( typeParameters != null ) {
        injectParameters( result.getUserType(), typeParameters );
    }
    return result;
}
项目:lams    文件:SerializableToBlobType.java   
@Override
@SuppressWarnings("unchecked")
public void setParameterValues(Properties parameters) {
    ParameterType reader = (ParameterType) parameters.get( PARAMETER_TYPE );
    if ( reader != null ) {
        setJavaTypeDescriptor( new SerializableTypeDescriptor<T>( reader.getReturnedClass() ) );
    } else {
        String className = parameters.getProperty( CLASS_NAME );
        if ( className == null ) {
            throw new MappingException( "No class name defined for type: " + SerializableToBlobType.class.getName() );
        }
        try {
            setJavaTypeDescriptor( new SerializableTypeDescriptor<T>( ReflectHelper.classForName( className ) ) );
        } catch ( ClassNotFoundException e ) {
            throw new MappingException( "Unable to load class from " + CLASS_NAME + " parameter", e );
        }
    }
}
项目:perecoder    文件:JsonBlobType.java   
@SuppressWarnings("unchecked")
@Override
public void setParameterValues(Properties parameters) {
    if (parameters == null) {
        throw new MappingException("No class or return type defined for type: " + JsonBlobType.class.getName());
    }
    DynamicParameterizedType.ParameterType reader = (DynamicParameterizedType.ParameterType) parameters.get(PARAMETER_TYPE);
    if (reader != null) {
        setJavaTypeDescriptor(new JsonTypeDescriptor<T>(reader.getReturnedClass()));
    } else {
        String className = parameters.getProperty(RETURNED_CLASS);
        if (className == null) {
            throw new MappingException("No class name defined for type: " + JsonBlobType.class.getName());
        }
        try {
            setJavaTypeDescriptor(new JsonTypeDescriptor<T>(ReflectHelper.classForName(className)));
        } catch (ClassNotFoundException e) {
            throw new MappingException("Unable to load class from " + RETURNED_CLASS + " parameter", e);
        }
    }
}
项目:lams    文件:GroupsPerOperation.java   
private void setGroupsForOperation(Operation operation, Properties properties) {
    Object property = properties.get( operation.getGroupPropertyName() );

    Class<?>[] groups;
    if ( property == null ) {
        groups = operation == Operation.DELETE ? EMPTY_GROUPS : DEFAULT_GROUPS;
    }
    else {
        if ( property instanceof String ) {
            String stringProperty = (String) property;
            String[] groupNames = stringProperty.split( "," );
            if ( groupNames.length == 1 && groupNames[0].equals( "" ) ) {
                groups = EMPTY_GROUPS;
            }
            else {
                List<Class<?>> groupsList = new ArrayList<Class<?>>(groupNames.length);
                for (String groupName : groupNames) {
                    String cleanedGroupName = groupName.trim();
                    if ( cleanedGroupName.length() > 0) {
                        try {
                            groupsList.add( ReflectHelper.classForName( cleanedGroupName ) );
                        }
                        catch ( ClassNotFoundException e ) {
                            throw new HibernateException( "Unable to load class " + cleanedGroupName, e );
                        }
                    }
                }
                groups = groupsList.toArray( new Class<?>[groupsList.size()] );
            }
        }
        else if ( property instanceof Class<?>[] ) {
            groups = (Class<?>[]) property;
        }
        else {
            //null is bad and excluded by instanceof => exception is raised
            throw new HibernateException( JPA_GROUP_PREFIX + operation.getGroupPropertyName() + " is of unknown type: String or Class<?>[] only");
        }
    }
    groupsPerOperation.put( operation, groups );
}
项目:lams    文件:JPAOverriddenAnnotationReader.java   
private void applyXmlDefinedConverts(
        Element containingElement,
        XMLContext.Default defaults,
        String attributeNamePrefix,
        Map<String,Convert> convertAnnotationsMap) {
    final List<Element> convertElements = containingElement.elements( "convert" );
    for ( Element convertElement : convertElements ) {
        final AnnotationDescriptor convertAnnotationDescriptor = new AnnotationDescriptor( Convert.class );
        copyStringAttribute( convertAnnotationDescriptor, convertElement, "attribute-name", false );
        copyBooleanAttribute( convertAnnotationDescriptor, convertElement, "disable-conversion" );

        final Attribute converterClassAttr = convertElement.attribute( "converter" );
        if ( converterClassAttr != null ) {
            final String converterClassName = XMLContext.buildSafeClassName(
                    converterClassAttr.getValue(),
                    defaults
            );
            try {
                final Class converterClass = ReflectHelper.classForName( converterClassName, this.getClass() );
                convertAnnotationDescriptor.setValue( "converter", converterClass );
            }
            catch (ClassNotFoundException e) {
                throw new AnnotationException( "Unable to find specified converter class id-class: " + converterClassName, e );
            }
        }
        final Convert convertAnnotation = AnnotationFactory.create( convertAnnotationDescriptor );
        final String qualifiedAttributeName = qualifyConverterAttributeName(
                attributeNamePrefix,
                convertAnnotation.attributeName()
        );
        convertAnnotationsMap.put( qualifiedAttributeName, convertAnnotation );
    }

}
项目:lams    文件:JPAOverriddenAnnotationReader.java   
private void checkForOrphanProperties(Element tree) {
    Class clazz;
    try {
        clazz = ReflectHelper.classForName( className, this.getClass() );
    }
    catch ( ClassNotFoundException e ) {
        return; //a primitive type most likely
    }
    Element element = tree != null ? tree.element( "attributes" ) : null;
    //put entity.attributes elements
    if ( element != null ) {
        //precompute the list of properties
        //TODO is it really useful...
        Set<String> properties = new HashSet<String>();
        for ( Field field : clazz.getFields() ) {
            properties.add( field.getName() );
        }
        for ( Method method : clazz.getMethods() ) {
            String name = method.getName();
            if ( name.startsWith( "get" ) ) {
                properties.add( Introspector.decapitalize( name.substring( "get".length() ) ) );
            }
            else if ( name.startsWith( "is" ) ) {
                properties.add( Introspector.decapitalize( name.substring( "is".length() ) ) );
            }
        }
        for ( Element subelement : (List<Element>) element.elements() ) {
            String propertyName = subelement.attributeValue( "name" );
            if ( !properties.contains( propertyName ) ) {
                LOG.propertyNotFound( StringHelper.qualify( className, propertyName ) );
            }
        }
    }
}
项目:lams    文件:JPAOverriddenAnnotationReader.java   
private EntityListeners getEntityListeners(Element tree, XMLContext.Default defaults) {
    Element element = tree != null ? tree.element( "entity-listeners" ) : null;
    if ( element != null ) {
        List<Class> entityListenerClasses = new ArrayList<Class>();
        for ( Element subelement : (List<Element>) element.elements( "entity-listener" ) ) {
            String className = subelement.attributeValue( "class" );
            try {
                entityListenerClasses.add(
                        ReflectHelper.classForName(
                                XMLContext.buildSafeClassName( className, defaults ),
                                this.getClass()
                        )
                );
            }
            catch ( ClassNotFoundException e ) {
                throw new AnnotationException(
                        "Unable to find " + element.getPath() + ".class: " + className, e
                );
            }
        }
        AnnotationDescriptor ad = new AnnotationDescriptor( EntityListeners.class );
        ad.setValue( "value", entityListenerClasses.toArray( new Class[entityListenerClasses.size()] ) );
        return AnnotationFactory.create( ad );
    }
    else if ( defaults.canUseJavaAnnotations() ) {
        return getPhysicalAnnotation( EntityListeners.class );
    }
    else {
        return null;
    }
}
项目:lams    文件:JPAOverriddenAnnotationReader.java   
private static Class resolveClassReference(String className, XMLContext.Default defaults) {
    if ( className == null ) {
        throw new AnnotationException( "<entity-result> without entity-class. " + SCHEMA_VALIDATION );
    }
    try {
        return ReflectHelper.classForName(
                XMLContext.buildSafeClassName( className, defaults ),
                JPAOverriddenAnnotationReader.class
        );
    }
    catch ( ClassNotFoundException e ) {
        throw new AnnotationException( "Unable to find specified class: " + className, e );
    }
}
项目:lams    文件:JPAOverriddenAnnotationReader.java   
private IdClass getIdClass(Element tree, XMLContext.Default defaults) {
    Element element = tree == null ? null : tree.element( "id-class" );
    if ( element != null ) {
        Attribute attr = element.attribute( "class" );
        if ( attr != null ) {
            AnnotationDescriptor ad = new AnnotationDescriptor( IdClass.class );
            Class clazz;
            try {
                clazz = ReflectHelper.classForName(
                        XMLContext.buildSafeClassName( attr.getValue(), defaults ),
                        this.getClass()
                );
            }
            catch ( ClassNotFoundException e ) {
                throw new AnnotationException( "Unable to find id-class: " + attr.getValue(), e );
            }
            ad.setValue( "value", clazz );
            return AnnotationFactory.create( ad );
        }
        else {
            throw new AnnotationException( "id-class without class. " + SCHEMA_VALIDATION );
        }
    }
    else if ( defaults.canUseJavaAnnotations() ) {
        return getPhysicalAnnotation( IdClass.class );
    }
    else {
        return null;
    }
}
项目:lams    文件:Collection.java   
public Comparator getComparator() {
    if ( comparator == null && comparatorClassName != null ) {
        try {
            setComparator( (Comparator) ReflectHelper.classForName( comparatorClassName ).newInstance() );
        }
        catch ( Exception e ) {
            throw new MappingException(
                    "Could not instantiate comparator class [" + comparatorClassName
                    + "] for collection " + getRole()  
            );
        }
    }
    return comparator;
}
项目:lams    文件:Component.java   
public Class getComponentClass() throws MappingException {
    try {
        return ReflectHelper.classForName(componentClassName);
    }
    catch (ClassNotFoundException cnfe) {
        throw new MappingException("component class not found: " + componentClassName, cnfe);
    }
}
项目:lams    文件:RootClass.java   
private void checkCompositeIdentifier() {
    if ( getIdentifier() instanceof Component ) {
        Component id = (Component) getIdentifier();
        if ( !id.isDynamic() ) {
            final Class idClass = id.getComponentClass();
            final String idComponendClassName = idClass.getName();
               if (idClass != null && !ReflectHelper.overridesEquals(idClass)) LOG.compositeIdClassDoesNotOverrideEquals( idComponendClassName );
               if (!ReflectHelper.overridesHashCode(idClass)) LOG.compositeIdClassDoesNotOverrideHashCode( idComponendClassName );
               if (!Serializable.class.isAssignableFrom(idClass)) throw new MappingException(
                                                                                             "Composite-id class must implement Serializable: "
                                                                                             + idComponendClassName);
        }
    }
}
项目:lams    文件:PersistentClass.java   
public Class getMappedClass() throws MappingException {
    if (className==null) return null;
    try {
        if(mappedClass == null) {
            mappedClass = ReflectHelper.classForName(className);
        }
        return mappedClass;
    }
    catch (ClassNotFoundException cnfe) {
        throw new MappingException("entity class not found: " + className, cnfe);
    }
}
项目:lams    文件:PersistentClass.java   
public Class getProxyInterface() {
    if (proxyInterfaceName==null) return null;
    try {
        if(proxyInterface == null) {
            proxyInterface = ReflectHelper.classForName( proxyInterfaceName );
        }
        return proxyInterface;
    }
    catch (ClassNotFoundException cnfe) {
        throw new MappingException("proxy class not found: " + proxyInterfaceName, cnfe);
    }
}
项目:lams    文件:SimpleValue.java   
public void setTypeUsingReflection(String className, String propertyName) throws MappingException {
    // NOTE : this is called as the last piece in setting SimpleValue type information, and implementations
    // rely on that fact, using it as a signal that all information it is going to get is defined at this point...

    if ( typeName != null ) {
        // assume either (a) explicit type was specified or (b) determine was already performed
        return;
    }

    if ( type != null ) {
        return;
    }

    if ( attributeConverterDefinition == null ) {
        // this is here to work like legacy.  This should change when we integrate with metamodel to
        // look for SqlTypeDescriptor and JavaTypeDescriptor individually and create the BasicType (well, really
        // keep a registry of [SqlTypeDescriptor,JavaTypeDescriptor] -> BasicType...)
        if ( className == null ) {
            throw new MappingException( "you must specify types for a dynamic entity: " + propertyName );
        }
        typeName = ReflectHelper.reflectedPropertyClass( className, propertyName ).getName();
        return;
    }

    // we had an AttributeConverter...
    type = buildAttributeConverterTypeAdapter();
}
项目:lams    文件:SimpleValue.java   
private void createParameterImpl() {
    try {
        String[] columnsNames = new String[columns.size()];
        for ( int i = 0; i < columns.size(); i++ ) {
            Selectable column = columns.get(i);
            if (column instanceof Column){
                columnsNames[i] = ((Column) column).getName();
            }
        }

        final XProperty xProperty = (XProperty) typeParameters.get( DynamicParameterizedType.XPROPERTY );
        // todo : not sure this works for handling @MapKeyEnumerated
        final Annotation[] annotations = xProperty == null
                ? null
                : xProperty.getAnnotations();

        typeParameters.put(
                DynamicParameterizedType.PARAMETER_TYPE,
                new ParameterTypeImpl(
                        ReflectHelper.classForName(
                                typeParameters.getProperty( DynamicParameterizedType.RETURNED_CLASS )
                        ),
                        annotations,
                        table.getCatalog(),
                        table.getSchema(),
                        table.getName(),
                        Boolean.valueOf( typeParameters.getProperty( DynamicParameterizedType.IS_PRIMARY_KEY ) ),
                        columnsNames
                )
        );
    }
    catch ( ClassNotFoundException cnfe ) {
        throw new MappingException( "Could not create DynamicParameterizedType for type: " + typeName, cnfe );
    }
}
项目:lams    文件:PropertyAccessorFactory.java   
private static PropertyAccessor resolveCustomAccessor(String accessorName) {
    Class accessorClass;
    try {
        accessorClass = ReflectHelper.classForName( accessorName );
    }
    catch (ClassNotFoundException cnfe) {
        throw new MappingException("could not find PropertyAccessor class: " + accessorName, cnfe);
    }
    try {
        return (PropertyAccessor) accessorClass.newInstance();
    }
    catch (Exception e) {
        throw new MappingException("could not instantiate PropertyAccessor class: " + accessorName, e);
    }
}
项目:lams    文件:EntityTuplizerFactory.java   
/**
 * Construct an instance of the given tuplizer class.
 *
 * @param tuplizerClassName The name of the tuplizer class to instantiate
 * @param metamodel The metadata for the entity.
 * @param persistentClass The mapping info for the entity.
 *
 * @return The instantiated tuplizer
 *
 * @throws HibernateException If class name cannot be resolved to a class reference, or if the
 * {@link Constructor#newInstance} call fails.
 */
@SuppressWarnings({ "unchecked" })
public EntityTuplizer constructTuplizer(
        String tuplizerClassName,
        EntityMetamodel metamodel,
        PersistentClass persistentClass) {
    try {
        Class<? extends EntityTuplizer> tuplizerClass = ReflectHelper.classForName( tuplizerClassName );
        return constructTuplizer( tuplizerClass, metamodel, persistentClass );
    }
    catch ( ClassNotFoundException e ) {
        throw new HibernateException( "Could not locate specified tuplizer class [" + tuplizerClassName + "]" );
    }
}
项目:lams    文件:EntityTuplizerFactory.java   
/**
 * Construct an instance of the given tuplizer class.
 *
 * @param tuplizerClassName The name of the tuplizer class to instantiate
 * @param metamodel The metadata for the entity.
 * @param entityBinding The mapping info for the entity.
 *
 * @return The instantiated tuplizer
 *
 * @throws HibernateException If class name cannot be resolved to a class reference, or if the
 * {@link Constructor#newInstance} call fails.
 */
@SuppressWarnings({ "unchecked" })
public EntityTuplizer constructTuplizer(
        String tuplizerClassName,
        EntityMetamodel metamodel,
        EntityBinding entityBinding) {
    try {
        Class<? extends EntityTuplizer> tuplizerClass = ReflectHelper.classForName( tuplizerClassName );
        return constructTuplizer( tuplizerClass, metamodel, entityBinding );
    }
    catch ( ClassNotFoundException e ) {
        throw new HibernateException( "Could not locate specified tuplizer class [" + tuplizerClassName + "]" );
    }
}
项目:lams    文件:PojoInstantiator.java   
public PojoInstantiator(PersistentClass persistentClass, ReflectionOptimizer.InstantiationOptimizer optimizer) {
    this.mappedClass = persistentClass.getMappedClass();
    this.isAbstract = ReflectHelper.isAbstractClass( mappedClass );
    this.proxyInterface = persistentClass.getProxyInterface();
    this.embeddedIdentifier = persistentClass.hasEmbeddedIdentifier();
    this.optimizer = optimizer;

    try {
        constructor = ReflectHelper.getDefaultConstructor( mappedClass );
    }
    catch ( PropertyNotFoundException pnfe ) {
        LOG.noDefaultConstructor(mappedClass.getName());
        constructor = null;
    }
}
项目:lams    文件:PojoInstantiator.java   
public PojoInstantiator(EntityBinding entityBinding, ReflectionOptimizer.InstantiationOptimizer optimizer) {
    this.mappedClass = entityBinding.getEntity().getClassReference();
    this.isAbstract = ReflectHelper.isAbstractClass( mappedClass );
    this.proxyInterface = entityBinding.getProxyInterfaceType().getValue();
    this.embeddedIdentifier = entityBinding.getHierarchyDetails().getEntityIdentifier().isEmbedded();
    this.optimizer = optimizer;

    try {
        constructor = ReflectHelper.getDefaultConstructor( mappedClass );
    }
    catch ( PropertyNotFoundException pnfe ) {
        LOG.noDefaultConstructor(mappedClass.getName());
        constructor = null;
    }
}
项目:lams    文件:PojoComponentTuplizer.java   
protected Instantiator buildInstantiator(Component component) {
    if ( component.isEmbedded() && ReflectHelper.isAbstractClass( component.getComponentClass() ) ) {
        return new ProxiedInstantiator( component );
    }
    if ( optimizer == null ) {
        return new PojoInstantiator( component, null );
    }
    else {
        return new PojoInstantiator( component, optimizer.getInstantiationOptimizer() );
    }
}
项目:lams    文件:PropertyFactory.java   
private static Constructor getConstructor(PersistentClass persistentClass) {
    if ( persistentClass == null || !persistentClass.hasPojoRepresentation() ) {
        return null;
    }

    try {
        return ReflectHelper.getDefaultConstructor( persistentClass.getMappedClass() );
    }
    catch( Throwable t ) {
        return null;
    }
}
项目:lams    文件:PropertyFactory.java   
private static Constructor getConstructor(EntityBinding entityBinding) {
    if ( entityBinding == null || entityBinding.getEntity() == null ) {
        return null;
    }

    try {
        return ReflectHelper.getDefaultConstructor( entityBinding.getEntity().getClassReference() );
    }
    catch( Throwable t ) {
        return null;
    }
}
项目:lams    文件:DriverManagerConnectionProviderImpl.java   
private Driver loadDriverIfPossible(String driverClassName) {
    if ( driverClassName == null ) {
        log.debug( "No driver class specified" );
        return null;
    }

    if ( serviceRegistry != null ) {
        final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
        final Class<Driver> driverClass = classLoaderService.classForName( driverClassName );
        try {
            return driverClass.newInstance();
        }
        catch ( Exception e ) {
            throw new ServiceException( "Specified JDBC Driver " + driverClassName + " could not be loaded", e );
        }
    }

    try {
        return (Driver) Class.forName( driverClassName ).newInstance();
    }
    catch ( Exception e1 ) {
        try{
            return (Driver) ReflectHelper.classForName( driverClassName ).newInstance();
        }
        catch ( Exception e2 ) {
            throw new ServiceException( "Specified JDBC Driver " + driverClassName + " could not be loaded", e2 );
        }
    }
}