Moderator (MDR): MDR-Andrea
Guest-Speaker (SPK): SPK-regman
MDR-Andrea: Hello and welcome to Java Live. Today's topic is
the JavaBeansTM Developement Kit (BDK). Our guest is BDK engineer Reggie
Adkins. Go ahead and start sending in your questions and we'll start through
them. Thanks for joining!
snarayanan: How are JavaBeans components used with
Communicator or IE? Netscape supports something called Bean connect, while IE
dosen't support it. So do I wrap my Bean in an applet and use it in the
browser?
SPK-regman:
- You could wrap the Bean in an applet.
- You could use the JavaTM Plug-in (formerly known as Project JavaTM
Activator).
JamieS: If I've defined a nice GUI customizer for a
JavaBean component, should I bother to expose its getter/setter methods in the
BeanInfo class? Do you think that this redundancy would be
helpful, or merely confusing?
SPK-regman: Good question. Well, let's see. Builder tools,
ideally, will always use your customizer. However, if for some reason it does
not, you might still want to be able to use your Bean (or for someone else to
use it) in a builder tool that only uses property sheets. I would go for
redundancy.
RefuX: I program Java apps, but I have no idea what
Beans are. What are they? :)
SPK-regman: JavaBeans are reusable software components that
can be visually manipulated in a builder tool. See http://java.sun.com/beans
for much more detail. There is a Beans Development Kit (BDK) there that you
can download, which will get you started.
JamieS: Is Bean introspection information cached by
the Introspector, or should I maintain a Bean Class <-> Customizer Class
table for frequently used classes?
SPK-regman: The Introspector does cache some information. I
don't recall what it specifically caches off-hand, other than BeanInfo's.
q3: I'm a Java programming newcomer. Does using a
JavaBean component in my design affect the overall efficiency of my application?
SPK-regman: No, JavaBeans are implemented in the Java
programming language. There is nothing new to learn (except for some coding
conventions outlined in the spec), and everything on the Java Platform is
available to you.
JamieS: Is the BeanBox being updated (as sample code)?
Should I expect a BeanBox that uses the 1.2 Bean features (contexts, Swing,
etc.) at some point? Thanks.
SPK-regman: Yes. The BeanBox is being updated. We will have a
version with 1.2 support for BeanContexts soon. We are also going
to provide Swing, drag and drop, and InfoBus support, appropriate as they come
online.
JamieS: If I extend a Bean (i.e. class
betterBean extends aBean), do I need to define a
BeanInfo for betterBean (probably class
betterBeanBeanInfo extends aBeanBeanInfo), or will
the beanInfo for aBean be found and applied by the
Introspector? The experimenting I've done implies that the Introspector does
not look at parent classes, but I figure since you're here I might as well
check with the guru.
SPK-regman: The Introspector will look at the parent classes,
unless you tell it to stop by providing a stop class. Think of
BeanInfo as "overriding" for that hierarchy level.
RefuX: Surely Beans generate huge amounts of unused
code, thus bloating Java apps and slowing them down?
SPK-regman: Theoretically, there should be no slow down at
all. Also, if you use Beans off-the-shelf and then only use a little bit of
the functionality it provides, then yes, you are getting unused code bloat. On
the other hand, a well-written Bean will do one thing and do it well so that a
good portion of its code is being used when trying to provide its functionality.
(Does that make sense?)
39988: Can you recommend a text book for beginners
trying to learn JavaBeans?
SPK-regman: Actually, I can't off the top of my head. I
recommend looking at our web site. It recommends lots of books. Also,
downloading the BDK from http://java.sun.com/beans is where I would start.
MDR-Andrea: Chuckie has informed me that the JavaWorldTM
site (www.javaworld.com) currently has some reviews posted on Beans books.
Thanks for the tip.
snarayanan: Why doesn't the event target dialog in
the BDK show all the public methods in my Bean? It shows only the methods of my
Beans that would take no args or Object class as args. But the
behavior of JavaStudioTM is quite different.
SPK-regman: The BeanBox event target dialog only shows the
event targets that are compatible with the event you are trying to connect to
the Bean.
snarayanan: This is a continuation of my previous
question. Is this a limitation with the BDK? Will the event target dialog also
show static methods?
SPK-regman: I have not confirmed that myself, but it should.
(Would you like to let us know?) :-)
rickm74: Can you elaborate on the differences between
JavaBeans and Enterprise JavaBeansTM (EJB)?
SPK-regman: EJB has a different event model than JavaBeans.
They are used more on the server side.
chuckie: Speaking of JDKTM 1.2, will there be any
differences in Bean support from JDK 1.1 to JDK 1.2? Thanks.
SPK-regman: In JDK 1.2 we will support
BeanContexts and BeanContextServices. This will
allow a Bean to dynamically get services from its logical container. Also, the
design time vs. runtime flag will be information that can be obtained from the
logical container as well.
snarayanan: I do not understand the need for InfoBus
and how it can be used with BDK.
SPK-regman: InfoBus allows Beans to locate each other in an
application and interchange data in a well-defined fashion. You can "plug
together" content/data consumers and producers using InfoBus.
tng713: This is more specific to Java programming
than JavaBeans. I have been trying to compile two classess which are
interdependent of one another. In C++, I can declare one class as a forward
declaration variable. Does the Java programming language have something similar
to C++? Or do you have any other ways to get around this problem? Thanks for
the help.
SPK-regman: There are no issues with forward references that I
am aware of.
snarayanan: I am not familiar with JavaStudio. But I
would still like to ask another question. Can I use JavaStudio to develop
Beans, or is it just connect to the Beans to develop another Bean or app?
SPK-regman: JavaStudio is used primarily to connect existing
Beans together to create an application.
snarayanan: I understand that all Swing components
are Beans. When I try to use them with BDK, I get exceptions. Any reasons? I
don't remember the type of exception ;-(
SPK-regman: The current version of the Swing components do not
have a full compliment of Bean customizers and property editors. Hence the
BeanBox warns that it cannot find some of them. This may be what you are
looking at.
snarayanan: I understand Java Foundation Classes
components are Beans themselves. But when I try to use it with BDK, I get
exceptions. Any reasons? I tried using JOptionPane and
CheckBox.
SPK-regman: Again, because of the lack of property editors and
customizers in the BeanBox, the Swing components may not be fully and properly
configured while you are trying to use them. Indeed, it may not be possible to
configure some using just the BeanBox. This will be fixed in the future. In the
meantime, the Swing components are very accessible from a programmatic point of
view.
JamieS: I know that some workarounds were provided to
Bean GUI environment vendors to help them manipulate the properties of Swing
components, because the standard model was not quite sufficient for covering
all of the bases. Do you know where I might find more information about this?
Thanks.
SPK-regman: Did my last two responses answer your question?
JamieS: I have a question about Beans and JDK 1.2
security. JDK 1.2 security enhancements include a new privilege for the
reflection APIs. Does this privilege grant the right to introspect beyond the
normal access rights (i.e. to use reflection to access privates, such as for
debugging), or does it grant the right to use reflection at all? If this
privilege grants the former ability, then it's not really that important (for
Beans), but if it controlls the latter, then it would be pretty important to
have enabled when using Beans. I've experimented with JDK 1.2 Beta 3 and the
reflection APIs, but have not tried running them from a secure environment,
like a browser or a 1.2 Activator, so I'm not really sure. Thanks.
SPK-regman: I'm not familiar with the semantics of this
priviledge. You could:
- Run an experiement.
- Check the Beta 3 docs.
muleman: Hi. There seems to be some confusion between
the white papers and tutorials about which parts of a Bean (events, properties,
methods) are intended for design-time versus run-time. Any comments? The question
I'm really getting at is: For a Bean that could also be a class library,
shouldn't one write the class library without regard to the Bean API, but then
wrap it in a Bean?
SPK-regman: When you package your Bean in a Java ARchive (JAR)
file, you can mark some of the entries as design-time only. This is a hint to
builder tools that when they use your Bean in a generated application, anything
marked "design-time only" does not need to be included in the final output.
snarayanan: What tool should I use to connect servlet
Beans? I understand that JavaServerTM comes with some tool to deploy Beans,
but what if I'm not using JavaServer?
SPK-regman: Sorry, I am not familiar with servlets. You can
check the web site. They should also have references to tool vendors.
snarayanan: Sometimes when I design a Bean and load
it using BDK, I get a ClassNotFound exception. I am sure all
classes are there. If I reinstall BDK, would things would work? Do you know
what might be happening?
SPK-regman: The BeanBox is just a tool. It's not meant for
formal app development. As such, it does not use the classpath variable (Yes,
we know you have taken painstaking efforts to set properly :-) ).
The BeanBox only looks for classes and JARs in a directory local and relative
to it. If your classes are not in one of these locations (one escapes me, the
other is the JAR's folder), you will get a ClassNotFound exception.
You can of course, change the .bat or .sh file to use the classpath you specify.
0 FYI.
JamieS: I've got a somewhat off-topic inner classes
question. If you have two classes, in two packages, like this: