Return-Path: X-Original-To: apmail-camel-dev-archive@www.apache.org Delivered-To: apmail-camel-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 97FF598CA for ; Sun, 23 Oct 2011 08:11:28 +0000 (UTC) Received: (qmail 38730 invoked by uid 500); 23 Oct 2011 08:11:28 -0000 Delivered-To: apmail-camel-dev-archive@camel.apache.org Received: (qmail 38544 invoked by uid 500); 23 Oct 2011 08:11:25 -0000 Mailing-List: contact dev-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list dev@camel.apache.org Received: (qmail 38534 invoked by uid 99); 23 Oct 2011 08:11:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 23 Oct 2011 08:11:24 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_FRT_INTEREST,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of claus.ibsen@gmail.com designates 209.85.215.173 as permitted sender) Received: from [209.85.215.173] (HELO mail-ey0-f173.google.com) (209.85.215.173) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 23 Oct 2011 08:11:18 +0000 Received: by eyh6 with SMTP id 6so5300529eyh.32 for ; Sun, 23 Oct 2011 01:10:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=4oufSi2sCtoQ2tfx689re3vrIvpNpmeNkAVruKyB5+k=; b=jKEk4T7C4LctnoCY+Dg3zAmCLbStOuqQuj9VXvqd44ZPBqfPSHtkv6299kn+bebCoE BAI5v28y868hg5aNXAByBOlfhlCpCn/pm+FLoWN2K1DZQxiL2AJ6So5uFWRSeFZsmT96 oD5yW3rtc4lb6BAovFmPcUPdGvYWqcFOpXgu8= Received: by 10.14.5.202 with SMTP id 50mr1263950eel.111.1319357457342; Sun, 23 Oct 2011 01:10:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.14.97.7 with HTTP; Sun, 23 Oct 2011 01:10:36 -0700 (PDT) In-Reply-To: <4EA185BF.4060303@die-schneider.net> References: <4E9C27AB.60601@die-schneider.net> <4EA185BF.4060303@die-schneider.net> From: Claus Ibsen Date: Sun, 23 Oct 2011 10:10:36 +0200 Message-ID: Subject: Re: [Discuss] How to do JMX in Apache Camel? To: dev@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 On Fri, Oct 21, 2011 at 4:46 PM, Christian Schneider wrote: > Am 21.10.2011 13:28, schrieb Claus Ibsen: >> >> Hi Christian >> >> On Tue, Oct 18, 2011 at 8:42 AM, Claus Ibsen >> =A0wrote: >>> >>> Hi >>> >>> There is a JIRA ticket from the community about adding interfaces for >>> the various MBean we have in camel-core >>> https://issues.apache.org/jira/browse/CAMEL-4468 >>> >> I think it would be valuable if you took at look at CAMEL-4468. You >> have an keen interrest in API which can help here. >> >> Its although API for JMX Clients (eg for Camel end users from a client >> to access the Camel MBeans using an interface.). CAMEL-4468 makes this >> easier for clients as the JDK JMX API has a way of proxy using a >> interface, which makes it much easier for clients to access MBeans. >> >> Basically something like this code line >> =A0 =A0Object jmx_proxy =3D >> MBeanServerInvocationHandler.newProxyInstance(getMBeanServerConnection()= , >> objectName, interfaceClass, notificationBroadcaster); >> >> That makes it easier for Camel end users to acces the Camel MBeans. >> >> >> However the other point is how Camel itself registers MBeans in the >> MBeanServer. This is still using JMX annotations (Camel or Spring JMX >> annotations). But we can add support for MXBean interfaces as well (eg >> possible the interfaces from CAMEL-4468). >> However the benefit of the JMX annotations is that they allow you to >> add meta data such as description and possible other stuff we can add >> as well. Also with JMX annotations its sort of a "mix in" approach >> where Camel can use a ManagedEndpoint as base class and then add those >> additional JMX annotations for a component. See for example camel-jms >> in the JmsEndpoint class, how we can easily add special JMX attributes >> and operators. Using interfaces this becomes as far as I can see, more >> difficult. > > Can you explain how this Mixin aproach is better than an interface? > With interfaces you need to implement or extend other interfaces. The annotations doesn't require this per see. You can just add annotations to your existing class, and no need to implement interfaces, etc. Also with annotations you do keep the code in *one* file, as well as annotations can have additional meta-data such as the descriptio= n. > To do the same for JmsEndpoint =A0that the annotations do you would just = have > to let it implement JmsEndpointMXBean and also have the getters and sette= rs > for the attributes there. > Yeah its compelling but unfortunately JMX forces you to use *MXBean as the = name, which essentially forces you to create a special interface for JMX itself. You may also have an interface for client users to use. This essentially duplicate your effort. With annotations you don't need this. Just add the annotations on the attribute/operations and you are done. > >> >> >> >> >>> I assume those interface would transpose to the MXBeans beans you refer >>> to? > > Exactly if you create the MXBeans using interfaces named ClasNameMXBean t= hen > the JDK knows how to instantiate the MXBean and the user can use this > interface for proxies. > That is the only compelling reason for MXBean interaces as Camel end users who want to access the Camel MBeans as a client can use those interfaces instead of using the cumbersome generic JMX API. But *any* interface can do from a client point of view, it does not need to be named *MXBean. >>> >>> That would be a good idea to have both the interfaces and the @Managed >>> annotations, >>> the interfaces makes it easier for community end users who want as a >>> client to access Camel JMX details. >>> And this is easier to do with a proxy from a interface. > > At the moment I have no idea how we could have both in the same bean. So = we > have to decide for each bean. > > Christian > > -- > Christian Schneider > http://www.liquid-reality.de > > Open Source Architect > Talend Application Integration Division http://www.talend.com > > --=20 Claus Ibsen ----------------- FuseSource Email: cibsen@fusesource.com Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/