|
From: <pka...@us...> - 2009-07-31 21:58:09
|
Revision: 415
http://cse-ip.svn.sourceforge.net/cse-ip/?rev=415&view=rev
Author: pkasprzak
Date: 2009-07-31 21:57:59 +0000 (Fri, 31 Jul 2009)
Log Message:
-----------
* Added test code
Modified Paths:
--------------
trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyManagerImpl.java
Modified: trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyManagerImpl.java
===================================================================
--- trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyManagerImpl.java 2009-07-31 21:53:30 UTC (rev 414)
+++ trunk/sandbox/lsf-adapter-demo/CSECore-ejb/src/java/de/campussource/cse/core/DependencyManagerImpl.java 2009-07-31 21:57:59 UTC (rev 415)
@@ -11,8 +11,14 @@
import java.util.HashSet;
import java.util.List;
import java.util.logging.Logger;
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
import javax.ejb.EJB;
+import javax.ejb.EJBContext;
+import javax.ejb.SessionContext;
import javax.ejb.Stateless;
+import javax.ejb.Timeout;
+import javax.ejb.Timer;
import javax.persistence.PersistenceContext;
import javax.xml.ws.WebServiceRef;
@@ -26,6 +32,9 @@
@WebServiceRef(wsdlLocation = "META-INF/wsdl/client/DependencyManager/DependencyManager.wsdl")
private DependencyManagerNotificationService service;
+ @Resource
+ private EJBContext ctx;
+
@PersistenceContext
private javax.persistence.EntityManager em;
@@ -44,6 +53,34 @@
private final static Logger logger = Logger.getLogger("de.campussource.cse.core.DependencyManager");
// ----------------------------------------------------------------------------------------------------------------
+// @PostConstruct
+ protected void init() {
+ ctx.getTimerService().createTimer(10000, null);
+ logger.info("*** Timer created!");
+ }
+
+ // ----------------------------------------------------------------------------------------------------------------
+ @Timeout
+ public void handleTimeout(Timer timer) {
+ logger.info("*** Timer called => waking up process!");
+ List<WaitingProcess> processes = getBySystem("Ilias");
+ if (!processes.isEmpty()) {
+ wakeUpWaitingProcess(processes.get(0));
+ } else {
+ logger.info("*** No processes waiting => doing nothing!");
+ }
+ }
+
+ // ----------------------------------------------------------------------------------------------------------------
+ protected List<WaitingProcess> getBySystem(String System) {
+
+ List<WaitingProcess> processes = em.createNamedQuery(WaitingProcess.QUERY_getBySystem). setParameter("system", System).
+ getResultList();
+
+ return processes;
+ }
+
+ // ----------------------------------------------------------------------------------------------------------------
protected boolean updateDependencies(WaitingProcess process) {
boolean satisfied = true;
@@ -100,6 +137,8 @@
// ----------------------------------------------------------------------------------------------------------------
public void waitForDependencies(int cseId) {
+ init();
+
Entity entity = em.find(Entity.class, cseId);
for (String system : systemManager.getOutboundSystems()) {
@@ -156,8 +195,6 @@
// ----------------------------------------------------------------------------------------------------------------
protected void wakeUpWaitingProcess(WaitingProcess process) {
-
-
/* Call process */
try {
de.campussource.cse.ejb.dependencymanager.DependencyManagerNotification port = service.getDependencyManagerNotificationPort();
@@ -165,10 +202,12 @@
int entityId = process.getEntityId();
String system = process.getSystem();
+ logger.info("*** Waking up process (" + system + ": " + entityId + ")");
+
port.notify(entityId, system);
} catch (Exception ex) {
- logger.severe("Exception while notifying process: " + ex.getMessage());
+ logger.severe("*** Exception while notifying process: " + ex.getMessage());
}
/* Remove dependencies */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|