Return-Path: Delivered-To: apmail-felix-dev-archive@www.apache.org Received: (qmail 6668 invoked from network); 7 Apr 2010 12:55:25 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 7 Apr 2010 12:55:25 -0000 Received: (qmail 23529 invoked by uid 500); 7 Apr 2010 12:55:24 -0000 Delivered-To: apmail-felix-dev-archive@felix.apache.org Received: (qmail 23494 invoked by uid 500); 7 Apr 2010 12:55:24 -0000 Mailing-List: contact dev-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list dev@felix.apache.org Received: (qmail 23486 invoked by uid 99); 7 Apr 2010 12:55:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Apr 2010 12:55:24 +0000 X-ASF-Spam-Status: No, hits=-1.0 required=10.0 tests=AWL,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of fmeschbe@gmail.com designates 209.85.220.210 as permitted sender) Received: from [209.85.220.210] (HELO mail-fx0-f210.google.com) (209.85.220.210) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Apr 2010 12:55:17 +0000 Received: by fxm2 with SMTP id 2so967369fxm.30 for ; Wed, 07 Apr 2010 05:54:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=zrFUfSzo/3qLi+7sfI1prtXrmb6p42nJqTI02Y5lCJg=; b=YUjSlyDBwC89/PHRZGcZYG14NEygb8S7s3KAoRo6MngNnzRRRr1hCwlkLBzPVEJLZ0 JTCyxvNtMzY+X4Yy13dPiSp4VpkEB/ujxrqiu5s71+WtuNdwYW0IzCS2FvLYVUDSjOxX X79je0eaXLdfaVJ3jGyGKHI7AOVlMZHH5BUj8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=JrjEt9p41ewpPkKnlpXZPlgHUs4xo+qL7BdZSdJWxE1bvYMlLMNk3MVrfFVQqz0KK0 8T74t7Jo73qkFhjk3T2FKQfhGIRg6EfsYlLnomUKdkVySaxKMAj8/ZKjrArKgZFClP3z FwsdnUmmTz3z3hOX7ThpeUbtysu+95eonGWDA= Received: by 10.223.7.78 with SMTP id c14mr9118504fac.64.1270644895367; Wed, 07 Apr 2010 05:54:55 -0700 (PDT) Received: from [192.168.1.21] (cable-static-138-82.eblcom.ch [87.102.138.82]) by mx.google.com with ESMTPS id 14sm9485084fxm.13.2010.04.07.05.54.54 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 07 Apr 2010 05:54:54 -0700 (PDT) Message-ID: <4BBC809D.3000803@gmail.com> Date: Wed, 07 Apr 2010 14:54:53 +0200 From: Felix Meschberger User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.8pre) Gecko/20100120 Shredder/3.0.2pre MIME-Version: 1.0 To: dev@felix.apache.org Subject: Re: [jira] Commented: (FELIX-2246) Lazy initialization of plugins References: <927298449.41611270644093522.JavaMail.jira@brutus.apache.org> In-Reply-To: <927298449.41611270644093522.JavaMail.jira@brutus.apache.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi, On 07.04.2010 14:41, Valentin Valchev (JIRA) wrote: > lazy wiring? If i have a bundle A exporting packages: > a > a.b > > And Bundle B importing > a.b > > Will the framework try to resolve only a.b dependency or the whole bundle? (All package dependencies) No, it will really only resolve a.b (if you do Import-Package). The question of when resolution takes place is controlled by two aspects: When the Bundle classloader is created and how the imports are defined. The Bundle classloader is created when the bundle is resolved. At this time all imports defined by the Import-Package header are resolved. Imports defined by the DynamicImport-Package header are only resolved on demand when they are really needed - on-demand or lazily. So, if you have a plugin, which defines the o.a.f.webconsole package as a dynamic import you might not want to have this import resolved until when the plugin is really instantiated. By moving the SimpleWebConsoleFactory class in its own package we help with two issues: * We can embed the class in the plugin bundle, without creating a split-package situation. * We can still lazily wire to the o.a.f.webconsole package on-demand when the actual plugin is really instantiated. Does this answer the question ? Or did I misunderstand the question ? Regards Felix > > > > >> Lazy initialization of plugins >> ------------------------------ >> >> Key: FELIX-2246 >> URL: https://issues.apache.org/jira/browse/FELIX-2246 >> Project: Felix >> Issue Type: Improvement >> Components: Web Console >> Affects Versions: webconsole-3.0.0 >> Reporter: Valentin Valchev >> Assignee: Felix Meschberger >> Attachments: FELIX-2246.patch, lazy-webconsole-plugins.jude, lazy-webconsole-plugins.png, lazyloading.patch, SimpleWebConsoleFactory.java, SimpleWebConsoleFactory.java >> >> >> Here at ProSyst we use a small trick to delay initialization of our services: >> When the service is quite big, and loads many resources (incl. too many classes), we register not a service, but a ServiceFactory instead. With that factory we delay the instantiation of the service, when it is actually needed and obtained by other bundle. >> Yes, this makes the code a little bit more complex, but it greatly improves the start-up time and the overall memory usage. >> This can be applied to webconsole plugins too. My idea is that Web Console should only track Service Reference without actually obtaining the service itself [not getService()]. >> When the user makes request the WebConsole calls the factory to create instance. Instance is created and returned to the Web Console, which uses it to generate content for the request. >> This way a plugin is actually not initialized until it is really used. Only small portion of classes, from the bundle are initialized. >> Unfortunately the ServiceTracker, when notified for added service obtains the real service object. So it might be better to use directly ServiceListener for the plugins. >