Pramati Technologies

Organizing Source Files

Studio provides an archetype called Desk, an intuitive and adaptable way of organizing and visually managing various artefacts that form the application under development. The Desk is a visual management tool and enables faster development cycles for J2EE applications by constantly tracking changes made to the application artefacts and making sure that the application is always in a ready-to-run state.

What is a Desk

The Desk is a logical organization of application artefacts into a hierarchical tree structure. The nodes of the Desk tree can be Modules, Archives, or general-purpose folders or files.

EJB and Web Modules function as complete J2EE applications in a ready-to-deploy state and the Java, Web and Enterprise Archives comprise their corresponding packaged components. The Desk also provides a general-purpose folder for storing other supporting files for building the application.

The developer has complete freedom to define the structure of the Desk, although one of the provided templates can be used as a starting point. Creating a Desk maps the structure on to an underlying directory structure in the file system. Creating a new Desk creates a corresponding folder with the same name in the file system. All meta data related to the desk and its components are stored in a file with the same name as the Desk and a .dsk extension.

Example

Creating a Desk myDesk under Studio installation directory creates the following folder and .dsk file:

<install_dir>/myDesk/myDesk.dsk

Desk Root

Creating a Desk creates a directory in the file system. The fully qualified path to this directory is called the Desk Root. The .dsk file is located under the Desk Root.

Example

If ArchiveDesk is created under the target location <install_dir>, then <install_dir>/ArchiveDesk represents the Desk Root. The file ArchiveDesk.dsk is stored under the location: <install_dir>/ArchiveDesk

Modules

The application source files are organized under Desk nodes called Modules. An application can contain many Modules, of different types indicating the nature of the contents of the Module. Studio Desk consists of three such types of Modules - EJB Module, Web Module, and Java Module.

EJB Modules can be of two types - EJB 1.1 and EJB 2.0. While EJB 2.0 modules can hold both 1.1 and 2.0 types of enterprise beans, EJB 1.1 modules can hold only 1.1 type of enterprise beans. The type of a Module is of significance, as different Studio tools could treat the content according to their type.

Source Root

The directory in the file system, where sources for Enterprise JavaBeans, Servlets, helper classes, and other Java files are physically located, is called the Source Root.

The Desk uses the Source Root to organize Java files in their class-package hierarchies. Studio expects the source files organized under Source Root to be in a directory tree, that matches the class-package hierarchy.

Every Module in the Desk has a Source Root. More than one EJB Module or Java Module can point to the same Source Root in the file system.

Java Module

This Module stores pure Java source files of an application and points to a Source Root in the file system.

Example

In the above illustration, ArchiveDesk is a Desk stored in <install_dir>. Java Mod represents a Java Module and points to a Source Root (c:/src_root). Hello.Java is a Java file with the package class hierarchy com.pramati and stored under Java Mod in the Desk.

Though the file is stored in the following path c:/src_root/com/pramati, the Desk represents it as ArchiveDesk/Java Mod/com/pramati

EJB Module

The EJB Module represents an extracted view of an EJB Archive (JAR). The module points to a Source Root and is always stored under the Desk node in the Desk hierarchy. The Source Root contains all files forming the beans, including bean classes, helper classes, and other meta data.

Ejb Modules can be of two types - EJB 1.1 module and EJB 2.0 module. While EJB 2.0 modules can hold both 1.1 and 2.0 types of enterprise beans, EJB 1.1 modules can hold only 1.1 type of enterprise beans.

Organizing Enterprise JavaBeans under EJB Modules enables Express Development facility that speeds up development cycles through:

Example

The figure below illustrates an example Desk with two EJB Modules point to the same Source Root.

Two EJB Modules - Employee EJB and Sales EJB are stored in a Desk. The beans under the respective modules can be viewed as ArchiveDesk/Employee EJB/com/pramati/hr/ejb/EmployeeBean.java and ArchiveDesk/Sales EJB/com/pramati/sales/ejb/SalesBean.java in the Desk tree hierarchy.

Both these modules can point to the same source root directory, c:/src_root. The files are therefore respectively stored in the following locations -

c:/src_root/com/pramati/hr/ejb/EmployeeBean.java and c:/src_root/com/pramati/sales/ejb/SalesBean.java.

Web Module

A Web Module is a folder directly under the Desk in the Desk tree hierarchy, which represents a WAR and provides the user with the following added functions:

A Web Module points to a Source Root in the file system. A Web Module can therefore also have Java files under it along with the Web components. A Web Module is always in a ready-to-be-deployed state. There can be more than one Web Module in a Desk. More than one Web Module cannot point to the same Source Root in the file system.

When a Web Module is created in the Desk, a directory with the same name as that of the Web Module gets created under the specified Doc Root in the file system. A Doc Root is the path of the root directory where web applications are stored and sourced.

