当前位置: 首页>>代码示例>>Java>>正文


Java LazyLoader类代码示例

本文整理汇总了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;
}
 
开发者ID:sbrinkmann,项目名称:jcrom-extended,代码行数:20,代码来源:Mapper.java

示例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());
}
 
开发者ID:forge,项目名称:furnace,代码行数:22,代码来源:ClassLoaderAdapterProxiedTest.java

示例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());
}
 
开发者ID:forge,项目名称:furnace,代码行数:21,代码来源:ClassLoaderAdapterProxiedTest.java

示例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());
}
 
开发者ID:forge,项目名称:furnace,代码行数:21,代码来源:ClassLoaderAdapterProxiedTest.java

示例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();
}
 
开发者ID:forge,项目名称:furnace,代码行数:20,代码来源:ClassLoaderAdapterProxiedTest.java

示例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());
}
 
开发者ID:forge,项目名称:furnace,代码行数:23,代码来源:ClassLoaderAdapterProxiedTest.java

示例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);
}
 
开发者ID:forge,项目名称:furnace,代码行数:23,代码来源:ClassLoaderAdapterProxiedTest.java

示例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));
}
 
开发者ID:forge,项目名称:furnace,代码行数:20,代码来源:ClassLoaderAdapterProxiedTest.java

示例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()));
}
 
开发者ID:forge,项目名称:furnace,代码行数:20,代码来源:ClassLoaderAdapterProxiedTest.java

示例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()));
}
 
开发者ID:forge,项目名称:furnace,代码行数:19,代码来源:ClassLoaderAdapterProxiedTest.java

示例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;
}
 
开发者ID:dooApp,项目名称:jcromfx,代码行数:14,代码来源:Mapper.java

示例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;
}
 
开发者ID:forge,项目名称:furnace,代码行数:15,代码来源:MockService.java

示例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;
}
 
开发者ID:xingyuli,项目名称:some-ldap,代码行数:32,代码来源:EntityProxyFactory.java


注:本文中的net.sf.cglib.proxy.LazyLoader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。