Pramati Technologies

Organizing Source Files as a Desk in Studio

Overview

Studio provides an archetype called Desk, an intuitive and adaptable way of organizing and managing various artefacts that constitute the application being developed. 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.

This document introduces you to the concept of desk and describes desk components, hierarchy, templates, properties, search within desk, and desk merge.

What is a desk

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 the corresponding packaged components. A desk provides a general-purpose folder for storing other supporting files for building the application. Desk structure can be defined as required and one of the 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 with .dsk extension. For example, creating myDesk under Studio installation directory creates a folder and .dsk file as <install_dir>/desks/myDesk/myDesk.dsk.

Desk root

Creating a desk creates a directory in the file system. The fully qualified path to this directory is called desk root. The .dsk file is located under desk root. For example, If ArchiveDesk is created under the target location <install_dir>, then <install_dir>/desks/ArchiveDesk represents the desk root. The file ArchiveDesk.dsk is located in <install_dir>/desks/ArchiveDesk.

Modules

Application source files are organized under desk nodes called modules. An application can contain many modules of different types indicating the nature of the module content. Studio desk consists of:

The type of a module is significant as different Studio tools treat the content according to their type.

Source root

The directory in the file system, where sources for EJBs, servlets, helper classes, and other Java files are located, is called the source root. The desk uses 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.

EJB module

EJB module represents an extracted view of an EJB archive, JAR. It 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 metadata.

EJB modules can be of two types, EJB 1.1 and EJB 2.0. 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 EJBs under EJB modules enables Express Development that speeds up development cycles through:

A desk with two EJB modules point to the same source root. For example, 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 modules can point to the same source root directory, c:/src_root. The files are stored in c:/src_root/com/pramati/hr/ejb/EmployeeBean.java and c:/src_root/com/pramati/sales/ejb/SalesBean.java, respectively.

Web module

A web module is a folder that contains all components constituting a WAR and provides the user with the following added functions:

A web module is stored directly under the desk in the desk tree hierarchy and points to a source root in the file system. It can also have Java files under along with the web components. This module is always in a ready-to-deploy state. There can be more than one web modules in a desk but only one can point to the same source root.

When a web module is created in the desk, a directory with the same name as the module is created under the specified DocRoot in the file system. A DocRoot 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. Here, 8181 is the default port and file is the file name with extension. Context roots have the same name as the module. For example, a web module, WebMod is stored in a desk, ArchiveDesk. The module is created under a DocRoot called c:/doc_root. A directory called c:/doc_root/WebMod gets created in the file system. The web module contains a file called index.jsp stored in c:/doc_root/WebMod/index.jsp. It is represented in the desk as ArchiveDesk/WebMod/index.jsp. Explore panel displays the desk view.