The Web Module name acts as the context root of the web application. To access any content, the URL is http://localhost:8181/web-module-name/file where 8181 is the default port name and the file is the file name of the file with the extension. Typically, context roots have the same name as the Web Module. To modify the context root, follow the instructions provided in the chapter Express Development.

Example

A Web Module called WebMod is stored in a Desk called ArchiveDesk. The Web Module is created under a Doc Root called c:/doc_root. A directory called c:/doc_root/WebMod gets created in the file system. The web Module comprises a file called index.jsp under it.

Though the specific file is physically stored in the following path c:/doc_root/WebMod/index.jsp, it is represented in the Desk as ArchiveDesk/WebMod/index.jsp

In the diagram given below, the above example is illustrated. The left side displays the Desk view and the right side the File system view.

Desk Templates

A Desk template is characterized by the types of folders and files it holds. Studio ships with five default Desk templates -Blank Desk, Default Desk, EJB 2.0 Desk, EJB 1.1 Desk and Web Desk. The Blank Desk is a blank Desk with no folders and files in it.

The Default Desk has a directory structure and folder attributes Suited for J2EE application development. The Default Desk Template comprises folders that hold typical J2EE components like Enterprise JavaBeans, JavaServer Pages, Servlets, HTML, images, Tags, Java Archives (JAR), Web Archives (WAR), Resource Adapter Archives (RAR), Enterprise Archives (EAR) and other file types. The folders in the DefaultDesk.dsk have the following attributes:

Node
Description
EJB 2.0 Module
All Java source files like Enterprise 2.0 and 1.1 JavaBeans, Servlets, helper and normal Java files in a Java-class-package-hierarchy. All files under this folder are always in a ready to deploy state.
Web Module
All Web components like JavaServer Pages, HTML files, tag files, graphics, image files and Servlet files. All files under this folder are always in a ready to deploy state.
JAR
Java archives (JARs) of EJB components (.JAR)
WAR
Web archives (WARs) of Web components (.war)
RAR
Resource adapter archives (RARs) of resource adapter components
EAR
JARs and WARs packaged as enterprise archives (EARs) (.ear)

EJB 2.0 Desk comprises the following folders: EJB 2.0 Module, a Java archive and an enterprise archive. WebDesk comprises the following folders: Web Module, a Web archive and an enterprise archive.

Creating Desk

Desk > New

Desk Name Enter the Desk name in New Desk dialog.

Location Browse and select the location to store the Desk.

Template Choose a Desk Template.

EJB Module The Source Root for the EJB Module is automatically filled when the name of the Desk is entered. Browse and select any other Source Root required by you.

Web Module The Source Root for the Web Module is automatically filled when the name of the Desk is entered. Browse and select any other Source Root required by you.

Classes Dir The directory where all the compiled classes are to be stored is automatically filled when the user types the Desk name. Clicking OK creates a Desk at the location specified. This is the default classes directory where the compiled classes are stored, if the Java files being compiled do not belong to any source root.

Opening Desk

Desk > Open...

This opens an existing Desk from a specified location. Desks are stored as files with extension .dsk. Open Desks can be viewed as a new tab in the Explore Panel of Studio with the name of the Desk as the tab label.

If two Desks have the same name, then an asterisk (*) is suffixed to the name of the second Desk on the tab label. Dragging and dropping the files in the Editor can open files within a Desk.

Studio keeps the list of last five opened Desks, and these can be opened directly from the Desk main menu. The last opened Desk in Studio's previous session can also be re-opened automatically when Studio is restarted. To do this, go to File > Preferences and check the option, Reopen the last opened Desk.

Active Desk

Several Desks can be opened at the same time. Only the Desk that is being currently viewed (the selected tab) is the Active Desk. Operations of all general-purpose tools in Studio would relate to this Active Desk.

Besides the Desk, the Explore panel can have other tools open. For Example, Debugger.

If no Desk is selected, the Active Desk is the Desk last selected. A newly opened or created Desk is automatically set as the Active Desk.

Closing Desk

Desk > Close

Closes the Desk. The Desk is saved when it is closed.

Deleting Desk

Desk > Delete

Deletes the Desk, and all associated folders and files, from the file system. The Desk once deleted, cannot be recovered.

Creating Folder in Desk

Studio allows new folders to be added under the Desk. The user can create folders of the following type in the Desk - Java Module, EJB Module, Web Module, Java archive, Web archive, enterprise archive and other.

Creating a Java Module

Right Click on Desk Node > New Folder > Java Module

Choosing this option brings up the dialog box that helps create a Java Module in the Desk. Enter the following information to create the module:

Name Enter the name of the Java Module to be created.

Location The location where the module is to be physically created in the file system.

Classes Dir The location of the directory under which the classes are to be stored. Click OK.

Creating an EJB Module

