本文整理汇总了Java中net.sf.cglib.proxy.LazyLoader类的典型用法代码示例。如果您正苦于以下问题:Java LazyLoader类的具体用法?Java LazyLoader怎么用?Java LazyLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LazyLoader类属于net.sf.cglib.proxy包,在下文中一共展示了LazyLoader类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: triggerLazyLoading
import net.sf.cglib.proxy.LazyLoader; //导入依赖的package包/类
Object triggerLazyLoading(Object obj) throws IllegalAccessException
{
for (Field field : ReflectionUtils.getDeclaredAndInheritedFields(obj.getClass(), false))
{
field.setAccessible(true);
if (field.getName().equals("CGLIB$CALLBACK_0"))
{
try
{
return ((LazyLoader) field.get(obj)).loadObject();
}
catch (Exception e)
{
throw new JcrMappingException("Could not trigger lazy loading", e);
}
}
}
return obj;
}
示例2: testAdaptProxiedType
import net.sf.cglib.proxy.LazyLoader; //导入依赖的package包/类
@Test
public void testAdaptProxiedType() throws Exception
{
ClassLoader loader = MockService.class.getClassLoader();
final MockService internal = new MockService();
MockService delegate = (MockService) Enhancer.create(MockService.class, new LazyLoader()
{
@Override
public Object loadObject() throws Exception
{
return internal;
}
});
MockService adapter = ClassLoaderAdapterBuilder.callingLoader(loader).delegateLoader(loader)
.enhance(delegate, MockService.class);
Assert.assertNotEquals(internal.getResult(), adapter.getResult());
Assert.assertEquals(internal.getResult().getValue(), adapter.getResult().getValue());
}
示例3: testAdaptProxiedResult
import net.sf.cglib.proxy.LazyLoader; //导入依赖的package包/类
@Test
public void testAdaptProxiedResult() throws Exception
{
ClassLoader loader = MockService.class.getClassLoader();
final MockService internal = new MockService();
MockService delegate = (MockService) Enhancer.create(MockService.class, new LazyLoader()
{
@Override
public Object loadObject() throws Exception
{
return internal;
}
});
MockService adapter = ClassLoaderAdapterBuilder.callingLoader(loader).delegateLoader(loader)
.enhance(delegate, MockService.class);
Assert.assertNotEquals(internal.getResult(), adapter.getResultEnhanced());
}
示例4: testAdaptProxiedResultReturnTypeObject
import net.sf.cglib.proxy.LazyLoader; //导入依赖的package包/类
@Test
public void testAdaptProxiedResultReturnTypeObject() throws Exception
{
ClassLoader loader = MockService.class.getClassLoader();
final MockService internal = new MockService();
MockService delegate = (MockService) Enhancer.create(MockService.class, new LazyLoader()
{
@Override
public Object loadObject() throws Exception
{
return internal;
}
});
MockService adapter = ClassLoaderAdapterBuilder.callingLoader(loader).delegateLoader(loader)
.enhance(delegate, MockService.class);
Assert.assertNotEquals(internal.getResult(), adapter.getResultEnhancedReturnTypeObject());
}
示例5: testCannotAdaptFinalResultReturnType
import net.sf.cglib.proxy.LazyLoader; //导入依赖的package包/类
@Test(expected = ClassCastException.class)
public void testCannotAdaptFinalResultReturnType() throws Exception
{
ClassLoader loader = MockService.class.getClassLoader();
final MockService internal = new MockService();
MockService delegate = (MockService) Enhancer.create(MockService.class, new LazyLoader()
{
@Override
public Object loadObject() throws Exception
{
return internal;
}
});
MockService adapter = ClassLoaderAdapterBuilder.callingLoader(loader).delegateLoader(loader)
.enhance(delegate, MockService.class);
adapter.getResultFinalReturnType();
}
示例6: testCanAdaptFinalResultReturnTypeObject
import net.sf.cglib.proxy.LazyLoader; //导入依赖的package包/类
@Test
public void testCanAdaptFinalResultReturnTypeObject() throws Exception
{
ClassLoader loader = MockService.class.getClassLoader();
final MockService internal = new MockService();
MockService delegate = (MockService) Enhancer.create(MockService.class, new LazyLoader()
{
@Override
public Object loadObject() throws Exception
{
return internal;
}
});
MockService adapter = ClassLoaderAdapterBuilder.callingLoader(loader).delegateLoader(loader)
.enhance(delegate, MockService.class);
Assert.assertNotEquals(internal.getResultFinalReturnTypeObject(), adapter.getResultFinalReturnTypeObject());
Assert.assertEquals(((Result) internal.getResultFinalReturnTypeObject()).getValue(),
((Result) adapter.getResultFinalReturnTypeObject()).getValue());
}
示例7: testAdaptFinalResult
import net.sf.cglib.proxy.LazyLoader; //导入依赖的package包/类
@Test
public void testAdaptFinalResult() throws Exception
{
ClassLoader loader = MockService.class.getClassLoader();
final MockService internal = new MockService();
MockService delegate = (MockService) Enhancer.create(MockService.class, new LazyLoader()
{
@Override
public Object loadObject() throws Exception
{
return internal;
}
});
MockService adapter = ClassLoaderAdapterBuilder.callingLoader(loader).delegateLoader(loader)
.enhance(delegate, MockService.class);
Assert.assertNotEquals(internal.getResultInterfaceFinalImpl(), adapter.getResultInterfaceFinalImpl());
Object unwrapped = Proxies.unwrap(adapter);
Assert.assertNotSame(adapter, unwrapped);
}
示例8: testNullValuesAsMethodParameters
import net.sf.cglib.proxy.LazyLoader; //导入依赖的package包/类
@Test
public void testNullValuesAsMethodParameters() throws Exception
{
ClassLoader loader = MockService.class.getClassLoader();
final MockService internal = new MockService();
MockService delegate = (MockService) Enhancer.create(MockService.class, new LazyLoader()
{
@Override
public Object loadObject() throws Exception
{
return internal;
}
});
MockService adapter = ClassLoaderAdapterBuilder.callingLoader(loader).delegateLoader(loader)
.enhance(delegate, MockService.class);
Assert.assertNull(internal.echo(null));
Assert.assertNull(adapter.echo(null));
}
示例9: testShouldNotProxyJavaNioPath
import net.sf.cglib.proxy.LazyLoader; //导入依赖的package包/类
@Test
public void testShouldNotProxyJavaNioPath() throws Exception
{
ClassLoader loader = JavaIOFactory.class.getClassLoader();
final JavaIOFactory internal = new JavaIOFactory();
JavaIOFactory delegate = (JavaIOFactory) Enhancer.create(JavaIOFactory.class, new LazyLoader()
{
@Override
public Object loadObject() throws Exception
{
return internal;
}
});
JavaIOFactory adapter = ClassLoaderAdapterBuilder.callingLoader(loader).delegateLoader(loader)
.enhance(delegate, JavaIOFactory.class);
Path path = adapter.getPath();
Assert.assertFalse(Proxies.isProxyType(path.getClass()));
}
示例10: testShouldNotProxyJavaUtilLogging
import net.sf.cglib.proxy.LazyLoader; //导入依赖的package包/类
@Test
public void testShouldNotProxyJavaUtilLogging() throws Exception {
ClassLoader loader = JavaUtilLoggingFactory.class.getClassLoader();
final JavaUtilLoggingFactory internal = new JavaUtilLoggingFactory();
JavaUtilLoggingFactory delegate = (JavaUtilLoggingFactory) Enhancer.create(JavaUtilLoggingFactory.class, new LazyLoader() {
@Override
public Object loadObject() throws Exception {
return internal;
}
});
JavaUtilLoggingFactory adapter = ClassLoaderAdapterBuilder.callingLoader(loader).delegateLoader(loader)
.enhance(delegate, JavaUtilLoggingFactory.class);
LogRecord logRecord = adapter.getLogRecord();
Assert.assertFalse(Proxies.isProxyType(logRecord.getClass()));
Assert.assertFalse(Proxies.isProxyType(logRecord.getLevel().getClass()));
}
示例11: triggerLazyLoading
import net.sf.cglib.proxy.LazyLoader; //导入依赖的package包/类
Object triggerLazyLoading(Object obj) throws IllegalAccessException {
for (Field field : ReflectionUtils.getDeclaredAndInheritedFields(obj.getClass(), false)) {
field.setAccessible(true);
if (field.getName().equals("CGLIB$CALLBACK_0")) {
try {
return ((LazyLoader) getObject(field, obj)).loadObject();
} catch (Exception e) {
throw new JcrMappingException("Could not trigger lazy loading", e);
}
}
}
return obj;
}
示例12: getResultEnhanced
import net.sf.cglib.proxy.LazyLoader; //导入依赖的package包/类
public MockResult getResultEnhanced()
{
final MockResult internal = new MockResult();
MockResult delegate = (MockResult) Enhancer.create(MockResult.class, new LazyLoader()
{
@Override
public Object loadObject() throws Exception
{
return internal;
}
});
return delegate;
}
示例13: getLazyLoadingProxiedEntity
import net.sf.cglib.proxy.LazyLoader; //导入依赖的package包/类
static Object getLazyLoadingProxiedEntity(final Session session, final Class<?> entityClass, final String dn) {
Object entity = null;
if (isDistinguishable(entityClass)) {
entity = Enhancer.create(entityClass, new Class[] { Persistent.class, Distinguishable.class },
FINALIZE_AND_DISTINGUISHABLE_INTEFERCE_FILTER,
new Callback[] {
new LazyLoader() {
public Object loadObject() throws Exception {
return session.read(entityClass, dn);
}
},
NoOp.INSTANCE
}
);
((Distinguishable)entity).setDN(dn);
} else {
entity = Enhancer.create(entityClass, new Class[] { Persistent.class }, FINALIZE_FILTER,
new Callback[] {
new LazyLoader() {
public Object loadObject() throws Exception {
return session.read(entityClass, dn);
}
},
NoOp.INSTANCE
}
);
}
return entity;
}