Professional Documents
Culture Documents
Created 04/14/05 Updated 07/10/05, Updated 10/15/05, Updated 01/01/06, Updated 01/31/06, Updated 03/25/06, Updated 04/29/06 Updated 05/21/06, Updated 02/18/07, Updated 03/02/07, Updated 04/01/07, Updated 08/30/07, Updated 09/12/07 Updated 02/27/08, Updated 03/02/08, Updated 03/12/08, Updated 03/23/08, Updated 07/10/08, Updated 08/07/08 Updated 03/17/09, Updated 04/27/11
Introduction
MyEclipse is one of the largest plug-ins provided for Eclipse, but dont think of it as a plug-in, think of it as a complete environment. MyEclipse adds tools for J2EE developers and for configuration of related Java tools, such as Web frameworks including Struts, Spring, and Tapestry. There are also tools for handling database mappers. When we first began to use it, the most important feature is that it adds JSP compilation in the editing environment, which is important for finding problems before run-time. The second most important feature is that it adds XML and DTD processing to the Eclipse environment, to aid in creating configuration files for web services, Hibernate mappings, Spring definitions, etc. The third most important feature is that it provides facilities to manage deployments to application servers such as Tomcat and WebLogic. Here is a diagram of the layers of capabilities in MyEclipse:
Page 1 of 19
MyEclipse is from Genuitec, at www.myeclipseide.com. They call it the Enterprise Workbench. Their business model is one of providing software on a subscription basis, at a low annual fee. The relationship between MyEclipse and the various projects within the Eclipse community is one of consolidation and shrink-wrapping. MyEclipse itself is heavily based upon the Eclipse tools, particularly the Enterprise Modeling Framework and the Web Tools Project. But rather than a developer having to fetch each of these and track down version incompatibilities, MyEclipse provides a known consistent development point, with additional capabilities such as the Image Editor and the UML editor that are not in any of the Eclipse projects.
Page 2 of 19
MyEclipse UML Editor Enhanced Oracle Connector JavaScript Debugger Image Editor
The Professional subscription has a cost of $52.95 per developer per year including handling costs We have an account on the MyEclipseIDE web site, which is jrisberg, and the usual password. We purchased a Standard subscription for $31.75 on 02/07/05, and renewed as of 01/30/06, 02/09/07, and early 2008. MyEclipse is to be installed in a directory that is NOT the Eclipse install directory. Currently on the T43, T60 and T61, we have Eclipse in C:\eclipse, and MyEclipse in C:\myEclipse. This is all set up by the Enterprise Workbench installer program that is the download from the MyEclipse web site. You then register it using the registration code, entering the code into a dialog box from the MyEclipse menu. We have found that MyEclipse installs all of its plugins and features into a directory within the MyEclipse directory. As of release 6.0.1, they include the following tools and versions: Eclipse Modeling Framework (EMF) 2.2.1 Graphical Editing Framework (GEF) 3.2.2 Java EMF Model (JEM) 1.2.1 Web Tools Project (WTP) 2.0.0, which also contains the Database Explorer
It appears that by installing these in a separate area, the MyEclipse main type list controller can group all of the new supported file types under a group called MyEclipse. However, the full list of file types can be shown by selecting the Show All Wizards button at the bottom of the screen. There is a note on the MyEclipse board that the recommended Eclipse memory configuration is specified as:
eclipse.exe vmargs Xms128M Xmx512M XX:PermSize=64M XX:MaxPermSize=128M
We have found this to be critical for MyEclipse versions 5.x, and it may have been raised in 6.x. The best approach to standardizing this configuration is to put it into the eclipse.ini file, which is the eclipse installation directory. Remember that when editing this file, you must place each argument on a separate line, and you must not use Notepad to edit the file at any time, or it will change the end-of-line codes. Not following these rules will mean that your .ini file is ignored by Eclipse.
Features
The MyEclipse capabilities are organized around file types, templates of files to be created for rapid set-up, and file editors. All of these fit within the types, tools, and wizards listed on the Eclipse File New menus which are used for creation of a file or object. The resulting list (expanded to show those most relevant to our development) looks like:
Page 3 of 19
MyEclipse adds several new file types that are related to J2EE 1.4 files and formats. It provides editors for HTML, Struts, JSF, CSS, JavaScript, SQL, Hibernate, and J2EE deployment descriptors, featuring: Code completion and syntax coloring Integrated outline edit view with insert/delete/move node capabilities Integrated editable properties view Open-On feature for selected text entities such as JSP fragments, Java classes, linked CSS and JavaScript files JSP source editor JSP 2.0 support JSP syntax validation and native JSP debugging - full support for JSR045 Supports breakpoints in both JSP files and included fragments JSP preview that depicts Struts HTML tags File level validation and error marking Real-time validation and error marking "as you type" Ability to edit any JSP file regardless of directory location
The largest pieces of code within the MyEclipse distribution (as measured in terms of why the download for MyEclipse is three times larger than sum of EMF, WTP, GEF, and JEM) is the addition of the Image Editor, the UML modeler, the Mozilla-based browser (which is used for previews), and the JavaScript debugger.
Page 4 of 19
At the level of basic XML and XSD editing, there is smart code completion, DTD caching for offline support and outline navigation viewer: Support for XSL and DTD design User-extensible XML DTD/Schema catalog Code completion and syntax highlighting for DTD-based or XSD-based documents Formatting and real time validation "as you type" Graphical editing for XSD files Create example XML document for any XSD file
Validation is provided for HTML, XML, XSD, DTD, JSP, XSL and XMI files Visual HTML Designer for WYSIWYG development, real-time preview, and round trip code generation Java Server Faces (JSF) configuration Editor - JSF 1.1 library upgrade from JSP 1.0 Database Explorer, 25 DB-JDBC connector profiles, SQL editor with code completion and SQL query evaluation and testing. Preserve explorer tree expansion state on refresh and table select Quick refresh of selecting tables in explorer or connections in connection Info view Improved project integration Supports multiple table selection Hibernate development tools with productivity wizards, code generation, and DB Explorer connector integration: Generation of Hibernate mapping files and corresponding Java classes directly from Database Explorer table selections Simplified project and package selection for generated classes and mapping files Support for composite ids and one-to-many relationships with other mapped objects Designate a custom base persistence class for all generated classes Regenerate mapped classes at any time to synchronize with database schema changes Update previously configuration file with auto-generated mappings Code generation is accomplished using flexible and customizable Velocity templates Generated Hibernate configuration file and SessionFactory reflect proper runtime classpath-relative locations
XDoclet support options. Ad-hoc image preview for GIF, JPG, BMP, PNG, ICO image types, in addition to the Image Editor in the Professional Edition. Snippet catalog with included library of HTML, JavaScript, CSS, JSP, Struts, and JSF snippets JSTL project support, allowing you to quickly add JSTL 1.0 Jars and Taglibs to any web project.
Resources
There are no third-party resources for learning to use MyEclipse at present. Most of what is available is located in the help files and guides. In Eclipse, select Help Contents from the Help menu. The ones for MyEclipse are in the MyEclipse Learning Center, which has the following topics as of 6.x:
Page 5 of 19
We have worked the most with Java EE projects and App Servers, Web Development and JPA/Spring/Hibernate Development. JEE is the new term after J2EE, which includes Java 5. This organization of the Learning Center was introduced in the 4.1 and later releases, and is an improvement over the help files in prior releases, but they continue to give the impression that MyEclipse is a large set of tools joined together, not all of which have a standard interface or terminology.
Page 6 of 19
Note that the javaee.jar includes the servlet and jsp API, plus JST, and a default implementation of JSF (later, we can add more JSF component libraries and facelets). This also took us into the MyEclipse Java Enterprise Development perspective, which has windows open for the outline view, and for managing servers.. Then we created a servlet under src, and directory for JSPs and for images under the WebRoot folder. Changed the JSP to include the image, and changed the servlet to generate an ArrayList of names, and then pass to the JSP. The JSP then iterated over the list of names and put them into an HTML table. The JSPs used JSTL tags instead of scriptlets throughout. When the Servlet class was added, the MyEclipse automatically updated the web.xml file to refer to it. The result is that we had the basic structure of a web application ready in minutes, rather than hours. For deployment of a web application, there are tools to manage the servers. Use the Deploy MyEclipse J2EE Project to Server command. This will bring up a list of servers. Define your server. Use the Deploy and Redeploy buttons. From the Java Enterprise Perspective, (or by adding the Servers view to another Perspective) you can start and stop the servers, such as Tomcat or JBoss. MyEclipse comes with a copy of Tomcat (currently version 6.0.13), and you can configure a copy of JBoss. There are two commands to start the server: Run, and Debug. The debug command will cause the deployed application to be placed into debug mode, which will allow you to place breakpoints, and make changes to code files. In addition, if Tomcat is started in debug mode, MyEclipse will have Tomcat automatically reload the changed files (regular mode doesnt). You can even put breakpoints into the Java scriptlets of JSP files.
Page 7 of 19
The Grid tab views and edits the file as a tree, while the Source tab views it as text. There are editing commands to clean-up and reformat the XML file. Syntax errors are shown with red markers to the left, just as with Java source. There is also way to create a file using a DTD specification, or validate against a DTD specification. These editing tools are similar to those in XMLBuddy, which we tested in April 2006. When editing an XML file, the outline view lists every element, and shows the nesting level. The main feature that we found lacking was a feature to collapse XML source branches, in same the way that the Java editor has a code folding feature. Next try out the HTML file type provides an editor with Source, Design, Design/Source, and Preview facilities. The Design mode includes a button-driven editor for HTML, much like a simple version of Dreamweaver or GoLive. There are also formatters and checkers. The Code Assistant now provides information about what HTML attributes are possible on which tags. This is very useful. Clean Up is more powerful than format, as it carries out a Format and can adjust the case of the tags, for instance.
Editing a JSP
Editing a JSP is a combination of editing Java and editing HTML. For instance, the parser determines if you in are a scriptlet tag or not, and offers Java or HTML code completion. The code completion facility, which knows the list of possible attributes for each of the JSP and HTML tags, and will offer them in a pop-up while editing source There are quite a few formatting facilities for JSP pages, mostly similar to those for XML or HTML. There is a design view and a preview view. There is also a code folding facility as of 5.1, which was missing in earlier releases. You can fold a scriptlet, as well as fold an HTML element and its subelements. Like NetBeans 3.5.1, MyEclipse has a facility to compile JSPs (as with the rest of Eclipse, this is done on Save). It gives you a set of markers for errors, which are red marks on the right side of the file lines. Moving the mouse over the red mark shows a mouse-over text giving the error. Having this editing and validation support is really quite powerful, however, there are still a few too many situations where the code is using JSP scriptlets in the middle of html elements that can cause the validator to generate an incorrect conclusion, particular if the there are scripts and scriptlets that are changing the scoping or grouping. However, if you think through the structure exactly as a DOM-like tree, and not play tricks in the scriptlets, then the page will be very clean and the editor/validator will help you greatly. For instance, the following produces incorrect validation
<% String selectedStr = ""; if (bCurItem) selectedStr = "checked"; %> <input type="radio" name="example" <%= selectedStr %>>
You can see from this just how picky the validator is being, even requiring the checked attribute to have a value.
Page 8 of 19
Next, we updated the Hibernate configuration file to use annotations, and changed the configuration initialization code to use an AnnotationConfiguration object. The HibernateSessionFactory performs a version of the following initialization statements, but in a thread-local manner: config = new AnnotationConfiguration(); config.configure(); sessionFactory = config.buildSessionFactory(); newSession = sessionFactory.openSession(); We have focused on an example project that is defined as the following: Java 1.5 Servlet 2.5 JSTL JSF Hibernate
Page 9 of 19
Hibernate Annotations
In these case, the web application framework is JSF, rather than Spring or Struts. We have derived a sample program from the program developed in the book JBoss at Work, and our example program supports List Views, plus CRUD operations on two related domain objects, (Cars and Inventory).
Note: an Enterprise Project must contain at least 1 Web Project or EJB Projects. My Eclipse allows you to create a project of either type, or project which combines both as sub projects, as shown in the following diagram:
Page 10 of 19
In practice, the WAR files are typically bound into the EAR files. To apply this approach, create the Enterprise Application Project, as shown in the below window, and select the Creation Tasks of New web module project, and New EJB module project.
Page 11 of 19
The contents of the three resulting projects will be similar to: Main: has METADATA: application.xml. This defines the modules, and the name for the web part. EJB: contains the Java EE libraries, contains all the source code. The EJB code will contain all of your entity and session beans. Since we are using JEE 5.0 with annotations, no extra configuration files are needed. Place all of the EJB libraries here. Web: defines all of the source code for backing beans, servlets, and web utilities, plus the web.xml configuration and other files related to Web applications tools that are being used, such as JSF. This project also contains the WebRoot directory, which includes the web files (.jsp or .xhtml), image files, CSS files, and the WEB-INF directory.
If you select Java Persistence during the time of creating the project, you will be asked for the database connection information, and the appropriate files will be created. MyEclipse will maintain the application.xml file in the top-level project. A typical appears below:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd"> <application> <display-name>TraderX</display-name> <module id="myeclipse.1057625013008"> <web> <web-uri>TraderXWeb.war</web-uri> <context-root>/TraderWeb</context-root> </web> </module> <module id="myeclipse.1058128801619"> <ejb>TraderXEJB.jar</ejb> </module> </application>
Page 12 of 19
5. 6.
Page 13 of 19
General Features
Database Browser for navigating the structure of a database o Hierarchically browse schema, tables, views, sequences, ... ER Designer provides graphical view of database structure o Smart auto-layout of tables and relationships o User sizable and positionable tables and relationship connections o Colors and fonts preferences o Export as PNG, JPG, BMP
Page 14 of 19
Database Explorer Perspective SQL Editor o Syntax color highlighting o Table and column name highlighting o Table and column name auto-completion (Ctrl+Space) o Associate editor with database connection and execute SQL snippets Multiple database connection management SQL generation utilities
These tools are a good subset of the tools in Squirrel or SQL Developer.
As of MyEclipse release 6.0.1, the copy of Hibernate is 3.2.x which was the then-current standard. We are not clear on what connection caching system is being used with this configuration. The typical installation uses c3po, but that is not included. What is useful about this list is that it defines a working core of libraries for Hibernate (once we add in a JDBC connector library). The Hibernate configuration file dialog box is as follows:
Page 15 of 19
It provides a simple way to configure the connection to one database, and to specify the list of mapping files. For commonly used DBConnectProfiles, there is a set of definitions, stored in area that is available across projects. This enables you to quickly create or set up a Hibernate configuration. If you use the Hibernate configuration viewer in a project that didnt have Add Hibernate Capabilities applied to it, you will get a warning dialog verifying that Hibernate 3.1 conventions should be used. This actually works fine, since there were no changes to the configuration conventions between Hibernate 3.1 and 3.2. After finding out that MyEclipse contains the complete libraries for tools such as Hibernate, we can better understand why the install size is so large for MyEclipse! There is also a facility to create a Hibernate mapping file and the corresponding DTO and DAO objects in Java, by reverse engineering from the database. You first connect to the DB, and then specify the table to use. The reverse engineering wizard can generate: The mapping file. The DTO class. This can have a specified superclass, but other than that includes pretty much the standard fields as one-to-one mappings. The DAO class. This will have methods such as save, delete, merge, attachDirty, attachClean, plus findBy methods for each of the properties in the class.
Unfortunately the reverse engineering wizard will not generate the non- one-to-one mappings. Basically it is only working on one table at a time. In addition, when it generates the DTO classes, it doesnt put in collections where it should. However, the literature for MyEclipse states that it will generate a one-to-many, but we have been able to perform this. After a mapping file has been created, it can be edited using the Hibernate Mapping Editor. This is an XML editor window that is enhanced with:
Page 16 of 19
Hyperlink navigation to referenced classes and properties. Class name auto-completion. Property name auto-completion. Content assist for mapping file elements, attributes and values
Finally, MyEclipse includes a Hibernate Query Language editor and several views that allow you to execute HQL queries against your Hibernate configuration.
Some of the capabilities of this tool are: creation of the JSP code, navigation through the elements of the page. One of the related tools will create the faces-config.xml file that includes actions and forwards to be defined. The way to use this screen is to visually drag and drop the object from the menu on the left, place it into the page being created, and use the properties facility on the right side. More information about JSF and support within MyEclipse is located in our file Notes on JSTL and JavaServer Faces.
Page 17 of 19
Since the majority of the effort in Spring development is writing the Controller classes (which are similar to Struts actions), this is a helpful way to navigate around the structure of your application. Create a new Spring bean definition by dragging and dropping a Java class from the Package Explorer view onto the Spring Bean Editor. This action will invoke the New Spring Bean Wizard prepopulated with the dropped classes as properties and constructor arguments. In the following screenshot the Person class was dropped on the editor.
Page 18 of 19
Page 19 of 19