Host Access Beans for Java

Host Access Beans for Java


Debugging Host Access Beans

This section describes the different tools for debugging Host Access Beans applets and applications and how to use them.

Trace facility

The Host Access Beans incorporate a trace mechanism that will fire trace events to any trace facility that implements the proper interface. A user can route the trace events to their own trace facility, or, alternatively, they can use the trace facility provided with the Host Access Beans (see RASTrace) which provides a user-friendly, windowed interface to enable, disable, and format the trace events. This trace facility can be found in hatrace.jar.

A user that wishes to use their own trace facility must provide a class that implements the TraceListener interface. This interface contains one method that receives a TraceEvent as a parameter. The trace listener can be added to the beans in one of two ways. The simplest way is to make use of the BeanTrace class. Alternatively, a trace listener can be added to each Bean via the addTraceListener method.

The Beans support different trace levels from 1 (TRACE_MINIMUM) to 3 (TRACE_MAXIMUM). Each trace level is cumulative with the previous trace level, with 1 producing the least trace information and 3 producing the most. Trace level 1 generates trace information for method entry and exit, including method parameters and return values. Trace level 2 generates all the trace level 1 information plus some additional information. Trace level 3 generates all the trace level 2 information plus a lot of additional detailed information. Trace level 0 (TRACE_NONE) turns trace off.

The following sample shows how to construct a Session Bean and enable tracing for the Session Bean, the ECLPS HACL class and the internal DataStream component. For another example, see the Trace sample found in toolkit\beans\samples\TraceDemo.

import com.ibm.eNetwork.HOD.trace.RASTrace;
import com.ibm.eNetwork.beans.HOD.trace.BeanTrace;
import com.ibm.eNetwork.ECL.trace.ECLTrace;
import com.ibm.eNetwork.beans.HOD.Session;

try {
  // Instantiate default Host Access Beans' trace facility
  RASTrace myTraceListener  = new RASTrace();
  BeanTrace.addTraceListener(myTraceListener);
  myTraceListener.setVisible(true);   // Displays trace GUI
  myTraceListener.setEnabled(true);   // Start logging trace events

  Properties p = new Properties();
  .
  .  // Add other properties
  .
  // Trace Session Bean at normal volume of trace message
  p.put(Session.TRACE_LEVEL, String.valueOf(Session.TRACE_NORMAL));
  // ELCPS component with minimum trace
  ECLTrace.SetTraceLevel(ECLTrace.SESSION_TRACE_PS, ECLTrace.TRACE_MINIMUM);
  // Datastream component with minimum trace
  ECLTrace.SetTraceLevel(ECLTrace.SESSION_TRACE_DS, ECLTrace.TRACE_MINIMUM);

  Session sess = new Session(p);
}
catch (PropertyVetoException pve) {}

Another way to set the trace level for a Bean is to use the getTraceLevel and setTraceLevel methods that are provided on each Bean. The following sample shows how to enable tracing for the Session Bean using the setTraceLevel method:

Session mySession = new Session();
mySession.setTraceLevel(Session.TRACE_NORMAL); // Trace Session Bean at normal
Note: In earlier versions of the Host Access Beans, the trace GUI would be displayed whenever the trace level was set on a Bean or a HACL component. In this version, the default trace GUI will not be displayed unless you have set Visible(true) on your RASTrace object.

Finally, trace listeners added to Terminal and Session beans will also receive trace events from underlying HACL components used by these Beans if HACL tracing is enabled. If multiple Terminals or Sessions are created, each one should have a unique sessionID. If this is done, the trace listener added to the Terminal or Session will only receive trace events from the HACL components associated with that Terminal or Session. If no unique sessionID is used, the trace listener will receive trace events from HACL components from every Terminal or Session that is active.

Each Bean provides the following constants for setting the traceLevel property of the Bean:

Constant Description
TRACE_NONE Turn trace off
TRACE_MINIMUM Turn trace on at lowest volume of trace msgs
TRACE_NORMAL Turn trace on at normal volume of trace msgs
TRACE_MAXIMUM Turn trace on at highest volume of trace msgs

In addition to the Bean trace constants, the following constants are provided in the ECLTrace class to turn on trace for HACL and selected internal components:

Constant Component Traced
SESSION_TRACE_SESSION ECLSession
SESSION_TRACE_PS ECLPS
SESSION_TRACE_FIELDLIST ECLFieldList
SESSION_TRACE_FIELD ECLField
SESSION_TRACE_OIA ECLOIA
SESSION_TRACE_ERR ECLErr
SESSION_TRACE_XFER ECLXfer
SESSION_TRACE_OIA_EVENT ECLOIAEvent
SESSION_TRACE_PS_EVENT ECLPSEvent
SESSION_TRACE_COMM_EVENT ECLCommEvent
SESSION_TRACE_DS Datastream
SESSION_TRACE_TRANSPORT Transport

Presentation Space Debugger

HACL incorporates a presentation space debugger which can be activated programmatically by providing special parameters to the Session (or Terminal) Bean constructor. The presentation space debugger provides a windowed interface, which can be used to peek at the various planes that comprise the complete presentation space. It has the ability to show the text, field, color, extended field, DBCS, and grid planes.

The presentation space debugger does not allow interaction with presentation space.

The following sample shows how to construct a Session Bean and activate the presentation space debugger.

Properties p = new Properties();
p.put(ECLSession.SESSION_PS_DEBUGGER, "");
Session mySession = new Session(p); 

[ Top of Page | Previous Page | Next Page | Table of Contents ]