package org.argeo.slc.detached;
-import java.io.PrintWriter;
-import java.io.StringWriter;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Vector;
-import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.argeo.slc.detached.admin.CloseSession;
.getLog(DetachedExecutionServerImpl.class);
private final DetachedContextImpl detachedContext;
- private final List sessions;
- private int skipCount = 1;// start skipCount at 1 since the first step is
- // always an open session
+ private DetachedSession currentSession;
+
+ /**
+ * Session being replayed, skipping the steps in the current session. If
+ * null, no session is replayed
+ */
+ private DetachedSession replayedSession = null;
private BundleContext bundleContext;
private ApplicationContext applicationContext;
public DetachedExecutionServerImpl() {
detachedContext = new DetachedContextImpl();
- sessions = new Vector();
+ currentSession = new DetachedSession();
+ currentSession.setUuid(Long.toString(System.currentTimeMillis()));
}
public synchronized DetachedAnswer executeRequest(DetachedRequest request) {
- log.info("Received " + request);
+ if(log.isDebugEnabled())
+ log.debug("Received " + request);
DetachedAnswer answer = null;
try {
} catch (Exception e) {
answer = new DetachedAnswer(request);
answer.setStatus(DetachedAnswer.ERROR);
- StringWriter writer = new StringWriter();
- e.printStackTrace(new PrintWriter(writer));
- answer.setLog(writer.toString());
- IOUtils.closeQuietly(writer);
- }
-
- // Case where current session is unexpectedly null
- if (getCurrentSession() == null) {
- log
- .error("CURRENT SESSION IS NULL."
- + " Detached status is inconsistent dumping sessions history:");
- log.error(dumpSessionsHistory(request, answer));
- if (answer != null) {
- answer.setStatus(DetachedAnswer.ERROR);
- answer
- .addToLog("CURRENT SESSION IS NULL."
- + " Detached status is inconsistent, see detached log for more details.");
- return answer;
- } else {
- throw new DetachedException(
- "Answer is null. Cannot return it. See log for more details.");
- }
-
+ log.error("Error executing request " + request, e);
}
- getCurrentSession().getRequests().add(request);
- getCurrentSession().getAnswers().add(answer);
- log.info("Sent " + answer);
+ currentSession.getRequests().add(request);
+ currentSession.getAnswers().add(answer);
+ if(log.isDebugEnabled())
+ log.debug("Sent " + answer);
return answer;
}
}
}
- // ServiceReference[] refs = bundleContext.getAllServiceReferences(
- // ApplicationContext.class.getName(), null);
- // Object obj = null;
- // for (int i = 0; i < refs.length; i++) {
- // ApplicationContext appContext = (ApplicationContext)
- // bundleContext
- // .getService(refs[i]);
- // try {
- // obj = appContext.getBean(request.getRef());
- // } catch (Exception e) {
- // // silent
- // if (log.isTraceEnabled())
- // log.trace("Could not find ref " + request.getRef(), e);
- // }
- // if (obj != null) {
- // break;
- // }
- // }
- // return obj;
-
throw new Exception(
"Cannot find any published application context containing bean "
+ request.getRef());
protected synchronized DetachedAnswer processStep(DetachedStep obj,
DetachedRequest request) {
DetachedAnswer answer;
- if (getCurrentSession() == null)
- throw new DetachedException("No open session.");
-
+
StringBuffer skippedLog = new StringBuffer();
boolean execute = true;
- if (getPreviousSession() != null && !getPreviousSession().isClosed()) {
- if (getCurrentSession().getDoItAgainPolicy().equals(
- DetachedSession.SKIP_UNTIL_ERROR)) {
- // Skip execution of already successful steps
- if (getPreviousSession().getAnswers().size() > skipCount) {
- DetachedAnswer previousAnswer = (DetachedAnswer) getPreviousSession()
- .getAnswers().get(skipCount);
- DetachedRequest previousRequest = (DetachedRequest) getPreviousSession()
- .getRequests().get(skipCount);
- // Check paths
- if (!previousRequest.getPath().equals(request.getPath())) {
- String msg = "New request is not consistent with previous path. previousPath="
- + previousRequest.getPath()
- + ", newPath="
- + request.getPath() + "\n";
- skippedLog.append(msg);
- log.warn(msg);
- }
-
- if (previousAnswer.getStatus() != DetachedAnswer.ERROR) {
- execute = false;
- String msg = "Skipped path " + request.getPath()
- + " (skipCount=" + skipCount + ")";
- skippedLog.append(msg);
- log.info(msg);
- skipCount++;
- } else {
- log
- .info("Path "
- + request.getPath()
- + " was previously in error, executing it again."
- + " (skipCount=" + skipCount
- + "). Reset skip count to 1");
- skipCount = 1;
- }
+
+ if (replayedSession != null) {
+ // Skip execution of already successful steps
+ int stepIndex = currentSession.getExecutedStepCount();
+
+ if (stepIndex < replayedSession.getExecutedStepCount()) {
+ DetachedAnswer previousAnswer = (DetachedAnswer) replayedSession
+ .getAnswers().get(stepIndex);
+ DetachedRequest previousRequest = (DetachedRequest) replayedSession
+ .getRequests().get(stepIndex);
+
+ // check step names
+ if (!previousRequest.getRef().equals(request.getRef())) {
+ String msg = "New request is not consistent with previous ref. previousRef="
+ + previousRequest.getRef()
+ + ", newRef="
+ + request.getRef() + "\n";
+ skippedLog.append(msg);
+ log.warn(msg);
+ }
+
+ // Check paths
+ if (!previousRequest.getPath().equals(request.getPath())) {
+ String msg = "New request is not consistent with previous path. previousPath="
+ + previousRequest.getPath()
+ + ", newPath="
+ + request.getPath() + "\n";
+ skippedLog.append(msg);
+ log.warn(msg);
+ }
+
+ if (previousAnswer.getStatus() != DetachedAnswer.ERROR) {
+ // if no error occurred in the replayedSession,
+ // skip the step
+ execute = false;
+ String msg = "Skipped Step " + request.getRef()
+ + " (stepIndex=" + stepIndex + ")";
+ skippedLog.append(msg);
+ log.info(msg);
+
} else {
- // went further as skip count, doing nothing.
+ // if an error occurred, execute the step and leave
+ // skipUntillError mode (even if replayedSession
+ // has more steps)
+ log.info("### End of SkipUntilError Mode ###");
+ log.info("Step " + request.getRef()
+ + " was previously in error, executing it again."
+ + " (stepIndex=" + stepIndex + ").");
+ replayedSession = null;
}
+ } else {
+ // went further as skip count, doing nothing.
}
}
DetachedAdminCommand obj, DetachedRequest request) {
DetachedAnswer answer;
if (obj instanceof OpenSession) {
- if (getCurrentSession() != null) {
- // TODO: better understand why there is sometimes two open
- // sessions sent.
- log.warn("There is already an open session #"
- + getCurrentSession().getUuid() + ". Closing it...");
- DetachedAnswer answerT = new DetachedAnswer(
- request,
- "Session #"
- + getCurrentSession().getUuid()
- + " forcibly closed. THIS ANSWER WAS NOT SENT BACK.");
- answerT.setStatus(DetachedAnswer.CLOSED_SESSION);
- getCurrentSession().getAnswers().add(answerT);
+ DetachedSession newSession = ((OpenSession) obj).execute(request,
+ bundleContext);
+
+ log.debug("Creating new DetachedSession : " + newSession);
+
+ if ((currentSession != null) && currentSession.lastActionIsError()
+ && DetachedSession.SKIP_UNTIL_ERROR.equals(newSession.getDoItAgainPolicy())) {
+ // switch to replay mode
+ log.info("### Start SkipUntilError Mode ###");
+ replayedSession = currentSession;
}
- sessions.add(((OpenSession) obj).execute(request, bundleContext));
+
+ currentSession = newSession;
+
answer = new DetachedAnswer(request, "Session #"
- + getCurrentSession().getUuid() + " open.");
+ + currentSession.getUuid() + " open.");
} else if (obj instanceof CloseSession) {
- if (getCurrentSession() == null)
+ if (currentSession == null)
throw new DetachedException("There is no open session to close");
answer = new DetachedAnswer(request, "Session #"
- + getCurrentSession().getUuid() + " closed.");
+ + currentSession.getUuid() + " closed.");
answer.setStatus(DetachedAnswer.CLOSED_SESSION);
} else {
answer = null;
return answer;
}
- /**
- * Returns the current session based on the list of previous sessions.
- *
- * @return the current session or null if there is no session yet defined or
- * if the last registered session is null or in error.
- */
- protected synchronized final DetachedSession getCurrentSession() {
- if (sessions.size() == 0) {
- return null;
- } else {
- DetachedSession session = (DetachedSession) sessions.get(sessions
- .size() - 1);
- List answers = session.getAnswers();
- if (answers.size() > 0) {
- DetachedAnswer lastAnswer = (DetachedAnswer) answers
- .get(answers.size() - 1);
- if (lastAnswer.getStatus() == DetachedAnswer.ERROR
- || lastAnswer.getStatus() == DetachedAnswer.CLOSED_SESSION)
- return null;
- }
- return session;
- }
- }
-
protected synchronized String dumpSessionsHistory(
DetachedRequest requestCurrent, DetachedAnswer answerCurrent) {
StringBuffer buf = new StringBuffer(
"##\n## SESSIONS HISTORY DUMP\n##\n");
buf.append("# CURRENT\n");
- buf.append("Current session: ").append(getCurrentSession())
+ buf.append("Current session: ").append(currentSession)
.append('\n');
buf.append("Current request: ").append(requestCurrent).append('\n');
buf.append("Current answer: ").append(answerCurrent).append('\n');
- buf.append("Skip count: ").append(skipCount).append('\n');
-
- buf.append("# SESSIONS\n");
- for (int i = 0; i < sessions.size(); i++) {
- DetachedSession session = (DetachedSession) sessions.get(i);
- buf.append(i).append(". ").append(session).append('\n');
- List requests = session.getRequests();
- List answers = session.getAnswers();
- for (int j = 0; j < requests.size(); j++) {
- DetachedRequest request = (DetachedRequest) requests.get(j);
- buf.append('\t').append(j).append(". ").append(request).append(
+
+ buf.append("# CURRENT SESSION\n");
+
+ List requests = currentSession.getRequests();
+ List answers = currentSession.getAnswers();
+ for (int j = 0; j < requests.size(); j++) {
+ DetachedRequest request = (DetachedRequest) requests.get(j);
+ buf.append('\t').append(j).append(". ").append(request)
+ .append('\n');
+ if (answers.size() > j) {
+ DetachedAnswer answer = (DetachedAnswer) answers.get(j);
+ buf.append('\t').append(j).append(". ").append(answer).append(
'\n');
- if (answers.size() > j) {
- DetachedAnswer answer = (DetachedAnswer) answers.get(j);
- buf.append('\t').append(j).append(". ").append(answer)
- .append('\n');
- }
}
}
return buf.toString();
}
- protected synchronized final DetachedSession getPreviousSession() {
- if (sessions.size() < 2)
- return null;
- else
- return (DetachedSession) sessions.get(sessions.size() - 2);
- }
-
public void setBundleContext(BundleContext bundleContext) {
this.bundleContext = bundleContext;
}
public void afterPropertiesSet() throws Exception {
- log.info("Detached execution server initialized.");
+ log.debug("Detached execution server initialized.");
}
public synchronized void destroy() throws Exception {
}
appContextServiceTrackers.clear();
- log.info("Detached execution server closed.");
+ log.debug("Detached execution server closed.");
}
public void setApplicationContext(ApplicationContext applicationContext) {
package org.argeo.slc.detached;
+import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
private String uuid = null;
private List requests = new Vector();
private List answers = new Vector();
- private String doItAgainPolicy = SKIP_UNTIL_ERROR;
+ private String doItAgainPolicy = REPLAY;
+ private List refreshedBundleNames = new ArrayList();
public boolean isClosed() {
if (answers.size() > 0) {
return false;
}
}
+
+ public boolean lastActionIsError() {
+ if (answers.size() > 0) {
+ DetachedAnswer answer = (DetachedAnswer) answers
+ .get(answers.size() - 1);
+ return answer.getStatus() == DetachedAnswer.ERROR;
+ } else {
+ return false;
+ }
+ }
+
+ public int getExecutedStepCount() {
+ if(requests.size() != answers.size()) {
+ throw new DetachedException("requests.size() != answers.size() in DetachedSession");
+ }
+ return answers.size();
+ }
public String getDoItAgainPolicy() {
return doItAgainPolicy;
return answers;
}
+ public List getRefreshedBundleNames() {
+ return refreshedBundleNames;
+ }
+
public String toString() {
StringBuffer buf = new StringBuffer(getClass().getName());
buf.append("#").append(uuid);
throw new DetachedException("Could not copy xml source", e);
}
- if (log.isDebugEnabled()) {
+ if (log.isTraceEnabled()) {
try {
DOMSource domSource = new DOMSource(result.getNode());
StringWriter stringWriter = new StringWriter();
StreamResult streamResult = new StreamResult(stringWriter);
copy.transform(domSource, streamResult);
- log.debug("Unmarshall communication:\n"
+ log.trace("Unmarshall communication:\n"
+ stringWriter.toString());
IOUtils.closeQuietly(stringWriter);
} catch (TransformerException e) {
package org.argeo.slc.detached.admin;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
* class in org.argeo.slc.support.osgi.
*/
class MinimalBundlesManager implements FrameworkListener {
+ private final static Log log = LogFactory
+ .getLog(MinimalBundlesManager.class);
+
private final BundleContext bundleContext;
private long defaultTimeout = 10000l;
private final Object refreshedPackageSem = new Object();
- private boolean debug = true;
-
public MinimalBundlesManager(BundleContext bundleContext) {
this.bundleContext = bundleContext;
bundleContext.addFrameworkListener(this);
}
/**
- * Stop the module, update it, refresh it and restart it. All synchronously.
+ * @see #upgradeSynchronous(Bundle[])
*/
public void upgradeSynchronous(Bundle bundle) {
+ upgradeSynchronous(new Bundle[] { bundle });
+ }
+
+ /**
+ * Stop the active bundles, update them, refresh them and restart the
+ * initially active bundles. All synchronously.
+ */
+ public void upgradeSynchronous(Bundle[] bundles) {
try {
- stopSynchronous(bundle);
- updateSynchronous(bundle);
- // Refresh in case there are fragments
- refreshSynchronous(bundle);
- startSynchronous(bundle);
-
- String filter = "(Bundle-SymbolicName=" + bundle.getSymbolicName()
- + ")";
- // Wait for application context to be ready
- // TODO: use service tracker
- getServiceRefSynchronous(
- "org.springframework.context.ApplicationContext", filter);
-
- if (debug)
- debug("Bundle " + bundle.getSymbolicName()
- + " ready to be used at latest version.");
+ // State (ACTIVE or other) before upgrading
+ int[] initialStates = new int[bundles.length];
+
+ // store initial state and stop active bundles
+ for (int i = 0; i < bundles.length; ++i) {
+ initialStates[i] = bundles[i].getState();
+ if (initialStates[i] == Bundle.ACTIVE) {
+ stopSynchronous(bundles[i]);
+ }
+ }
+
+ // update the bundles
+ for (int i = 0; i < bundles.length; ++i) {
+ updateSynchronous(bundles[i]);
+ }
+
+ // refresh the bundles
+ refreshSynchronous(bundles);
+
+ // restart the bundles that were ACTIVE before upgrading
+ for (int i = 0; i < bundles.length; ++i) {
+ if (initialStates[i] == Bundle.ACTIVE) {
+ startSynchronous(bundles[i]);
+
+ String filter = "(Bundle-SymbolicName="
+ + bundles[i].getSymbolicName() + ")";
+ // Wait for application context to be ready
+ // TODO: use service tracker
+ try {
+ getServiceRefSynchronous(
+ "org.springframework.context.ApplicationContext",
+ filter);
+ }
+ // in case of exception, catch and go on
+ catch (Exception e) {
+ log.error("getServiceRefSynchronous failed", e);
+ }
+ }
+ }
} catch (Exception e) {
- throw new RuntimeException("Cannot update bundle "
- + bundle.getSymbolicName(), e);
+ throw new RuntimeException("Cannot update bundles", e);
}
}
/** Updates bundle synchronously. */
protected void updateSynchronous(Bundle bundle) throws BundleException {
- // int originalState = bundle.getState();
bundle.update();
boolean waiting = true;
+ " timed out. Bundle state = " + bundle.getState());
} while (waiting);
- if (debug)
- debug("Bundle " + bundle.getSymbolicName() + " updated.");
+ if (log.isDebugEnabled())
+ log.debug("Bundle " + bundle.getSymbolicName() + " updated.");
}
/** Starts bundle synchronously. Does nothing if already started. */
+ " timed out. Bundle state = " + bundle.getState());
} while (waiting);
- if (debug)
- debug("Bundle " + bundle.getSymbolicName() + " started.");
+ if (log.isDebugEnabled())
+ log.debug("Bundle " + bundle.getSymbolicName() + " started.");
}
/** Stops bundle synchronously. Does nothing if already started. */
+ " timed out. Bundle state = " + bundle.getState());
} while (waiting);
- if (debug)
- debug("Bundle " + bundle.getSymbolicName() + " stopped.");
+ if (log.isDebugEnabled())
+ log.debug("Bundle " + bundle.getSymbolicName() + " stopped.");
}
/** Refresh bundle synchronously. Does nothing if already started. */
- protected void refreshSynchronous(Bundle bundle) throws BundleException {
+ protected void refreshSynchronous(Bundle[] bundles) throws BundleException {
ServiceReference packageAdminRef = bundleContext
.getServiceReference(PackageAdmin.class.getName());
PackageAdmin packageAdmin = (PackageAdmin) bundleContext
.getService(packageAdminRef);
- Bundle[] bundles = { bundle };
packageAdmin.refreshPackages(bundles);
synchronized (refreshedPackageSem) {
}
}
- if (debug)
- debug("Bundle " + bundle.getSymbolicName() + " refreshed.");
+ if (log.isDebugEnabled())
+ log.debug("Bundles refreshed.");
}
public void frameworkEvent(FrameworkEvent event) {
public ServiceReference[] getServiceRefSynchronous(String clss,
String filter) throws InvalidSyntaxException {
- if (debug)
- debug("Filter: '" + filter + "'");
+ if (log.isTraceEnabled())
+ log.trace("Filter: '" + filter + "'");
ServiceReference[] sfs = null;
boolean waiting = true;
long begin = System.currentTimeMillis();
return sfs;
}
- /*
- * protected void sleep(long ms) { try { Thread.sleep(ms); } catch
- * (InterruptedException e) { // silent } }
- *
- * public ServiceTracker newTracker(Class<?> clss) { ServiceTracker st = new
- * ServiceTracker(bundleContext, clss.getName(), null); st.open(); return
- * st; }
- *
- * @SuppressWarnings(value = { "unchecked" }) public <T> T
- * getSingleService(Class<T> clss, String filter) {
- * Assert.isTrue(OsgiFilterUtils.isValidFilter(filter), "valid filter");
- * ServiceReference[] sfs; try { sfs =
- * bundleContext.getServiceReferences(clss.getName(), filter); } catch
- * (InvalidSyntaxException e) { throw new
- * SlcException("Cannot retrieve service reference for " + filter, e); }
- *
- * if (sfs == null || sfs.length == 0) return null; else if (sfs.length > 1)
- * throw new SlcException("More than one execution flow found for " +
- * filter); return (T) bundleContext.getService(sfs[0]); }
- *
- * public <T> T getSingleServiceStrict(Class<T> clss, String filter) { T
- * service = getSingleService(clss, filter); if (service == null) throw new
- * SlcException("No execution flow found for " + filter); else return
- * service; }
- *
- * public Bundle findRelatedBundle(OsgiBundle osgiBundle) { Bundle bundle =
- * null; if (osgiBundle.getInternalBundleId() != null) { bundle =
- * bundleContext.getBundle(osgiBundle.getInternalBundleId()); Assert.isTrue(
- * osgiBundle.getName().equals(bundle.getSymbolicName()),
- * "symbolic name consistent");
- * Assert.isTrue(osgiBundle.getVersion().equals(
- * bundle.getHeaders().get(Constants.BUNDLE_VERSION)),
- * "version consistent"); } else { for (Bundle b :
- * bundleContext.getBundles()) { if
- * (b.getSymbolicName().equals(osgiBundle.getName())) { if
- * (b.getHeaders().get(Constants.BUNDLE_VERSION).equals(
- * osgiBundle.getVersion())) { bundle = b;
- * osgiBundle.setInternalBundleId(b.getBundleId()); } } } } return bundle; }
- *
- * public OsgiBundle findFromPattern(String pattern) { OsgiBundle osgiBundle
- * = null; for (Bundle b : bundleContext.getBundles()) { if
- * (b.getSymbolicName().contains(pattern)) { osgiBundle = new OsgiBundle(b);
- * break; } } return osgiBundle; }
- *
- * public OsgiBundle getBundle(Long bundleId) { Bundle bundle =
- * bundleContext.getBundle(bundleId); return new OsgiBundle(bundle); }
- *
- * public void setBundleContext(BundleContext bundleContext) {
- * this.bundleContext = bundleContext; }
- *
- * public void afterPropertiesSet() throws Exception {
- * bundleContext.addFrameworkListener(this); }
- *
- * public void setDefaultTimeout(Long defaultTimeout) { this.defaultTimeout
- * = defaultTimeout; }
- *
- * BundleContext getBundleContext() { return bundleContext; }
- */
-
- protected void debug(Object obj) {
- if (debug)
- System.out.println("#OSGiMANAGER DEBUG# " + obj);
- }
-
protected void sleep(long ms) {
try {
Thread.sleep(ms);
package org.argeo.slc.detached.admin;
-import java.util.ArrayList;
import java.util.List;
+import java.util.ArrayList;
import java.util.Properties;
import java.util.StringTokenizer;
public DetachedSession execute(DetachedRequest request,
BundleContext bundleContext) {
- MinimalBundlesManager bundlesManager = new MinimalBundlesManager(bundleContext);
DetachedSession session = new DetachedSession();
session.setUuid(Long.toString(System.currentTimeMillis()));
String refreshedBundles = props
.getProperty("slc.detached.refreshedBundles");
if (refreshedBundles != null) {
+
List refreshedBundleNames = new ArrayList();
StringTokenizer st = new StringTokenizer(refreshedBundles, ",");
while (st.hasMoreTokens()) {
refreshedBundleNames.add(st.nextElement());
- }
+ }
- Bundle[] bundles = bundleContext.getBundles();
+ Bundle[] allBundles = bundleContext.getBundles();
+ Bundle[] bundlesToRefresh = new Bundle[refreshedBundleNames.size()];
- List bundlesToRefresh = new ArrayList();
- for (int i = 0; i < bundles.length; i++) {
- if (refreshedBundleNames.contains(bundles[i].getSymbolicName())) {
- bundlesToRefresh.add(bundles[i]);
- }
+ log.debug("Bundles to refresh for DetachedSession:");
+
+ for(int i = 0; i < bundlesToRefresh.length; ++i) {
+ bundlesToRefresh[i] = getBundleForName((String)refreshedBundleNames.get(i), allBundles);
+ if(log.isDebugEnabled())
+ log.debug(" " + refreshedBundleNames.get(i));
}
- for (int i = 0; i < bundlesToRefresh.size(); i++) {
- Bundle bundle = (Bundle) bundlesToRefresh.get(i);
- try {
- bundlesManager.upgradeSynchronous(bundle);
-// bundle.stop();
-// bundle.update();
-// bundle.start();
- log.info("Refreshed bundle " + bundle.getSymbolicName());
-
-// try {
-// Thread.sleep(2000);
-// } catch (InterruptedException e) {
-// e.printStackTrace();
-// }
-
- } catch (Exception e) {
- throw new DetachedException("Could not refresh bundle "
- + bundle.getSymbolicName(), e);
- }
- }
+ (new MinimalBundlesManager(bundleContext)).upgradeSynchronous(bundlesToRefresh);
}
return session;
}
+
+ private Bundle getBundleForName(String symbolicName, Bundle[] bundles) {
+ for (int i = 0; i < bundles.length; i++) {
+ if (symbolicName.equals(bundles[i].getSymbolicName())) {
+ return bundles[i];
+ }
+ }
+ throw new DetachedException("No Bundle found for symbolic name " + symbolicName);
+ }
}
osgiLocations.append(location);
if (log.isTraceEnabled())
log.trace("Added bundle " + name
- + " to slc.osgi.locations: " + location);
+ + " to argeo.osgi.locations: " + location);
} else {
if (osgiBundles.length() != 0)
osgiBundles.append(',');
getSystemProperties().setProperty("osgi.bundles",
osgiBundles.toString());
- getSystemProperties().setProperty("slc.osgi.locations",
+ getSystemProperties().setProperty("argeo.osgi.locations",
osgiLocations.toString());
super.afterPropertiesSet();
import org.argeo.slc.core.test.context.DefaultContextTestData;
+/**
+ * @deprecated
+ *
+ */
public class DetachedTestData extends DefaultContextTestData {
}
import org.argeo.slc.core.structure.tree.TreeSRelatedHelper;
import org.argeo.slc.core.test.SimpleResultPart;
import org.argeo.slc.core.test.context.ContextUtils;
+import org.argeo.slc.core.test.context.DefaultContextTestData;
import org.argeo.slc.detached.DetachedAnswer;
import org.argeo.slc.detached.DetachedClient;
import org.argeo.slc.detached.DetachedRequest;
request.setUuid(UUID.randomUUID().toString());
request.setRef(stepBeanNameT);
- DetachedTestData testData = testRun.getTestData();
+ DefaultContextTestData testData = testRun.getTestData();
if (testData != null) {
Map<String, Object> values = testData.getValues();
Properties inputParameters = new Properties();
+ stepBeanNameT, e);
}
+ DetachedAnswer answer;
try {
- DetachedAnswer answer = client.receiveAnswer();
- if (answer.getStatus() == DetachedAnswer.ERROR)
- throw new SlcException("Error when executing step "
- + answer.getUuid() + ": " + answer.getLog());
- else
- log.info("Received answer for '" + request.getRef() + "' ("
- + answer.getStatusAsString() + "):" + answer.getLog());
-
- if (testData != null) {
- Properties outputParameters = answer.getProperties();
- for (Object key : outputParameters.keySet())
- testData.getValues().put(key.toString(),
- outputParameters.get(key));
- }
+ answer = client.receiveAnswer();
} catch (Exception e) {
throw new SlcException("Could not receive answer #"
+ request.getUuid() + " for step " + stepBeanNameT, e);
+ }
+
+ if (answer.getStatus() == DetachedAnswer.ERROR)
+ throw new SlcException("Error when executing step "
+ + answer.getUuid() + ": " + answer.getLog());
+ else
+ log.info("Received answer for '" + request.getRef() + "' ("
+ + answer.getStatusAsString() + "):" + answer.getLog());
+
+ if (testData != null) {
+ Properties outputParameters = answer.getProperties();
+ for (Object key : outputParameters.keySet())
+ testData.getValues().put(key.toString(),
+ outputParameters.get(key));
}
+
if (testData != null) {
ContextUtils.compareReachedExpected(testData, testRun
.getTestResult(), this);