org.apache.ibatis.reflection.factory.ObjectFactory Java Examples
The following examples show how to use
org.apache.ibatis.reflection.factory.ObjectFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MetaObject.java From mybatis with Apache License 2.0 | 6 votes |
private MetaObject(Object object, ObjectFactory objectFactory, ObjectWrapperFactory objectWrapperFactory) { this.originalObject = object; this.objectFactory = objectFactory; this.objectWrapperFactory = objectWrapperFactory; if (object instanceof ObjectWrapper) { //如果对象本身已经是ObjectWrapper型,则直接赋给objectWrapper this.objectWrapper = (ObjectWrapper) object; } else if (objectWrapperFactory.hasWrapperFor(object)) { //如果有包装器,调用ObjectWrapperFactory.getWrapperFor this.objectWrapper = objectWrapperFactory.getWrapperFor(this, object); } else if (object instanceof Map) { //如果是Map型,返回MapWrapper this.objectWrapper = new MapWrapper(this, (Map) object); } else if (object instanceof Collection) { //如果是Collection型,返回CollectionWrapper this.objectWrapper = new CollectionWrapper(this, (Collection) object); } else { //除此以外,返回BeanWrapper this.objectWrapper = new BeanWrapper(this, object); } }
Example #2
Source File: MetaObject.java From mybaties with Apache License 2.0 | 6 votes |
private MetaObject(Object object, ObjectFactory objectFactory, ObjectWrapperFactory objectWrapperFactory) { this.originalObject = object; this.objectFactory = objectFactory; this.objectWrapperFactory = objectWrapperFactory; if (object instanceof ObjectWrapper) { //如果对象本身已经是ObjectWrapper型,则直接赋给objectWrapper this.objectWrapper = (ObjectWrapper) object; } else if (objectWrapperFactory.hasWrapperFor(object)) { //如果有包装器,调用ObjectWrapperFactory.getWrapperFor this.objectWrapper = objectWrapperFactory.getWrapperFor(this, object); } else if (object instanceof Map) { //如果是Map型,返回MapWrapper this.objectWrapper = new MapWrapper(this, (Map) object); } else if (object instanceof Collection) { //如果是Collection型,返回CollectionWrapper this.objectWrapper = new CollectionWrapper(this, (Collection) object); } else { //除此以外,返回BeanWrapper this.objectWrapper = new BeanWrapper(this, object); } }
Example #3
Source File: JavassistProxyFactory.java From mybaties with Apache License 2.0 | 5 votes |
private EnhancedResultObjectProxyImpl(Class<?> type, ResultLoaderMap lazyLoader, Configuration configuration, ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) { this.type = type; this.lazyLoader = lazyLoader; this.aggressive = configuration.isAggressiveLazyLoading(); this.lazyLoadTriggerMethods = configuration.getLazyLoadTriggerMethods(); this.objectFactory = objectFactory; this.constructorArgTypes = constructorArgTypes; this.constructorArgs = constructorArgs; }
Example #4
Source File: XMLConfigBuilder.java From mybaties with Apache License 2.0 | 5 votes |
private void objectFactoryElement(XNode context) throws Exception { if (context != null) { String type = context.getStringAttribute("type"); Properties properties = context.getChildrenAsProperties(); ObjectFactory factory = (ObjectFactory) resolveClass(type).newInstance(); factory.setProperties(properties); configuration.setObjectFactory(factory); } }
Example #5
Source File: AbstractSerialStateHolder.java From mybatis with Apache License 2.0 | 5 votes |
public AbstractSerialStateHolder( final Object userBean, final Map<String, ResultLoaderMap.LoadPair> unloadedProperties, final ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) { this.userBean = userBean; this.unloadedProperties = new HashMap<String, ResultLoaderMap.LoadPair>(unloadedProperties); this.objectFactory = objectFactory; this.constructorArgTypes = constructorArgTypes.toArray(new Class<?>[constructorArgTypes.size()]); this.constructorArgs = constructorArgs.toArray(new Object[constructorArgs.size()]); }
Example #6
Source File: XMLConfigBuilder.java From mybatis with Apache License 2.0 | 5 votes |
private void objectFactoryElement(XNode context) throws Exception { if (context != null) { String type = context.getStringAttribute("type"); Properties properties = context.getChildrenAsProperties(); ObjectFactory factory = (ObjectFactory) resolveClass(type).newInstance(); factory.setProperties(properties); configuration.setObjectFactory(factory); } }
Example #7
Source File: AbstractSerialStateHolder.java From mybaties with Apache License 2.0 | 5 votes |
public AbstractSerialStateHolder( final Object userBean, final Map<String, ResultLoaderMap.LoadPair> unloadedProperties, final ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) { this.userBean = userBean; this.unloadedProperties = new HashMap<String, ResultLoaderMap.LoadPair>(unloadedProperties); this.objectFactory = objectFactory; this.constructorArgTypes = constructorArgTypes.toArray(new Class<?>[constructorArgTypes.size()]); this.constructorArgs = constructorArgs.toArray(new Object[constructorArgs.size()]); }
Example #8
Source File: MetaObject.java From mybaties with Apache License 2.0 | 5 votes |
public static MetaObject forObject(Object object, ObjectFactory objectFactory, ObjectWrapperFactory objectWrapperFactory) { if (object == null) { //处理一下null,将null包装起来 return SystemMetaObject.NULL_META_OBJECT; } else { return new MetaObject(object, objectFactory, objectWrapperFactory); } }
Example #9
Source File: BeanWrapper.java From mybaties with Apache License 2.0 | 5 votes |
@Override public MetaObject instantiatePropertyValue(String name, PropertyTokenizer prop, ObjectFactory objectFactory) { MetaObject metaValue; Class<?> type = getSetterType(prop.getName()); try { Object newObject = objectFactory.create(type); metaValue = MetaObject.forObject(newObject, metaObject.getObjectFactory(), metaObject.getObjectWrapperFactory()); set(prop, newObject); } catch (Exception e) { throw new ReflectionException("Cannot set value of property '" + name + "' because '" + name + "' is null and cannot be instantiated on instance of " + type.getName() + ". Cause:" + e.toString(), e); } return metaValue; }
Example #10
Source File: BeanWrapper.java From mybatis with Apache License 2.0 | 5 votes |
@Override public MetaObject instantiatePropertyValue(String name, PropertyTokenizer prop, ObjectFactory objectFactory) { MetaObject metaValue; Class<?> type = getSetterType(prop.getName()); try { Object newObject = objectFactory.create(type); metaValue = MetaObject.forObject(newObject, metaObject.getObjectFactory(), metaObject.getObjectWrapperFactory()); set(prop, newObject); } catch (Exception e) { throw new ReflectionException("Cannot set value of property '" + name + "' because '" + name + "' is null and cannot be instantiated on instance of " + type.getName() + ". Cause:" + e.toString(), e); } return metaValue; }
Example #11
Source File: DefaultMapResultHandler.java From mybatis with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public DefaultMapResultHandler(String mapKey, ObjectFactory objectFactory, ObjectWrapperFactory objectWrapperFactory) { this.objectFactory = objectFactory; this.objectWrapperFactory = objectWrapperFactory; this.mappedResults = objectFactory.create(Map.class); this.mapKey = mapKey; }
Example #12
Source File: MetaObject.java From mybatis with Apache License 2.0 | 5 votes |
public static MetaObject forObject(Object object, ObjectFactory objectFactory, ObjectWrapperFactory objectWrapperFactory) { if (object == null) { //处理一下null,将null包装起来 return SystemMetaObject.NULL_META_OBJECT; } else { return new MetaObject(object, objectFactory, objectWrapperFactory); } }
Example #13
Source File: XMLConfigBuilder.java From QuickProject with Apache License 2.0 | 5 votes |
private void objectFactoryElement(XNode context) throws Exception { if (context != null) { String type = context.getStringAttribute("type"); Properties properties = context.getChildrenAsProperties(); ObjectFactory factory = (ObjectFactory) resolveClass(type).newInstance(); factory.setProperties(properties); configuration.setObjectFactory(factory); } }
Example #14
Source File: HierarchicalXMLConfigBuilder.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private void objectFactoryElement(XNode context) throws Exception { if (context != null) { String type = context.getStringAttribute("type"); Properties properties = context.getChildrenAsProperties(); ObjectFactory factory = (ObjectFactory) resolveClass(type).newInstance(); factory.setProperties(properties); configuration.setObjectFactory(factory); } }
Example #15
Source File: AbstractEnhancedDeserializationProxy.java From mybatis with Apache License 2.0 | 5 votes |
protected AbstractEnhancedDeserializationProxy(Class<?> type, Map<String, ResultLoaderMap.LoadPair> unloadedProperties, ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) { this.type = type; this.unloadedProperties = unloadedProperties; this.objectFactory = objectFactory; this.constructorArgTypes = constructorArgTypes; this.constructorArgs = constructorArgs; this.reloadingPropertyLock = new Object(); this.reloadingProperty = false; }
Example #16
Source File: CglibProxyFactory.java From mybatis with Apache License 2.0 | 5 votes |
private EnhancedResultObjectProxyImpl(Class<?> type, ResultLoaderMap lazyLoader, Configuration configuration, ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) { this.type = type; this.lazyLoader = lazyLoader; this.aggressive = configuration.isAggressiveLazyLoading(); this.lazyLoadTriggerMethods = configuration.getLazyLoadTriggerMethods(); this.objectFactory = objectFactory; this.constructorArgTypes = constructorArgTypes; this.constructorArgs = constructorArgs; }
Example #17
Source File: JavassistSerialStateHolder.java From mybatis with Apache License 2.0 | 5 votes |
public JavassistSerialStateHolder( final Object userBean, final Map<String, ResultLoaderMap.LoadPair> unloadedProperties, final ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) { super(userBean, unloadedProperties, objectFactory, constructorArgTypes, constructorArgs); }
Example #18
Source File: JavassistSerialStateHolder.java From mybaties with Apache License 2.0 | 5 votes |
public JavassistSerialStateHolder( final Object userBean, final Map<String, ResultLoaderMap.LoadPair> unloadedProperties, final ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) { super(userBean, unloadedProperties, objectFactory, constructorArgTypes, constructorArgs); }
Example #19
Source File: JavassistProxyFactory.java From mybaties with Apache License 2.0 | 5 votes |
public static Object createProxy(Object target, ResultLoaderMap lazyLoader, Configuration configuration, ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) { final Class<?> type = target.getClass(); EnhancedResultObjectProxyImpl callback = new EnhancedResultObjectProxyImpl(type, lazyLoader, configuration, objectFactory, constructorArgTypes, constructorArgs); Object enhanced = crateProxy(type, callback, constructorArgTypes, constructorArgs); PropertyCopier.copyBeanProperties(type, target, enhanced); return enhanced; }
Example #20
Source File: JavassistProxyFactory.java From mybaties with Apache License 2.0 | 5 votes |
public static Object createProxy(Object target, Map<String, ResultLoaderMap.LoadPair> unloadedProperties, ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) { final Class<?> type = target.getClass(); EnhancedDeserializationProxyImpl callback = new EnhancedDeserializationProxyImpl(type, unloadedProperties, objectFactory, constructorArgTypes, constructorArgs); Object enhanced = crateProxy(type, callback, constructorArgTypes, constructorArgs); PropertyCopier.copyBeanProperties(type, target, enhanced); return enhanced; }
Example #21
Source File: CglibSerialStateHolder.java From mybatis with Apache License 2.0 | 5 votes |
public CglibSerialStateHolder( final Object userBean, final Map<String, ResultLoaderMap.LoadPair> unloadedProperties, final ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) { super(userBean, unloadedProperties, objectFactory, constructorArgTypes, constructorArgs); }
Example #22
Source File: CglibSerialStateHolder.java From mybaties with Apache License 2.0 | 5 votes |
public CglibSerialStateHolder( final Object userBean, final Map<String, ResultLoaderMap.LoadPair> unloadedProperties, final ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) { super(userBean, unloadedProperties, objectFactory, constructorArgTypes, constructorArgs); }
Example #23
Source File: DefaultMapResultHandler.java From mybaties with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public DefaultMapResultHandler(String mapKey, ObjectFactory objectFactory, ObjectWrapperFactory objectWrapperFactory) { this.objectFactory = objectFactory; this.objectWrapperFactory = objectWrapperFactory; this.mappedResults = objectFactory.create(Map.class); this.mapKey = mapKey; }
Example #24
Source File: JavassistProxyFactory.java From mybatis with Apache License 2.0 | 5 votes |
public static Object createProxy(Object target, Map<String, ResultLoaderMap.LoadPair> unloadedProperties, ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) { final Class<?> type = target.getClass(); EnhancedDeserializationProxyImpl callback = new EnhancedDeserializationProxyImpl(type, unloadedProperties, objectFactory, constructorArgTypes, constructorArgs); Object enhanced = crateProxy(type, callback, constructorArgTypes, constructorArgs); PropertyCopier.copyBeanProperties(type, target, enhanced); return enhanced; }
Example #25
Source File: CglibProxyFactory.java From mybaties with Apache License 2.0 | 5 votes |
private EnhancedResultObjectProxyImpl(Class<?> type, ResultLoaderMap lazyLoader, Configuration configuration, ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) { this.type = type; this.lazyLoader = lazyLoader; this.aggressive = configuration.isAggressiveLazyLoading(); this.lazyLoadTriggerMethods = configuration.getLazyLoadTriggerMethods(); this.objectFactory = objectFactory; this.constructorArgTypes = constructorArgTypes; this.constructorArgs = constructorArgs; }
Example #26
Source File: CglibProxyFactory.java From mybaties with Apache License 2.0 | 5 votes |
public static Object createProxy(Object target, ResultLoaderMap lazyLoader, Configuration configuration, ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) { final Class<?> type = target.getClass(); EnhancedResultObjectProxyImpl callback = new EnhancedResultObjectProxyImpl(type, lazyLoader, configuration, objectFactory, constructorArgTypes, constructorArgs); Object enhanced = crateProxy(type, callback, constructorArgTypes, constructorArgs); PropertyCopier.copyBeanProperties(type, target, enhanced); return enhanced; }
Example #27
Source File: JavassistProxyFactory.java From mybatis with Apache License 2.0 | 5 votes |
public static Object createProxy(Object target, ResultLoaderMap lazyLoader, Configuration configuration, ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) { final Class<?> type = target.getClass(); EnhancedResultObjectProxyImpl callback = new EnhancedResultObjectProxyImpl(type, lazyLoader, configuration, objectFactory, constructorArgTypes, constructorArgs); Object enhanced = crateProxy(type, callback, constructorArgTypes, constructorArgs); PropertyCopier.copyBeanProperties(type, target, enhanced); return enhanced; }
Example #28
Source File: CglibProxyFactory.java From mybaties with Apache License 2.0 | 5 votes |
public static Object createProxy(Object target, Map<String, ResultLoaderMap.LoadPair> unloadedProperties, ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) { final Class<?> type = target.getClass(); EnhancedDeserializationProxyImpl callback = new EnhancedDeserializationProxyImpl(type, unloadedProperties, objectFactory, constructorArgTypes, constructorArgs); Object enhanced = crateProxy(type, callback, constructorArgTypes, constructorArgs); PropertyCopier.copyBeanProperties(type, target, enhanced); return enhanced; }
Example #29
Source File: JavassistProxyFactory.java From mybatis with Apache License 2.0 | 5 votes |
private EnhancedResultObjectProxyImpl(Class<?> type, ResultLoaderMap lazyLoader, Configuration configuration, ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) { this.type = type; this.lazyLoader = lazyLoader; this.aggressive = configuration.isAggressiveLazyLoading(); this.lazyLoadTriggerMethods = configuration.getLazyLoadTriggerMethods(); this.objectFactory = objectFactory; this.constructorArgTypes = constructorArgTypes; this.constructorArgs = constructorArgs; }
Example #30
Source File: AbstractEnhancedDeserializationProxy.java From mybaties with Apache License 2.0 | 5 votes |
protected AbstractEnhancedDeserializationProxy(Class<?> type, Map<String, ResultLoaderMap.LoadPair> unloadedProperties, ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) { this.type = type; this.unloadedProperties = unloadedProperties; this.objectFactory = objectFactory; this.constructorArgTypes = constructorArgTypes; this.constructorArgs = constructorArgs; this.reloadingPropertyLock = new Object(); this.reloadingProperty = false; }