# RSE Artifacts

# Remote System Explorer Artifacts

With the RSE, you can create and manipulate the following artifacts, which we introduce here:

- Hosts
- Profiles
- Subsystems, created from subsystem configurations
- Connector Services, managed by connector service managers
- Filters and filter strings
- Filter pools
- Preferences
- System Registry

All the classes and interfaces mentioned here are defined in the `org.eclipse.rse.core` plugin.

## Hosts

The RSE's Remote Systems view shows all existing Hosts to remote systems. Hosts are objects that are persisted, containing the information needed to access a particular remote host. The view contains a prompt to create new Hosts, and pop-up menu actions to rename, copy, delete, and reorder existing Hosts.

Hosts contain attributes, or data, that is saved between sessions of the workbench. These attributes are the host name, the remote system's host name and system type, an optional description, and a user Id that is used by default by each subordinate subsystem, at host time. Underneath, all Hosts are stored via RSE persistence in an Eclipse project named `RemoteSystemshosts`, which the user can enable for team support, allowing Hosts to be shared by a team.

## Profiles

To facilitate team-shared and user-unique Hosts, Hosts are owned by profiles. These are simply folders in the RemoteSystemshosts project, as it turns out, within which all other data including Hosts are scoped. Internally profiles are realized as SystemProfile objects, managed by the SystemProfileManager. For each profile there is also a SystemhostPool object created to manage the Hosts within that profile. There are menu actions for the user to create and manage profiles. The collective of all Hosts of all active profiles are shown in the Remote Systems view, and the user can easily decide which profiles are active using the local pulldown menu of the Remote Systems view. The list of profiles currently active is stored locally on each user's workstation, and not shared by the team. By default, there exists a profile named `Team`, and a profile with a name unique to this user. When the first host is created the user is asked to supply this unique name, which defaults to the hostname of their workstation. Whenever a new host is created, the user is prompted for an active profile to contain the new host. Both default profiles are active initially, so all Hosts from each are shown. There is a preferences setting to show the host names qualified by their profile name. After synchronizing the RemoteSystemshost project with a team repository, using the RSE team view, all profiles of all members of the team will exist in the user's workspace, and hence all the Hosts created by all the team members. However, only the two default profiles are active, so the Hosts in the other profiles are not seen unless the user explicitly makes another profile active. This design allows for:

1. Team-shared Hosts (created in the team profile or any profile all team members make active)
2. User-private Hosts (created in their own profile or any profile not active by default)
3. User-roaming, whereby a user uses a different workstation than usual, and then synchronizes with the team repository and sets their profile to be active.

As an aside, user IDs and passwords are not shared with the team repository, but rather stored only locally per workstation. Each subsystem can have a unique user ID, which if not set is inherited from its host, which in turn if not set is inherited from the user ID preferences setting for the appropriate system type.

## Subsystems and subsystem configurations

When you expand a host, any tools registered with the Remote System Explorer are shown under the host. These tools are referred to as subsystems. The tool provider registers a subsystem configuration class via an RSE extension point, and whenever a new host is created, the configuration is asked to create a new subsystem object for that host. This subsystem is responsible for communicating with the remote host, and exposing artifacts and actions for working with remote resources. The subsystem configuration can elect not to supply a subsystem for a given host if it does not support the system type of that host

IBM supplies two subsystem configurations that supply common subsystems for all Hosts:

1. Files. The subsystems created by this factory access the folders and files of the remote system, and allow users to explore and manipulate those folders and files. Editing support for remote source files is also included. For programmers, the subsystems also supply common APIs and user interface actions, wizards, dialogs, and widgets for easy access to the remote file system for a given host. These APIs are typically used when coding actions that appear in the pop-up menu for selected remote objects, but might also be of value when writing any view, editor, or action that needs access to a remote file system.
2. Commands. The subsystems created by this factory access the command shell of the remote system and allow users to predefine commands, and subsequently run them remotely. The commands subsystems are hidden subsystems, not shown when you expand the host. However, they are used by any code needing to run remote commands. There is also a Remote Commands view supplied that logs all commands and allows users to randomly enter a command to be run remotely. The commands all execute within the same shell, and users can launch additional shells for the same host.

For iSeries Hosts, these subsystems work with the folders and files in the Integrated File System, and run commands in the QSHELL Unix-like environment. When using a WebSphere Studio configuration that supports it, there is also additional subsystem configurations that supply three more subsystems for each iSeries host:

