本文整理汇总了Java中net.sf.cglib.core.ReflectUtils类的典型用法代码示例。如果您正苦于以下问题:Java ReflectUtils类的具体用法?Java ReflectUtils怎么用?Java ReflectUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReflectUtils类属于net.sf.cglib.core包,在下文中一共展示了ReflectUtils类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: intercept
import net.sf.cglib.core.ReflectUtils; //导入依赖的package包/类
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
if(args.length == 2){
String name = method.getName() ;
if("invokeProxiedMethod".equals(name)){//pass the proxy
MethodProxy mp = MethodProxy.find(obj.getClass(), ReflectUtils.getSignature((Member) args[0])) ;
return mp.invokeSuper(obj, (Object[]) args[1]) ;
}
}
String methodKey = this.getMethodKey(method) ;
//call stub method
Method stubMethod = this.stubMethods.get(methodKey) ;
if(stubMethod != null){
return stubMethod.invoke(stub, args) ;
}
//call this RPCServiceImpl's method
Method thisMethod = this.thisMethods.get(methodKey) ;
if(thisMethod != null){
return thisMethod.invoke(this, args) ;
}
throw new NoSuchMethodException(methodKey) ;
}
开发者ID:ryanwli,项目名称:guzz,代码行数:26,代码来源:RPCServiceImpl.java
示例2: AddInitTransformer
import net.sf.cglib.core.ReflectUtils; //导入依赖的package包/类
public AddInitTransformer(Method method) {
info = ReflectUtils.getMethodInfo(method);
Type[] types = info.getSignature().getArgumentTypes();
if (types.length != 1 ||
!types[0].equals(Constants.TYPE_OBJECT) ||
!info.getSignature().getReturnType().equals(Type.VOID_TYPE)) {
throw new IllegalArgumentException(method + " illegal signature");
}
}
开发者ID:cglib,项目名称:cglib,代码行数:11,代码来源:AddInitTransformer.java
示例3: getInterfaces
import net.sf.cglib.core.ReflectUtils; //导入依赖的package包/类
protected Class[] getInterfaces(Class[] classes) {
List list = new ArrayList();
for (int i = 0; i < classes.length; i++) {
ReflectUtils.addAllInterfaces(classes[i], list);
}
return (Class[])list.toArray(new Class[list.size()]);
}
开发者ID:cglib,项目名称:cglib,代码行数:8,代码来源:MixinEverythingEmitter.java
示例4: getCallbackTypes
import net.sf.cglib.core.ReflectUtils; //导入依赖的package包/类
public Class[] getCallbackTypes()
{
if (callbacks.size() == 0)
return new Class[0];
if (callbacks.get(0) instanceof Callback) {
return ReflectUtils.getClasses(getCallbacks());
} else {
return (Class[])callbacks.toArray(new Class[callbacks.size()]);
}
}
开发者ID:cglib,项目名称:cglib,代码行数:11,代码来源:CallbackHelper.java
示例5: testAddStatic
import net.sf.cglib.core.ReflectUtils; //导入依赖的package包/类
public void testAddStatic() throws Exception {
Method m = ReflectUtils.findMethod("net.sf.cglib.transform.impl.TestTransformingLoader.initStatic(Class)");
ClassTransformer t = new AddStaticInitTransformer(m);
// t = new ClassTransformerChain(new ClassTransformer[]{ t, new ClassTransformerTee(new org.objectweb.asm.util.TraceClassVisitor(null, new java.io.PrintWriter(System.out))) });
Class loaded = loadHelper(t, Example.class);
Object obj = loaded.newInstance();
// TODO
}
开发者ID:cglib,项目名称:cglib,代码行数:9,代码来源:TestTransformingLoader.java
示例6: testSimple
import net.sf.cglib.core.ReflectUtils; //导入依赖的package包/类
public void testSimple() throws Exception {
BeanGenerator bg = new BeanGenerator();
bg.addProperty("sin", Double.TYPE);
Object bean = bg.create();
PropertyDescriptor[] pds = ReflectUtils.getBeanProperties(bean.getClass());
assertTrue(pds.length == 1);
assertTrue(pds[0].getName().equals("sin"));
assertTrue(pds[0].getPropertyType().equals(Double.TYPE));
}
开发者ID:cglib,项目名称:cglib,代码行数:11,代码来源:TestBeanGenerator.java
示例7: testArgInit
import net.sf.cglib.core.ReflectUtils; //导入依赖的package包/类
public void testArgInit() throws Throwable{
Enhancer e = new Enhancer();
e.setSuperclass(ArgInit.class);
e.setCallbackType(MethodInterceptor.class);
Class f = e.createClass();
ArgInit a = (ArgInit)ReflectUtils.newInstance(f,
new Class[]{ String.class },
new Object[]{ "test" });
assertEquals("test", a.toString());
((Factory)a).setCallback(0, TEST_INTERCEPTOR);
assertEquals("test", a.toString());
Callback[] callbacks = new Callback[]{ TEST_INTERCEPTOR };
ArgInit b = (ArgInit)((Factory)a).newInstance(new Class[]{ String.class },
new Object[]{ "test2" },
callbacks);
assertEquals("test2", b.toString());
try{
((Factory)a).newInstance(new Class[]{ String.class, String.class },
new Object[]{"test"},
callbacks);
fail("must throw exception");
}catch( IllegalArgumentException iae ){
}
}
开发者ID:cglib,项目名称:cglib,代码行数:28,代码来源:TestEnhancer.java
示例8: getCommand
import net.sf.cglib.core.ReflectUtils; //导入依赖的package包/类
/**
* Get the command this Action will use. This method uses the
* config value:
*
* web.com.redhat.rhn.frontend.action.satellite.GeneralConfigAction.command
*
* to determine a dynamic classname to use to instantiate the
* ConfigureSatelliteCommand. This can be useful if you want to
* specify a different class to use for the Command at runtime.
*
* @param currentUser who is requesting this config.
* @return ConfigureSatelliteCommand instance
*/
protected SatelliteConfigurator getCommand(User currentUser) {
if (logger.isDebugEnabled()) {
logger.debug("getCommand(User currentUser=" + currentUser + ") - start");
}
String className = getCommandClassName();
try {
Class c = Class.forName(className);
Class[] paramTypes = new Class[1];
paramTypes[0] = User.class;
Object[] args = new Object[1];
args[0] = currentUser;
SatelliteConfigurator sc = (SatelliteConfigurator)
ReflectUtils.newInstance(c, paramTypes, args);
if (logger.isDebugEnabled()) {
logger.debug("getCommand(User) - end - return value=" + sc);
}
return sc;
}
catch (ClassNotFoundException e) {
logger.error("getCommand(User)", e);
throw new RuntimeException(e);
}
}
开发者ID:spacewalkproject,项目名称:spacewalk,代码行数:42,代码来源:BaseConfigAction.java
示例9: getMethods
import net.sf.cglib.core.ReflectUtils; //导入依赖的package包/类
protected Method[] getMethods(Class type) {
return ReflectUtils.getPropertyMethods(ReflectUtils.getBeanProperties(type), true, true);
}
开发者ID:cglib,项目名称:cglib,代码行数:4,代码来源:MixinBeanEmitter.java
示例10: newArgInit
import net.sf.cglib.core.ReflectUtils; //导入依赖的package包/类
private static ArgInit newArgInit(Class clazz, String value) {
return (ArgInit)ReflectUtils.newInstance(clazz,
new Class[]{ String.class },
new Object[]{ value });
}
开发者ID:cglib,项目名称:cglib,代码行数:6,代码来源:TestEnhancer.java
示例11: firstInstance
import net.sf.cglib.core.ReflectUtils; //导入依赖的package包/类
protected Object firstInstance(Class type) throws Exception {
return ReflectUtils.newInstance(type);
}
开发者ID:cglib,项目名称:cglib,代码行数:4,代码来源:TestGenerator.java
注:本文中的net.sf.cglib.core.ReflectUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论