Return-Path: Delivered-To: apmail-activemq-users-archive@www.apache.org Received: (qmail 46065 invoked from network); 10 May 2007 15:59:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 May 2007 15:59:56 -0000 Received: (qmail 75655 invoked by uid 500); 10 May 2007 16:00:02 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 75632 invoked by uid 500); 10 May 2007 16:00:02 -0000 Mailing-List: contact users-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@activemq.apache.org Delivered-To: mailing list users@activemq.apache.org Received: (qmail 75618 invoked by uid 99); 10 May 2007 16:00:02 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 May 2007 09:00:02 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [66.101.216.164] (HELO duro.intalgent.com) (66.101.216.164) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 May 2007 08:59:55 -0700 Received: from [10.0.0.136] (localhost [127.0.0.1]) by duro.intalgent.com (8.13.1/8.13.1) with ESMTP id l4AFxX0S011163 for ; Thu, 10 May 2007 11:59:33 -0400 Mime-Version: 1.0 (Apple Message framework v752.3) In-Reply-To: References: <51B518A0-7F11-457C-A092-A14B3B9165E7@intalgent.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <0F6D4119-A132-4AB6-B3AA-953E7EEDF5BF@intalgent.com> Content-Transfer-Encoding: 7bit From: Jeff Gunther Subject: Re: [camel] Spring and Custom Components Date: Thu, 10 May 2007 11:59:24 -0400 To: users@activemq.apache.org X-Mailer: Apple Mail (2.752.3) X-Virus-Checked: Checked by ClamAV on apache.org Hi James, Thank you for the very detailed follow up! That worked wonderfully. Related to this issue, how would I set the ConnectionFactory for the JMS Component? Jeff Gunther On May 10, 2007, at 11:27 AM, James Strachan wrote: > Hi Jeff > > On 5/9/07, Jeff Gunther wrote: >> Hi All, >> >> Here is the code snippet I'm working to configure in Spring: >> >> final CamelContext container = new DefaultCamelContext(); >> container.addComponent("foo", new FooComponent(container)); > > FWIW if you don't need to explicitly configure the FooComponent > directly if it doesn't have much configuration data - you can create a > file called > > /META-INF/services/org/apache/camel/component/foo > > with contents > > class=org.acme.FooComponent > > (you can add other property configurations in there too if you like) > > Then if you refer to an endpoint as "foo://somethingOrOther" Camel > will auto-discover your component and register it. > > The downside of this approach though is if FooComponent needs some > actual injection; like a DataSource or whatever. You can configure > endpoints in a few different ways... > http://cwiki.apache.org/CAMEL/how-do-i-configure-endpoints.html > > > One thing thats not quite tested or documented yet that I wanted was > the ability to use the Injector on a CamelContext to dependency inject > the FooComponent (using either autowire mode in Spring or using > @Resource type dependency injection) so that you don't have to > explicitly add the FooComponent to the Spring XML, you just need to > add the resources which need to be injected into the FooComponent. > (This also has the nice benefit of avoiding component developers > having to worry about writing Spring XML namespace handler stuff) > > >> I'm using the Spring 2.0 XML Namespaces approach to define my routes. >> How can I add a custom component to a "camelContext"? > > If after my long ramble above you still want to explicitly have a > type XML within the then > you need to do some Spring XML NamespaceHandler hacking - which is > kinda ugly & crufty work unfortunately. You could use xbean-spring > which tries to automate most of this work for you. > > If you look in camel-spring at CamelNamespaceHandler you'll see how we > handle the Spring XML stuff (warning its kinda hairy code to look at). > If you wanted to be a standard part of the core Camel > schema then you'd hack that file to add your component & add a patch > to the camel XSD. Otherwise you could write your own namespace & > schema if you prefer. > > > Incidentally I've updated the website with more details > http://cwiki.apache.org/CAMEL/how-do-i-add-a-component.html > http://cwiki.apache.org/CAMEL/writing-components.html > -- > James > ------- > http://macstrac.blogspot.com/