Return-Path: X-Original-To: apmail-jackrabbit-oak-dev-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EE5FA10C20 for ; Mon, 10 Feb 2014 12:32:52 +0000 (UTC) Received: (qmail 41820 invoked by uid 500); 10 Feb 2014 12:32:51 -0000 Delivered-To: apmail-jackrabbit-oak-dev-archive@jackrabbit.apache.org Received: (qmail 41652 invoked by uid 500); 10 Feb 2014 12:32:45 -0000 Mailing-List: contact oak-dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-dev@jackrabbit.apache.org Received: (qmail 41630 invoked by uid 99); 10 Feb 2014 12:32:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Feb 2014 12:32:43 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jukka.zitting@gmail.com designates 209.85.214.177 as permitted sender) Received: from [209.85.214.177] (HELO mail-ob0-f177.google.com) (209.85.214.177) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Feb 2014 12:32:37 +0000 Received: by mail-ob0-f177.google.com with SMTP id wp18so7059053obc.22 for ; Mon, 10 Feb 2014 04:32:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=oBWZsKGhlv/hsvpsPjMa3lxQg3rZ35paV+Xn5QAF4m4=; b=AeE9Z6xb+uh5anUBkrk9ivz5JZCcozyRRL5CHqCZPzvXNRauNUVfYhglSbxziNKepu 1e7/AFQEFvs2eiuFtZQhaI4NM6rHHbbsZdi1rSdgwMr9LfPYelZae7Rj+KIQkq2uUTed PQpH/DuwsN1QBb2PZb7vOg4DM5rYVMcd9Ib08TzqEN677yPrxBKs6ajQlF+O7WiISZae cRBekwHcIk79UQApmw9nzQq6C0Zz7i4AEkEuJp41CiDfToAfXKNQdH9HZqhGq1Ut1gRd wN0DTh7cRE8+OHYvO3Nge40KWrUNkZnSsEXY69Qb+NtYOWP5j8uMI4mRdISNmF2+IbI0 xy3g== X-Received: by 10.183.3.102 with SMTP id bv6mr26946628obd.18.1392035536713; Mon, 10 Feb 2014 04:32:16 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.153.198 with HTTP; Mon, 10 Feb 2014 04:31:56 -0800 (PST) In-Reply-To: References: From: Jukka Zitting Date: Mon, 10 Feb 2014 07:31:56 -0500 Message-ID: Subject: Re: Make "Whiteboard" accessible through ContentRepository To: Oak devs Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org Hi, On Mon, Feb 10, 2014 at 1:01 AM, Tobias Bocanegra wrote: > ok...using Sling/Felix quite a lot, I'm used to the possibility to > create a Service that can have references to any other exported > Service via its ComponentContext, i.e. BundleContext, i.e underlying > OSGi service registry. The same thing works also without OSGi, you just add a new component constructor argument or a setter and adjust the code that does the wiring to provide that dependency to a component. I admit that doing it this way does require changing code in two places, but it also achieves better decoupling of the service from the way it's wired up, i.e. the component itself doesn't have to worry about the mechanics of the service lookup. This simplifies also things like unit test fixtures as you can just mock the direct dependencies of a component instead of setting up a full runtime environment. Declarative Services in OSGi works similarly in decoupling the wiring of services from the services themselves. A DS-based component doesn't necessarily need to access the Component/BundleContext at all, as it can just declare direct dependencies to all the services it needs. Most Oak components should work the same way instead of requiring direct access to the Whiteboard. By making the DS bind methods explicit, you could even write a normal DS-based component that you can also wire up statically in places like oak-run. > sure, in the end it is a specific service. but we don't want to limit > the set of services a login module can use. IMO, it should have access > to all the ones registered. So a login module (also in the non osgi > world) should be able to retrieve the Whiteboard to get a service. See above; instead of going through the Whiteboard, I'd rather see a component declaring direct dependencies to the services it needs. The wiring should happen elsewhere. > I think my problem is, that there are (were) several instances of the > 'DefautlWhiteboard" created, one in Oak.java, one by the > SecurityProviderImpl. Hmm, I only see a DefaultWhiteboard instance being created in Oak.java. SecurityProviderImpl uses OsgiWhiteboard. Did this change in OAK-1377? > And only allow to create Oak() with or without whiteboard, and remove > the Oak.with(Whiteboard) method. So it's clear that either we use the > external provided whiteboard, or the implicit internal one. We can do that, though one of the driving ideas behind Oak has been to keep things like "new Oak().with(new SomeComponent()).createContentSession()" as simple as possible. > the problem is, that each plugin, that needs a whiteboard, should be > able to get the default one. without some helper classes, the > construction gets a bit awkward: > > Oak oak = new Oak(); > SecurityProvider sp = new SecurityProvider(oak.getWhiteboard()); > oak.with(sp); > > IMO it's better that Oak.with() pushes its whiteboard to the plugin. If this becomes a common need, i.e. there are many components that need access to the whiteboard (instead of just a more specific set of services, as suggested above), then I'd rather pull the whiteboard entirely out of the Oak class, like this: Whiteboard whiteboard = ...; new Oak(...) .with(new SecurityProvider(whiteboard)) .createContentRepository(whiteboard); But as said, I think only a small subset of our components should really need direct access to the whiteboard. For example the authorizable action and restriction providers in SecurityProviderImpl are composite services, that in an OSGi deployment can/should be dynamic through the whiteboard mechanism, but in a static deployment shouldn't need the whiteboard as we could just provide a static list of all the available component providers. BR, Jukka Zitting