1. iSeries Objects. This accesses the libraries, objects, and members in the native QSYS file system, allowing users to explore and manipulate them via IBM-supplied actions. For programmers, this also supplies common APIs for listing remote libraries, objects, members, records, and fields, with various filtering capabilities, as well as editing remote source members. Furthermore, there are a number of iSeries-specific user interface actions, wizards, dialogs, and widgets that programmers can easily re-use.
2. iSeries Commands. This accesses the QSYS command shell and allows remote execution of any CL command. Users can pre-defined commands or use the Commands view to randomly enter and run a command. For programmers, there are APIs supplied to execute a remote CL command, with message retrieval.
3. iSeries Jobs. This accesses the iSeries jobs the user has access to, allowing limited exploration and manipulation of those jobs. For programmers, this also supplies APIs for listing jobs, with various filtering capabilities.

From any of these iSeries-specific subsystems, programmers can access the Toolbox for Java `AS400` object for the current session, thus avoiding redundant signon requests for the user, and inheritence of existing job attributes. There is also a method for returning a JDBC host object for accessing DB2/400 databases on that iSeries host. Both of these getter methods are available in the ISeries system object all iSeries subsystems share. System objects are described next.

## Systems and System Managers

While not seen by the user, subsystem objects are required to return a system object via the getSystem() method. A system object is an object implementing the ISystem interface. A system object manages the live host to the remote system, and supports lifecycle methods for that host such as connect, disconnect, and isConnected. The communication layer for that host is entirely the programmer's responsibility, and might use sockets, JDBC, HTTP or SOAP. It is up the provider of the subsystem factory to author their own communication layer; the framework only dictates the handful of methods in ISystem, that the RSE UI depends upon. The framework supplies a base system class that is easily extended.

It may be the case that multiple subsystems, each from a different subsystem factory, share the same live host for a given host object. To enable this, the framework supplies a base system manager class that can be used to manage a single shared system object across multiple subsystems. It uses a hashtable to store and return the system objects, keyed by a subsystem interface that all subsystems sharing the same system object are to implement. The subclass of the base system manager class supplies that interface. Further, the subclass must also implement the method for instantiating new instances of the system class, when no instance is found in the hashtable.

It is possible to author a subsystem factory whose subsystems simply use the same system object as that used by the IBM-supplied subsystems. You might do this if the subsystem factory uses only the IBM-supplied APIs for accessing remote objects, in which case there is no need for a unique communication layer. By sharing the same system object, it prevents the user from being prompted to signon multiple times. To do this, simply access any IBM-supplied subsystem for a given host, and ask for its system manager in your own subsystem's getSystemManager method.

## Filters

When a subsystem is expanded, users usually see filters. Since subsystems typically list remote artifacts, it is typical that a mechanism is needed to allow users to define which artifacts they wish to see, with some form of filtering criteria. Filters are this mechanism. The filter support is fully supplied by the RSE framework. A filter is simply a SystemFilter object containing a name and a collection of filter strings. Filter strings are just strings, which the subsystem is required to interpret. When a user expands a filter, the owning subsystem is asked to resolve the filter strings within the filter. The subsystem typically interprets each filter string as some form of filtering pattern, and returns a list of remote artifacts matching one or more of the filter string patterns in the filter. For example, file subsystems expect each filter string to represent a folder, and a file name pattern. Then, all files in the folder, matching the name pattern, are returned. The subsystem supplies the user interface the you use to create and change filter strings, so it is responsible for defining what the filter strings look like and for subsequently resolving those filter strings on a filter expansion. A default user interface for the filter string prompt is supplied, but it is a simple entry field.

It is possible to author a subsystem that does not support filters, if this is desired.

## Filter Pools

Subsystems do not actually "own" filters. Since each host has unique subsystems, if each subsystem owned its own filters then filters could not be shared across Hosts, which is sometimes desirable. Instead, filters are actually contained within filter pools. Filter pools are simply SystemFilterPool objects which have a name and a collection of filters. Filter pools are owned by subsystem configurations, per profile. That is, each subsystem factory will contain filter pools scoped by profile. Each such factory plus profile grouping is known internally as a filter pool manager. Subsystems contain references to filter pools. By default, each subsystem factory automatically creates one filter pool for each profile, named the "xxx Filter Pool", where "xxx" is the name of the profile. Subsystems contain references to filter pools, so that as the filters in the pool are created, changed, deleted or re-ordered, those changes are automatically reflected in every subsystem (and hence host) that references that filter pool. By default, subsystems are given a reference to the default filter pool in their host's profile (for their parent subsystem factory, so file filters are not used in command subsystems, for example).

