KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > engine > clock > sdk > ClockImpl


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id$
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.engine.clock.sdk;
23
24 import java.text.DateFormat JavaDoc;
25 import java.text.SimpleDateFormat JavaDoc;
26 import java.util.Date JavaDoc;
27 import java.util.logging.Level JavaDoc;
28 import java.util.logging.Logger JavaDoc;
29
30 public class ClockImpl implements Clock {
31
32     private Logger JavaDoc logger;
33
34     public String JavaDoc time() {
35         logger.log(Level.INFO,
36                 "The ClockImpl service is called to return current time");
37
38         DateFormat JavaDoc formatter = new SimpleDateFormat JavaDoc("MM/dd/yyyy HH:mm:ss");
39         String JavaDoc en = "<timeResponse xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
40                 + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><timeReturn xsi:type=\"xsd:string\">";
41         en += formatter.format(new Date JavaDoc(System.currentTimeMillis()));
42         en += "</timeReturn></timeResponse>";
43
44         logger.log(Level.INFO, "The ClockImpl answer : " + en);
45
46         return en;
47     }
48
49     public ClockImpl(Logger JavaDoc logger) {
50         super();
51         this.logger = logger;
52     }
53
54 }
55
Popular Tags