if ((localFrameworkUUID != null) && localFrameworkUUID.equals(endpoint.getFrameworkUUID())) { props = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER); props.putAll(endpoint.getProperties()); props.put(ENDPOINT_FRAMEWORK_UUID, new String[] {endpoint.getFrameworkUUID(), "<<LOCAL>>"}); } else { props = endpoint.getProperties();
/** * Determines whether an {@link EndpointDescription} contains a well-formed {@code ENDPOINT_URL} property. * * @param endpoint the endpoint * @return {@code true} if valid, {@code false} otherwise. */ private static boolean hasValidServiceLocation(EndpointDescription endpoint) { Object serviceLocation = endpoint.getProperties().get(ENDPOINT_URL); if (serviceLocation == null || !(serviceLocation instanceof String)) { return false; } try { new URL((String) serviceLocation); } catch (MalformedURLException e) { return false; } return true; }
/** * Create an service properties value from an Endpoint Description. * * @param endpointDescription * @return the properties */ private static Dictionary<String, Object> createImportedServiceProperties(EndpointDescription endpointDescription) { Dictionary<String, Object> serviceProperties = new Hashtable<String, Object>(); serviceProperties.put(SERVICE_IMPORTED, endpointDescription.getId()); for (String key : endpointDescription.getProperties().keySet()) { serviceProperties.put(key, endpointDescription.getProperties().get(key)); } return serviceProperties; } }
private static void appendEndpoint(Writer writer, EndpointDescription endpoint) throws IOException { writer.append(" <endpoint-description>\n"); for (Entry<String, Object> entry : endpoint.getProperties().entrySet()) { appendProperty(writer, entry.getKey(), entry.getValue()); } writer.append(" </endpoint-description>\n"); }
public static String computeHash(EndpointDescription endpoint) { return m_hasher.hash(endpoint.getProperties()); } }
public static String computeHash(EndpointDescription endpoint) { return m_hasher.hash(endpoint.getProperties()); } }
private static void appendEndpoint(Writer writer, EndpointDescription endpoint) throws IOException { writer.append(" <endpoint-description>\n"); for (Entry<String, Object> entry : endpoint.getProperties().entrySet()) { appendProperty(writer, entry.getKey(), entry.getValue()); } writer.append(" </endpoint-description>\n"); }
private static Set<Filter> getMatchingFilters(Set<Filter> filters, EndpointDescription endpoint) { Set<Filter> matchingFilters = new HashSet<Filter>(); if (endpoint == null) { return matchingFilters; } Dictionary<String, Object> dict = new Hashtable<String, Object>(endpoint.getProperties()); for (Filter filter : filters) { if (filter.match(dict)) { LOG.debug("Filter {} matches endpoint {}", filter, dict); matchingFilters.add(filter); } else { LOG.trace("Filter {} does not match endpoint {}", filter, dict); } } return matchingFilters; } }
/** * Return the first matching filter for the specified Endpoint Description. * * @param endpoint The Endpoint Description * @return The first matching Filter, or {@code null} */ private final Filter getFirstMatchingFilter(EndpointDescription endpoint) { for (Filter filter : m_filters) { if (filter.matches(endpoint.getProperties())) { return filter; } } return null; }
/** * Return the first matching filter for the specified Endpoint Description. * * @param endpoint The Endpoint Description * @return The first matching Filter, or {@code null} */ private final Filter getFirstMatchingFilter(EndpointDescription endpoint) { for (Filter filter : m_filters) { if (filter.matches(endpoint.getProperties())) { return filter; } } return null; }
@Override public Object importEndpoint(ClassLoader cl, BundleContext consumerContext, Class[] interfaces, EndpointDescription endpoint) throws IntentUnsatisfiedException { String address = (String) endpoint.getProperties().get(FASTBIN_ADDRESS); InvocationHandler handler = client.getProxy(address, endpoint.getId(), cl); return Proxy.newProxyInstance(cl, interfaces, handler); }
@SuppressWarnings("rawtypes") public Object importEndpoint(ClassLoader consumerLoader, BundleContext consumerContext, Class[] interfaces, EndpointDescription endpoint) { if (interfaces.length > 1) { throw new IllegalArgumentException("Multiple interfaces are not supported by this provider"); } Set<String> intentNames = intentManager.getImported(endpoint.getProperties()); List<Object> intents = intentManager.getRequiredIntents(intentNames); Class<?> iClass = interfaces[0]; String address = PropertyHelper.getProperty(endpoint.getProperties(), RsConstants.RS_ADDRESS_PROPERTY); if (address == null) { LOG.warn("Remote address is unavailable"); return null; } return createJaxrsProxy(address, iClass, null, endpoint, intents); }
private Class<?>[] loadEndpointInterfaces(ServiceReference<?> reference, EndpointDescription endpoint) { BundleContext context = getBundleContext(); Object service = context.getService(reference); if (service == null) { logWarning( "Export failed. Unable to aquire service for reference (%s) and endpoint (%s). Service Registration closed?", reference, endpoint); return null; } Map<String, Class<?>> interfaces = collectInterfaces(service.getClass()); context.ungetService(reference); String[] endpointInterfaces = getStringPlusValue(endpoint.getProperties().get(OBJECTCLASS)); Class<?>[] exportedInterfaces = new Class<?>[endpointInterfaces.length]; for (int i = 0; i < endpointInterfaces.length; i++) { exportedInterfaces[i] = interfaces.get(endpointInterfaces[i]); if (exportedInterfaces[i] == null) { logWarning( "Export failed. Unable load exported interface (%s) from bundle for reference (%s) and endpoint (%s)", exportedInterfaces[i], reference, endpoint); return null; } } return exportedInterfaces; }
if ((localFrameworkUUID != null) && localFrameworkUUID.equals(endpoint.getFrameworkUUID())) { props = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER); props.putAll(endpoint.getProperties()); props.put(ENDPOINT_FRAMEWORK_UUID, new String[] {endpoint.getFrameworkUUID(), "<<LOCAL>>"}); } else { props = endpoint.getProperties();
if ((localFrameworkUUID != null) && localFrameworkUUID.equals(endpoint.getFrameworkUUID())) { props = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER); props.putAll(endpoint.getProperties()); props.put(ENDPOINT_FRAMEWORK_UUID, new String[] {endpoint.getFrameworkUUID(), "<<LOCAL>>"}); } else { props = endpoint.getProperties();
if ((localFrameworkUUID != null) && localFrameworkUUID.equals(endpoint.getFrameworkUUID())) { props = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER); props.putAll(endpoint.getProperties()); props.put(ENDPOINT_FRAMEWORK_UUID, new String[] {endpoint.getFrameworkUUID(), "<<LOCAL>>"}); } else { props = endpoint.getProperties();
if ((localFrameworkUUID != null) && localFrameworkUUID.equals(endpoint.getFrameworkUUID())) { props = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER); props.putAll(endpoint.getProperties()); props.put(ENDPOINT_FRAMEWORK_UUID, new String[] {endpoint.getFrameworkUUID(), "<<LOCAL>>"}); } else { props = endpoint.getProperties();
&& localFrameworkUUID.equals(endpoint.getFrameworkUUID())) { props = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER); props.putAll(endpoint.getProperties()); props.put(ENDPOINT_FRAMEWORK_UUID, new String[] { endpoint.getFrameworkUUID(), "<<LOCAL>>"}); props = endpoint.getProperties();
&& localFrameworkUUID.equals(endpoint.getFrameworkUUID())) { props = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER); props.putAll(endpoint.getProperties()); props.put(ENDPOINT_FRAMEWORK_UUID, new String[] { endpoint.getFrameworkUUID(), "<<LOCAL>>"}); props = endpoint.getProperties();
private Object createJaxrsProxy(String address, Class<?> iClass, ClassLoader loader, EndpointDescription endpoint, List<Object> intents) { JAXRSClientFactoryBean factory = new JAXRSClientFactoryBean(); factory.setAddress(address); if (loader != null) { factory.setClassLoader(loader); } addContextProperties(factory, endpoint.getProperties(), RsConstants.RS_CONTEXT_PROPS_PROP_KEY); factory.setServiceClass(iClass); applyIntents(intents, factory); return ProxyFactory.create(factory.create(), iClass); }