setTransients(null, parseActions(actions)); Map<String, Object> props; 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();
/** * Returns a hash code value for the object. * * @return An integer which is a hash code value for this object. */ public int hashCode() { return getId().hashCode(); }
/** * Answers if this Endpoint Description refers to the same service instance * as the given Endpoint Description. * * Two Endpoint Descriptions point to the same service if they have the same * id or their framework UUIDs and remote service ids are equal. * * @param other The Endpoint Description to look at * @return True if this endpoint description points to the same service as * the other */ public boolean isSameService(EndpointDescription other) { if (this.equals(other)) { return true; } if (this.getFrameworkUUID() == null) { return false; } return (this.getServiceId() == other.getServiceId()) && this.getFrameworkUUID().equals(other.getFrameworkUUID()); }
conditionProperties(props); this.properties = Collections.unmodifiableMap(props); interfaces = verifyObjectClassProperty(); serviceId = verifyLongProperty(ENDPOINT_SERVICE_ID); frameworkUUID = verifyStringProperty(ENDPOINT_FRAMEWORK_UUID); id = verifyStringProperty(ENDPOINT_ID).trim(); if (id == null) { throw new IllegalArgumentException(ENDPOINT_ID + " property must be set"); if (getConfigurationTypes().isEmpty()) { throw new IllegalArgumentException(SERVICE_IMPORTED_CONFIGS + " property must be set and non-empty");
/** * Map a Remote Service Admin Event to an EventAdmin event according to OSGi Enterprise R5 122.7.1. * * @param event the Remote Service Admin event * @return the Event Admin event */ private Event createEventAdminEvent(RemoteServiceAdminEvent event, EndpointDescription description, Throwable exception) { Map<String, Object> properties = new HashMap<String, Object>(); properties.put("bundle", getBundleContext().getBundle()); properties.put("bundle.id", getBundleContext().getBundle().getBundleId()); properties.put("bundle.symbolicname", getBundleContext().getBundle().getSymbolicName()); properties.put("bundle.version", getBundleContext().getBundle().getVersion()); properties.put("bundle.signer", new String[] {}); // TODO impl properties.put("event", event); properties.put("timestamp", System.currentTimeMillis()); putIfValueNotNull(properties, "cause", exception); if (description != null) { putIfValueNotNull(properties, "endpoint.service.id", description.getServiceId()); putIfValueNotNull(properties, "endpoint.framework.uuid", description.getFrameworkUUID()); putIfValueNotNull(properties, "endpoint.id", description.getId()); putIfValueNotNull(properties, "endpoint.imported.configs", description.getConfigurationTypes()); } return new Event(getEventTopic(event.getType()), properties); }
/** * 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; } }
/** * Return the list of intents implemented by this endpoint. * * The intents are based on the service.intents on an imported service, * except for any intents that are additionally provided by the importing * distribution provider. All qualified intents must have been expanded. * * This value of the intents is stored in the * {@link RemoteConstants#SERVICE_INTENTS} service property. * * @return An unmodifiable list of expanded intents that are provided by * this endpoint. */ public List<String> getIntents() { return getStringPlusProperty(SERVICE_INTENTS); }
@Override public boolean update(EndpointDescription endpoint) { if (m_closed.get()) { throw new IllegalStateException("Updating closed Import Registration not supported"); } if (m_exception != null) { throw new IllegalStateException("Updating invalid Import Registration not allowed"); } if (!endpoint.equals(m_endpoint)) { throw new IllegalArgumentException( "Updating Import Registation with different service instance not allowed"); } List<String> configurationTypes = endpoint.getConfigurationTypes(); if (!configurationTypes.contains(CONFIGURATION_TYPE)) { // TODO setexception return false; } String updateHash = computeHash(endpoint); if (!updateHash.equals(m_endpointHash)) { m_endpoint = endpoint; m_endpointHash = updateHash; Dictionary<String, Object> serviceProperties = createImportedServiceProperties(m_endpoint); m_clientRegistration.setProperties(serviceProperties); m_admin.importedEndpointUpdated(this); } return true; }
/** * Determines the equality of two EndpointPermission objects. * * Checks that specified object has the same name, actions and endpoint as * this {@code EndpointPermission}. * * @param obj The object to test for equality. * @return true If obj is a {@code EndpointPermission}, and has the same * name, actions and endpoint as this {@code EndpointPermission} * object; {@code false} otherwise. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof EndpointPermission)) { return false; } EndpointPermission ep = (EndpointPermission) obj; return (action_mask == ep.action_mask) && getName().equals(ep.getName()) && ((endpoint == ep.endpoint) || ((endpoint != null) && (ep.endpoint != null) && endpoint.equals(ep.endpoint))); }
Class<?> valueType = value.getClass(); if (Object[].class.isAssignableFrom(valueType)) { append(sb, (Object[]) value); continue;
try { getPackageVersion(packageName); } catch (IllegalArgumentException e) { IllegalArgumentException iae = new IllegalArgumentException("Improper version for package " + packageName);
if (!endpoint.getConfigurationTypes().contains(CONFIGURATION_TYPE)) { logInfo("No supported configuration type found. Not importing endpoint: %s", endpoint); return null;
conditionProperties(props); this.properties = Collections.unmodifiableMap(props); interfaces = verifyObjectClassProperty(); serviceId = verifyLongProperty(ENDPOINT_SERVICE_ID); frameworkUUID = verifyStringProperty(ENDPOINT_FRAMEWORK_UUID); id = verifyStringProperty(ENDPOINT_ID).trim(); if (id == null) { throw new IllegalArgumentException(ENDPOINT_ID + " property must be set"); if (getConfigurationTypes().isEmpty()) { throw new IllegalArgumentException(SERVICE_IMPORTED_CONFIGS + " property must be set and non-empty");
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"); }
@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); }
/** * Returns the configuration types. * * A distribution provider exports a service with an endpoint. This endpoint * uses some kind of communications protocol with a set of configuration * parameters. There are many different types but each endpoint is * configured by only one configuration type. However, a distribution * provider can be aware of different configuration types and provide * synonyms to increase the change a receiving distribution provider can * create a connection to this endpoint. * * This value of the configuration types is stored in the * {@link RemoteConstants#SERVICE_IMPORTED_CONFIGS} service property. * * @return An unmodifiable list of the configuration types used for the * associated endpoint and optionally synonyms. */ public List<String> getConfigurationTypes() { return getStringPlusProperty(SERVICE_IMPORTED_CONFIGS); }
private boolean alreadyImported(EndpointDescription endpoint, Set<ImportRegistration> importRegistrations) { for (ImportRegistration ir : importRegistrations) { if (endpoint.equals(ir.getImportReference().getImportedEndpoint())) { return true; } } return false; }
Class<?> valueType = value.getClass(); if (Object[].class.isAssignableFrom(valueType)) { append(sb, (Object[]) value); continue;
try { getPackageVersion(packageName); } catch (IllegalArgumentException e) { IllegalArgumentException iae = new IllegalArgumentException("Improper version for package " + packageName);