public Object getAttribute(ObjectName objectName, String attribute) throws Exception { String name = objectName.getCanonicalName(); KernelRegistryEntry entry = kernel.getRegistry().getEntry(name); if (entry != null) { Object target = entry.getTarget(); Field field = target.getClass().getField(attribute); return field.get(target); } return null; }
public Object invoke( ObjectName objectName, String operationName, Object[] params, String[] signature) throws Exception { String name = objectName.getCanonicalName(); KernelRegistryEntry entry = kernel.getRegistry().getEntry(name); if (entry != null) { Object target = entry.getTarget(); Class[] types = new Class[signature.length]; for (int i = 0; i < signature.length; ++i) { types[i] = Thread.currentThread().getContextClassLoader().loadClass(signature[i]); } Method method = target.getClass().getMethod(operationName, types); return method.invoke(target, params); } return null; }