5 Replies Latest reply on Apr 24, 2002 11:31 AM by dsundstrom

    why must fields be public

    gzhong

      I finally got a simple CMP bean working. But only after I changed the fields to public. This can't be the case, I said to myself, but can it? Is it possible that JBoss is forcing me to allow public access to the fields for which I already have public set/get functions? Having public set/get is not the same as allowing public access to the instance variables for which these set/get methods apply.

      So I probably did something wrong. But according to the example on JBoss that I followed, they also made all their fields public, in addition to the set/get methods. So is this something I can change in the configuration file? I just don't like directly exposing instance variables to the public.

      Thanks,
      G

        • 1. Re: why must fields be public
          dsundstrom

          This is required by the EJB 1.1 specification. Don't worry about access, because all clients have to access your bean using the remote interface.

          If this still irks you, upgrade to JBoss 3.0 and use CMP 2.0. In CMP 2.0 you don't have fields, you just define abstract methods to access your persistent fields.

          • 2. Re: why must fields be public
            gzhong

            Ah, I see now. THat also explains why there is a discrepancy between what I found from the Sun EJB tutorial and the JBoss tutorial. On the Sun tutorial they use these abstract methods. ANyway, JBoss 3.0 is still beta. Is it stable enough for development use only (I am just using it for teaching myself EJB, not for any real life project). Is there a timeline for it being non-beta?

            Thanks again!
            G

            • 3. Re: why must fields be public
              dsundstrom

              > ANyway, JBoss 3.0 is still beta.

              Actually, it is at release canidate 1. Check the files section at sourceforge.

              > Is it stable enough for development
              > use only (I am just using it for teaching myself EJB,
              > not for any real life project).

              Yes.

              • 4. EJB 2.0 useful?
                gzhong

                Ah, so JBoss 3.0 implements EJB 2.0. Is EJB 2.0 widely implemented? I know Sun obviously implements it, what about other big EJB containers? I don't know how long EJB 2.0 has been around.

                Thanks again,
                G

                • 5. Re: EJB 2.0 useful?
                  dsundstrom

                  > Ah, so JBoss 3.0 implements EJB 2.0. Is EJB 2.0
                  > widely implemented? I know Sun obviously implements
                  > it, what about other big EJB containers?

                  Yes, it is a huge feature of EJB 2.0.

                  > I don't know how long EJB 2.0 has been around.

                  In final form about 6 months, but the spec was in development for over a year.