By default, users do not see filter pools. Instead, filters are created in the default filter pool referenced by this subsystem. As a result, users will see the same list of filters for every host. However, users can use a preference setting to see filter pools. In this case, when a subsystem is expanded, the users see the filter pools referenced by this subsystem. Only then when a filter pool is expanded will the user see the filters within that filter pool. In this mode, users also see new actions to create filter pools and to add and remove references to filter pools within a subsystem. Whenever filters are changed by the user, this change is reflected in all subsystems that reference the parent filter pool. This design of filter pools owned by profiles, and subsystems that reference filter pools, facilitates filter sharing:

1. Users can share filters across Hosts, by adding references to their parent filter pool in various subsystems.
2. Users can have filters unique to a host, by placing them in a filter pool not referenced by other subsystems.
3. Users can have both shared and host-unique filters in a single host, by having both shared and private references to filter pools.
4. Teams can share filters by asking each user to add a reference to the same filter pool in their Hosts. For example, this is the default case for the default filter pool.
5. Users can create filters that are not shared by the team, by creating their own filter pools and not asking others to reference it.

## User Actions and Named Types

If the subsystem factory returns true to the supportsUserDefinedActions method, users can create their own actions that appear in the pop-up menu for remote objects, using the Work With User Actions action and dialog. User actions use substitution variables that are resolved at runtime to various attributes of the selected remote objects. The actions themselves are run on the remote system of the host where the objects are listed from. User actions are instances of the SystemUDAActionElement class from the org.eclipse.rse.core.ui.uda package.
User actions can be scoped to only appear for objects of a particular type. To facilitate this, users can create named types which are names that represent one or more types of remote objects. Internally, they are SystemUDTypeElement objects. This is done using the Work With Named Types action and dialog.

User actions are contained by each subsystem factory, scoped by profile. You can programmatically access them by calling getActionSubSystem in a subsystem factory object. They are scoped to the factory, not the subsystem, so the same list of actions is available for every host. The User Actions cascading menu for remote objects lists all the actions defined for all active profiles, whose file type scoping criteria matches the types of the currently selected remote objects. When users define new actions, they specify the profile to contain them. This design allows for:

1. Team actions. This is done by defining actions in the team profile or any profile all team members have been instructed to make active. This is useful for common actions shared by all team members.
2. Private actions. This is done by defining actions in the user's profile or any profile that other team members do not make active.

Named types, however, are not scoped by profile. Rather, there is only one master list, per subsystem factory. It is assumed there will be fewer of these, and they are not likely to be different per user.

## Compile Commands

If the subsystem factory returns true to the supportsCompileActions method, users will see a Compile action in the pop-up menu for compilable source files. Clearly, this support usually only makes sense for subsystems that list remote source files. Whether a selected file is compilable or not is decided by the subsystem factory. It actually defers this request to a compile manager, which must be programmed by subclassing the supplied base class for this. The compile manager is also responsible for pre-supplying default compile commands.

The framework also supplies a Work With Compile Commands action and dialog, by which users can create their own compile commands, per source type. Compile commands internally are SystemCompileCommand objects. These compile commands are stored per subsystem factory, such that they are usable across all Hosts. They are also scoped by profile, and the cascading compile action will list all compile commands from all active profiles, for the selected file's source type. This scoping by profile, as with user actions, enables team support such that users can see and can easily access their own compile commands and any shared compile commands.

## Preferences

Many of the default characterics of the Remote System Explorer view and perspective are configurable by each user by way of the Remote Systems node of the Preferences window, accessible from the Window pull-down of the main menu. Furthermore, many of these preferences are directly accessible from the pull-down menu of the title bar for the Remote Systems view. These preferences, like all preferences, are unique to each user and not shared by the team, although they can be exported and imported.

## System Registry

The programmatic front door to all the artifacts in the RSE is the System Registry, which is an object implementing SystemRegistry. This is a singleton object that you can access by calling the static method getTheSystemRegistry() in the SystemPlugin class in the `org.eclipse.rse.core` plugin.