58
Writing Controls Applications on Java TM An overview of the infrastructure for the user application development in Accelerator Controls Department. June 30, 2003 Andrey Petrov

Writing Controls Applications on Java TM

  • Upload
    bunny

  • View
    48

  • Download
    0

Embed Size (px)

DESCRIPTION

Writing Controls Applications on Java TM. An overview of the infrastructure for the user application development in Accelerator Controls Department. June 30, 2003 Andrey Petrov. Agenda. Application Framework Application Index Covered: Development of console user applications. - PowerPoint PPT Presentation

Citation preview

Page 1: Writing Controls Applications  on Java TM

Writing Controls Applications on JavaTM

An overview of the infrastructure for the user application development in Accelerator Controls Department.

June 30, 2003

Andrey Petrov

Page 2: Writing Controls Applications  on Java TM

Agenda

1.1. Application FrameworkApplication Framework

2.2. Application IndexApplication Index

Covered: Development of console user applications.

Not covered: Development of Open Access Clients, servelts, and other server-side programs.

Page 3: Writing Controls Applications  on Java TM

I

Application Application FrameworkFramework

Page 4: Writing Controls Applications  on Java TM

Application Framework Definition

A library of reusable components for the development of console user applications.

Reference guide is Beams-doc-688, or http://www-bd.fnal.gov/controls/java/ framework/af-guide.pdf

Page 5: Writing Controls Applications  on Java TM

Application Framework Functions

Interacts with Application Index services (property repository, heartbeat service, central logging, operation locks, etc.);

Provides a uniform application's look-and-feel (for swing applications);

Implements some common functions (printing, image capture, DAE connection, message window, etc.).

Page 6: Writing Controls Applications  on Java TM

Classpath

framework.jar (gov.jar is not enough), or framework-lite.jar (without swing) mail.jar activation.jar jhall.jar jlfgr-1_0.har govcore.jar jconn2.jar

af_bunch.jar

for DAE connection

Page 7: Writing Controls Applications  on Java TM

Core Application Framework Classes

ApplicationManager – implements most of the functions, not related to GUI;

DaeSupport – serves the DAE connection; Implementations of user interfaces:JControlsFrame, JSimpleControlsFrame, JControlsDialog0, …1, …2.

Page 8: Writing Controls Applications  on Java TM

Application Manager

Singleton; All public methods are static; Must be initialized at the application startup:

public static void main( String[] args ) { ApplicationManager.init( args ); /* rest of the code */ }

Page 9: Writing Controls Applications  on Java TM

Frame & Dialog Hierarchy

Page 10: Writing Controls Applications  on Java TM

Graphical User Interface[JControlsFrame]

Page 11: Writing Controls Applications  on Java TM

JControlsFrame Features

Dynamic GUI generation from the interface descriptors (text files);

Persistent frame size and location; Predefined actions; A "smart" default close operation:

1st frame – EXIT_ON_CLOSE, others – DISPOSE_ON_CLOSE;

Splash screen for the first frame.

Page 12: Writing Controls Applications  on Java TM

Interface Descriptor

An XML file, that describes the appearance of the whole frame, menu bar, toolbar, and status bar;

Has the same name, as the corresponding frame (with .xml extension), and must be placed in the same directory;

Supports inheritance; Three logical levels.

Page 13: Writing Controls Applications  on Java TM

Interface DescriptorStructure

<frame … > 1. root element

<menu id="…"> 2. element description

item1 3. sub-element IDs item2 item3

</menu>

</frame>

Page 14: Writing Controls Applications  on Java TM

Inheritance of Interface Descriptors

Page 15: Writing Controls Applications  on Java TM

Interface Descriptor Example I

<frame menuBarID="MenuBar" toolBarID="ToolBar" statusBarID="StatusBar" restoreSize="true" restoreLocation="true" visibleOnStartup="true">

<!-- code omitted -->

</frame>

Page 16: Writing Controls Applications  on Java TM

Interface Descriptor Example II

<tool_bar id="ToolBar">

Cut Copy Paste

</tool_bar>

<item id="Cut" mnemonic="t" actionCommand= "CutAction" accelerator= "Ctrl+X" icon="…" enabled="false"

/>

Page 17: Writing Controls Applications  on Java TM

Interface Descriptor Example III

MyFrame.xml

<tool_bar id="ToolBar">

!default Delete

</tool_bar>

JControlsFrame.xml

<tool_bar id="ToolBar">

Cut Copy Paste

</tool_bar>

Page 18: Writing Controls Applications  on Java TM

