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


Java NoOp类代码示例

本文整理汇总了Java中net.sf.cglib.proxy.NoOp的典型用法代码示例。如果您正苦于以下问题:Java NoOp类的具体用法?Java NoOp怎么用?Java NoOp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NoOp类属于net.sf.cglib.proxy包,在下文中一共展示了NoOp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toEntityBean

import net.sf.cglib.proxy.NoOp; //导入依赖的package包/类
@DB()
protected T toEntityBean(final ResultSet result, final boolean cache) throws SQLException {
    final T entity = (T) _factory.newInstance(new Callback[]{NoOp.INSTANCE, new UpdateBuilder(this)});

    toEntityBean(result, entity);

    if (cache && _cache != null) {
        try {
            _cache.put(new Element(_idField.get(entity), entity));
        } catch (final Exception e) {
            s_logger.debug("Can't put it in the cache", e);
        }
    }

    return entity;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:17,代码来源:GenericDaoBase.java

示例2: testSupportForClassBasedProxyWithAdditionalInterface

import net.sf.cglib.proxy.NoOp; //导入依赖的package包/类
public void testSupportForClassBasedProxyWithAdditionalInterface()
    throws NullPointerException {
    final Enhancer enhancer = new Enhancer();
    enhancer.setSuperclass(HashMap.class);
    enhancer.setCallback(NoOp.INSTANCE);
    enhancer.setInterfaces(new Class[]{Runnable.class});
    final Map orig = (Map)enhancer.create();
    final String xml = ""
        + "<CGLIB-enhanced-proxy>\n"
        + "  <type>java.util.HashMap</type>\n"
        + "  <interfaces>\n"
        + "    <java-class>java.lang.Runnable</java-class>\n"
        + "  </interfaces>\n"
        + "  <hasFactory>true</hasFactory>\n"
        + "  <net.sf.cglib.proxy.NoOp_-1/>\n"
        + "</CGLIB-enhanced-proxy>";

    final Object serialized = assertBothWays(orig, xml);
    assertTrue(serialized instanceof HashMap);
    assertTrue(serialized instanceof Map);
    assertTrue(serialized instanceof Runnable);
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:23,代码来源:CglibCompatibilityTest.java

示例3: testSupportsProxiesWithMultipleInterfaces

import net.sf.cglib.proxy.NoOp; //导入依赖的package包/类
public void testSupportsProxiesWithMultipleInterfaces() throws NullPointerException {
    final Enhancer enhancer = new Enhancer();
    enhancer.setCallback(NoOp.INSTANCE);
    enhancer.setInterfaces(new Class[]{Map.class, Runnable.class});
    final Map orig = (Map)enhancer.create();
    final String xml = ""
        + "<CGLIB-enhanced-proxy>\n"
        + "  <type>java.lang.Object</type>\n"
        + "  <interfaces>\n"
        + "    <java-class>java.util.Map</java-class>\n"
        + "    <java-class>java.lang.Runnable</java-class>\n"
        + "  </interfaces>\n"
        + "  <hasFactory>true</hasFactory>\n"
        + "  <net.sf.cglib.proxy.NoOp_-1/>\n"
        + "</CGLIB-enhanced-proxy>";

    final Object serialized = assertBothWays(orig, xml);
    assertTrue(serialized instanceof Map);
    assertTrue(serialized instanceof Runnable);
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:21,代码来源:CglibCompatibilityTest.java

示例4: testSupportProxiesWithMultipleCallbackSetToNull

import net.sf.cglib.proxy.NoOp; //导入依赖的package包/类
public void testSupportProxiesWithMultipleCallbackSetToNull() throws NullPointerException {
    final Enhancer enhancer = new Enhancer();
    enhancer.setSuperclass(HashMap.class);
    enhancer.setCallback(NoOp.INSTANCE);
    final HashMap orig = (HashMap)enhancer.create();
    ((Factory)orig).setCallback(0, null);
    final String xml = ""
        + "<CGLIB-enhanced-proxy>\n"
        + "  <type>java.util.HashMap</type>\n"
        + "  <interfaces/>\n"
        + "  <hasFactory>true</hasFactory>\n"
        + "  <null/>\n"
        + "</CGLIB-enhanced-proxy>";

    assertBothWays(orig, xml);
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:17,代码来源:CglibCompatibilityTest.java

示例5: testSupportsSerialVersionUID

import net.sf.cglib.proxy.NoOp; //导入依赖的package包/类
public void testSupportsSerialVersionUID()
    throws NullPointerException, NoSuchFieldException, IllegalAccessException {
    final Enhancer enhancer = new Enhancer();
    enhancer.setCallback(NoOp.INSTANCE);
    enhancer.setInterfaces(new Class[]{Runnable.class});
    enhancer.setSerialVersionUID(new Long(20060804L));
    final Runnable orig = (Runnable)enhancer.create();
    final String xml = ""
        + "<CGLIB-enhanced-proxy>\n"
        + "  <type>java.lang.Object</type>\n"
        + "  <interfaces>\n"
        + "    <java-class>java.lang.Runnable</java-class>\n"
        + "  </interfaces>\n"
        + "  <hasFactory>true</hasFactory>\n"
        + "  <net.sf.cglib.proxy.NoOp_-1/>\n"
        + "  <serialVersionUID>20060804</serialVersionUID>\n"
        + "</CGLIB-enhanced-proxy>";

    final Object serialized = assertBothWays(orig, xml);
    final Field field = serialized.getClass().getDeclaredField("serialVersionUID");
    field.setAccessible(true);
    assertEquals(20060804L, field.getLong(null));
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:24,代码来源:CglibCompatibilityTest.java

示例6: testSupportsProxiesAsFieldMember

import net.sf.cglib.proxy.NoOp; //导入依赖的package包/类
public void testSupportsProxiesAsFieldMember() throws NullPointerException {
    ClassWithProxyMember expected = new ClassWithProxyMember();
    xstream.alias("with-proxy", ClassWithProxyMember.class);
    final Enhancer enhancer = new Enhancer();
    enhancer.setCallback(NoOp.INSTANCE);
    enhancer.setInterfaces(new Class[]{Map.class, Runnable.class});
    final Map orig = (Map)enhancer.create();
    expected.runnable = (Runnable)orig;
    expected.map = orig;
    final String xml = ""
        + "<with-proxy>\n"
        + "  <runnable class=\"CGLIB-enhanced-proxy\">\n"
        + "    <type>java.lang.Object</type>\n"
        + "    <interfaces>\n"
        + "      <java-class>java.util.Map</java-class>\n"
        + "      <java-class>java.lang.Runnable</java-class>\n"
        + "    </interfaces>\n"
        + "    <hasFactory>true</hasFactory>\n"
        + "    <net.sf.cglib.proxy.NoOp_-1/>\n"
        + "  </runnable>\n"
        + "  <map class=\"CGLIB-enhanced-proxy\" reference=\"../runnable\"/>\n"
        + "</with-proxy>";

    final Object serialized = assertBothWays(expected, xml);
    assertTrue(serialized instanceof ClassWithProxyMember);
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:27,代码来源:CglibCompatibilityTest.java

示例7: toEntityBean

import net.sf.cglib.proxy.NoOp; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@DB()
protected T toEntityBean(final ResultSet result, final boolean cache) throws SQLException {
    final T entity = (T)_factory.newInstance(new Callback[] {NoOp.INSTANCE, new UpdateBuilder(this)});

    toEntityBean(result, entity);

    if (cache && _cache != null) {
        try {
            _cache.put(new Element(_idField.get(entity), entity));
        } catch (final Exception e) {
            s_logger.debug("Can't put it in the cache", e);
        }
    }

    return entity;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:18,代码来源:GenericDaoBase.java

示例8: benchmarkCglib

import net.sf.cglib.proxy.NoOp; //导入依赖的package包/类
/**
 * Performs a benchmark of an interface implementation using cglib.
 *
 * @return The created instance, in order to avoid JIT removal.
 */
@Benchmark
public ExampleInterface benchmarkCglib() {
    Enhancer enhancer = new Enhancer();
    enhancer.setUseCache(false);
    enhancer.setClassLoader(newClassLoader());
    enhancer.setSuperclass(baseClass);
    CallbackHelper callbackHelper = new CallbackHelper(Object.class, new Class[]{baseClass}) {
        @Override
        protected Object getCallback(Method method) {
            if (method.getDeclaringClass() == baseClass) {
                return new FixedValue() {
                    @Override
                    public Object loadObject() throws Exception {
                        return null;
                    }
                };
            } else {
                return NoOp.INSTANCE;
            }
        }
    };
    enhancer.setCallbackFilter(callbackHelper);
    enhancer.setCallbacks(callbackHelper.getCallbacks());
    return (ExampleInterface) enhancer.create();
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:31,代码来源:ClassByImplementationBenchmark.java

示例9: createServiceEndpoint

import net.sf.cglib.proxy.NoOp; //导入依赖的package包/类
public Remote createServiceEndpoint() throws ServiceException {
        //TODO figure out why this can't be called in readResolve!
//        synchronized (this) {
//            if (!initialized) {
//                initialize();
//                initialized = true;
//            }
//        }
        Service service = ((ServiceImpl) serviceImpl).getService();
        GenericServiceEndpoint serviceEndpoint = new GenericServiceEndpoint(portQName, service, location);
        Callback callback = new ServiceEndpointMethodInterceptor(serviceEndpoint, sortedOperationInfos, credentialsName);
        Callback[] callbacks = new Callback[]{NoOp.INSTANCE, callback};
        Enhancer.registerCallbacks(serviceEndpointClass, callbacks);
        try {
            return (Remote) constructor.newInstance(new Object[]{serviceEndpoint});
        } catch (InvocationTargetException e) {
            throw (ServiceException) new ServiceException("Could not construct service instance", e.getTargetException()).initCause(e);
        }
    }
 
开发者ID:apache,项目名称:tomee,代码行数:20,代码来源:SeiFactoryImpl.java

示例10: getProxyClass

import net.sf.cglib.proxy.NoOp; //导入依赖的package包/类
public static Class<?> getProxyClass(Class<?> clazz) {
    Enhancer e = new Enhancer();
    if (clazz.isInterface()) {
     e.setSuperclass(clazz);
    } else {
     e.setSuperclass(clazz);
     e.setInterfaces(clazz.getInterfaces());
    }
    e.setCallbackTypes(new Class[]{
        InvocationHandler.class,
        NoOp.class,
    });
    e.setCallbackFilter(BAD_OBJECT_METHOD_FILTER);
    e.setUseFactory(true);
    e.setNamingPolicy(new LithiumTestProxyNamingPolicy());
    return e.createClass();
}
 
开发者ID:lithiumtech,项目名称:multiverse-test,代码行数:18,代码来源:FunctionalTestClassLoader.java

示例11: newProxyByCglib

import net.sf.cglib.proxy.NoOp; //导入依赖的package包/类
private static Object newProxyByCglib(Typing typing, Handler handler) {
  Enhancer enhancer = new Enhancer() {
    /** includes all constructors */
    protected void filterConstructors(Class sc, List constructors) {}
  };
  enhancer.setClassLoader(Thread.currentThread().getContextClassLoader());
  enhancer.setUseFactory(true);
  enhancer.setSuperclass(typing.superclass);
  enhancer.setInterfaces(typing.interfaces.toArray(new Class[0]));
  enhancer.setCallbackTypes(new Class[] { MethodInterceptor.class, NoOp.class });
  enhancer.setCallbackFilter(new CallbackFilter() {
    /** ignores bridge methods */
    public int accept(Method method) {
      return method.isBridge() ? 1 : 0;
    }
  });
  Class<?> proxyClass = enhancer.createClass();
  Factory proxy = (Factory) new ObjenesisStd().newInstance(proxyClass);
  proxy.setCallbacks(new Callback[] { asMethodInterceptor(handler), new SerializableNoOp() });
  return proxy;
}
 
开发者ID:maciejmikosik,项目名称:testory,代码行数:22,代码来源:CglibProxer.java

示例12: createProxyClass

import net.sf.cglib.proxy.NoOp; //导入依赖的package包/类
@Override
protected Class<?> createProxyClass() {
	Enhancer en = new Enhancer();
   	en.setInterceptDuringConstruction(false);
   	en.setUseFactory(true);
   	
   	en.setSuperclass(unproxiedClass);
   	en.setInterfaces(new Class[] { Persistent.class });
   	en.setCallbackType(NoOp.class);
   	en.setStrategy(new DefaultGeneratorStrategy() {
		protected ClassGenerator transform(ClassGenerator cg) throws Exception {
			return new TransformingClassGenerator(cg, new AddPropertyTransformer(
					new String[] { ORIGINAL_ONE, ORIGINAL_THE_OTHER },
					new Type[] { Type.getType(String.class), Type.getType(List.class) }
				));
		}
   	});
   	
   	return en.createClass();
}
 
开发者ID:xingyuli,项目名称:some-ldap,代码行数:21,代码来源:IndirectionsProxyFactory.java

示例13: getProxiedEntity

import net.sf.cglib.proxy.NoOp; //导入依赖的package包/类
static Map.Entry<Object, SetterInterceptor> getProxiedEntity(Class<?> entityClass) {
    EntityProxyFactory proxyFactory = getFactory(ClassHelper.actualClass(entityClass));
    
    try {
        Object entity = null;
        SetterInterceptor interceptor = proxyFactory.new SetterInterceptor();
        
        if (proxyFactory.isDistinguishable) {
            entity = proxyFactory.factory.newInstance(new Callback[] { interceptor, NoOp.INSTANCE });
        } else {
            entity = proxyFactory.factory.newInstance(interceptor);
        }
        
        proxyFactory.modifiedPropNames.set(entity, new HashSet<String>());
        interceptor.setEntity(entity);
        
        return new AbstractMap.SimpleEntry<Object, SetterInterceptor>(entity, interceptor);
        
    } catch (Throwable t) {
        throw new ODMException("Unable to instantiate proxy instance", t);
    }
}
 
开发者ID:xingyuli,项目名称:some-ldap,代码行数:23,代码来源:EntityProxyFactory.java

示例14: enhance

import net.sf.cglib.proxy.NoOp; //导入依赖的package包/类
public T enhance(Class<T> clz) {
    Enhancer enhancer = new Enhancer();
    enhancer.setSuperclass(clz);
    enhancer.setCallbacks(new Callback[]{new PropertyInterceptor<>(this, schema), NoOp.INSTANCE});
    enhancer.setCallbackFilter(new SchemaFilter<>(clz));
    return (T) enhancer.create();
}
 
开发者ID:eclecticlogic,项目名称:eclectic-orc,代码行数:8,代码来源:ProxyManager.java

示例15: readCallback

import net.sf.cglib.proxy.NoOp; //导入依赖的package包/类
private void readCallback(final HierarchicalStreamReader reader, final UnmarshallingContext context,
        final List<Callback> callbacksToEnhance, final List<Callback> callbacks) {
    final Callback callback = (Callback)context.convertAnother(null, mapper.realClass(reader.getNodeName()));
    callbacks.add(callback);
    if (callback == null) {
        callbacksToEnhance.add(NoOp.INSTANCE);
    } else {
        callbacksToEnhance.add(callback);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:CGLIBEnhancedConverter.java


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