commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <blorit...@apache.org>
Subject Re: [clazz] Clazz API mock-up
Date Mon, 28 Oct 2002 02:44:23 GMT
Dmitri Plotnikov wrote:
> Berin,
> 
> ----- Original Message -----
> From: "Berin Loritsch" <bloritsch@apache.org>
> To: "Jakarta Commons Developers List" <commons-dev@jakarta.apache.org>
> Sent: Sunday, October 27, 2002 8:05 PM
> Subject: Re: [clazz] Clazz API mock-up
> 
> 
> 
>>Dmitri Plotnikov wrote:
>>
>>>Please check out the two attached classes: Clazz and Field. These are
>>
> client
> 
>>>APIs only.  Nothing is said about where the metadata is coming from -
>>
> that's
> 
>>>to come later.
>>>
>>>Here are some notes on the design of these two classes:
>>>
>>>1. Clazz is a metadescription of a  generalized bean (JDK bean, "modern"
>>>bean, DynaBean, Map, EJB etc).
>>>
>>>2. In some cases there is more than one Clazz that can describe a
>>
> particular
> 
>>>object. For example, the same object can be described as a standard bean
>>
> as
> 
>>>well as a "modern" bean.  Therefore I have introduced the notion of a
>>>"model" identified by a URI.  I am thinking the URI itself might map to
>>
> a
> 
>>>verbal description of the model.
>>>
>>>3. Clazz has a newInstance() method that is responsible for object
>>>allocation.
>>
>>I looked at the API stuff.  I think there is an awful lot of extra stuff.
>>KISS (Keep It Simple, Stupid).
> 
> I think the expression is actually "Keep It Simple and Stupid", otherwise it
> might sound like you are calling me stupid, which of course you never would.

:)  That's the way my mom taught it to me.  But know I am not calling you
stupid.  Another variation is "Keep It Short and Simple"

> 
> Do you really mean that there is an "awful" lot of extra stuff or you mean
> that the stuff is not very well compartmentalized into little Method
> objects?  I'll buy that for a dollar.

There is some extra stuff.  It just feels cluttered.  But proper
compartmentalization would help.

> 
>>Let's follow the java.lang.reflect.* as much as possible.  Provide a
>>getClass() method to get the original class.  Provide a getMethod() for
>>the AttributeMethod from the clazz.  That sort of thing.
> 
> Could you elaborate a little bit?  Could you give some examples of APIs
> along with examples of how you envision them being used?  I am especially
> interested in the dynamic case where there are no concrete classes, just
> data and metadata constructed at runtime.
> 
> What would I use getClass() for?  Why not call object.getClass() directly?

It's another way of getting it.  What if you are passing the meta object
directly?  Without the original reference there is no other way of getting
the Class object.

> 
> What is the benefit of encapsulating access into a Method object? At this
> early stage of design work the reason has to be more than pure esthetics.

I am thinking about symetry with java.lang.Reflet.*

I am also looking for a way of determining from the method implemented by
a component and defined by an interface what the attributes are.  For example,
if I want to generate JMX MBeans based on an interface, I need to find the
attributes for each of the methods so that the MBean has the proper description
and every thing.

Lets look at two examples (both with javadoc style attribute declaration):

/**
  * @avalon-requires:org.apache.avalon.excalibur.datasource.DataSourceComponent
  */
void service( ServiceManager manager );

/**
  * @mx-description: Retrieve a resource from a remote location
  * @mx-method
  * @mx-parameter:java.lang.String
  * @mx-parameter:java.net.URL
  * @mx-return:java.io.InputStream
  */
InputStream getResourceName( String key, URL location );


In the first example, the attribute is used by the container to ensure that
the DataSource pool is provided.  In the second example, the code to generate
MBeans will use the description and the fact that the mx-method attribute
exists.

To be even more powerful, we need a special classloader that can query all
attributes and return the appropriate AttributeMethod/AttributeClass associated
with the requested attribute.

-- 

"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message