June 2018
Intermediate to advanced
280 pages
7h 46m
English
The following code simulates a remote proxy that looks up a bean from the localhost EJB context. Our remote proxy is a geometry calculator running in another JVM. We will use a factory method to make both our proxy and real objects to demonstrate that they are interchangeable. The proxy version takes longer to compute, since we also simulate the JNI lookup part and send/retrieve the result. Take a look at the code:
package gof.structural.proxy;publicclass Main{ publicstaticvoid main (String[] args) throws java.lang.Exception { GeometryCalculatorBean circle = GeometryCalculatorBeanFactory. REMOTE_PROXY.makeGeometryCalculator(); System.out.printf("Circle diameter %fn", circle.calculateCircleCircumference(new Circle())); }}class Circle ...Read now
Unlock full access