/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
/**
* TimerBean is a facade for the persistent state of an EJB Timer.
* It is part of the EJB container and is implemented using
* Java Persistence API. The standard JPA behavior is useful in
* implementing the transactional properties of EJB timers.
* When an EJB timer is created by an application, it is not
* eligible for expiration until the transaction commits.
* Likewise, if a timer is cancelled and the transaction rolls
* back, the timer must be reactivated.
* To accomplish this, TimerBean registers callbacks with the
* transaction manager and interacts with the EJBTimerService
* accordingly.
*
* @author Kenneth Saks
* @author Marina Vatkina
*/
// Find Timer by Id
}
//
// Query methods for timer ids
//
return toPKeys(q.getResultList());
}
(long containerId, int state) {
return toPKeys(q.getResultList());
}
return toPKeys(q.getResultList());
}
return toPKeys(q.getResultList());
}
return toPKeys(q.getResultList());
}
return toPKeys(q.getResultList());
}
//
// Query methods for timer beans
// XXX These methods return Sets XXX
//
return new HashSet(q.getResultList());
}
(long containerId, int state) {
return new HashSet(q.getResultList());
}
return new HashSet(q.getResultList());
}
return new HashSet(q.getResultList());
}
return new HashSet(q.getResultList());
}
return new HashSet(q.getResultList());
}
//
// Query methods for timer counts
//
}
}
public int countTimersByContainerAndState
(long containerId, int state) {
}
public int countTimersByContainerAndOwner
}
public int countTimersByContainerAndOwnerAndState
}
}
public int countTimersByOwnerAndState
}
//
// These data members contain derived state for
// some immutable fields.
//
// deserialized state from blob
private boolean blobLoaded_;
throws CreateException {
try {
} catch(IOException ioe) {
throw ce;
}
" ::timedObjectPK=" + timedObjectPrimaryKey +
" ::initialExpiration=" + initialExpiration +
" ::intervalDuration=" + intervalDuration +
}
//
// Only proceed with transactional semantics if this timer
// is owned by the current server instance. NOTE that this
// will *ALWAYS* be the case for timers created from EJB
// applications via the javax.ejb.EJBTimerService.create methods.
//
// For testing purposes, ejbCreate takes an ownerId parameter,
// which allows us to easily simulate other server instances
// by creating timers for them. In those cases, we don't need
// the timer transaction semantics and ejbTimeout logic. Simulating
// the creation of timers for the same application and different
// server instances from a script is difficult since the
// containerId is not generated until after deployment.
//
try {
} catch(Exception e) {
throw ce;
}
return timer;
}
return getEJBTimerService().getOwnerIdOfThisServer();
}
}
}
}
}
try {
} catch(Exception e) {
" for unknown container ", e);
}
}
}
throws FinderException, Exception {
// If timer is null need to throw a FinderException so
// that the caller can handle it.
}
// First set the timer to the cancelled state. This step is
// performed whether or not the current server instance owns
// the timer.
// already cancelled or removed
return;
}
// XXX ???? WHY WAS IT: NOTE that it's the caller's responsibility to call remove().
return;
}
try {
} catch(Exception e) {
}
}
}
}
return pkeys;
}
//
// Other query methods for timer ids
//
}
}
(long containerId) {
}
(long containerId) {
}
(long containerId) {
}
return findTimerIdsByOwner(getOwnerIdOfThisServer());
}
return findTimerIdsByOwnerAndState
}
return findTimerIdsByOwnerAndState
}
return findTimerIdsByOwner(ownerId);
}
return findTimerIdsByOwnerAndState(ownerId,
}
return findTimerIdsByOwnerAndState(ownerId,
}
//
// Helper query methods for timer beans
//
}
}
(long containerId) {
}
(long containerId) {
}
(long containerId) {
}
return findTimersByOwner(getOwnerIdOfThisServer());
}
return findTimersByOwnerAndState
}
return findTimersByOwnerAndState
}
return findTimersByOwner(ownerId);
}
return findTimersByOwnerAndState(ownerId,
}
return findTimersByOwnerAndState(ownerId,
}
//
// Helper query methods for timer counts
//
}
}
public int countTimersOwnedByThisServerByContainer
(long containerId) {
}
(long containerId) {
}
(long containerId) {
}
public int countTimersOwnedByThisServer() {
return countTimersByOwner(getOwnerIdOfThisServer());
}
int i = 0;
i++;
}
return totalTimers;
}
public int countActiveTimersOwnedByThisServer() {
return countTimersByOwnerAndState
}
public int countCancelledTimersOwnedByThisServer() {
return countTimersByOwnerAndState
}
return countTimersByOwner(ownerId);
}
return countTimersByOwnerAndState(ownerId,
}
return countTimersByOwnerAndState(ownerId,
}
boolean checkDatabase) {
boolean success = false;
try {
if( checkDatabase ) {
connection.close();
connection = null;
// Now try to a query that will access the timer table itself.
// Use a query that won't return a lot of data(even if the
// table is large) to reduce the overhead of this check.
}
success = true;
} catch(Exception e) {
"");
// Log exception itself at FINE level. The most likely cause
// is a connection error when the database is not started. This
// is already logged twice by the jdbc layer.
} finally {
if( connection != null ) {
try {
connection.close();
} catch(Exception e) {
e);
}
}
}
return success;
}
return q.executeUpdate();
}
return q.executeUpdate();
}
return q.executeUpdate();
}
long intervalDuration,
return;
}
}
// XXX Called by TimerState via a static call
}
// Called by TimerWelcomeServlet
return ejbTimerService.getActiveTimerIdsByThisServer();
}
/**
* To be used to read in TimerBean.Blob and replace with TimerState.Blob
* on v2.x upgrade
*/
}
}
}