org.osgi.framework.dto.ServiceReferenceDTO Java Examples
The following examples show how to use
org.osgi.framework.dto.ServiceReferenceDTO.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServiceRegistrationImpl.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
ServiceReferenceDTO getDTO() { ServiceReferenceDTO res = new ServiceReferenceDTO(); PropertiesDictionary p = properties; res.id = ((Long)p.get(Constants.SERVICE_ID)).longValue(); res.properties = p.getDTO(); Bundle [] using = getUsingBundles(); if (using != null) { res.usingBundles = new long [using.length]; for (int i = 0; i < using.length; i++) { res.usingBundles[i] = using[i].getBundleId(); } } else { res.usingBundles = new long [0]; } BundleImpl b = bundle; if (b == null) { return null; } res.bundle = b.id; return res; }
Example #2
Source File: SystemBundle.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
private FrameworkDTO getFrameworkDTO() { FrameworkDTO res = new FrameworkDTO(); res.bundles = new ArrayList<BundleDTO>(); for (BundleImpl bi : fwCtx.bundles.getBundles()) { res.bundles.add(bi.getDTO()); } res.properties = fwCtx.props.getFWProperties(); res.services = new ArrayList<ServiceReferenceDTO>(); for (ServiceRegistrationImpl sri : fwCtx.services.getAllRegistered()) { ServiceReferenceDTO srdto = sri.getDTO(); if (srdto != null) { res.services.add(srdto); } } return res; }
Example #3
Source File: ServiceComponentRuntimeImpl.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
private ServiceReferenceDTO getServiceReferenceDTO(ServiceReference<?> sr) { ServiceReferenceDTO res = new ServiceReferenceDTO(); res.properties = new HashMap<String, Object>(); for (String key : sr.getPropertyKeys()) { Object val = safeDTOObject(sr.getProperty(key)); res.properties.put(key, val); } res.id = ((Long)sr.getProperty(Constants.SERVICE_ID)).longValue(); Bundle [] using = sr.getUsingBundles(); if (using != null) { res.usingBundles = new long [using.length]; for (int i = 0; i < using.length; i++) { res.usingBundles[i] = using[i].getBundleId(); } } else { res.usingBundles = new long [0]; } Bundle b = sr.getBundle(); if (b == null) { return null; } res.bundle = b.getBundleId(); return res; }
Example #4
Source File: AbstractBundle.java From concierge with Eclipse Public License 1.0 | 6 votes |
protected final ServiceReferenceDTO getServiceReferenceDTO(ServiceReference ref){ ServiceReferenceDTO dto = new ServiceReferenceDTO(); dto.bundle = bundleId; dto.id = (Long) ref.getProperty(Constants.SERVICE_ID); dto.properties = new HashMap<String, Object>(); for(String key : ref.getPropertyKeys()){ Object val = ref.getProperty(key); dto.properties.put(key, getDTOValue(val)); } Bundle[] usingBundles = ref.getUsingBundles(); if(usingBundles == null){ dto.usingBundles = new long[0]; } else { dto.usingBundles = new long[usingBundles.length]; for(int j=0;j<usingBundles.length;j++){ dto.usingBundles[j] = usingBundles[j].getBundleId(); } } return dto; }
Example #5
Source File: FrameworkNodeImpl.java From concierge with Eclipse Public License 1.0 | 5 votes |
public ServiceReferenceDTO getServiceReference(long id) { for(ServiceReferenceDTO r : getServiceReferences()){ if(r.id == id) return r; } return null; // TODO should we throw exception here? }
Example #6
Source File: ServiceComponentRuntimeImpl.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
private ServiceReferenceDTO [] getServiceReferenceDTOs(Set<ServiceReference<?>> services) { ServiceReferenceDTO[] res = new ServiceReferenceDTO[services.size()]; int i = 0; for (ServiceReference sr : services) { res[i++] = getServiceReferenceDTO(sr); } return res; }
Example #7
Source File: Concierge.java From concierge with Eclipse Public License 1.0 | 5 votes |
/** * @see org.osgi.framework.Bundle#adapt(java.lang.Class) * @category Framework * @category SystemBundle */ @SuppressWarnings("unchecked") public <A> A adapt(final Class<A> type) { if (type == BundleStartLevel.class) { return (A) systemBundleStartLevel; } if (type == BundleWiring.class) { return (A) wirings.get(this); } if(type == FrameworkStartLevelDTO.class){ FrameworkStartLevelDTO fsl = new FrameworkStartLevelDTO(); fsl.initialBundleStartLevel = initStartlevel; fsl.startLevel = startlevel; return (A) fsl; } if(type == FrameworkDTO.class){ FrameworkDTO dto = new FrameworkDTO(); dto.bundles = new ArrayList<BundleDTO>(); for(Bundle b : bundles){ dto.bundles.add(b.adapt(BundleDTO.class)); } dto.services = new ArrayList<ServiceReferenceDTO>(); for(ServiceReference ref : serviceRegistry.getAllValues()){ dto.services.add(getServiceReferenceDTO(ref)); } dto.properties = new HashMap<String, Object>(); for(Object k : properties.keySet()){ String key = (String) k; dto.properties.put(key, getDTOValue(properties.getProperty(key))); } return (A) dto; } return super.adapt(type); }
Example #8
Source File: RestClientImpl.java From concierge with Eclipse Public License 1.0 | 5 votes |
/** * @see org.osgi.rest.client.RestClient#getServiceReference(java.lang.String) */ public ServiceReferenceDTO getServiceReference(final String servicePath) throws Exception { final Representation repr = new ClientResource(Method.GET, baseUri.resolve(servicePath)).get(SERVICE); return DTOReflector.getDTO(ServiceReferenceDTO.class, repr); }
Example #9
Source File: RestClientImpl.java From concierge with Eclipse Public License 1.0 | 5 votes |
/** * @see org.osgi.rest.client.RestClient#getServiceRepresentations(java.lang.String * ) */ public Collection<ServiceReferenceDTO> getServiceReferences( final String filter) throws Exception { final ClientResource res = new ClientResource(Method.GET, baseUri.resolve("framework/services/representations")); if (filter != null) { res.getQuery().add("filter", filter); } final Representation repr = res.get(SERVICES_REPRESENTATIONS); return DTOReflector.getDTOs(ServiceReferenceDTO.class, repr); }
Example #10
Source File: FrameworkNodeImpl.java From concierge with Eclipse Public License 1.0 | 5 votes |
public Collection<ServiceReferenceDTO> getServiceReferences(String filter) throws InvalidSyntaxException { Filter f = context.createFilter(filter); List<ServiceReferenceDTO> filtered = new ArrayList<ServiceReferenceDTO>(); for(ServiceReferenceDTO r : getServiceReferences()){ if(f.matches(r.properties)){ filtered.add(r); } } return filtered; }
Example #11
Source File: RestClientImpl.java From concierge with Eclipse Public License 1.0 | 4 votes |
/** * @see org.osgi.rest.client.RestClient#getServiceRepresentations() */ public Collection<ServiceReferenceDTO> getServiceReferences() throws Exception { return getServiceReferences(null); }
Example #12
Source File: RestClientImpl.java From concierge with Eclipse Public License 1.0 | 4 votes |
/** * @see org.osgi.rest.client.RestClient#getServiceReference(long) */ public ServiceReferenceDTO getServiceReference(final long id) throws Exception { return getServiceReference("framework/service/" + id); }
Example #13
Source File: FrameworkNodeImpl.java From concierge with Eclipse Public License 1.0 | 4 votes |
public Collection<ServiceReferenceDTO> getServiceReferences() { FrameworkDTO framework = context.getBundle(0).adapt(FrameworkDTO.class); return framework.services; }
Example #14
Source File: AriesJaxrsServiceRuntime.java From aries-jax-rs-whiteboard with Apache License 2.0 | 4 votes |
@Override public RuntimeDTO getRuntimeDTO() { RuntimeDTO runtimeDTO = new RuntimeDTO(); if (_defaultApplicationProperties != null) { runtimeDTO.defaultApplication = buildApplicationDTO( _defaultApplicationProperties); } runtimeDTO.applicationDTOs = applicationDTOStream(). toArray( ApplicationDTO[]::new ); runtimeDTO.failedApplicationDTOs = Stream.concat( contextDependentApplicationsDTOStream(), Stream.concat( invalidApplicationsDTOStream(), Stream.concat( shadowedApplicationsDTOStream(), Stream.concat( unreferenciableApplicationsDTOStream(), Stream.concat( clashingApplicationsDTOStream(), Stream.concat( dependentApplicationsDTOStream(), erroredApplicationsDTOStream()))))) ).toArray( FailedApplicationDTO[]::new ); runtimeDTO.failedResourceDTOs = Stream.concat( invalidResourcesDTOStream(), Stream.concat( clashingResourcesDTOStream(), Stream.concat( unreferenciableEndpointsDTOStream(), Stream.concat( dependentServiceStreamDTO(), Stream.concat( applicationDependentResourcesDTOStream(), erroredEndpointsStreamDTO())))) ).toArray( FailedResourceDTO[]::new ); runtimeDTO.failedExtensionDTOs = Stream.concat( clashingExtensionsDTOStream(), Stream.concat( unreferenciableExtensionsDTOStream(), Stream.concat( applicationDependentExtensionsDTOStream(), Stream.concat( erroredExtensionsDTOStream(), Stream.concat(dependentExtensionsStreamDTO(), invalidExtensionsDTOStream())))) ).toArray( FailedExtensionDTO[]::new ); ServiceReference<JaxrsServiceRuntime> serviceReference = _whiteboard.getServiceReference(); ServiceReferenceDTO serviceDTO = new ServiceReferenceDTO(); serviceDTO.bundle = serviceReference.getBundle().getBundleId(); serviceDTO.id = (long)serviceReference.getProperty("service.id"); serviceDTO.usingBundles = Arrays.stream( serviceReference.getUsingBundles() ).mapToLong( Bundle::getBundleId ).toArray(); serviceDTO.properties = Utils.getProperties(serviceReference); runtimeDTO.serviceDTO = serviceDTO; return runtimeDTO; }
Example #15
Source File: RestClient.java From concierge with Eclipse Public License 1.0 | 2 votes |
/** * Get the service representation for a service given by its service Id. * * @param id Addresses the service by its identifier. * @return The service representation as {@link ServiceReferenceDTO}. * @throws Exception An exception representing a failure in the underlying * REST call. */ ServiceReferenceDTO getServiceReference(long id) throws Exception;
Example #16
Source File: RestClient.java From concierge with Eclipse Public License 1.0 | 2 votes |
/** * Get the service representation for a service given by its URI path. * * @param servicePath Addresses the service by its URI path. * @return The service representation as {@link ServiceReferenceDTO}. * @throws Exception An exception representing a failure in the underlying * REST call. */ ServiceReferenceDTO getServiceReference(String servicePath) throws Exception;
Example #17
Source File: RestClient.java From concierge with Eclipse Public License 1.0 | 2 votes |
/** * Get the service representations for all services. * * @param filter Passes a filter to restrict the result set. * @return Returns the service representations in the form of * {@link ServiceReferenceDTO} objects. * @throws Exception An exception representing a failure in the underlying * REST call. */ Collection<ServiceReferenceDTO> getServiceReferences(String filter) throws Exception;
Example #18
Source File: RestClient.java From concierge with Eclipse Public License 1.0 | 2 votes |
/** * Get the service representations for all services. * * @return Returns the service representations in the form of * {@link ServiceReferenceDTO} objects. * @throws Exception An exception representing a failure in the underlying * REST call. */ Collection<ServiceReferenceDTO> getServiceReferences() throws Exception;
Example #19
Source File: FrameworkManager.java From concierge with Eclipse Public License 1.0 | 2 votes |
/** * Get the service representations for all services. * * @param filter Passes a filter to restrict the result set. * @return Returns the service representations in the form of * {@link ServiceReferenceDTO} objects. * @throws Exception An exception representing a failure in the underlying * remote call. */ Collection<ServiceReferenceDTO> getServiceReferences(String filter) throws Exception;
Example #20
Source File: FrameworkManager.java From concierge with Eclipse Public License 1.0 | 2 votes |
/** * Get the service representations for all services. * * @return Returns the service representations in the form of * {@link ServiceReferenceDTO} objects. * @throws Exception An exception representing a failure in the underlying * remote call. */ Collection<ServiceReferenceDTO> getServiceReferences() throws Exception;
Example #21
Source File: FrameworkManager.java From concierge with Eclipse Public License 1.0 | 2 votes |
/** * Get the service representation for a service given by its service Id. * * @param id Addresses the service by its identifier. * @return The service representation as {@link ServiceReferenceDTO}. * @throws Exception An exception representing a failure in the underlying * remote call. */ ServiceReferenceDTO getServiceReference(long id) throws Exception;