Right Click on Desk Node > New Folder > EJB Module

Choosing this option brings up the dialog box that helps create an EJB Module in the Desk. Enter the following information to create the module:

Name Enter the name of the EJB Module to be created.

Location The location where the module is to be physically created in the file system.

Classes Dir The location of the directory under which the classes are to be stored. This field cannot be edited. The classes' directory is <install_dir>/desk_name/classes/ejb_module_name where <install_dir> is the installation directory of Studio. Click OK.

EJB Version Ejb Modules can be of two types - EJB 1.1 module and EJB 2.0 module, depending on the EJB version selected. This field allows the user to choose the EJB version for the module to be created.

Creating a Web Module

Right Click on the Desk Node > New Folder > Web Mod

Choosing this option brings up the dialog box that helps create a Web Module in the Desk. Enter the following information to create the module:

Name Enter the name of the Web Module to be created.

Doc Root The location where the module is to be physically created in the file system. The Web Module is always created under the Doc Root specified in the file system.

Classes Dir The location of the directory under which the classes are to be stored. This field cannot be edited. The classes' directory is <install_dir>/desk_name/web_module_name/WEB-INF/classes where <install_dir> is the installation directory of Studio. Click OK.

Creating Archives

Right Click on the Desk Node > New Folder > Java Archive/Web Archive/Resource Adapter Archive/ Enterprise Archive

Choosing the archive to be created creates the specific archive folder under the Desk tree node.

Searching in Explore Panel

The Explore Panel in Studio allows the user three kinds of search facilities, Find In Desk Items, Incremental Search and Deep Search. These search facilities are also available in the other tree structures available in Studio like File Chooser, and Directory Chooser. Incremental and Deep Search facilities are also available in Object Browser.

Find In Desk Items

Right clicking on a folder in the Desk and selecting Find In Desk Items searches for a word in all the files of the specified type in the specified folder, and displays the results in the Output Panel. The results are displayed in a tree format.

In the dialog that comes up after the option, Find In Desk items has been selected, enter the following information, and search for the word:

Find In the Find field, enter the text to be searched for.

File Types In File Types, the type of file that is being searched for is written. For example, *.java.

In Folder In the In Folder section, the folders where the files are available are written. It also provides you with six options for advanced search.

Find searches for all occurrences of the word, while Cancel cancels the Find in Files command.

In the results that are displayed in the Output Panel, you can delete a few of the results, and then press Ctrl + Shift + A. This searches for the next non excluded result. Pressing Ctrl + Shift + Z searches for the previous non excluded result.

Press Ctrl + Shift + Q, or click on the close button to close the tab in the Output Panel. To re-run the search, press Ctrl + Alt + R, or use the re-run button available in the tab.

Incremental Search

Select the node in the Desk tree in the Explore Panel, and begin typing the string to be searched for. As each character is typed, the search proceeds to the next occurrence of the string as specified so far, in the open tree structure in the Explore Panel. Press Enter/Return to open the specific file. Typing a word which has no match makes the text red in color.

Deep Search

Selecting a node in the Desk tree in Explore Panel and clicking on Ctrl + F, brings up a small dialog, where the user enters the text to be searched for. Typing the required text and pressing Enter searches for the first occurrence of the text specified, in the Explore Panel tree. Use F3 to search for the next occurrences.

Desk Properties

Desk Root > Right Click > Properties

Clicking on this brings up a dialog box where three types of properties can be set for the Desk and its folders:

Folder Properties

View the following folder properties here. The fields here cannot be edited.

Name The name of the Desk or folder can be viewed here.

Folder Type Displays the type of folder. The folder can be any of the given types - Desk Root, Java Module, EJB Module, Web Module, Normal Folder or any of the Archives.

Absolute Path This option displays the absolute path of the folder.

Output Classes Dir The directory where all the output classes are placed.

Build Properties

The build properties for the Desk or the folder chosen can be edited here. To know more on build properties, read the chapter on Compiling Applications.

Deploy Properties

Choose the components to be deployed in the module or the Desk tree node. By default all the modules in the Desk and all the beans/servlets/filters in the module are selected. To know more on Deploy properties, read the chapter on Express Development.

Converting the Desk into an EAR

Desk > Right Click > Export As Archive

This ensures for at least one EJB Module or Web Module folder under the Desk and then converts the Desk into an EAR. The file is placed under the EAR folder of the Desk. This archive can be then be used for commercial deployment.

EJB Modules and Web Modules can also be exported as archive. Right Clicking on the respective nodes > Export As Archive converts the EJB Modules into JARs and Web Modules into WARs and positions them under the respective folders in the Desk.

Archiving the Desk

Packing Desk

Desk > Pack Desk

Desk provides its owner a way of taking a snapshot of the work status at any stage and archiving that information to be retrieved later or in another location.

