本文整理汇总了Java中org.apache.ibatis.reflection.factory.DefaultObjectFactory类的典型用法代码示例。如果您正苦于以下问题:Java DefaultObjectFactory类的具体用法?Java DefaultObjectFactory怎么用?Java DefaultObjectFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultObjectFactory类属于org.apache.ibatis.reflection.factory包,在下文中一共展示了DefaultObjectFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldSerializeAProxyForABeanWithoutDefaultConstructor
import org.apache.ibatis.reflection.factory.DefaultObjectFactory; //导入依赖的package包/类
@Test
public void shouldSerializeAProxyForABeanWithoutDefaultConstructor() throws Exception {
AuthorWithoutDefaultConstructor author = new AuthorWithoutDefaultConstructor(999, "someone", "[email protected]#@!#[email protected]#", "[email protected]", "blah", Section.NEWS);
ArrayList<Class<?>> argTypes = new ArrayList<Class<?>>();
argTypes.add(Integer.class);
argTypes.add(String.class);
argTypes.add(String.class);
argTypes.add(String.class);
argTypes.add(String.class);
argTypes.add(Section.class);
ArrayList<Object> argValues = new ArrayList<Object>();
argValues.add(999);
argValues.add("someone");
argValues.add("[email protected]#@!#[email protected]#");
argValues.add("[email protected]");
argValues.add("blah");
argValues.add(Section.NEWS);
Object proxy = proxyFactory.createProxy(author, new ResultLoaderMap(), new Configuration(), new DefaultObjectFactory(), argTypes, argValues);
Object proxy2 = deserialize(serialize((Serializable) proxy));
assertEquals(author, proxy2);
}
示例2: shouldSerializeAProxyForABeanWithoutDefaultConstructorAndUnloadedProperties
import org.apache.ibatis.reflection.factory.DefaultObjectFactory; //导入依赖的package包/类
@Test
public void shouldSerializeAProxyForABeanWithoutDefaultConstructorAndUnloadedProperties() throws Exception {
AuthorWithoutDefaultConstructor author = new AuthorWithoutDefaultConstructor(999, "someone", "[email protected]#@!#[email protected]#", "[email protected]", "blah", Section.NEWS);
ArrayList<Class<?>> argTypes = new ArrayList<Class<?>>();
argTypes.add(Integer.class);
argTypes.add(String.class);
argTypes.add(String.class);
argTypes.add(String.class);
argTypes.add(String.class);
argTypes.add(Section.class);
ArrayList<Object> argValues = new ArrayList<Object>();
argValues.add(999);
argValues.add("someone");
argValues.add("[email protected]#@!#[email protected]#");
argValues.add("[email protected]");
argValues.add("blah");
argValues.add(Section.NEWS);
ResultLoaderMap loader = new ResultLoaderMap();
loader.addLoader("id", null, null);
Object proxy = proxyFactory.createProxy(author, loader, new Configuration(), new DefaultObjectFactory(), argTypes, argValues);
Object proxy2 = deserialize(serialize((Serializable) proxy));
assertEquals(author, proxy2);
}
示例3: shouldNotGenerateWriteReplaceItThereIsAlreadyOne
import org.apache.ibatis.reflection.factory.DefaultObjectFactory; //导入依赖的package包/类
@Test
public void shouldNotGenerateWriteReplaceItThereIsAlreadyOne() throws Exception {
AuthorWithWriteReplaceMethod beanWithWriteReplace = new AuthorWithWriteReplaceMethod(999, "someone", "[email protected]#@!#[email protected]#", "[email protected]", "blah", Section.NEWS);
try {
beanWithWriteReplace.getClass().getDeclaredMethod("writeReplace");
} catch (NoSuchMethodException e) {
fail("Bean should declare a writeReplace method");
}
Object proxy = proxyFactory.createProxy(beanWithWriteReplace, new ResultLoaderMap(), new Configuration(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
Class<?>[] interfaces = proxy.getClass().getInterfaces();
boolean ownInterfaceFound = false;
for (Class<?> i : interfaces) {
if (i.equals(WriteReplaceInterface.class)) {
ownInterfaceFound = true;
break;
}
}
assertFalse(ownInterfaceFound);
}
示例4: intercept
import org.apache.ibatis.reflection.factory.DefaultObjectFactory; //导入依赖的package包/类
@Override
public Object intercept(Invocation invocation) throws Throwable {
StatementHandler statementHandler = (StatementHandler) invocation.getTarget();
BoundSql boundSql = statementHandler.getBoundSql();
MetaObject metaStatementHandler = MetaObject.forObject(statementHandler, new DefaultObjectFactory(), new DefaultObjectWrapperFactory());
RowBounds rowBounds = (RowBounds) metaStatementHandler.getValue("delegate.rowBounds");
if ((rowBounds != null) && (rowBounds != RowBounds.DEFAULT)) {
Configuration configuration = (Configuration) metaStatementHandler.getValue("delegate.configuration");
Dialect dialect = DialectParser.parse(configuration);
String sql = (String) metaStatementHandler.getValue("delegate.boundSql.sql");
sql = dialect.addLimitString(sql, rowBounds.getOffset(), rowBounds.getLimit());
metaStatementHandler.setValue("delegate.boundSql.sql", sql);
metaStatementHandler.setValue("delegate.rowBounds.offset", RowBounds.NO_ROW_OFFSET);
metaStatementHandler.setValue("delegate.rowBounds.limit", RowBounds.NO_ROW_LIMIT);
}
log.debug("SQL : " + boundSql.getSql());
return invocation.proceed();
}
示例5: intercept
import org.apache.ibatis.reflection.factory.DefaultObjectFactory; //导入依赖的package包/类
@Override
public Object intercept(Invocation invocation) throws Throwable {
List<Sort> sortList = getSortList();
if (sortList == null || sortList.size() == 0) {
return invocation.proceed();
}
Executor executor = (Executor) invocation.getTarget();
Object[] args = invocation.getArgs();
MappedStatement ms = (MappedStatement) args[0];
Object parameter = args[1];
RowBounds rowBounds = (RowBounds) args[2];
ResultHandler resultHandler = (ResultHandler) args[3];
// 计算修改BoundSql
BoundSql boundSql = ms.getBoundSql(parameter);
MetaObject boundSqlHandler = MetaObject.forObject(boundSql, new DefaultObjectFactory(), new DefaultObjectWrapperFactory());
Dialect dialect = DialectParser.parse(ms.getConfiguration());
String sql = (String) boundSqlHandler.getValue("sql");
sql = dialect.addSortString(sql, sortList);
boundSqlHandler.setValue("sql", sql);
// 继续执行原来的代码
CacheKey key = executor.createCacheKey(ms, parameter, rowBounds, boundSql);
return executor.query(ms, parameter, rowBounds, resultHandler, key, boundSql);
}
示例6: shouldCreateAProxyForAPartiallyLoadedBean
import org.apache.ibatis.reflection.factory.DefaultObjectFactory; //导入依赖的package包/类
@Test
public void shouldCreateAProxyForAPartiallyLoadedBean() throws Exception {
ResultLoaderMap loader = new ResultLoaderMap();
loader.addLoader("id", null, null);
Object proxy = proxyFactory.createProxy(author, loader, new Configuration(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
Author author2 = (Author) deserialize(serialize((Serializable) proxy));
assertTrue(author2 instanceof Factory);
}
示例7: shouldFailCallingAnUnloadedProperty
import org.apache.ibatis.reflection.factory.DefaultObjectFactory; //导入依赖的package包/类
@Test(expected = ExecutorException.class)
public void shouldFailCallingAnUnloadedProperty() throws Exception {
// yes, it must go in uppercase
HashMap<String, ResultLoaderMap.LoadPair> unloadedProperties = new HashMap<String, ResultLoaderMap.LoadPair>();
unloadedProperties.put("ID", null);
Author author2 = (Author) ((CglibProxyFactory)proxyFactory).createDeserializationProxy(author, unloadedProperties, new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
author2.getId();
}
示例8: shouldSerizalizeADeserlizaliedProxy
import org.apache.ibatis.reflection.factory.DefaultObjectFactory; //导入依赖的package包/类
@Test
public void shouldSerizalizeADeserlizaliedProxy() throws Exception {
Object proxy = ((CglibProxyFactory)proxyFactory).createDeserializationProxy(author, new HashMap<String, ResultLoaderMap.LoadPair>(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
Author author2 = (Author) deserialize(serialize((Serializable) proxy));
assertEquals(author, author2);
assertFalse(author.getClass().equals(author2.getClass()));
}
示例9: shouldKeepGenericTypes
import org.apache.ibatis.reflection.factory.DefaultObjectFactory; //导入依赖的package包/类
@Test
public void shouldKeepGenericTypes() throws Exception {
for (int i = 0; i < 10000; i++) {
Author pc = new Author();
Author proxy = (Author) proxyFactory.createProxy(pc, new ResultLoaderMap(), new Configuration(), new DefaultObjectFactory(),
new ArrayList<Class<?>>(), new ArrayList<Object>());
proxy.getBio();
}
}
示例10: shouldGenerateWriteReplace
import org.apache.ibatis.reflection.factory.DefaultObjectFactory; //导入依赖的package包/类
@Test
public void shouldGenerateWriteReplace() throws Exception {
try {
author.getClass().getDeclaredMethod("writeReplace");
fail("Author should not have a writeReplace method");
} catch (NoSuchMethodException e) {
// ok
}
Object proxy = proxyFactory.createProxy(author, new ResultLoaderMap(), new Configuration(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
Method m = proxy.getClass().getDeclaredMethod("writeReplace");
}
示例11: shouldNotLetReadUnloadedPropertyAfterSerialization
import org.apache.ibatis.reflection.factory.DefaultObjectFactory; //导入依赖的package包/类
@Test(expected = ExecutorException.class)
public void shouldNotLetReadUnloadedPropertyAfterSerialization() throws Exception {
ResultLoaderMap loader = new ResultLoaderMap();
loader.addLoader("id", null, null);
Object proxy = proxyFactory.createProxy(author, loader, new Configuration(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
Author author2 = (Author) deserialize(serialize((Serializable) proxy));
author2.getId();
}
示例12: shouldNotLetReadUnloadedPropertyAfterTwoSerializations
import org.apache.ibatis.reflection.factory.DefaultObjectFactory; //导入依赖的package包/类
@Test(expected = ExecutorException.class)
public void shouldNotLetReadUnloadedPropertyAfterTwoSerializations() throws Exception {
ResultLoaderMap loader = new ResultLoaderMap();
loader.addLoader("id", null, null);
Object proxy = proxyFactory.createProxy(author, loader, new Configuration(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
Author author2 = (Author) deserialize(serialize(deserialize(serialize((Serializable) proxy))));
author2.getId();
}
示例13: shouldLetReadALoadedPropertyAfterSerialization
import org.apache.ibatis.reflection.factory.DefaultObjectFactory; //导入依赖的package包/类
@Test
public void shouldLetReadALoadedPropertyAfterSerialization() throws Exception {
Object proxy = proxyFactory.createProxy(author, new ResultLoaderMap(), new Configuration(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
byte[] ser = serialize((Serializable) proxy);
Author author2 = (Author) deserialize(ser);
assertEquals(999, author2.getId());
}
示例14: shouldCreateAProxyForAPartiallyLoadedBean
import org.apache.ibatis.reflection.factory.DefaultObjectFactory; //导入依赖的package包/类
@Test
public void shouldCreateAProxyForAPartiallyLoadedBean() throws Exception {
ResultLoaderMap loader = new ResultLoaderMap();
loader.addLoader("id", null, null);
Object proxy = proxyFactory.createProxy(author, loader, new Configuration(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
Author author2 = (Author) deserialize(serialize((Serializable) proxy));
assertTrue(author2 instanceof Proxy);
}
示例15: shouldFailCallingAnUnloadedProperty
import org.apache.ibatis.reflection.factory.DefaultObjectFactory; //导入依赖的package包/类
@Test(expected = ExecutorException.class)
public void shouldFailCallingAnUnloadedProperty() throws Exception {
// yes, it must go in uppercase
HashMap<String, ResultLoaderMap.LoadPair> unloadedProperties = new HashMap<String, ResultLoaderMap.LoadPair> ();
unloadedProperties.put("ID", null);
Author author2 = (Author) ((JavassistProxyFactory)proxyFactory).createDeserializationProxy(author, unloadedProperties, new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
author2.getId();
}