Creates the list of service models from the list of the currently available services.

@param context the bundle context
@return the list of models
497905
public static List<ServiceModel> services(BundleContext context) {
        List<ServiceModel> services = new ArrayList<>();
        try {
            ServiceReference[] references = context.getAllServiceReferences(null, null);
            if (references != null) {
                for (ServiceReference ref : references) {
                    services.add(new ServiceModel(ref));
                }
            }
        } catch (InvalidSyntaxException e) {  //NOSONAR
            // Ignore it.
        }
        return services;
    }
94290
public static List<CommerceCountry> toModels(
		CommerceCountrySoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<CommerceCountry> models = new ArrayList<CommerceCountry>(soapModels.length);

		for (CommerceCountrySoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}
410792
public static List<CommerceAccountUserRel> toModels(
		CommerceAccountUserRelSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<CommerceAccountUserRel> models = new ArrayList<CommerceAccountUserRel>(soapModels.length);

		for (CommerceAccountUserRelSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}
107479
private void createManagedServiceFactory(BundleContext context) {
		// sanity check
		if (managedServiceFactoryReg != null) {
			managedServiceFactoryReg.unregister();
			managedServiceFactoryReg = null;
		}
		final Dictionary<String, String> props = new Hashtable<>();
		props.put(Constants.SERVICE_PID, HttpContextProcessing.PID);
		httpContextProcessing = new HttpContextProcessing(bundleContext, serverController);
		managedServiceFactoryReg = context.registerService(ManagedServiceFactory.class, httpContextProcessing, props);
	}
1237532
public static List<CommercePriceList> toModels(
		CommercePriceListSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<CommercePriceList> models = new ArrayList<CommercePriceList>(soapModels.length);

		for (CommercePriceListSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}
72036
public static List<CommerceNotificationTemplate> toModels(
		CommerceNotificationTemplateSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<CommerceNotificationTemplate> models = new ArrayList<CommerceNotificationTemplate>(soapModels.length);

		for (CommerceNotificationTemplateSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}
479632
@Override
    public ModelService getModelService(String serviceName){
        ModelServiceClientCache cache = getCache().get(serviceName);
        ModelService lookup;
        if (cache == null) {
            // cache has not never been created, initialize an new one.
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("service has not been cached, try to cache the service {} ", serviceName);
            }
            lookup = super.getModelService(serviceName);
            if (lookup!=null) {
                getCache().putIfAbsent(serviceName, new ModelServiceClientCache(lookup));
                cache = getCache().get(serviceName);
                addInstanceChangeListener(serviceName, cache);
            }
        } else {
            // service cached has been removed
            if (cache.getData() == null) {
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("cached service={} is obsoleted, try to get service from server", serviceName);
                }
                lookup = super.getModelService(serviceName);
                if (lookup != null) {
                    // replace old cached service by new one
                    if (LOGGER.isDebugEnabled()) {
                        LOGGER.debug("try to replace the obsoleted cached service={} by service from server {}", serviceName,lookup.getServiceInstances());
                    }
                    removeInstanceChangeListener(serviceName, cache);
                    boolean replaced = getCache().replace(serviceName, cache, new ModelServiceClientCache(lookup));
                    if (replaced) {
                        addInstanceChangeListener(serviceName, getCache().get(serviceName));

                    } else {
                        LOGGER.error("fail to replace the obsoleted cached service={}", serviceName);
                    }
                }else{
                    LOGGER.error("fail to lookup service={} from server",serviceName);
                }
            }
            // use the use cached service
            else {
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("service={} has been cached, get service from cache. {}", serviceName,cache.getData().getServiceInstances());
                }
                lookup = cache.getData();
            }
        }
        return lookup;
    }
386024
public <S> S getService(final ServiceReference<S> reference, final BundleContext context) {
        if (System.getSecurityManager() == null)
            return context.getService(reference);
        return AccessController.doPrivileged(new PrivilegedAction<S>() {
            @Override
            public S run() {
                return context.getService(reference);
            }
        }, controlContext);
    }
692678
public static <T> T getService(BundleContext bundleContext, Class<T> serviceClass) {
        T service = null;
        if (FrameworkState.isValid()) {
            ServiceReference<T> ref = bundleContext.getServiceReference(serviceClass);

            if (ref != null) {
                service = bundleContext.getService(ref);
            }
        }
        return service;
    }
565471
public static List<CommerceOrderNote> toModels(
		CommerceOrderNoteSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<CommerceOrderNote> models = new ArrayList<CommerceOrderNote>(soapModels.length);

		for (CommerceOrderNoteSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}
290698
public List<ServiceRefType<WebAppDescriptor>> getAllServiceRef()
   {
      List<ServiceRefType<WebAppDescriptor>> list = new ArrayList<ServiceRefType<WebAppDescriptor>>();
      List<Node> nodeList = model.get("service-ref");
      for(Node node: nodeList)
      {
         ServiceRefType<WebAppDescriptor>  type = new ServiceRefTypeImpl<WebAppDescriptor>(this, "service-ref", model, node);
         list.add(type);
      }
      return list;
   }
825752
private Set<ModelDescription> loadModelsOfBundle(Bundle bundle) {
        Enumeration<URL> classEntries = bundle.findEntries("/", "*.class", true);
        Set<ModelDescription> models = new HashSet<ModelDescription>();
        if (classEntries == null) {
            LOGGER.debug("Found no classes in the bundle {}", bundle);
            return models;
        }
        while (classEntries.hasMoreElements()) {
            URL classURL = classEntries.nextElement();
            String classname = extractClassName(classURL);
            if (isModelClass(classname, bundle)) {
                models.add(new ModelDescription(classname, bundle.getVersion().toString()));
            }
        }
        return models;
    }
1309103
public static List<BundleModel> bundles(BundleContext context) {
        List<BundleModel> bundles = new ArrayList<>();
        for (Bundle bundle : context.getBundles()) {
            bundles.add(new BundleModel(bundle));
        }
        return bundles;
    }
167932
public static List<CPDefinitionOptionRel> toModels(
		CPDefinitionOptionRelSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<CPDefinitionOptionRel> models = new ArrayList<CPDefinitionOptionRel>(soapModels.length);

		for (CPDefinitionOptionRelSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}
267584
public ServiceCall<TranslationModels> listModels(ListModelsOptions listModelsOptions) {
    String[] pathSegments = { "v3/models" };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
    builder.query("version", versionDate);
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "listModels");
    for (Entry<String, String> header : sdkHeaders.entrySet()) {
      builder.header(header.getKey(), header.getValue());
    }
    builder.header("Accept", "application/json");
    if (listModelsOptions != null) {
      if (listModelsOptions.source() != null) {
        builder.query("source", listModelsOptions.source());
      }
      if (listModelsOptions.target() != null) {
        builder.query("target", listModelsOptions.target());
      }
      if (listModelsOptions.defaultModels() != null) {
        builder.query("default", String.valueOf(listModelsOptions.defaultModels()));
      }
    }
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TranslationModels.class));
  }
446908
public static List<CommerceWarehouse> toModels(
		CommerceWarehouseSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<CommerceWarehouse> models = new ArrayList<CommerceWarehouse>(soapModels.length);

		for (CommerceWarehouseSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}
56518
public static WebApplicationService getService(final RequestContext context) {
        return context != null ? (WebApplicationService) context.getFlowScope().get(PARAMETER_SERVICE) : null;
    }