Polymorphism

<item id="Cut"mnemonic="t"actionCommand= "CutAction"accelerator= "Ctrl+X"icon="…"enabled="false"

/>

Page 19: Writing Controls Applications  on Java TM

Getting GUI Components

ControlsWidget w = getWidget( "Cut" );

w.setEnabled( true );w.setSelected( false ); // radio buttonsw.setText( "Any Key" );

Object[] objs = w.getComponents();

Page 20: Writing Controls Applications  on Java TM

Handling Events

Action a = new AbstractAction() {public void actionPerformed( ActionEvent e ) { System.out.println( "!!!" ); }}

getActionMap().put( "CutAction", a );

Page 21: Writing Controls Applications  on Java TM

Predefined Actions

Export To File Send Mail Post E-log Message Print Page Setup Cut Copy Copy Special Paste

Select All DAE Connection Message Viewer Application Properties Logging Help Topics About Exit

Page 22: Writing Controls Applications  on Java TM

Custom Frame Initialization

jbInit method is used for the custom initialization of the frame (e.g., placing elements on the content pane).

jbInit should not be called explicitly (this is a duty of JControlsFrame);

The local variables are not initialized when jbInit is invoked — see documentation…

Page 23: Writing Controls Applications  on Java TM

"Hidden" Functions ofApplication Framework

Access to the property repository; Self-determination service (application finds

itself in the Application Index database); Heartbeat service (application notifies

Application Index, that it is running); Operation locks; Central logging.

Page 24: Writing Controls Applications  on Java TM

Application Properties

Named string values, used for program configuration and keeping of persistent data;

Properties are stored in local files and on the server;

Name and value < 256 chars both.

Page 25: Writing Controls Applications  on Java TM

Property Sources

1. Global framework configuration file(the user can not change it);

2. Application property file(optional, created by the user);

3. Property repository on the server(user may have write access).

Loading order: 1 2 3.

Page 26: Writing Controls Applications  on Java TM

Application Property File

<app_name>.properties,where app_name – name of the main class; property file must be placed in the same directory.

application.title=Test Application application.version=0.1.2 application.author=Andrey Petrovdae.connect=1

Page 27: Writing Controls Applications  on Java TM

Property Repository

http://www-bd.fnal.gov/appix/select/props

Used to manage properties online and store data changed in running applications (e.g., user e-mail).

Properties can be user-specific and application-specific.

Properties, changed in running applications, are always user-specific.

Page 28: Writing Controls Applications  on Java TM

Using Properties In Application

Properties p = ApplicationManager.getProperties();

String s = p.getProperty( "foo" );

// "foo=new_value" will be stored// on the serverp.setProperty( "foo", "new_value" );

Page 29: Writing Controls Applications  on Java TM

Self-determination Service

Determines the application's main class and type of the launcher (standalone, web-startable, etc.);

Search for the application's description in Application Index database;

ApplicationManager.getAppDescriptor();

Page 30: Writing Controls Applications  on Java TM

Heartbeat Service

Notifies Application Index, that the application is launched or terminated;

Notifies Application Index, that the application is running (every 6 minutes); application usage history is available online.

Available only for the registered applications.

framework.heartbeat=0 disables

Page 31: Writing Controls Applications  on Java TM

Operation Lock Service

Allows to set named locks in order to avoid the concurrent execution of critical routines in multiple instances of one application.

Locks are automatically released at the application termination;

Available only for the registered applications.

Page 32: Writing Controls Applications  on Java TM

Operation Lock Example

