001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Rodrigo Westrupp
028: */
029:
030: package com.caucho.ejb.timer;
031:
032: import javax.ejb.*;
033: import java.io.Serializable;
034: import java.util.Date;
035: import java.util.logging.*;
036:
037: import com.caucho.util.L10N;
038:
039: /**
040: * Implements the EJB timer handle.
041: */
042: public class EjbTimerHandle implements TimerHandle {
043: private static final L10N L = new L10N(EjbTimerHandle.class);
044: protected static final Logger log = Logger
045: .getLogger(EjbTimerHandle.class.getName());
046:
047: private Date _expiration;
048: private long _interval;
049: private Serializable _info;
050: private String _serverId;
051: private long _timerId;
052:
053: EjbTimerHandle(Date expiration, long interval, Serializable info,
054: String serverId, long timerId) {
055: _expiration = expiration;
056: _interval = interval;
057: _info = info;
058: _serverId = serverId;
059: _timerId = timerId;
060: }
061:
062: /**
063: * Returns the timer.
064: */
065: public Timer getTimer() throws NoSuchObjectLocalException,
066: EJBException {
067: /*
068: try {
069: EjbServerManager manager = EjbServerManager.getLocal();
070:
071: checkNotNull(manager);
072:
073: AbstractServer server = manager.getServer(_serverId);
074:
075: checkNotNull(server);
076:
077: EjbTimerService timerService
078: = (EjbTimerService) server.getTimerService();
079:
080: checkNotNull(timerService);
081:
082: EjbTimer timer = timerService.__caucho_find(_timerId);
083:
084: checkNotNull(timer);
085:
086: return timer;
087: } catch (RuntimeException e) {
088: log.log(Level.FINE, e.toString(), e);
089: throw e;
090: } catch (Exception e) {
091: log.log(Level.FINE, e.toString(), e);
092: throw new EJBException(e);
093: }
094: */
095: return null;
096: }
097:
098: private void checkNotNull(Object obj)
099: throws NoSuchObjectLocalException {
100: if (obj == null)
101: throw new NoSuchObjectLocalException(this + " not found");
102: }
103:
104: public String toString() {
105: return "EjbTimerHandle[" + _serverId + ", " + _timerId + ", "
106: + _expiration + ", " + _interval + ", " + _info + "]";
107: }
108: }
|