To modify the context root, read the instructions provided in `Express Development'.

Java module

A Java module stores pure Java source files of an application and points to a source root. For example, JavaMod represents a Java module and points to a source root, c:/src_root. Hello.Java is a Java file with package class hierarchy, com.pramati and is stored under JavaMod in the desk. The file is stored in c:/src_root/com/pramati and the desk represents it as ArchiveDesk/Java Mod/com/pramati.

Using 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. A Blank Desk contains no folders or files in it. Default Desk has a directory structure and folder attributes required for J2EE application development. This template contains folders that hold J2EE components such as EJBs, JSPs, servlets, HTML, images, tags, JARs, WARs, RARs, EAR and other file types.

Table 1: Attributes for folders in a default desk
Node
Description
EJB 2.0 Module
All Java source files such as EJB 1.1 and EJB 2.0, 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 such as JSPs, 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 of EJB components (.jar)
WAR
Web archives of Web components (.war)
RAR
Resource adapter archives of connector components (.rar)
EAR
JARs, WARs, RARs packaged as enterprise archives (.ear)

EJB 2.0 desk contains a EJB 2.0 module, a Java archive and an enterprise archive. WebDesk contains a Web module, a web archive and an enterprise archive.

Creating a desk

To create a new desk, select Desk > New and enter details.

Table 2:
Attribute
Description
Desk Name
Enter a name for the new desk
Location
Browse and select a location to store the new desk
Template
Select a desk template from the dropdown
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 if necessary
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 if necessary
Classes Dir
The directory where all the compiled classes will be stored is automatically filled when the desk name is typed. Click OK to create a desk at the specified location. 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 an existing desk

To open an existing desk, select Desk > Open. Browse and select an existing desk. Desks are stored as files with extension .dsk. Open desks have a tab in the explore panel of Studio with the desk name 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 desks opened and these can be opened directly from the desk main menu. To reopen the desk last opened in the previous Studio session on Studio restart, select File > IDE Options > General and select Reopen last used desk as startup option.

Active desk

Several desks can be opened at the same time. The desk being viewed is the active desk. Operations of all configured tools in Studio would relate to the active desk.

The explore panel can have other tools open besides the desk. For example, Debugger.

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

Creating a folder in a desk

Studio allows new folders such as EJB module, web module, Java module, MIDlet suite, JSP Test Module, Java archive, web archive, resource adapter archive, enterprise archive, or a blank folder to be added under a desk.

Creating an EJB module

Right click on a desk node and select New Folder > EJB module.

Table 3:
Attribute
Description
Name
Enter a name for the EJB module to be created
Location
The location in the file system where the module should be created
Classes Dir
The location of the directory under which the classes should 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 types EJB 1.1 and 2.0 module, depending on the EJB version selected. Version 2.0 is selected by default

Creating a Java module

Right click on the desk node and select New Folder > Java Module.

Table 4:
Attribute
Description
Name
Enter the name of the Java module to be created
Location
The location within the file system where the module will be created
Classes Dir
The location of the directory under which the classes will be stored

Creating a Web module

Right click on the desk node and select New Folder > Web module.

Table 5:
Attribute
Description
Name
Enter a name for the Web module
Doc Root
The location in the file system where the module should be created. 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 will be stored. This field cannot be edited. The classes directory is <install_dir>/desk_name/web_module_name/WEB-INF/classes

Creating archives

Right click on the desk node and select New Folder > Java Archive. This creates a node jar under the desk tree node. Web Archive and Enterprise Archive options can be used similarly.

Creating a blank folder

Right click on the desk node and select New Folder > Other. This creates a node New Folder under the desk tree node.

Desk properties

Right click on a desk root and select Properties. The types of properties that can be set for the desk and its folders is explained in the following sections.

General properties

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

Build properties

The build properties for the desk or the folder chosen can be edited here. For more information, read `Compiling and Building Applications'.

Deploy properties