try { ApplicationManager. setOperationLock( "foo" );} catch (Exception ex) { // The lock is already set}

ApplicationManager. releaseOperationLock( "foo" );

Page 33: Writing Controls Applications  on Java TM

Central Logging

Instead of System.out.println( … ); Logging records are stored in a database on

the server side and available online; Automated purge (once a day), every

application may have an individual "storage time" for logging records (default – 1 day).

Available only for the registered applications.

Page 34: Writing Controls Applications  on Java TM

Logging API

Logger log = Logger.getLogger( "…" );

log.warning( "This is a warning" );

try { // some code} catch (Exception ex) { log.log( Level.SEVERE, "Error", ex );}

Page 35: Writing Controls Applications  on Java TM

Logging Configuration

Custom handlers: MessageViewerHandler, AppixHandler;

Configuration through application properties (default values – in property files);

Configuration at the runtime through GUI (stored in the property repository).

Page 36: Writing Controls Applications  on Java TM

Logging Configuration Dialog

Page 37: Writing Controls Applications  on Java TM

DAE Connection

DAE connection = getting of DaqUser object; For the console applications, DaqUser must

be obtained from Application Manager. Then DaqUser is used to create DAQ jobs.

Page 38: Writing Controls Applications  on Java TM

DAE Connection Requirements

Client machine must be inside the firewall; Two libraries are required in the classpath: govcore.jar and jconn2.jar.

User, node, and application must have enough privileges to do settings.

Page 39: Writing Controls Applications  on Java TM

DAE Connection GUI

Page 40: Writing Controls Applications  on Java TM

Getting DaqUser

ApplicationManager.getDaqUser();

Returns either DaqUser instance, or null; Application (service) permissions are

automatically set in DaqUser; Do not cache DaqUser in the program!

Page 41: Writing Controls Applications  on Java TM

DaeConnectionListener

public void daeStatusChange( short oldStatus, short newStatus );

public void settingsLockChange( boolean newVal );

public void daeException( Exception exception );

ApplicationManager.getDaeSupport(). addDaeConnectionListener( … );

Page 42: Writing Controls Applications  on Java TM

Settings

By default, settings are locked, except of the Main Control Room users;

Maximum unlock time is considered; Settings may be unlocked from GUI. Do not unlock settings programmatically in

productional versions!

Page 43: Writing Controls Applications  on Java TM

DAE Connection Configuration

dae.enabled 1/0 App. prop. file

dae.connect 1/0 App. prop. file

dae.name String On the server

dae.name.fixed String App. prop. file

dae.unlock.time(debug only!)

Int (minutes)

App. prop. file

Page 44: Writing Controls Applications  on Java TM

DAE Security

DAE uses a user/node pair for authorization; If this pair is not found in DB, the Kerberos

authentication is requested; All users with valid user/node combination

are allowed to do readings; Users, nodes, and applications have settings

privileges and maximum unlock time;

Page 45: Writing Controls Applications  on Java TM

DAE Security – Example

Page 46: Writing Controls Applications  on Java TM

Security Service

Will be ready soon; “Single Sign-On” based on MIT Kerberos; In most cases will use existing cached

Kerberos ticket (JAAS extension); This ticket will be forwarded to the server

(servlets?), in order to present the client-side user (GSS-API).

Page 47: Writing Controls Applications  on Java TM

II

Application IndexApplication Index

(APPiX)(APPiX)

Page 48: Writing Controls Applications  on Java TM

Application Index Funtions

Keeps all information on applications in the database;

Provides GUI for editing and monitoring of application data;

Provides data for the running applications through web-services.

Page 49: Writing Controls Applications  on Java TM

APPiX Architecture

Page 50: Writing Controls Applications  on Java TM

Representation Of An Application In Database

Page 51: Writing Controls Applications  on Java TM

Application Index GUI

Main page: http://www-bd.fnal.gov/appix An applet-based application launcher; Standalone application launcher; Read-only access for all (except of a small

restricted area); Authentication required to modify data; From outside Fermilab – read-only access

ever.

Page 52: Writing Controls Applications  on Java TM
Page 53: Writing Controls Applications  on Java TM

Launching An Application

Web launcher (based on an applet), and Standalone application browser (web-startable itself);

7 program types, each has own launching procedure;

Web launcher does not support STDALONE type;

Page 54: Writing Controls Applications  on Java TM

Program Types

JWS-AUTO JRE

JWS-MANUAL JRE

STDALONE JRE, P:\

HTML –

SYNOPTIC SVG

EXCEL MS Excel

APPLET Java plug-in

Page 55: Writing Controls Applications  on Java TM

JWS-AUTO Programs

A dynamic generation of JNLP file, basing on the application record in the database.

User does not have to write and maintain JNLP file.

JNLP generator is being kept up-to-date (to resolve certain JRE bugs, etc.).

Page 56: Writing Controls Applications  on Java TM

Application Tree

Top level – machine name (B, C, F, …); There may be several references to one

application; Each reference may have individual

command line arguments (STDALONE, JWS-AUTO).

Page 57: Writing Controls Applications  on Java TM

Information Needed To Register An Application

Application Name Application description < 256 chars; Help URL, if any; Responsible person; Program type; Main class (STDALONE, JWS-AUTO), or URL; Required libraries (jars); Desired place in the application tree;

Page 58: Writing Controls Applications  on Java TM

Q & A

Project URL:http://www-bd.fnal.gov/appix

All questions:[email protected]@fnal.gov