This is achieved by the Packing routine. To archive (pack) a Desk, choose the Desk from the Pack Desk dialog. This compresses (archives) all files stored under the Desk into a Desk Archive (DAR) (file with extension .dar). The DAR is stored at the selected location. It stores the Desk (.dsk file) along with its contents.

Unpacking Desk

Desk > Unpack Desk

To unpack a Desk archive, choose the DAR to be unpacked in the Source Desk Archive section. Then specify where the DAR is to be unpacked in the Target Location section.

Unpacking the Desk creates a one-to-one file structure under a parent directory with the name of the Desk.

Migrating a 2.5 Desk into a 3.0 Desk

To convert a Desk created in Pramati Studio 2.5 into a Desk in Pramati Studio 3.0, follow the given steps:

  1. Start Pramati Studio 3.0
  2. Open the 2.5 Desk by clicking on Desk > Open in the main menu.
  3. This brings up an alert dialog asking the user to confirm the migration.

  4. Click Yes. This prompts for the Studio 2.5 installation directory. The installation directory is required to retrieve the resources and queries, if any.
  5. Browse for the installation directory, and click OK. The Desk is converted into a Pramati Studio 3.0 Desk automatically and opened in Studio.

  6. The migrated Desk opens automatically in Studio.
  7. To make the Desk "ready-to-be-deployed", right click on the Desk node in the Explore panel and select Clean Build.

A copy of the old Desk is also stored by archiving and storing it in the parent directory of the original Desk.

Example

If the 2.5 Desk, ejbDesk.desk was stored in the location <install_dir>\samples\ejbDesk, the archive is stored in the location <install_dir>\samples\ejbDesk.dar.

Merging Desks

Use the Merge Desks feature provided in Studio to merge two existing Desks into a single Desk. To start using this feature, click on Desk > Desk Merge from the main menu. This brings up the Desk Merge dialog, where the following fields have to be filled:

Use Open Desk Check this option to select the target Desk from one of the open Desks in Studio. The target Desk field becomes a combo box listing all the open desks. This is disabled if no Desk is open.

Target Desk This is the Desk, open in Studio and the final contents of the merged Desk are added to this Desk. Checking the option, Use Open Desk displays all the open Desks in a combo box, else the user has to browse for the Desk.

Source Desk This is the Desk, whose contents are added to the target Desk. This Desk is opened in a frame outside Studio. The contents of this Desk can then selectively/ fully copied to the target desk by the user.

After filling in all the required fields, click on OK. This opens a new frame called the Staging Area, which allows the user to customize the Desk to be created using the source Desk that is displayed on the left side of Studio. This gives the user greater control on the structure of the target Desk, and also helps resolve all the Pending Tasks with the appropriate UI.

Pending Tasks are the tasks, which are to be performed after the Desks have been merged. Usually these are missing resource tasks and represents the resources that are present in the Source Desk and absent in the Target Desk

When a module is moved from the Staging area to the destination Desk, all the meta-data required are also moved transparently. Moving files individually requires the user to move the corresponding meta-data files separately. For example, the ejb-jar.xml in EJB Module.

Note: If the Target Desk is closed while the Merge is in still in progress, the Merge action gets cancelled and the Merge Frame (Source Desk) is also closed.

Using the Staging Area

The Staging Area shows the discovered Desk and a set of pending tasks. The target Desk is displayed in Studio.

To move modules/files from the source Desk to the target Desk, select one or more files in the Staging Area, and a single node in the target Desk, and click the forward arrow button. This moves the selected files from the source Desk to the target Desk. Modules can also be moved to the target Desk using this button. To undo and redo the tasks, use the Undo and Redo buttons in the Staging Area. To move the entire Desk from the discovered Desk to the target Desk, select the Desk root node in the Staging Area and click the forward arrow icon.

Resolving Pending Tasks

All the pending tasks that could not be automatically resolved during migration are displayed in the Pending Tasks area. To resolve the pending tasks, double click on the pending task in the Pending Tasks list. A dialog comes up, that can be used to resolve the task. For example if the pending task is a missing file, then the file chooser dialog box pops up, which can be used to select the file.

Example of pending task

When a resource required in the target Desk is not present, clicking on the pending task opens the Resource tool for the user to create the resource required.

Staging Restrictions

In order to maintain the Desk semantics, there are some restrictions in moving file(s)/folder(s) to the target Desk from Staging Area:

  1. If a module is moved to a target Desk, then irrespective of the target node selected the module always is moved to Desk Root node.
  2. If the target node is the Desk Root node and the selected node in the Staging Area is not a module, then the move is invalid and the selected nodes are not moved to the target Desk.
  3. If the node selected in the target Desk is a file node, then the selected items are moved to the to its immediate parent node (which could be a normal folder or module).


Pramati Technologies  © Copyright   TOCPREVNEXTINDEX