IBM alphaWorks
E-Mail Site Map
Search

alphaWorks
Internet Access Required Internet Access Required alphaWorks Press and Awards Information about alphaWorks Internet Access Required XML Tutorials and Papers
Bean Markup Language                                                                           | Overview | FAQ | Requirements | Discussion |

Update: [04/27/99] New version of BML now adds supports for scripts in JavaScript and Net Rexx. Dynamic event adapter generator is also included.

OVERVIEW

Version 2.2 of BML includes the following significant changes:

  • ‹script›s may be written in JavaScript and NetRexx, as opposed to solely in BML.
  • ‹script›s may exist anywhere now, as opposed to solely as the child of an ‹event-binding›.
  • The dynamic event adapter generator is now included.

The ability to write scripts in languages such as JavaScript and NetRexx enables BML users to script Java beans together using BML, and implement the necessary logic in a scripting language. This capability combined with the dynamic event adapter generation capability, eliminates the need to write any Java "glue" code.

Bean Markup Language (BML) is an instance of an XML-based component configuration or wiring language customized for the JavaBean component model. The language is designed to be directly executable; i.e., processing a BML script will result in a running application configured as described in the script. The BML language has elements that can be used to describe the creation of new beans, accessing of existing beans, configuration of beans by setting/getting their properties and/or fields, binding of events from some beans to other beans as well as calling of arbitrary methods in beans.

We provide two implementations of BML - the first is an interpreter that "plays" a BML script to create the desired bean hierarchy (which is then a running application). This is implemented using reflection and is very small approximately a 35K jar file (without class compression).

The second implementation is a compiler that compiles any BML script into reflection-free Java code. The advantage of this is that it allows one to capture the inter-component structure of the application using a first-class language designed for that purpose and yet be able to compile it into "regular" Java code with basically no performance loss.


