admin@glassfish.java.net

Re: how can AMX access _at_Configured classes?

From: Jerome Dochez <Jerome.Dochez_at_Sun.COM>
Date: Fri, 14 Mar 2008 22:40:35 -0700

On Mar 14, 2008, at 4:42 PM, Lloyd L Chambers wrote:

> Jerome et al,
>
> Suppose I define a new module "chicken-farm" that uses configuration
> like this:
>
> // internal interface describing the injected configuration
> @AMXConfigInfo( amxInterface=com.farming.AMXChickenFarmConfig.class )
> @Configured
> public interface ChickenFarm extends ConfigBeanProxy, Injectable {
> @Attribute // why do I have to annotate this anyway?
> public String getEggsToLayPerDay();
> public void setEggsToLayPerDay( String num );
>
> @Attribute // why do I have to annotate this anyway?
> public String getTurkeySlaughterDate();
> public void setTurkeySlaughterDate( String d );
> }
>
> // interface for use by AMX clients
> public interface AMXChickenFarmConfig extends AMXConfig {
> public String getEggsToLayPerDay();
> public void setEggsToLayPerDay( String num );
>
> public String getTurkeySlaughterDate();
> public void setTurkeySlaughterDate( String d );
> }
>
> COMMENTS/QUESTIONS
>
> 1. COMMENT: Notice the undesirable duplication. Perhaps a base
> interface could be used to factor it out, or AMXChickenFarmConfig
> could extend ChickenFarm (But AMX doesn't need or want the
> @Configured, @Element, or @Attribute annotations that HK2 uses, nor
> do AMX clients want them, or want to have dependencies on HK2!). So
> maybe this is just life. Or maybe it is AMX that should be defining
> these annotations, and AMX should be a standalone jar used by HK2.
well we talked about that at the beginning and the design pattern that
Kohsuke was selling (which I liked) was only one interface with both
@Attribute for correct xml processing and potentially JMX annotations.

I think you must remember that Configured interfaces are primarily
used to describe the xml mapping and we cannot just use jmx style of
annotations as it would be insufficient. Having a merged annotation
would be weird, I think it would be perfectly fine to have 2
annotations per attribute/element as it is to describe very different
things.

>
>
> 2. PROBLEM? Now the ConfigBean for 'ChickenFarm' is registered in
> the Habitat. Soon, AMX comes along and wants to register an MBean
> supporting AMXChickenFarmConfig corresponding to that ConfigBean.
>
> Since the amx-impl module doesn't depend on this new module, won't
> the classloader just throw a ClassNotFoundException for these classes?
>
it shouldn't be a problem because you will have the instance passed to
you in the onEntered so you will not have to do any class loading.

Jerome

>
> Lloyd
> ---
> Lloyd L Chambers
> lloyd.chambers_at_sun.com
> Sun Microsystems, Inc
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: admin-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: admin-help_at_glassfish.dev.java.net
>