From: Bryan T. <tho...@us...> - 2007-03-18 12:59:37
|
Update of /cvsroot/cweb/bigdata/src/test/org/CognitiveWeb/bigdata/jini In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv12438/src/test/org/CognitiveWeb/bigdata/jini Modified Files: TestServiceDiscovery.java TestServer.java Log Message: A little more work setting up for the services architecture. Index: TestServiceDiscovery.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/org/CognitiveWeb/bigdata/jini/TestServiceDiscovery.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestServiceDiscovery.java 26 Aug 2006 19:30:21 -0000 1.1 --- TestServiceDiscovery.java 17 Mar 2007 23:14:59 -0000 1.2 *************** *** 50,54 **** import java.io.Serializable; import java.net.InetAddress; - import java.rmi.RMISecurityManager; import junit.framework.TestCase; --- 50,53 ---- *************** *** 64,68 **** * </p> * <p> ! * jini MUST be running. * </p> * --- 63,84 ---- * </p> * <p> ! * Note: jini MUST be running. You can get the jini starter kit and install it ! * to get jini running. ! * </p> ! * <p> ! * Note: The registered service will NOT show up correctly in the Service ! * Browser (you will see "Unknown service") unless you set the codebase when ! * executing this test class and the .class files are available for download ! * from the codebase URL. I jump start the tests myself using ! * </p> ! * ! * <pre> ! * -Djava.security.policy=policy.all -Djava.rmi.server.codebase=http://proto.cognitiveweb.org/maven-repository/bigdata/jars/ ! * </pre> ! * ! * <p> ! * which presuposes that the required class files are on that server available ! * for download. The security policy is overlax, but you do need to grant some ! * privledges in order to partitipate in discovery, etc. * </p> * *************** *** 74,90 **** * client remain that minimal. Right now I am also using jini-ext.jar, * reggie.jar and sun-util.jar to run this test. jini-ext.jar is the big ! * one at over 1M. ! * ! * @todo The registered service is not showing up in the Service Browser because ! * the classes required to deserialize an instance of the service item ! * (including our MyStatus and other Entry classes) and the service proxy ! * itself are not being deployed to a directory where reggie can be used ! * to download those classes to the Service Browser. Solving this problem ! * will also solve the above configuration issue and will make it possible ! * to bundle fewer JARs with bigdata. For this workstation IIS must be ! * running and the class files (or JAR) must be copied to ! * "C:\Inetpub\wwwroot". The -Djava.rmi.server.codebase=... property must ! * be set for the JARs to be downloaded from that server. I am not sure ! * yet what needs to be done to get the Service Browser working smoothly. * * @todo Figure out how to divide the service into a proxy and a remote object. --- 90,95 ---- * client remain that minimal. Right now I am also using jini-ext.jar, * reggie.jar and sun-util.jar to run this test. jini-ext.jar is the big ! * one at over 1M. (this can be facilitated using the dljar ant task and ! * specifing jini-core as the target platform.) * * @todo Figure out how to divide the service into a proxy and a remote object. *************** *** 97,100 **** --- 102,113 ---- * e.g., there is no locking, but we can handle all of that. * + * @see http://archives.java.sun.com/cgi-bin/wa?A2=ind0311&L=jini-users&F=&S=&P=7182 + * for a description of policy files and + * http://www.dancres.org/cottage/jini-start-examples-2_1.zip for the + * policy files described.<br> + * When testing standalone with only trusted code and NO downloaded code, + * it is reasonable to consider running the test code using + * "-Djava.security.policy=policy.all" so that you can get things moving. + * * @version $Id$ * @author <a href="mailto:tho...@us...">Bryan Thompson *************** *** 114,121 **** */ ! public void test_serviceDiscover() throws IOException, ClassNotFoundException { ! // install suitable security manager ! System.setSecurityManager(new RMISecurityManager()); /* --- 127,137 ---- */ ! public void test_serviceDiscovery() throws IOException, ClassNotFoundException { ! /* ! * install suitable security manager. this is required before the ! * application can download code. ! */ ! System.setSecurityManager(new SecurityManager()); /* *************** *** 134,137 **** --- 150,154 ---- // Find the service registrar (unicast protocol). final int timeout = 4*1000; // seconds. + System.err.println("hostname: "+hostname); LookupLocator lookupLocator = new LookupLocator("jini://"+hostname); ServiceRegistrar serviceRegistrar = lookupLocator.getRegistrar( timeout ); *************** *** 201,204 **** --- 218,229 ---- { + /** + * + */ + private static final long serialVersionUID = -920558820563934297L; + + /** + * De-serialization constructor (required). + */ public TestServerImpl() { log.info("Created: "+this); *************** *** 210,213 **** --- 235,256 ---- } + + public static void main(String[] args) throws Exception { + + TestServiceDiscovery test = new TestServiceDiscovery(); + + test.setUp(); + + try { + + test.test_serviceDiscovery(); + + } finally { + + test.tearDown(); + + } + + } } Index: TestServer.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/org/CognitiveWeb/bigdata/jini/TestServer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestServer.java 26 Aug 2006 19:30:21 -0000 1.1 --- TestServer.java 17 Mar 2007 23:14:59 -0000 1.2 *************** *** 48,51 **** --- 48,52 ---- import java.io.IOException; + import java.rmi.RMISecurityManager; import java.rmi.RemoteException; *************** *** 108,122 **** /* ! * Generate a ServiceID ourselves. This makes it easier to register ! * the same service against multiple lookup services. * ! * @todo If you want to restart (or re-register) the same service, ! * then you need to read the serviceID from some persistent ! * location. If you are using activation, then the service can be ! * remotely started using its serviceID which takes that ! * responsibility out of your hands. When using activation, you will ! * only create a serviceID once when you install the service onto ! * some component and activity takes responsiblity for starting the ! * service on demand. */ Uuid uuid = UuidFactory.generate(); --- 109,122 ---- /* ! * Generate a ServiceID ourselves. This makes it easier to register the ! * same service against multiple lookup services. * ! * @todo If you want to restart (or re-register) the same service, then ! * you need to read the serviceID from some persistent location. If you ! * are using activation, then the service can be remotely started using ! * its serviceID which takes that responsibility out of your hands. When ! * using activation, you will only create a serviceID once when you ! * install the service onto some component and activition takes ! * responsiblity for starting the service on demand. */ Uuid uuid = UuidFactory.generate(); *************** *** 197,205 **** "locality", "stateOrProvince", "postalCode", "country"), ! new ServiceInfo("BigTable", // product or package name "SYSTAP,LLC", // manufacturer ! "CognitiveWeb", // vendor "0.1-beta", // version ! "model", // model "serial#" // serialNumber ) }); --- 197,205 ---- "locality", "stateOrProvince", "postalCode", "country"), ! new ServiceInfo("bigdata", // product or package name "SYSTAP,LLC", // manufacturer ! "SYSTAP,LLC", // vendor "0.1-beta", // version ! "bigdata", // model "serial#" // serialNumber ) }); *************** *** 305,310 **** /** ! * {@link Status} is abstract so a service basically needs to provide their own ! * concrete implementation. * * @version $Id$ --- 305,310 ---- /** ! * {@link Status} is abstract so a service basically needs to provide their ! * own concrete implementation. * * @version $Id$ *************** *** 313,316 **** --- 313,321 ---- public static class MyStatus extends Status { + /** + * + */ + private static final long serialVersionUID = 3431522046169284463L; + /* * Note: public fields are required and must be Serializable. *************** *** 330,346 **** /** ! * {@link ServiceType}is abstract so a service basically needs to ! * provide their own concrete implementation. This class does not ! * support icons (always returns null for ! * {@link ServiceType#getIcon(int)}. See {@link java.beans.BeanInfo} ! * for how to interpret and support the getIcon() method. * * @version $Id$ ! * @author <a href="mailto:tho...@us...">Bryan ! * Thompson </a> */ public static class MyServiceType extends ServiceType { public String displayName; public String shortDescription; --- 335,356 ---- /** ! * {@link ServiceType} is abstract so a service basically needs to provide ! * their own concrete implementation. This class does not support icons ! * (always returns null for {@link ServiceType#getIcon(int)}. See ! * {@link java.beans.BeanInfo} for how to interpret and support the ! * getIcon() method. * * @version $Id$ ! * @author <a href="mailto:tho...@us...">Bryan Thompson ! * </a> */ public static class MyServiceType extends ServiceType { + /** + * + */ + private static final long serialVersionUID = -2088608425852657477L; + public String displayName; public String shortDescription; |