Human Resources Example - Indirectly Access the Bean
4.4. Indirect Access The run.sh script can be called with an optional parameter bus, which causes calls to the Human Resources service to use the Microcontainer bus. Instead of using a direct reference to the bean instance obtained from the Microcontainer controller, the new behavior is to call an invoke() method on the bus, passing in the bean name, method name, method arguments and method types. The bus uses this information to call the bean on the client's behalf. private final static String HRSERVICE = "HRService"; ... @SuppressWarnings("unchecked") Set listEmployees() { if (useBus) return (Set) invoke(HRSERVICE, "getEmployees", new Object[] {}, new String[] {}); else return manager.getEmployees(); } private Object invoke(String serviceName, String methodName, Object[] args, String[] types) { Object result = null; try { result = bus.invoke(serviceName, methodName, args, types); } catch (Throwable t) { t.printStackTrace(); } return result; }