On Sep 14, Juha-P Lindfors quoth:
> On Thu, 14 Sep 2000, Ingo Bruell wrote:
> > Hi,
> >
> > > immidiately found out why my Bean wouldn't deploy. I had to declare all
> > > CMP managed fields as public, not as private. Why is that ? I thought
> > > they should only be accessed through the set/get methods. Seems like I
> > > have to read the specs again ...
> >
> > if i have understood the documentation from the java Reflection API right,
> > the API could only access public attributes from a class. And the container
> > should also have access to the attributes to map the stored attributes to
> > the bean attributes (with the reflection API)...
>
> getDeclaredFields() would return all fields, including private, right?
Yep. From the horses mouth:
Returns an array of Field objects reflecting all the fields
declared by the class or interface represented by this Class
object. This includes public, protected, default (package) access,
and private fields, but excludes inherited fields.
> Anyhow, with EJB2.0 all access to CMP fields will go through accessor
> methods, so it would seem that at least then it is not necessary to keep
> these fields public (though the spec draft doesn't change the requirements
> for this, CMP fields are still required to be public).
When you say "...all access to CMP fields..." do you mean access by the
container? I ask because we have at least one class where there are some
fields which are not directly set/get but are used to construct an object
that is set/get. It sounds odd but it makes sense in our application.
There do not exist matching set/get operators for the component variables
yet we rely upon the container to place them independently in the tables.
> Not sure why this requirement was made in the first place. Although since
> the container is the only one accessing the bean class I guess it doesn't
> make that much difference but still it seems to go against the coding
> practice many OO programmers use.
Unless the members are public, how would the container externally load the
fields? The container cannot violate visibility without complicity on the
part of the JVM, no?
C=)
--------------------------------------------------------------------------
There are no significant bugs in our released software that any significant
number of users want fixed. -Bill Gates, Focus Magazine, Oct 23, 1995
--------------------------------------------------------------------------
Caskey <caskey*technocage.com> /// TechnoCage Inc.
--------------------------------------------------------------------------
"Welcome to the slippery slope, here is your handbasket.
...say, can you work 70 hours this week?"
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]