|
From: Michael R. <mr...@us...> - 2004-08-10 13:28:52
|
Update of /cvsroot/openorb/OpenORB/src/examples/org/openorb/orb/examples/rmi/calculator In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7788/src/examples/org/openorb/orb/examples/rmi/calculator Added Files: Client.java Server.java Removed Files: CalculatorClt.java CalculatorServer.java Log Message: Fixed the remaining checkstyle warnings --- NEW FILE: Client.java --- /* * Copyright (C) The Community OpenORB Project. All rights reserved. * * This software is published under the terms of The OpenORB Community Software * License version 1.0, a copy of which has been included with this distribution * in the LICENSE.txt file. */ package org.openorb.orb.examples.rmi.calculator; import javax.naming.InitialContext; /** * The clien application for the calculator. * * @author Chris Wood */ public final class Client { // do not instantiate private Client() { } /** * The entry point for this application. * * @param args The command line parameters. */ public static void main( String[] args ) { CalculatorInterface calc = null; try { InitialContext context = new InitialContext(); Object o = context.lookup ( "Calculator" ); calc = ( CalculatorInterface ) javax.rmi.PortableRemoteObject.narrow( o, CalculatorInterface.class ); } catch ( Exception ex ) { ex.printStackTrace(); System.exit( 0 ); } try { System.out.println( "6 + 2 = " + calc.add( 6, 2 ) ); System.out.println( "6 / 2 = " + calc.div( 6, 2 ) ); System.out.println( "6 / 0 !!!!" + calc.div( 6, 0 ) ); } catch ( DivisionByZero e ) { System.out.println( "\n==> Error : Division by zero" ); } catch ( Exception ex ) { ex.printStackTrace(); } } } --- NEW FILE: Server.java --- /* * Copyright (C) The Community OpenORB Project. All rights reserved. * * This software is published under the terms of The OpenORB Community Software * License version 1.0, a copy of which has been included with this distribution * in the LICENSE.txt file. */ package org.openorb.orb.examples.rmi.calculator; import javax.naming.InitialContext; /** * The server application. * * @author Chris Wood */ public final class Server extends javax.rmi.PortableRemoteObject { /** * Default constructor. * * @throws java.rmi.RemoteException When a problem during instantiation occurs. */ public Server() throws java.rmi.RemoteException { } /** * This method creates the object and registers it to the NamingService. */ public void run() { try { java.util.Properties env = new java.util.Properties(); env.setProperty( "java.naming.factory.initial", "org.openorb.ns.jndi.CtxFactory" ); InitialContext context = new InitialContext( env ); CalculatorImpl addObj = new CalculatorImpl(); javax.rmi.PortableRemoteObject.exportObject( addObj ); context.bind( "addition", addObj ); System.out.println( "The calculator server is now ready..." ); } catch ( Exception ex ) { ex.printStackTrace(); System.out.println( ex.getMessage() ); } } /** * The entry point for this application. * * @param args The command line arguments. */ public static void main( String[] args ) { try { Server srv = new Server(); srv.run(); } catch ( Exception ex ) { ex.printStackTrace(); } } } --- CalculatorClt.java DELETED --- --- CalculatorServer.java DELETED --- |