FAQ

  1. What's new in this version of BML (v2.2)??

    BML v2.2 greatly extends the script element introduced in v2.1. You can now use script pretty much anywhere within a BML document and, more importantly, scripts can be written in BML as well as JavaScript and NetRexx! You can now use BML to wire together Java applications and write the glue logic in a scripting language!

    The other major change is the inclusion of the dynamic event adapter generator. This eliminates the need to write the one liner event adapters that you may have had to write previously - this generator automatically generates byte codes (not Java code) for these adapters on demand!

    Finally, a "value" attribute has been added to string and cast by popular demand.

  2. What's the purpose of BML?

    There are two uses of BML corresponding to the two implementations:

    The player can be used as a driver to run Java applications created dynamically or otherwise. The BML language allows one to easily and completely describe the structure of component Java applications (i.e., apps consisting of a set of beans wired together to form the functions of the application). The player is a very small interpreter for this language that can be easily embedded in applications or Web pages (using the Java plug-in from Javasoft). By embedding the player in an application, you can expose the application to dynamic configuration and editing by BML scripts at any time.

    The BML compiler generates Java code from a BML script. The code that is generated is basically the same Java code you would have written to implement the configuration that the script describes. Hmm, in that case, why would I have written something in BML if I could've done it in Java directly you ask?

    BML, the language is really an abstract model for describing the structure of a component-based application. The advantage of describing the structure in this form vs. in Java is that the structure is explicit rather than implicit. If you don't need the dynamic execution flexibility offered by the BML Player which interprets these scripts, then you can simply compile the script to get the .java and .class files which do exactly what you want without the added overhead of including the player in your application. The compiler is also useful if you generate wirings using processes such as XSL, but you don't need the dynamicism. Then, you generate the BML script (since that's a lot more natural to generate in an XML environment such as XSL vs. generating Java code) and then compile it to get the Java code you want.

  3. How does BML compare to visual builders?

    The BML language is an XML language for describing the desired configuration of a set of Java beans. Yes, it can be done (probably) more conveniently and more intuitively using visual bean builders such as VisualAge for Java. So, why BML??

    The capabilities of BML as a bean configuration mechanism are similar to those of bean builders, with the added advantage of being an automatically generable text form instead of an interactive tool. No, we're not expecting that VisualAge for Java users would suddenly switch to BML either! So, why BML??

    - BML is useful in cases where you want to configure a set of beans in a non-interactive setting. For example, if you are using XSL to generate a Java application, then you want BML.

    - It is also useful when you want to dynamically modify or create new components and wire them into the running application (using the player, see below). A demo of this is available now using the base juggler demo and adding functionality to it (see the user's guide for details).

    - It is also a useful high-level, textual abstraction to capture the structure of component-based applications. That is, while bean configuration in Java is of course possible and extremely popular, writing Java code does not make explicit the set of components (beans) that comprise the application and how they inter-relate. Java is a superb language for implementing components, but when Java is used to wire the components together (which is the typical task of the "main" program), Java is not necessarily the best tool; BML is what you want.

  4. What's the relationship between BML and XSL?

    The motivation for BML came from wanting to use XSL to generate Java user interfaces from some XML content. We needed a way to describe the beans we wanted to create to form the UI and BML was born. It has now evolved to being a wiring language to wire together totally arbitrary beans, not just visual components. There are no assumptions made about the nature of the beans in any way.

    Application generation via XSL still remains as a major use of BML. This allows one to generate (from a server say) a Java application instead of an HTML application in response to a query against the server for some XML content.

  5. What features might we see in a future version of BML?

    We expect to add one major function in the next major release: the ability to define a bean using a BML document. As a corollary, we will also add the ability to create pseudo (or virtual) beans by saying something like: bean class="foo.bml"/.

    BML's architecture is fully extensible and if there's interest we will document it and make it available. The extension framework which was mentioned earlier is also in the same category!


REQUIREMENTS
Click here to view the
Installation Procedures

BML Platform Requirements
Platform Win NT, Solaris 2.5, and any other Java platforms
Java tool JDK 1.1.6 or greater (it may work with older versions, no guarantees)
Additional Java packages We use IBM's XML4J XML parser in our development (and is included in this distribution for use by the sample driver). You are free to use whatever XML parser you want as long as it produces a DOM that's compatible with the October 1, 1998 DOM recommendation of the W3C.
Browsers Both the player and the compiler require Java reflection to run. Currently browsers do not allow reflection access for applets; which means that the player cannot be embedded as an applet. However, the Java plug-in from Javasoft, does allow reflection and works well as a host for the player within a browser.


Installation Procedures

Installation Procedures

  1. Download and unzip the bml22.zip file into a new directory

  2. Follow additional installation instructions in the README file.

    Unzip the zip file to create:

      - README
      this file
      - changes.html
      list of changes to BML

    doc/

      -bml.dtd
      DTD
      - api
      API documentation (javadoc)
      - guide.pdf
      user's guide
      - guide.ps
      user's guide
      - tutorial.pdf
      tutorial
      - tutorial.ps
      tutorial
      - tutorial.ps
      tutorial

    demos/

    BML samples - see READMEs in each directory for instructions on how to run

    lib/

    jar files

      - bmlall.jar
      jar file with all bml stuff. Use this in your classpath unless you are concerned about size as this will give you all the bml things: player, compiler and extensions.
      -bmlcompiler.jar
      bml compiler
      - bmlextensions.jar
      bml extensions: currently dynamic event adapter generator and BML-provided event adapters
      - bmlplayer.jar
      bml player
      - xml4j_1_1_9.jar
      IBM's XML4J xml parser jar file. You do not *have* to use this xml parser unless you use the sample BML drivers in the demos/driver directory (those are coded to use the XML4J parser). For general use, use any parser that produces a DOM compatible with the 10/01/98 DOM recommendation works.
      - src/
      BML source (not in alphaworks version yet)

Additional files to download:

  • If you want to define scripts in JavaScript, you need to download js.jar & place it in your classpath.
  • If you want to define scripts in NetRexx, you need to download NetRexxC.zip & place it in your classpath.


DOWNLOADS
File Size Comments  
bml22.zip 978 KB ZIP file containing Bean Markup Language (BML) package.
js.jar.zip 978 KB Zip file containing the JavaScript jar file to run ‹script› in Java Script.
NetRexxC.zip 978 KB NetRexx zip file to run ‹script›s in NetRexx.