⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch13s101.html

📁 详细介绍了jboss3.0的配置等
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<html><head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   <title>EJX/AWT Development HowTo</title><link rel="stylesheet" href="styles.css" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/styles.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets Vimages/callouts/"><link rel="home" href="index.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/index.html" title="JBoss 3.0 Documentation"><link rel="up" href="ch13.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13.html" title="Chapter 13. HOWTO"><link rel="previous" href="ch13s98.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13s98.html" title="Using JavaMail in JBoss"><link rel="next" href="ch13s126.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13s126.html" title="External JNDI Configuration and JNDI Viewing"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table border="0" cellpadding="0" cellspacing="0" height="65"><tr height="65"><td rowspan="2"><img src="jboss.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/jboss.gif" border="0"></td><td rowspan="2" background="gbar.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/gbar.gif" width="100%" align="right" valign="top"><a href="index.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/index.html"><img src="doc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/doc.gif" border="0"></a><a href="ch13.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13.html"><img src="toc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/toc.gif" border="0"></a><a href="ch13s98.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13s98.html"><img src="prev.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/prev.gif" border="0"></a><a href="ch13s126.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13s126.html"><img src="next.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/next.gif" border="0"></a></td></tr><tr></tr></table><div class="section"><a name="d0e11311"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="d0e11311"></a>EJX/AWT Development HowTo</h2></div></div><p>Author:<span class="author">Andreas Shaefer</span>
		<tt>&lt;<a href="mailto:andreas.schaefer@madplanet.com">andreas.schaefer@madplanet.com</a>&gt;</tt>     
	</p><div class="section"><a name="d0e11325"></a><div class="titlepage"><div><h3 class="title"><a name="d0e11325"></a>Introduction</h3></div></div><p>         This How To serie is about how to develop EJX plugins with the help of Rickard's AWT, XML and
         BeanContext and NOT about how to use EJX and its plugins (at least for now)!! </p><div class="orderedlist"><ol type="1"><li><p><a name="d0e11331"></a>
					<a href="ch13s101.html#ejx1" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13s101.html#ejx1" title="EJX Insights">Insights to EJX internals by Simon Bordet</a>
				</p></li><li><p><a name="d0e11337"></a>
					<a href="ch13s101.html#ejx2" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13s101.html#ejx2" title="Getting strted with EJX">Getting started with EJX</a>
				</p></li><li><p><a name="d0e11343"></a>
					<a href="ch13s101.html#ejx3" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13s101.html#ejx3" title="EJX/AWT GUI Basics HowTo">GUI Basics</a>
				</p></li></ol></div><p>         Next steps
         </p><div class="orderedlist"><ol type="1"><li><p><a name="d0e11352"></a>How to use resources (especially XML files) in EJX </p></li><li><p><a name="d0e11355"></a>Advanced GUIs </p></li></ol></div></div><div class="section"><a name="ejx1"></a><div class="titlepage"><div><h3 class="title"><a name="ejx1"></a>EJX Insights</h3></div></div><p>EJX (created by Rickard Oeberg and are available at his DreamBean Website: www.dreambean.com) is a launcher for JavaBean plugins
