Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 76185 invoked from network); 5 Jul 2010 15:32:25 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 5 Jul 2010 15:32:25 -0000 Received: (qmail 88464 invoked by uid 500); 5 Jul 2010 15:32:25 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 88420 invoked by uid 500); 5 Jul 2010 15:32:24 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 88412 invoked by uid 99); 5 Jul 2010 15:32:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Jul 2010 15:32:24 +0000 X-ASF-Spam-Status: No, hits=1.3 required=10.0 tests=FREEMAIL_FROM,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of claus.ibsen@gmail.com designates 209.85.161.45 as permitted sender) Received: from [209.85.161.45] (HELO mail-fx0-f45.google.com) (209.85.161.45) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Jul 2010 15:32:19 +0000 Received: by fxm10 with SMTP id 10so3925498fxm.32 for ; Mon, 05 Jul 2010 08:31:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=SVGm301A1pRzEM1c76HsLJX8oAbLEdeyzE/FGjXJtZY=; b=n5YQqmIcwjr8DQb4FFc9vV+iV9NjeUplE5Bl1kLybyu0cOrWJgIt40W1hTy2f1/deo C+1Gpz4+d6P7UAs5mywx1SAeWkPruveOAsi/1XVPYfE0PTrWoNbu1ujck/8hQOv2l8Kc rAbxVTkWoKewuL4ELXWrkQOA1v+C6yPYFU/JM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=oi/MpZLrXxRZAgntxLL580oVtHPNGh6j1frHsW2kIJhhNa1PMSRi6TEEg6XIB36uPZ 1qNwn9waBFZvqe4FEkidcjqG6P2Y8v9F3YlJrPbm4Mlhq8nrMIPcTKEiJPaCe7U3FHAG mg0UDPOabs563EmSSAmFAOwLjcqMs3lam3YoM= Received: by 10.223.114.80 with SMTP id d16mr2628355faq.81.1278343916659; Mon, 05 Jul 2010 08:31:56 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.103.209 with HTTP; Mon, 5 Jul 2010 08:31:36 -0700 (PDT) In-Reply-To: <1278342030618-696567.post@n5.nabble.com> References: <1278342030618-696567.post@n5.nabble.com> From: Claus Ibsen Date: Mon, 5 Jul 2010 17:31:36 +0200 Message-ID: Subject: Re: Using Policy to alter Definitions before building To: users@camel.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Hi Have you looked at org.apache.camel.spi.InterceptStrategy? On Mon, Jul 5, 2010 at 5:00 PM, Mark Proctor wrote: > > As well as using Policy to wrap the child processors, I'd like to be able= to > change/augment the child definitions before they are built. My current us= e > case for this is so I can augment the DataFormats, with additional > configurations. Additionally this Policy also takes care of setting the > current context ClassLoader, but that already works fine with the existin= g > Policy wrap api. > > API comptability is a problem, but as a sketch to what I'm trying to > achieve, here is a change that while a little clunky (due api compatabili= ty) > should achieve the job. This allows the wrap to still call the child > Process, via the delegate, but to also inspect and change the child > Definitions prior to building. > > public interface DefinitionAwarePolicy extends Policy { > =A0 =A0Processor wrap(RouteContext routeContext, > ProcessorDefinition processorDefinition, Processor > processor); > } > > PolicyDefinition. > =A0 =A0public Processor createProcessor(RouteContext routeContext) throws > Exception { > =A0 =A0 =A0 =A0DelegateProcessor childProcessor =3D new DelegateProcessor= (); > > =A0 =A0 =A0 =A0Policy policy =3D resolvePolicy(routeContext); > =A0 =A0 =A0 =A0ObjectHelper.notNull(policy, "policy", this); > =A0 =A0 =A0 =A0Processor target; > =A0 =A0 =A0 =A0if ( policy instanceof Policy ) { > =A0 =A0 =A0 =A0 =A0 =A0target =3D policy.wrap(routeContext, childProcesso= r); > =A0 =A0 =A0 =A0} else { > =A0 =A0 =A0 =A0 =A0 =A0target =3D ((DefinitionAwarePolicy)policy).wrap(ro= uteContext, > this, childProcessor); > =A0 =A0 =A0 =A0} > > =A0 =A0 =A0 =A0childProcessor.setProcessor( this.createChildProcessor(rou= teContext, > true) ); > > =A0 =A0 =A0 =A0// wrap the target so it becomes a service and we can mana= ge its > lifecycle > =A0 =A0 =A0 =A0WrapProcessor wrap =3D new WrapProcessor(target, childProc= essor); > =A0 =A0 =A0 =A0return wrap; > =A0 =A0} > -- > View this message in context: http://camel.465427.n5.nabble.com/Using-Pol= icy-to-alter-Definitions-before-building-tp696567p696567.html > Sent from the Camel - Users mailing list archive at Nabble.com. > --=20 Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus