Return-Path: X-Original-To: apmail-felix-users-archive@minotaur.apache.org Delivered-To: apmail-felix-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 632F6FECA for ; Fri, 12 Dec 2014 18:08:38 +0000 (UTC) Received: (qmail 28773 invoked by uid 500); 12 Dec 2014 18:08:38 -0000 Delivered-To: apmail-felix-users-archive@felix.apache.org Received: (qmail 28717 invoked by uid 500); 12 Dec 2014 18:08:38 -0000 Mailing-List: contact users-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@felix.apache.org Delivered-To: mailing list users@felix.apache.org Received: (qmail 28686 invoked by uid 99); 12 Dec 2014 18:08:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Dec 2014 18:08:37 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of dean.w.schulze@gmail.com designates 74.125.82.49 as permitted sender) Received: from [74.125.82.49] (HELO mail-wg0-f49.google.com) (74.125.82.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Dec 2014 18:08:33 +0000 Received: by mail-wg0-f49.google.com with SMTP id n12so9788808wgh.36 for ; Fri, 12 Dec 2014 10:06:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=ju9n5YCa/B9qHyL5K/OcwoOYVRbtSFqC/JPkn1PyHSc=; b=sG2gB94pBOBeN1mg61nxOVaADfSUemyz81CCecqi8zmyRIA7wa4CfBBML4MhhMhrIv v8cpiD5ub2UehyKL+DayRPesog5bZdzsL0NXmtWaYTx/B3Gq29SM/4LhKadBT4gzp6tN V94gkaIQHIEHijB4F5HpEUWb2Tf9R6ljQB7XuKS2qQqfJ2tcR1o6hqeU8w5uBZ9Z9I25 GHtq1p0ZvmcLkDJev2XFbheymdC8ZPTl73fhM2h3TKCgRozAjyrCPUStqYvoOhND61YG Ez8xn9DepmgrUBmrgxxfnHTO7jzr3scnP811+Vl4vWyU6Bu0kPfBluelFsx8ZZjw4kNz vc8w== MIME-Version: 1.0 X-Received: by 10.180.91.136 with SMTP id ce8mr6362003wib.29.1418407601908; Fri, 12 Dec 2014 10:06:41 -0800 (PST) Received: by 10.194.162.2 with HTTP; Fri, 12 Dec 2014 10:06:41 -0800 (PST) In-Reply-To: <548AFE88.6010200@die-schneider.net> References: <1418362876.24529.7.camel@ubuntu-14-dean> <1418394247.24529.32.camel@ubuntu-14-dean> <548AFE88.6010200@die-schneider.net> Date: Fri, 12 Dec 2014 11:06:41 -0700 Message-ID: Subject: Re: Loading a class from a different bundle dynamically From: Dean Schulze To: users@felix.apache.org Content-Type: multipart/alternative; boundary=f46d043c7ebe423389050a08c17c X-Virus-Checked: Checked by ClamAV on apache.org --f46d043c7ebe423389050a08c17c Content-Type: text/plain; charset=UTF-8 I don't know what you mean when you say instantiate the class in the Activator. The Activator runs after the @Reference classes have been injected. I tried to load the test classes dynamically in the Activator, but I got a ClassNotFoundException. In order to get the implementation below to work the production module depends on the test module, but the test module depends on the production module, which won't work. This approach probably can't be made to work. As an alternative I can move the test classes into their own package in the production module and have maven exclude that package from the production binary. @Component @Service { .....} public class ProductionClass implements ... { private @Reference ITestClass testClass; @Activate public void activate() { } } On Fri, Dec 12, 2014 at 7:41 AM, Christian Schneider < chris@die-schneider.net> wrote: > > I also recommend to use a service for this. > > Simply put your test class into a separate bundle. In the activator > instantiate the test class and publish it as a service using the test > interface you provide. > > The production bundle would then listen for services implementing the test > interface e.g. using a service tracker and call them. > > This has the advantage that you do not need any system property and class > loading specialities. Another advantage is that you can start the test by > deploying the test bundle and stop it again by removing it. > So no restart required. > > Christian > > > On 12.12.2014 15:31, Achim Nierbeck wrote: > >> Dynamic Import? >> Add a manifest header or dynamically importing your testclass in case it's >> available, >> but I would actually work with a service tracker that waits for the >> "testservice" to be available and trigger the "test" then. >> >> regards, Achim >> >> >> > -- > Christian Schneider > http://www.liquid-reality.de > > Open Source Architect > http://www.talend.com > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org > For additional commands, e-mail: users-help@felix.apache.org > > --f46d043c7ebe423389050a08c17c--