public static void main(String[] args) { try { RemoteInterface c = (RemoteInterface) Naming.lookup("//127.0.0.1:1099/CalculatorService"); c.displayString("((()))"); } catch (Exception e) { System.out.println("this is the exception in the client side"); } }
public SomeBean getBeanFromServer() { try { return hello.getMessage(); } catch (Exception e) { System.out.println("Client exception: " + e); } return null; }
/** * Send trace information to a remote listener. A Rule will normally be installed to invoke this * on entry to each method of interest. * * @param className the name of the instrumented, i.e. traced, class * @param methodName the name of the traced method. * @param dollarStar the method args starting with this * @throws Exception if the info cannto be sent * @see Instrumentor#instrumentClass InstrumentedClass#trace */ public void remoteTrace(String className, String methodName, Object[] dollarStar) throws Exception { Map<Object, Integer> knownInstancesOfType = targetInstances.get(className); if (knownInstancesOfType == null) { knownInstancesOfType = new HashMap<Object, Integer>(); targetInstances.put(className, knownInstancesOfType); } Object targetObject = dollarStar[0]; Integer objectId = knownInstancesOfType.get(targetObject); if (objectId == null) { objectId = knownInstancesOfType.size(); knownInstancesOfType.put(targetObject, objectId); } Object[] args = convertForRemoting(dollarStar); args[0] = objectId; RemoteInterface server = (RemoteInterface) registry.lookup(className); server.trace(methodName, args); }