that are written following the Glasgow specification, in particular the Extensible Runtime Containment and Services Protocol. This
document is intended for programmers that want to write plugins for EJX, and will (try to) explain the insights of the bean context
hierarchy of EJX, and also classloader issues regarding this hierarchy. </p></div><div class="section"><a name="d0e11363"></a><div class="titlepage"><div><h3 class="title"><a name="d0e11363"></a>The launcher</h3></div></div><p>com.dreambean.ejx.editor.Main is the launcher for EJX. It does the following: </p><div class="orderedlist"><ol type="1"><li><p><a name="d0e11369"></a>creates a new URLClassLoader, whose parent is the current context classloader </p></li><li><p><a name="d0e11372"></a>all files under ../lib and ../lib/ext are added to this URLClassLoader (PENDING: really all files or only jars) </p></li><li><p><a name="d0e11375"></a>the context class loader is set to this URLClassLoader  </p></li><li><p><a name="d0e11378"></a>the class com.dreambean.ejx.editor.EJX is instantiated using the new context class loader (ie the URLClassLoader) </p></li></ol></div><p>All plugins you would like to show in the EJX framework must be under ../lib or ../lib/ext, so that their classes can be loaded through the
context class loader. If this is not the case, your plugin is not even shown in the EJX first window, where you can choose, among the
available plugins, which one you want to use.</p><p>Every EJX plugin is archived in a jar and must have an entry in the manifest file that reads:</p><p>EJX-plugin: &lt;factory-class-name&gt;</p><p>where &lt;factory-class-name&gt; is the fully qualified name of the ResourceManagerFactory implementation that can instantiate the
ResourceManager implementation for that plugin.</p></div><div class="section"><a name="d0e11389"></a><div class="titlepage"><div><h3 class="title"><a name="d0e11389"></a>The bean context framework</h3></div></div><p>Following the Glasgow specification, JavaBeans can be logically grouped in containers, called BeanContext. A BeanContext can
contain other nested BeanContext, or directly BeanContextChild JavaBeans. While normal JavaBeans can be added to BeanContexts,
to obtain the full potentiality of the new framework, they should implement the BeanContextChild interface. A BeanContextChild is
normally a terminal child of the containment hierarchy, so it cannot have nested JavaBeans. JavaBeans, being they BeanContext or
BeanContextChild can be added to or removed from a BeanContext, and notification of these events is delivered to registered
membership listeners.</p><p>A BeanContext can expose services to its children, services that can easily accessed by them simply specifying the interface that
represent the wanted service. The interfaces that provides this support are BeanContextServices and BeanContextServiceProvider.</p><p>BeanContextServices is a BeanContext with the possibility to be queried for services that it hosts. BeanContextServiceProvider is the
service hosted by a BeanContextServices. Services can be added or removed from a BeanContextServices, and notification of these
events is delivered to registered service listeners.</p><p>Within this framework, JavaBeans can obtain a reference to the BeanContext in which they are hosted and thus be aware of the
environment in which they're running; plus they can query the BeanContext for services, if the BeanContext hosting them is a
BeanContextServices. If this BeanContextServices does not have the requested service, the request goes up in the hierarchy, eventually
finding the BeanContextServices that provides the service.</p></div><div class="section"><a name="d0e11400"></a><div class="titlepage"><div><h3 class="title"><a name="d0e11400"></a>The bean context root and the services</h3></div></div><p>As you may have guessed, com.dreambean.ejx.editor.EJX is a BeanContextServices instance, and is the root of the bean context
hierarchy of the application.</p><p>It hosts 2 services: </p><div class="orderedlist"><ol type="1"><li><p><a name="d0e11408"></a>a Preference service, used to store user preferences like screen size </p></li><li><p><a name="d0e11411"></a>an XMLManager service, used to allow JavaBeans to read from / write to XML files.</p></li></ol></div><p>Direct children EJX are the plugins, that implements the ResourceManager interface. ResourceManager extends BeanContextChild so
that implementors can be directly plugged in the containment hierarchy, but normally implementors of the ResourceManager interface
implements BeanContextServices, to provide plugin-specific services to their nested JavaBeans.</p><p>PENDING: add a figure / schema of the containment tree with different colors representing services</p></div><div class="section"><a name="d0e11418"></a><div class="titlepage"><div><h3 class="title"><a name="d0e11418"></a>Where the GUI comes in ?</h3></div></div><p>We saw the bean context hierarchy, but what you can see on the screen is not totally related to it (though there is a relationship). How
can EJX show the GUI for JavaBeans component seamlessly ?</p><p>Every JavaBean that wants to display a GUI in EJX must implement either BeanContextContainerProxy or
BeanContextChildComponentProxy. </p><p>com.dreambean.ejx.editor.EJX implements BeanContextContainerProxy and its getContainer() method expose a JDesktopPane of a
JFrame (also held by com.dreambean.ejx.editor.EJX [NOTE: this JFrame is not exposed (as of 15 Nov 2000), so it is not accessible from
nested JavaBeans if they want play with the menu bar. I have in mind to change this and indirectly expose the JFrame as a EJX
service]).</p><p>JDesktopPane is the specialized class that hosts JInternalFrames. Normally plugins implement the BeanContextChildComponentProxy
interface returning a java.awt.Component (subclass) that can be added to a JInternalFrame and finally added to the JDesktopPane.</p><p>The difference between BeanContextChildComponentProxy and BeanContextContainerProxy is that the former is implemented by
JavaBeans whose enclosing BeanContext is responsible to call getComponent and add the resulting java.awt.Component to some
existing GUI, while the latter is implemented by JavaBeans whose enclosed JavaBeans are responsible to call getContainer() and add to
this java.awt.Container GUI components taken from somewhere else. The former says "I know my children, let's take their GUI
components and add them here", the latter says "I know my parent, let's add this GUI components to its GUI container".</p></div><div class="section"><a name="ejx2"></a><div class="titlepage"><div><h3 class="title"><a name="ejx2"></a>Getting strted with EJX</h3></div></div><div class="section"><a name="d0e11434"></a><div class="titlepage"><div><h4 class="title"><a name="d0e11434"></a>Introduction</h4></div></div><p>       EJX/AWT written by Rickard Oeberg</p><p>         Both packages are created by Rickard Oeberg and are available at his DreamBean Website: www.dreambean.com.
         Both packages are heavily used in jBoss do create/maintain EJB descriptor and other XML files. 
         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 still under construction and will maybe never
         be finished. </p><p> Idea of EJX</p><p>         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 predefined package /lib/ext 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. 
         EJX uses XML but at the moment this is not quite clear for me but I am working on it (AS 9/15/00), </p><p>         Idea of AWT</p><p> 
         AWT (or here called Advanced Window Toolkit and do not mix it up with java.awt.*) enables you to use an
         uniform GUI Environment and to use BeanContext with an easy to write XML definition file. 
         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 examples. </p></div><div class="section"><a name="d0e11449"></a><div class="titlepage"><div><h4 class="title"><a name="d0e11449"></a>Project</h4></div></div><div class="section"><a name="d0e11452"></a><div class="titlepage"><div><h5 class="title"><a name="d0e11452"></a>Introduction</h5></div></div><p>      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. </p></div><div class="section"><a name="d0e11457"></a><div class="titlepage"><div><h5 class="title"><a name="d0e11457"></a>Structure</h5></div></div><p>      To go through this document download the EJX module from the jBoss CVS server. 
      Attention: Before you start with compiling any examples you have 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. 
      Now you are ready for the examples. </p></div><div class="section"><a name="d0e11462"></a><div class="titlepage"><div><h5 class="title"><a name="d0e11462"></a>Plain Pane Example</h5></div></div><p>      This example can be found under "ejx/examples/plain.pane". 
      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. 
      According to the EJX spec the only necessary thing you have to to is: </p><div class="orderedlist"><ol type="1"><li><p><a name="d0e11468"></a>Create a class extending the com.dreambean.ejx.FileManagerFactory interface </p></li><li><p><a name="d0e11471"></a>Create a class extending the com.dreambean.ejx.FileManager interface</p></li><li><p><a name="d0e11474"></a>Create an appropriate Manifest file with looks like this for this example: 

                         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 

              </p></li><li><p><a name="d0e11477"></a>Compile these two classes </p></li><li><p><a name="d0e11480"></a>Put these two classes and the Manifest file into a jar-file (name does not matter but I always name
                 it this way: ejx.&lt;ProjectName&gt;.jar).</p></li><li><p><a name="d0e11483"></a>And last but not least the just created jar-file into the ejx/dist/lib/ext directory. </p></li></ol></div><p> 
      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. 
      Now let's have a closer look to the classes we created in our plugin.</p></div><div class="section"><a name="d0e11488"></a><div class="titlepage"><div><h5 class="title"><a name="d0e11488"></a>FileManagerFactoryImpl</h5></div></div><p> 
      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 </p><p>                 Classes to be imported </p><pre class="programlisting">                         import java.io.File; 
				 import javax.swing.filechooser.FileFilter; 
                         import com.dreambean.ejx.FileManager; 
                         import com.dreambean.ejx.FileManagerFactory; 
				 </pre><p>                 Class definition (to extend this class from FileFilter is just convenience because it is needed either
                 way):</p><pre class="programlisting">                         public class FileManagerFactoryImpl extends FileFilter
                         implements FileManagerFactory </pre><p>   
                 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. </p><pre class="programlisting">  
                         public FileManager createFileManager() { 
					return new FileManagerImpl( this ); 
                         } 
				 public FileFilter getFileFilter() { 
					return this; 
				 } 
				 public String toString(){ 
					return "Plain Pane XML"; 
				 } 
				 </pre></div><div class="section"><a name="d0e11505"></a><div class="titlepage"><div><h5 class="title"><a name="d0e11505"></a>FileManagerImpl</h5></div></div><p>      Implements the com.dreambean.ejx.FileManager and enables the plugin to decide what GUI element to display. For each

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -