}
}
private static byte[] generateGenericInterface(Class serviceInterface) {
String interfazeName = serviceInterface.getCanonicalName();
ClassWriter cw = new ClassWriter(false);
cw.visit(Constants.V1_5,
Constants.ACC_PUBLIC + Constants.ACC_ABSTRACT + Constants.ACC_INTERFACE,
interfazeName.replace('.',
'/'),
"java/lang/Object",
null,
serviceInterface.getSimpleName() + ".java");
StringBuffer argsAndReturn = new StringBuffer("(");
Method[] methods = serviceInterface.getMethods();
for (int count = 0; count < methods.length; ++count) {
argsAndReturn = new StringBuffer("(");
Class[] paramTypes = methods[count].getParameterTypes();
Class returnType = methods[count].getReturnType();
for (int paramCount = 0; paramCount < paramTypes.length; ++paramCount) {
argsAndReturn.append(Type.getType(Object.class));
}
argsAndReturn.append(")");
argsAndReturn.append(Type.getType(Object.class));
Class[] exceptionTypes = methods[count].getExceptionTypes();
String[] exceptions = new String[exceptionTypes.length];
for (int excCount = 0; excCount < exceptionTypes.length; ++excCount) {
exceptions[excCount] = exceptionTypes[excCount].getName();
exceptions[excCount] = exceptions[excCount].replace('.',
'/');
}
CodeVisitor cv = cw.visitMethod(Constants.ACC_PUBLIC + Constants.ACC_ABSTRACT,
methods[count].getName(),
argsAndReturn.toString(),
exceptions,
null);
cw.visitEnd();
}
cw.visitEnd();
return cw.toByteArray();
}