User: andreas
Date: 00/10/14 09:42:05
Modified: . getting_startedJB2.htm
Added: . EJX.HowTo.Getting-Started.html
Removed: . EJX.Getting-Started.HowTo.html ejx-project.zip
Log:
The EJX HowTo now uses the EJX CVS Module instead
of my own project.
I also renamed the file because it should not remain the
only one and I added it to the jBoss Getting Started Web
Page.
Revision Changes Path
1.10 +1 -0 jbossweb/getting_startedJB2.htm
Index: getting_startedJB2.htm
===================================================================
RCS file: /products/cvs/ejboss/jbossweb/getting_startedJB2.htm,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- getting_startedJB2.htm 2000/10/12 18:13:19 1.9
+++ getting_startedJB2.htm 2000/10/14 16:42:04 1.10
@@ -74,6 +74,7 @@
<p><font face="Myriad Web,Arial"><a
href="rmh_howto.html">RMH (run the examples) Howto</a></font></p>
-->
<p><a href="JMX.Connector.Howto.html"><font face="Myriad
Web,Arial">JMX Connector Howto</font></a></p>
+
<p><a href="EJX.Howto.Getting-Started.html"><font
face="Myriad Web,Arial">EJX HowTo: Introduction</font></a></p>
<p></p>
<p><font face="Myriad Web,Arial"><b>Container developer
documentation</b></font></p>
<p><a href="container.html"><font face="Myriad
Web,Arial">jboss container architecture.</font></a></p>
1.1 jbossweb/EJX.HowTo.Getting-Started.html
Index: EJX.HowTo.Getting-Started.html
===================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>EJX/AWT Introduction and HowTo</TITLE>
<LINK REL="stylesheet" type="text/css" href="HowTo.css" >
</HEAD>
<BODY>
<DIV class="page">
<H1>EJX/AWT Description and HowTo</H1>
<H2>Introduction</H2>
<H3>EJX/AWT written by <A href="mailto:[EMAIL PROTECTED]" >Rickard �berg</A></H3>
<DIV class="para" ALIGN="left">
Both packages are created by Rickard �berg and are available at his DreamBean
Website: <A HREF="http://www.dreambean.com">www.dreambean.com</A>. Both packages
are heavily used in jBoss do create/maintain EJB descriptor and other XML files.
</DIV>
<DIV class="para" ALIGN="left">
The reason or motivation for me to write this HowTo was that I struggle to
understand EJX
and AWT. On the other hand Rickard was so busy with other stuff that I had to dig
throug
myself and to save time for other members of jBoss I started writing this HowTo. This
document is <B>still under construction</B> and will maybe never be finished.
</DIV>
<H4>Idea of EJX</H4>
<DIV class="para" ALIGN="left">
EJX is a package and runtime environment enabling you to create a plugin to add new
functionality and new GUI elements. EJX will dynamically lookup for plugins on the
<B>predefined</B> package <B>/lib/ext</B> and load them for you. Whenever you create
a new file or open a given file it will instantiate your plugin and show as an Frame
within
the EJX framework.
</DIV>
<DIV class="para" ALIGN="left">
EJX uses XML but at the moment this is not quite clear for me but I am working on it
(AS 9/15/00),
</DIV>
<H4>Idea of AWT</H4>
<DIV class="para" ALIGN="left">
AWT (or here called <I>Advanced Window Toolkit</I> and do not mix it up with
<B>java.awt.*</B>) enables you to use an uniform GUI Environment and to use
BeanContext
with an easy to write XML definition file.
</DIV>
<DIV class="para" ALIGN="left">
I am still at the beginning to understand AWT and EJX but I will upgrade this
document
as soon as I have more information and <B>examples</B>.
</DIV>
<H2>Project</H2>
<H3>Introduction</A></H3>
<DIV class="para" ALIGN="left">
Based on the first draft of this document I separated the core EJX stuff from the
EJX examples
to make it a little bit more clear. Afterwards I implemented these changes in the
EJX module
of jBoss CVS server. If you now download the EJX module you can create a slim
release of EJX
without the examples. If you need them you can just jump to the examples directory
and build
the example from there (one by one) and only the examples you want or need.
</DIV>
<H3>Structure</A></H3>
<DIV class="para" ALIGN="left">
To go through this document download the EJX module from the jBoss CVS server.
</DIV>
<DIV class="para" ALIGN="left">
<B>Attention:</B> Before you start with compiling any examples you <B>have</B> to
run the
compilation of the core project first. For this go to the "ejx/src/build"
and start the
build.bat file. This compiles the core project, copies the necessary jar-files to
the right
place and creates the necessary ejxeditor.jar file.
</DIV>
<DIV class="para" ALIGN="left">
Now you are ready for the examples.
</DIV>
<H3>Plain Pane Example</A></H3>
<DIV class="para" ALIGN="left">
This example can be found under "ejx/examples/plain.pane".
</DIV>
<DIV class="para" ALIGN="left">
This was my first example and the goal was to creat a Panel within EJX framework to
display
just a simple text. I used this example to find simplest example within EJX.
</DIV>
<DIV class="para" ALIGN="left">
According to the EJX spec the only necessary thing you have to to is:
<OL>
<LI>
Create a class extending the com.dreambean.ejx.FileManagerFactory interface
</LI>
<LI>
Create a class extending the com.dreambean.ejx.FileManager interface
</LI>
<LI>
Create an appropriate Manifest file with looks like this for this example:
<PRE class="code" ALIGN="left">
Class-Path: awt.jar ejb.jar
EJX-plugin: com.madplanet.plainPane.FileManagerFactoryImpl
Name: com/madplanet/plainPane/
Specification-Title: PlanePane 0.1
Specification-Version: v0.1
Specification-Vendor: MAD plaNET plc
Implementation-Title: ejx-plain-pane
Implementation-Version: build1
Implementation-Vendor: MAD plaNET plc
</PRE>
</LI>
<LI>
Compile these two classes
</LI>
<LI>
Put these two classes and the Manifest file into a jar-file (name does not matter
but I always name it this way: ejx.<ProjectName>.jar).
</LI>
<LI>
And last but not least the just created jar-file into the ejx/dist/lib/ext
directory.
</LI>
</OL>
Now the only thing left is to start EJX (go to ejx/dist/bin directory and start
EJX with "java -jar ejx.jar"). When the EJX Frame comes up go to
file/new and select "Plain Pane XML" and you will see our plugin
coming up.
</DIV>
<DIV class="para" ALIGN="left">
Now let's have a closer look to the classes we created in our plugin.
</DIV>
<H4>FileManagerFactoryImpl</H4>
<DIV class="para" ALIGN="left">
Implements the com.dreambean.ejx.FileManagerFactory and enables the EJX
framework to select the right file for you. But now let's delf into the code
<UL>
<LI>
Classes to be imported
<PRE class="code" ALIGN="left">
import java.io.File;
import javax.swing.filechooser.FileFilter;
import com.dreambean.ejx.FileManager;
import com.dreambean.ejx.FileManagerFactory;
</PRE>
</LI>
<LI>
Class definition (to extend this class from FileFilter is just convenience because
it is needed either way):
<PRE class="code" ALIGN="left">
public class FileManagerFactoryImpl
extends FileFilter
implements FileManagerFactory
</PRE>
</LI>
<LI>
These methods must be implement due FileManagerFactory interface. The first
method creates the FileManager when a file is selected or in a given directory
a new one can be created. The second method returns a FileFilter to select a
file or directory and the last is used to get a name for the Plugin to select the
right one.
<PRE class="code" ALIGN="left">
public FileManager createFileManager() {
return new FileManagerImpl( this );
}
public FileFilter getFileFilter() {
return this;
}
public String toString() {
return "Plain Pane XML";
}
</PRE>
</LI>
</UL>
</DIV>
<H4>FileManagerImpl</H4>
<DIV class="para" ALIGN="left">
Implements the com.dreambean.ejx.FileManager and enables the plugin
to decide what GUI element to display. For each file or directory selected
a new instance of this class is created.
<UL>
<LI>
Classes to be imported
<PRE class="code" ALIGN="left">
import java.awt.BorderLayout;
import java.awt.Component;
import java.beans.beancontext.BeanContextServicesSupport;
import java.io.File;
import javax.swing.JPanel;
import javax.swing.JLabel;
import com.dreambean.ejx.FileManager;
import com.dreambean.ejx.FileManagerFactory;
</PRE>
I am only so pitty about what classes are imported to show you at the
header where the used classes are coming from.
</LI>
<LI>
Constructor of the class:
<PRE class="code" ALIGN="left">
FileManagerImpl( FileManagerFactory pCaller ) {
mFactory = pCaller;
}
</PRE>
</LI>
<LI>
Methods must be overwriten by the class, The important part is the
getComponent() method which is called by the EJX framework to get
the GUI component to be displayed.
<PRE class="code" ALIGN="left">
public boolean isChanged() {
return true;
}
public void createNew() {
}
public void load( File file )
throws Exception
{
}
public void save( File f )
throws Exception
{
}
public File getFile() {
return null;
}
public void setFile( File pFile ) {
}
public FileManagerFactory getFactory() {
return mFactory;
}
public Component getComponent() {
JPanel lPane = new JPanel( new BorderLayout() );
lPane.add(
new JLabel( "<HTML><BODY><H1>Hello
World</H1>" +
"<H2>Next
Step</H2></BODY></HTML>" ),
BorderLayout.CENTER
);
return lPane;
}
</PRE>
</LI>
</UL>
</DIV>
<H3>Simple Component Example</A></H3>
<DIV class="para" ALIGN="left">
This example can be found under "ejx/examples/simple.component".
</DIV>
<DIV class="para" ALIGN="left">
This example is an introduction to AWT and how it can be used to define a GUI by the
XML description file, compiled and display on the Panel in the EJX framework. To
shorten
the further discussion I only show the important stuff having changed or is new.
</DIV>
<DIV class="para" ALIGN="left">
The only thing with AWT you have to consider is that you have to use XMLBeans to
compile
the BeanInfo XML description into a Java class and then to compile it to a java
bytecode
class. For that have a look at the build.xml and look for xmlbeans.
</DIV>
<DIV class="para" ALIGN="left">
According to the AWT spec the only necessary thing you have to to is:
<OL>
<LI>
Create an Bean Info XML description file like this:
<PRE class="code" ALIGN="left">
<bean
class="com.madplanet.simpleComponent.MainPane"
displayname="Simple Component's Main Pane"
iconcolor16="/images/container.gif">
<property
name="FirstProperty" class="java.lang.String"
displayname="First Property"/>
<property
name="SecondProperty" class="java.lang.String"
displayname="Second Property"/>
</bean>
</PRE>
</LI>
<LI>
Create a GUI component class and add the GenericCustomizer to it (as parameter
you have to pass the class instance which is referred above (here it is
com.madplanet.singleComponent.MainPane). There are other classes you can use
but at the moment I have no more informations.
</LI>
<LI>
Compile all the java classes
</LI>
<LI>
User XMLBeans to create the java sourcecode from the XML beaninfo. The newly
created java classes are named like the referred class but with Beaninfo at
the end (same package structure).
</LI>
<LI>
Compile the bean info java sourcecode files.
</LI>
</OL>
That's it.
</DIV>
<H4>FileManagerImpl</H4>
<DIV class="para" ALIGN="left">
Like the one before except the getComponent() method:
<PRE class="code" ALIGN="left">
public Component getComponent() {
// Create the Property Container and return its GUI component
return new MainPane().getComponent();
}
</PRE>
</DIV>
<H4>MainPane</H4>
<DIV class="para" ALIGN="left">
This class now creates the GUI component using AWT to display the properties
this class have.
<UL>
<LI>
Classes to be imported
<PRE class="code" ALIGN="left">
import java.awt.BorderLayout;
import java.awt.Component;
import java.beans.beancontext.BeanContextSupport;
import java.beans.beancontext.BeanContextChildComponentProxy;
import javax.swing.JPanel;
import com.dreambean.awt.GenericCustomizer;
</PRE>
</LI>
<LI>
This class has to supclass the BeanContextSupport
<PRE class="code" ALIGN="left">
public class MainPane
extends BeanContextSupport
</PRE>
</LI>
<LI>
There are the properties the Main Pane offer and which can
then be set by GUI component defined by the Bean Context
<B>Attention:</B> All the properties in the BeanInfo XML file need
here a public getter and setter method with the appropriate
type.
<PRE class="code" ALIGN="left">
public String getFirstProperty() {
return mFirstProperty;
}
public void setFirstProperty( String pToSet ) {
mFirstProperty = pToSet;
}
public String getSecondProperty() {
return mSecondProperty;
}
public void setSecondProperty( String pToSet ) {
mSecondProperty = pToSet;
}
</PRE>
</LI>
<LI>
This method returns the GUI component which contains the Generic
Customizer need to display the properties of this instance accordingly
to the Bean Info XML description mentioned above.
<PRE class="code" ALIGN="left">
public Component getComponent() {
JPanel lPane = new JPanel( new BorderLayout() );
lPane.add(
new GenericCustomizer( this ),
BorderLayout.CENTER
);
return lPane;
}
</PRE>
</LI>
</UL>
Eh voil�, that's it. When you build this example, start EJX and select
Simple Component XML you will see two lines with the tag "First Property"
and a Text Field (and also for Second Property).
</DIV>
<DIV class="para" ALIGN="left">
That's all for now. In the next step I will delf further into AWT and how
you can use the Bean Info XML description to describe more advanced application.
In addition I will then use the save() and load() method to load XML files
which are the persistent part of a plugin.
</DIV>
<DIV class="footer" ALIGN="left">
I anything is wrong or not correct please contact me at
<A HREF="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</A>.
Also if you want to know more in detail or have a request for changes in this
HowTo document.
</DIV>
</BODY>
</HTML>