1 package org
.argeo
.slc
.autoui
.internal
;
3 import org
.argeo
.slc
.autoui
.DetachedContextImpl
;
4 import org
.argeo
.slc
.autoui
.DetachedException
;
5 import org
.argeo
.slc
.autoui
.DetachedExecutionServer
;
6 import org
.argeo
.slc
.autoui
.DetachedStep
;
7 import org
.argeo
.slc
.autoui
.DetachedStepAnswer
;
8 import org
.argeo
.slc
.autoui
.DetachedStepRequest
;
9 import org
.argeo
.slc
.autoui
.StaticRefProvider
;
10 import org
.osgi
.framework
.BundleContext
;
11 import org
.osgi
.framework
.ServiceReference
;
13 public class DetachedExecutionServerImpl
implements DetachedExecutionServer
{
14 private final DetachedContextImpl detachedContext
;
16 private BundleContext bundleContext
;
18 public DetachedExecutionServerImpl() {
19 detachedContext
= new DetachedContextImpl();
22 public DetachedStepAnswer
executeStep(DetachedStepRequest request
) {
24 DetachedStep step
= null;
27 ServiceReference
[] refs
= bundleContext
.getAllServiceReferences(
28 StaticRefProvider
.class.getName(), null);
29 for (int i
= 0; i
< refs
.length
; i
++) {
30 StaticRefProvider provider
= (StaticRefProvider
) bundleContext
32 Object obj
= provider
.getStaticRef(request
.getStepRef());
34 step
= (DetachedStep
) obj
;
40 throw new DetachedException("Could not find step with ref "
41 + request
.getStepRef());
43 return step
.execute(detachedContext
, request
);
44 } catch (DetachedException e
) {
46 } catch (Exception e
) {
48 throw new DetachedException(
49 "Unexpected exception while executing request " + request
,
54 public void setBundleContext(BundleContext bundleContext
) {
55 this.bundleContext
= bundleContext
;