1 package org
.argeo
.slc
.detached
.admin
;
3 import java
.util
.Properties
;
5 import org
.apache
.commons
.logging
.Log
;
6 import org
.apache
.commons
.logging
.LogFactory
;
7 import org
.argeo
.slc
.detached
.DetachedAdminCommand
;
8 import org
.argeo
.slc
.detached
.DetachedException
;
9 import org
.argeo
.slc
.detached
.DetachedRequest
;
10 import org
.argeo
.slc
.detached
.DetachedSession
;
11 import org
.osgi
.framework
.Bundle
;
12 import org
.osgi
.framework
.BundleContext
;
13 import org
.osgi
.framework
.BundleException
;
15 public class OpenSession
implements DetachedAdminCommand
{
16 private final static Log log
= LogFactory
.getLog(OpenSession
.class);
18 public DetachedSession
execute(DetachedRequest request
,
19 BundleContext bundleContext
) {
20 DetachedSession session
= new DetachedSession();
21 session
.setUuid(Long
.toString(System
.currentTimeMillis()));
23 Properties props
= request
.getProperties();
24 if (props
.containsKey(DetachedSession
.PROP_DO_IT_AGAIN_POLICY
))
25 session
.setDoItAgainPolicy(props
26 .getProperty(DetachedSession
.PROP_DO_IT_AGAIN_POLICY
));
28 String refreshedBundles
= props
29 .getProperty("slc.detached.refreshedBundles");
30 if (refreshedBundles
!= null) {
31 Bundle
[] bundles
= bundleContext
.getBundles();
33 for (int i
= 0; i
< bundles
.length
; i
++) {
34 if (bundles
[i
].getSymbolicName().equals(refreshedBundles
)) {
44 log
.info("Refreshed bundle " + bundle
.getSymbolicName());
45 } catch (BundleException e
) {
46 throw new DetachedException("Could not refresh bundle "
47 + bundle
.getSymbolicName(), e
);
50 log
.warn("Did not find bundle to refresh " + refreshedBundles
);