コード例 #1
0
 private static ServiceReferenceDTO getServiceReferenceDTO(ServiceReference<?> ref) {
   if (ref == null) {
     return null;
   }
   Bundle b = ref.getBundle();
   if (b == null) {
     // service has been unregistered
     return null;
   }
   ServiceReferenceDTO dto = new ServiceReferenceDTO();
   dto.bundle = b.getBundleId();
   String[] keys = ref.getPropertyKeys();
   Map<String, Object> properties = newMap(keys.length);
   for (String k : keys) {
     Object v = ref.getProperty(k);
     if (Constants.SERVICE_ID.equals(k)) {
       dto.id = ((Long) v).longValue();
     }
     properties.put(k, mapValue(v));
   }
   dto.properties = properties;
   Bundle[] using = ref.getUsingBundles();
   final int length = (using == null) ? 0 : using.length;
   long[] usingBundles = new long[length];
   for (int i = 0; i < length; i++) {
     usingBundles[i] = using[i].getBundleId();
   }
   dto.usingBundles = usingBundles;
   return dto;
 }
コード例 #2
0
 public static BundleDTO newBundleDTO(Bundle bundle) {
   if (bundle == null) {
     return null;
   }
   BundleDTO dto = new BundleDTO();
   dto.id = bundle.getBundleId();
   dto.lastModified = bundle.getLastModified();
   dto.state = bundle.getState();
   dto.symbolicName = bundle.getSymbolicName();
   dto.version = bundle.getVersion().toString();
   return dto;
 }
コード例 #3
0
 public static BundleStartLevelDTO newBundleStartLevelDTO(Bundle b, BundleStartLevel bsl) {
   if (bsl == null) {
     return null;
   }
   BundleStartLevelDTO dto = new BundleStartLevelDTO();
   dto.bundle = b.getBundleId();
   dto.activationPolicyUsed = bsl.isActivationPolicyUsed();
   dto.persistentlyStarted = bsl.isPersistentlyStarted();
   dto.startLevel = bsl.getStartLevel();
   return dto;
 }