hammant 02/01/07 11:38:30 Modified: armi PROPOSAL armi/src/java/org/apache/commons/armi/client/impl AbstractArmiFactory.java BaseServedObject.java armi/src/java/org/apache/commons/armi/test DirectTest.java DirectTestC.java PipeTest.java RmiClientTest.java SocketClientTest.java TestClient.java TestInterface.java TestInterface2.java TestInterface2Impl.java TestInterfaceImpl.java Log: No more duplcicate instances on the client side. Revision Changes Path 1.16 +4 -0 jakarta-commons-sandbox/armi/PROPOSAL Index: PROPOSAL =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/armi/PROPOSAL,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- PROPOSAL 7 Jan 2002 16:24:33 -0000 1.15 +++ PROPOSAL 7 Jan 2002 19:38:30 -0000 1.16 @@ -96,6 +96,10 @@ - ARMI started life as 'pass by value' only. In now supports return types and parameters wrapped in another ARMI Facade. +13) No duplicate instances. + + - If you call Person p = getPerson("Fred") twice you will get the same instance + on the client side is it is the same instance on the server side. Limitations: 1.4 +10 -4 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/AbstractArmiFactory.java Index: AbstractArmiFactory.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/AbstractArmiFactory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- AbstractArmiFactory.java 7 Jan 2002 16:24:34 -0000 1.3 +++ AbstractArmiFactory.java 7 Jan 2002 19:38:30 -0000 1.4 @@ -1,8 +1,8 @@ /* - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/AbstractArmiFactory.java,v 1.3 2002/01/07 16:24:34 hammant Exp $ - * $Revision: 1.3 $ - * $Date: 2002/01/07 16:24:34 $ + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/AbstractArmiFactory.java,v 1.4 2002/01/07 19:38:30 hammant Exp $ + * $Revision: 1.4 $ + * $Date: 2002/01/07 19:38:30 $ * * ==================================================================== * @@ -72,12 +72,13 @@ * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ public abstract class AbstractArmiFactory implements ArmiFactory { protected ArmiHostContext mHostContext; protected HashMap mObjRefs = new HashMap(); + protected HashMap mRefObjs = new HashMap(); /** @@ -125,10 +126,15 @@ */ public void registerReferenceObject(Object obj, String referenceID) { mObjRefs.put(obj, referenceID); + mRefObjs.put(referenceID, obj); } public String getReferenceID(Object obj) { return (String) mObjRefs.get(obj); + } + + public Object getImplObj(String referenceID) { + return mRefObjs.get(referenceID); } } 1.6 +14 -8 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/BaseServedObject.java Index: BaseServedObject.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/BaseServedObject.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- BaseServedObject.java 7 Jan 2002 16:24:34 -0000 1.5 +++ BaseServedObject.java 7 Jan 2002 19:38:30 -0000 1.6 @@ -1,8 +1,8 @@ /* - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/BaseServedObject.java,v 1.5 2002/01/07 16:24:34 hammant Exp $ - * $Revision: 1.5 $ - * $Date: 2002/01/07 16:24:34 $ + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/BaseServedObject.java,v 1.6 2002/01/07 19:38:30 hammant Exp $ + * $Revision: 1.6 $ + * $Date: 2002/01/07 19:38:30 $ * * ==================================================================== * @@ -80,7 +80,7 @@ * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ */ public final class BaseServedObject { @@ -131,10 +131,16 @@ if (reply.getReplyCode() == ArmiReply.METHODFACADEREPLY) { MethodFacadeReply mfr = (MethodFacadeReply) reply; - BaseServedObject bo2 = new BaseServedObject(mArmiFactory, mInvocationHandler, mPublishedServiceName, objectName, mfr.getReferenceID()); - Object retFacade = mArmiFactory.getInstance(mPublishedServiceName, objectName ,bo2); - bo2.registerImplObject(retFacade); - return retFacade; + String ref = mfr.getReferenceID(); + Object implBean = mArmiFactory.getImplObj(ref); + if (implBean == null) { + BaseServedObject bo2 = new BaseServedObject(mArmiFactory, mInvocationHandler, mPublishedServiceName, objectName, ref); + Object retFacade = mArmiFactory.getInstance(mPublishedServiceName, objectName ,bo2); + bo2.registerImplObject(retFacade); + return retFacade; + } else { + return implBean; + } } else if (reply.getReplyCode() == ArmiReply.EXCEPTIONREPLY) { ExceptionReply er = (ExceptionReply) reply; throw er.getReplyException(); 1.7 +8 -5 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/DirectTest.java Index: DirectTest.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/DirectTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- DirectTest.java 6 Jan 2002 15:39:53 -0000 1.6 +++ DirectTest.java 7 Jan 2002 19:38:30 -0000 1.7 @@ -1,8 +1,8 @@ /* - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/DirectTest.java,v 1.6 2002/01/06 15:39:53 hammant Exp $ - * $Revision: 1.6 $ - * $Date: 2002/01/06 15:39:53 $ + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/DirectTest.java,v 1.7 2002/01/07 19:38:30 hammant Exp $ + * $Revision: 1.7 $ + * $Date: 2002/01/07 19:38:30 $ * * ==================================================================== * @@ -79,7 +79,7 @@ * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ public class DirectTest { @@ -117,7 +117,7 @@ * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ static class DirectTestClient implements Runnable { @@ -144,12 +144,15 @@ try { ArmiHostContext arhc = new DirectArmiHostContext(mInvocationHandler); ArmiFactory af = null; + if (mServerOrClientFactory.equals("S")) { af = new ServerClassArmiFactory(); } else { af = new ClientClassArmiFactory(); } + af.setHostContext(arhc); + TestInterface ti = (TestInterface) af.lookup("Hello"); TestClient tc = new TestClient(ti); } catch (ArmiConnectionException ace) { 1.2 +6 -6 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/DirectTestC.java Index: DirectTestC.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/DirectTestC.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DirectTestC.java 4 Jan 2002 21:09:14 -0000 1.1 +++ DirectTestC.java 7 Jan 2002 19:38:30 -0000 1.2 @@ -1,8 +1,8 @@ /* - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/DirectTestC.java,v 1.1 2002/01/04 21:09:14 hammant Exp $ - * $Revision: 1.1 $ - * $Date: 2002/01/04 21:09:14 $ + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/DirectTestC.java,v 1.2 2002/01/07 19:38:30 hammant Exp $ + * $Revision: 1.2 $ + * $Date: 2002/01/07 19:38:30 $ * * ==================================================================== * @@ -81,7 +81,7 @@ * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class DirectTestC extends DirectTest { @@ -104,7 +104,8 @@ DirectServer ds = new DirectServer(); BCELClassRetriever bcr = new BCELClassRetriever(); - bcr.generate("Hello", new Class[] { TestInterface.class }); + + bcr.generate("Hello", new Class[]{ TestInterface.class }); ds.setClassRetriever(bcr); TestInterfaceImpl ti = new TestInterfaceImpl(); @@ -117,5 +118,4 @@ thread.start(); } - } 1.7 +8 -5 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/PipeTest.java Index: PipeTest.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/PipeTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- PipeTest.java 6 Jan 2002 15:39:53 -0000 1.6 +++ PipeTest.java 7 Jan 2002 19:38:30 -0000 1.7 @@ -1,8 +1,8 @@ /* - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/PipeTest.java,v 1.6 2002/01/06 15:39:53 hammant Exp $ - * $Revision: 1.6 $ - * $Date: 2002/01/06 15:39:53 $ + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/PipeTest.java,v 1.7 2002/01/07 19:38:30 hammant Exp $ + * $Revision: 1.7 $ + * $Date: 2002/01/07 19:38:30 $ * * ==================================================================== * @@ -80,7 +80,7 @@ * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ public class PipeTest { @@ -118,7 +118,7 @@ * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ static class PipedTestClient implements Runnable { @@ -145,12 +145,15 @@ try { ArmiHostContext arhc = new PipedArmiHostContext(mPipedServer); ArmiFactory af = null; + if (mServerOrClientFactory.equals("S")) { af = new ServerClassArmiFactory(); } else { af = new ClientClassArmiFactory(); } + af.setHostContext(arhc); + TestInterface ti = (TestInterface) af.lookup("Hello"); TestClient tc = new TestClient(ti); } catch (ArmiConnectionException ace) { 1.6 +7 -7 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/RmiClientTest.java Index: RmiClientTest.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/RmiClientTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- RmiClientTest.java 6 Jan 2002 15:39:53 -0000 1.5 +++ RmiClientTest.java 7 Jan 2002 19:38:30 -0000 1.6 @@ -1,8 +1,8 @@ /* - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/RmiClientTest.java,v 1.5 2002/01/06 15:39:53 hammant Exp $ - * $Revision: 1.5 $ - * $Date: 2002/01/06 15:39:53 $ + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/RmiClientTest.java,v 1.6 2002/01/07 19:38:30 hammant Exp $ + * $Revision: 1.6 $ + * $Date: 2002/01/07 19:38:30 $ * * ==================================================================== * @@ -75,7 +75,7 @@ * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ */ public class RmiClientTest { @@ -92,18 +92,18 @@ System.out.println("ARMI over RMI Client"); - - ArmiHostContext arhc = new RmiArmiHostContext("127.0.0.1", 4321); ArmiFactory af = null; + if (args[0].equals("S")) { af = new ServerClassArmiFactory(); } else { af = new ClientClassArmiFactory(); } + af.setHostContext(arhc); - TestInterface ti = (TestInterface) af.lookup("Hello"); + TestInterface ti = (TestInterface) af.lookup("Hello"); new TestClient(ti); } 1.6 +7 -6 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/SocketClientTest.java Index: SocketClientTest.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/SocketClientTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- SocketClientTest.java 6 Jan 2002 15:39:53 -0000 1.5 +++ SocketClientTest.java 7 Jan 2002 19:38:30 -0000 1.6 @@ -1,8 +1,8 @@ /* - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/SocketClientTest.java,v 1.5 2002/01/06 15:39:53 hammant Exp $ - * $Revision: 1.5 $ - * $Date: 2002/01/06 15:39:53 $ + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/SocketClientTest.java,v 1.6 2002/01/07 19:38:30 hammant Exp $ + * $Revision: 1.6 $ + * $Date: 2002/01/07 19:38:30 $ * * ==================================================================== * @@ -78,7 +78,7 @@ * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ */ public class SocketClientTest { @@ -95,16 +95,17 @@ System.out.println("Stream over Socket Client"); - - ArmiHostContext arhc = new PlainSocketArmiHostContext("127.0.0.1", 1234); ArmiFactory af = null; + if (args[0].equals("S")) { af = new ServerClassArmiFactory(); } else { af = new ClientClassArmiFactory(); } + af.setHostContext(arhc); + TestInterface ti = (TestInterface) af.lookup("Hello"); new TestClient(ti); 1.7 +26 -16 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestClient.java Index: TestClient.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestClient.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- TestClient.java 7 Jan 2002 16:24:34 -0000 1.6 +++ TestClient.java 7 Jan 2002 19:38:30 -0000 1.7 @@ -1,8 +1,8 @@ /* - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestClient.java,v 1.6 2002/01/07 16:24:34 hammant Exp $ - * $Revision: 1.6 $ - * $Date: 2002/01/07 16:24:34 $ + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestClient.java,v 1.7 2002/01/07 19:38:30 hammant Exp $ + * $Revision: 1.7 $ + * $Date: 2002/01/07 19:38:30 $ * * ==================================================================== * @@ -77,7 +77,7 @@ * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ public class TestClient { @@ -109,46 +109,56 @@ } System.out.println("CLT: " + ti.hello4((float) 1.3, 2.1)); - System.out.println("CLT: Other Facade tests"); - TestInterface2 ti2One = ti.makeSecondThing("One"); - TestInterface2 ti2Two = ti.makeSecondThing("Two"); + TestInterface2 ti2One = ti.makeTestInterface2("One"); + TestInterface2 ti2Two = ti.makeTestInterface2("Two"); System.out.println("CLT: One name = '" + ti2One.getName() + "'"); System.out.println("CLT: Two name = '" + ti2Two.getName() + "'"); - System.out.println("CLT: Changing name for One to '111'"); ti2One.setName("111"); - System.out.println("CLT: One name = '" + ti2One.getName() + "'"); System.out.println("CLT: Two name = '" + ti2Two.getName() + "'"); - System.out.println("CLT: Morphing Two's name via TestInterface"); ti.morphName(ti2Two); - System.out.println("CLT: One name = '" + ti2One.getName() + "'"); System.out.println("CLT: Two name = '" + ti2Two.getName() + "'"); + System.out + .println("CLT: using findByName method to find the 'One' ... actually '111' now"); + + TestInterface2 ti2OneB = ti.findTestInterface2ByName("111"); + System.out.println("CLT: One name = '" + ti2One.getName() + "'"); + System.out.println("CLT: Two name = '" + ti2Two.getName() + "'"); + System.out.println("CLT: One (by finder) name = '" + ti2OneB.getName() + "'"); + System.out.println("CLT: new object == (instance equality) to '111' obj ? -> " + + (ti2One == ti2OneB)); System.out.println("CLT: Two timings about to start, please stand by..."); + ti.testSpeed(); // to ignore for timing - ti.testSpeed(); // to ignore for timing long start = System.currentTimeMillis(); + for (int i = 0; i < 100000; i++) { ti.testSpeed(); } + long end = System.currentTimeMillis(); - System.out.println("CLT: Total time take for 100,000 simple calls (millis) = " + (end - start)); + + System.out.println("CLT: Total time take for 100,000 simple calls (millis) = " + + (end - start)); String rv = ti.testSpeed2("toIgnoreForTiming"); + start = System.currentTimeMillis(); + for (int i = 0; i < 100000; i++) { rv = ti.testSpeed2("qwerty"); } - end = System.currentTimeMillis(); - System.out.println("CLT: Total time take for 100,000 retval/param calls (millis) = " + (end - start)); + end = System.currentTimeMillis(); + System.out.println("CLT: Total time take for 100,000 retval/param calls (millis) = " + + (end - start)); } - } 1.4 +45 -5 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterface.java Index: TestInterface.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterface.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- TestInterface.java 7 Jan 2002 16:24:34 -0000 1.3 +++ TestInterface.java 7 Jan 2002 19:38:30 -0000 1.4 @@ -1,8 +1,8 @@ /* - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterface.java,v 1.3 2002/01/07 16:24:34 hammant Exp $ - * $Revision: 1.3 $ - * $Date: 2002/01/07 16:24:34 $ + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterface.java,v 1.4 2002/01/07 19:38:30 hammant Exp $ + * $Revision: 1.4 $ + * $Date: 2002/01/07 19:38:30 $ * * ==================================================================== * @@ -73,7 +73,7 @@ * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> - * @version * $Revision: 1.3 $ + * @version * $Revision: 1.4 $ */ public interface TestInterface { @@ -121,12 +121,52 @@ */ StringBuffer hello4(float greeting1, double greeting2); + /** + * Method testSpeed + * + * + */ void testSpeed(); + /** + * Method testSpeed2 + * + * + * @param string + * + * @return + * + */ String testSpeed2(String string); - TestInterface2 makeSecondThing(String thingName); + /** + * Method makeTestInterface2 + * + * + * @param thingName + * + * @return + * + */ + TestInterface2 makeTestInterface2(String thingName); + /** + * Method morphName + * + * + * @param forThisImpl + * + */ void morphName(TestInterface2 forThisImpl); + /** + * Method findTestInterface2ByName + * + * + * @param nameToFind + * + * @return + * + */ + TestInterface2 findTestInterface2ByName(String nameToFind); } 1.2 +3 -5 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterface2.java Index: TestInterface2.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterface2.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TestInterface2.java 6 Jan 2002 15:39:53 -0000 1.1 +++ TestInterface2.java 7 Jan 2002 19:38:30 -0000 1.2 @@ -1,8 +1,8 @@ /* - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterface2.java,v 1.1 2002/01/06 15:39:53 hammant Exp $ - * $Revision: 1.1 $ - * $Date: 2002/01/06 15:39:53 $ + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterface2.java,v 1.2 2002/01/07 19:38:30 hammant Exp $ + * $Revision: 1.2 $ + * $Date: 2002/01/07 19:38:30 $ * * ==================================================================== * @@ -73,7 +73,7 @@ * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> - * @version * $Revision: 1.1 $ + * @version * $Revision: 1.2 $ */ public interface TestInterface2 { @@ -86,7 +86,6 @@ */ void setName(String newThingName); - /** * Method getName * @@ -95,6 +94,5 @@ * @return * */ - String getName(); - + String getName(); } 1.2 +15 -2 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterface2Impl.java Index: TestInterface2Impl.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterface2Impl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TestInterface2Impl.java 6 Jan 2002 15:39:53 -0000 1.1 +++ TestInterface2Impl.java 7 Jan 2002 19:38:30 -0000 1.2 @@ -1,8 +1,8 @@ /* - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterface2Impl.java,v 1.1 2002/01/06 15:39:53 hammant Exp $ - * $Revision: 1.1 $ - * $Date: 2002/01/06 15:39:53 $ + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterface2Impl.java,v 1.2 2002/01/07 19:38:30 hammant Exp $ + * $Revision: 1.2 $ + * $Date: 2002/01/07 19:38:30 $ * * ==================================================================== * @@ -61,19 +61,30 @@ */ package org.apache.commons.armi.test; + + /** * Class TestInterface2Impl * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> - * @version * $Revision: 1.1 $ + * @version * $Revision: 1.2 $ */ public class TestInterface2Impl implements TestInterface2 { private String mName; + /** + * Constructor TestInterface2Impl + * + * + * @param name + * + */ public TestInterface2Impl(String name) { + System.out.println("SVR: Object " + this + " created with name: '" + name + "'"); + mName = name; } @@ -85,7 +96,9 @@ * */ public void setName(String newThingName) { + mName = newThingName; + System.out.println("SVR: Object " + this + " name changed to: '" + newThingName + "'"); } 1.4 +72 -9 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterfaceImpl.java Index: TestInterfaceImpl.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterfaceImpl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- TestInterfaceImpl.java 7 Jan 2002 16:24:34 -0000 1.3 +++ TestInterfaceImpl.java 7 Jan 2002 19:38:30 -0000 1.4 @@ -1,8 +1,8 @@ /* - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterfaceImpl.java,v 1.3 2002/01/07 16:24:34 hammant Exp $ - * $Revision: 1.3 $ - * $Date: 2002/01/07 16:24:34 $ + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterfaceImpl.java,v 1.4 2002/01/07 19:38:30 hammant Exp $ + * $Revision: 1.4 $ + * $Date: 2002/01/07 19:38:30 $ * * ==================================================================== * @@ -67,16 +67,20 @@ import java.io.IOException; +import java.util.Vector; + /** * Class TestInterfaceImpl * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ public class TestInterfaceImpl implements TestInterface { + Vector ti2Holder = new Vector(); + /** * Method hello * @@ -145,24 +149,83 @@ return sb; } - public void testSpeed() { - } + /** + * Method testSpeed + * + * + */ + public void testSpeed() {} + /** + * Method testSpeed2 + * + * + * @param string + * + * @return + * + */ public String testSpeed2(String string) { return "abc123"; } - public TestInterface2 makeSecondThing(String thingName) { - return new TestInterface2Impl(thingName); + /** + * Method makeTestInterface2 + * + * + * @param thingName + * + * @return + * + */ + public TestInterface2 makeTestInterface2(String thingName) { + + TestInterface2 ti2 = new TestInterface2Impl(thingName); + + ti2Holder.add(ti2); + + return ti2; } + /** + * Method morphName + * + * + * @param forThisImpl + * + */ public void morphName(TestInterface2 forThisImpl) { + String name = forThisImpl.getName(); StringBuffer sb = new StringBuffer(); + for (int i = 0; i < name.length(); i++) { - sb.append(name.substring(i,i+1).toUpperCase()); + sb.append(name.substring(i, i + 1).toUpperCase()); sb.append("_"); } + forThisImpl.setName(sb.toString()); + } + + /** + * Method findTestInterface2ByName + * + * + * @param nameToFind + * + * @return + * + */ + public TestInterface2 findTestInterface2ByName(String nameToFind) { + + for (int i = 0; i < ti2Holder.size(); i++) { + TestInterface2 ti2 = (TestInterface2) ti2Holder.elementAt(i); + + if (ti2.getName().equals(nameToFind)) { + return ti2; + } + } + + return new TestInterface2Impl("Not Found"); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>