1 package org.sapia.ubik.rmi.examples.time; 2 3 import org.sapia.ubik.rmi.server.Stateless; 4 5 import java.text.SimpleDateFormat ; 6 7 import java.util.Date ; 8 9 10 13 public class StatelessTimeServiceImpl implements TimeServiceIF, Stateless { 14 private SimpleDateFormat _theFormat; 15 private int _theCoutner; 16 private String _theId; 17 18 21 public StatelessTimeServiceImpl() { 22 System.out.println("Creating a new stateless time service..."); 23 _theFormat = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss z"); 24 _theId = Integer.toHexString(String.valueOf( 25 System.currentTimeMillis()).hashCode()); 26 } 27 28 33 public String getTime() { 34 long aCurrentTime = System.currentTimeMillis(); 35 Date aCurrentDate = new Date (aCurrentTime); 36 String aResult = _theFormat.format(aCurrentDate); 37 38 System.out.println((++_theCoutner) + " - Invocation took " + 39 (System.currentTimeMillis() - aCurrentTime) + " ms @" + _theId); 40 41 return aResult + " @" + _theId; 42 } 43 } 44 | Popular Tags |