001: /**
002: * LibreSource
003: * Copyright (C) 2004-2008 Artenum SARL / INRIA
004: * http://www.libresource.org - contact@artenum.com
005: *
006: * This file is part of the LibreSource software,
007: * which can be used and distributed under license conditions.
008: * The license conditions are provided in the LICENSE.TXT file
009: * at the root path of the packaging that enclose this file.
010: * More information can be found at
011: * - http://dev.libresource.org/home/license
012: *
013: * Initial authors :
014: *
015: * Guillaume Bort / INRIA
016: * Francois Charoy / Universite Nancy 2
017: * Julien Forest / Artenum
018: * Claude Godart / Universite Henry Poincare
019: * Florent Jouille / INRIA
020: * Sebastien Jourdain / INRIA / Artenum
021: * Yves Lerumeur / Artenum
022: * Pascal Molli / Universite Henry Poincare
023: * Gerald Oster / INRIA
024: * Mariarosa Penzi / Artenum
025: * Gerard Sookahet / Artenum
026: * Raphael Tani / INRIA
027: *
028: * Contributors :
029: *
030: * Stephane Bagnier / Artenum
031: * Amadou Dia / Artenum-IUP Blois
032: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033: */package org.libresource.so6.server.ls.ejb;
034:
035: import org.libresource.Libresource;
036:
037: import org.libresource.scheduler.LibresourceJob;
038:
039: import org.libresource.so6.server.ls.ejb.model.SynchronizerResourceValue;
040: import org.libresource.so6.server.ls.interfaces.LibresourceSynchronizerService;
041:
042: import javax.ejb.MessageDrivenBean;
043: import javax.ejb.MessageDrivenContext;
044:
045: import javax.jms.Message;
046: import javax.jms.MessageListener;
047:
048: /**
049: * @author <a href="mailto:jourdain@loria.fr">Sebastien Jourdain</a> - <a href="http://www.inria.fr">INRIA Lorraine</a>
050: *
051: * @ejb.bean
052: * name="CompressJobsListener"
053: * transaction-type="Container"
054: * acknowledge-mode="Auto-acknowledge"
055: * destination-type="javax.jms.Topic"
056: * subscription-durability="NonDurable"
057: * message-selector="name LIKE 'libresourceSynchronizer.compressHistory'"
058: *
059: * @jonas.bean ejb-name="CompressJobsListener"
060: *
061: * @jonas.message-driven-destination jndi-name="libresource.jobs"
062: *
063: * @jboss.destination-jndi-name name="topic/libresource.jobs"
064: *
065: * @ejb.transaction type="NotSupported"
066: */
067: public class CompressJobsListenerBean implements MessageDrivenBean,
068: MessageListener {
069: private transient MessageDrivenContext mdbContext;
070:
071: public void onMessage(Message message) {
072: try {
073: LibresourceJob libresourceJob = LibresourceJob
074: .toLibresourceJob(message);
075: LibresourceSynchronizerService libresourcesynchronizerService = (LibresourceSynchronizerService) Libresource
076: .getService("LibresourceSynchronizer");
077:
078: SynchronizerResourceValue[] syncs = libresourcesynchronizerService
079: .listAllSynchronizers();
080:
081: for (int k = 0; k < syncs.length; k++) {
082: SynchronizerResourceValue sync = syncs[k];
083:
084: try {
085: String synchronizerId = sync.getId();
086: libresourcesynchronizerService.tagStateSystem(sync
087: .getUri());
088: } catch (Exception e) {
089: }
090: }
091: } catch (Exception e) {
092: e.printStackTrace();
093: }
094: }
095:
096: // standard call back methods
097: public void setMessageDrivenContext(MessageDrivenContext ctx) {
098: mdbContext = ctx;
099: }
100:
101: public void ejbRemove() {
102: }
103:
104: public void ejbCreate() {
105: }
106: }
|