Select 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, or filters in the module are selected. For more information on Deploy properties, read `Express Development'.

Repair properties

Repair option is used to check if the modules under the desk are reflecting the state of the application. Select the Sync State tab to regenerate deployment information for the application.

Converting the desk into an EAR

Open a desk in Studio; right click on desk root and select Export As Archive. It ensure that at least one EJB module or web module folder is present under the desk and then converts the desk into an EAR and places the file under the EAR folder of the desk. This archive can be used for commercial deployment.

EJB modules and web modules can also be exported as archives. Right click on the module node and select Export As Archive to convert the EJB modules into JARs and web modules into WARs. The archives are placed under the respective folders in the desk.

Archiving a desk

Archiving a desk involves packaging a desk into an EAR as explained in the following sections.

Packing a desk

Select Desk > Pack from the main menu.

The work status can be archived in desk at any stage and can be retrieved in another location. This is achieved by the packing routine. To archive a desk, choose the desk from the Pack Desk dialog. This compresses all files stored under the desk into a Desk Archive (DAR) file with .dar extension. The DAR is stored at the selected location and contains the .dsk file along with its contents.

Unpacking desk

Select Desk > Unpack.

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

Migrating an old desk into Pramati Studio 3.5

To convert a desk created in previous Pramati Studio versions into a desk in Pramati Studio 3.5:

  1. Start Pramati Studio 3.5.
  2. Select Desk > Open from the main menu.
  3. Browse to an old desk. This brings up an alert dialog asking the user to confirm the migration.
  4. Click Yes. This prompts for the old Studio installation directory required to retrieve resources and queries, if any.
  5. Browse for the installation directory and click OK. The desk is converted into a Pramati Studio 3.5 desk and is opened in Studio, automatically.
  6. To make the desk ready-to-deploy, right click on the desk node in the explore panel and select Clean Build.
Note: A copy of the old desk is also stored by archiving and storing it in the parent directory of the original desk. For example, if the old desk, ejbDesk.dsk was stored in the location <install_dir>\samples\ejbDesk, the archive is stored in the location <install_dir>\samples\ejbDesk.dar.
Merging desks

To merge existing desks, select Desk > Desk Merge from the main menu.

Enter all required details and click OK.

The new panel allows to customize the desk to be created using the source desk displayed in the explore panel. This gives greater control on the structure of target desk, and also helps resolve pending tasks.

Note: Pending tasks are the tasks, which are performed after merging desk. Usually, these are missing resource tasks and represent the resources present in the source desk but absent from the target desk.

When a module is moved from the Staging area to the destination desk, metadata is also moved transparently. Moving files individually requires the user to move corresponding metadata files separately. For example, the ejb-jar.xml in EJB module.

Note: If the Target desk is closed when merge is in progress, the action gets cancelled and the Source desk is also closed.

Using the staging area

The target desk is displayed in Studio. To move modules from the source desk to the target desk, select a node in the staging area and a single node in the target desk; click forward icon. The staging area highlights the module and components that have been moved and a set of pending tasks. To move the entire desk from source desk to target desk, select the desk root in staging area and click the forward icon.

Resolving pending tasks

All the pending tasks are displayed in the Pending Tasks area after migration. To resolve the tasks, double click on a task in the list. A dialog appears which can be used to resolve the task. For example, if the pending task is a missing file, the file chooser appears. If a resource required in the target desk is not present, clicking on the pending task opens the Resource Tool.

Staging restrictions

In order to maintain the desk semantics, there are some restrictions in merging desks:

Closing a desk

To close an active desk, select Desk > Close. If some changes have not been saved, a dialog displaying the unsaved file names appears. Select from Save All and Save none options before the desk is closed.

Deleting a desk

To delete a desk, select Desk > Delete. An alert appears; select from Yes and No buttons to continue. Selecting Yes removes all associated folders and files from the file system. A desk once deleted, cannot be recovered.

Opening existing files

To open existing files, select File > Open from the main menu. In the dialog, browse to the file location and click Open. It is possible to open a desk by clicking a .dsk file using File > Open or Desk > Open.

The file menu displays the ten recently opened files. To modify the number of recent files using IDE Options dialog. For details, read `Setting general properties' section in `Working with Studio Editor'.

Opening Files from the Explore Panel

Double clicking on a closed file in the Explore Panel opens it in Editor. To make an open file active, click on the file name node in explore panel. All open files appear in black font with colored icons; all closed files appear in grey font with grey icons, in explore panel. The active file always appears in bold font.

Importing files

Right click on a module node in the explore panel and select Import Files.

Table 6:
Attribute
Description
Base Directory
Location of the files and folders to be imported
Recurse
Enable this option to import all the files under a specific folder and its subfolders.
Filter
Select the filter to be implemented while searching for the files and click Search. Displays a list of all files available with the specific requirements
Target Directory
Select a target directory to adds the specific path before the file that is added. This is optional. Not selecting a target directory adds the files under the node where the right click was implemented
Add
Click Add to places the selected files in the Selected Files box

Click OK to add all the files to the target directories.

Importing files into web modules

Importing large number of files into a web module may increase memory load on the system, and cause Studio to become very slow. To reduce memory load, import only those files that are going to be edited in Editor. Other files can be manually copied under the web module directory but not imported to the desk.

The web container serves all files present in the file system and will not be restricted to files in the desk. Similarly, Export as Archive will package all files from the file-system. Large files like image (*.gif, *.bmp), zip ,and other content files need not be imported into Studio.

Viewing files in current desk

Select Files > Quick Open from the main menu.

To view all files of a type, type *.<file type>. Click on a file name to view it in Editor.

To view all files in the current desk, type *.

Viewing open files

Select View > Show Open Files from main menu. This opens a floating panel that displays the names of all open files.

Click a file name to make it active.

Saving, closing, and printing files

To save the active file, select File > Save from main menu. To save a copy of the file to a desired location, select File > Save As. To save all files currently open in the Editor, select File > Save All.

Select File > Print from main menu to print the active file.

Select File > Close from main menu to close the active file. To close all files open in the editor, select File > Close All from main menu.


Pramati Technologies  © Copyright   TOCPREVNEXTINDEX