기본 관리 > 공동 작업 지원 > 워크플로 관리 > 워크플로 도구 > 워크플로 템플릿 관리 > 워크플로 코드 예 > 응용 프로그램 시작 로봇 예 > 응용 프로그램 시작 로봇으로 환경 변수 설정
  
응용 프로그램 시작 로봇으로 환경 변수 설정
이 항목에서는 실행 파일을 시작하고 매개변수를 시작한 응용 프로그램으로 전달하기 위해 응용 프로그램 시작 로봇 노드에서 표현식을 사용하는 예제를 제공합니다.
참조된 워크플로
ApplicationLaunchExample.xml
설명
응용 프로그램 시작 로봇 노드를 사용하여 실행 파일을 시작하고 매개변수를 시작된 응용 프로그램으로 전달할 수 있습니다. 아래 명령줄은 Java 클래스를 실행하며, 세 개의 문자열 인수를 전달합니다. 이 예제에서는 이 명령줄이 포함된 응용 프로그램 시작 로봇 노드를 비동기화로 정의합니다.
지침
1. 템플릿에서 이름, 날짜, 메시지 등 세 개의 문자열 변수를 작성합니다. 각각 초기 값을 지정합니다. 변수에 둘 이상의 단어를 지정하려면 따옴표(")로 묶어야 합니다. 예를 들어 변수 메시지에 Hello how are you를 지정하려면 값을 "Hello how are you"로 지정합니다.
2. 응용 프로그램 로봇 안에 classpath라는 환경 변수를 작성하고 이 값을 시스템의 jdk 폴더와 Java 클래스가 있는 폴더에 설정합니다.
3. 이 코드("Code for Java file")를 포함하는 Java 파일을 작성하고 컴파일합니다. 해당 경로가 위의 classpath 변수 안에 있는지 확인합니다.
4. 다음 코드를 복사합니다.
java MessageDisplay {name} {date} {message}
Java 파일을 위한 코드
import java.awt.*;
import java.awt.event.*
public class MessageDisplay extends Frame{
public MessageDisplay( ) {
//{{ INIT_CONTROLS
setLayout(null );
setSize(628,389);
label1 = new java.awt.Label( "Hello", Label.RIGHT );
label1.setBounds(108,36,103,22);
label1.setFont(new Font( "Dialog", Font.BOLD , 16));
add(label1);
label2 = new java.awt.Label( "Date", Label.RIGHT );
label2.setBounds(103,72,103,24);
label2.setFont(new Font( "Dialog", Font.BOLD , 16));
add(label2);
label3 = new java.awt.Label( "Message", Label.RIGHT );
label3.setBounds(103,108,103,27);
label3.setFont(new Font( "Dialog", Font.BOLD , 16));
add(label3);
TFName = new java.awt.TextField( );
TFName.setBounds(228,24,280,28);
add(TFName );
TFDate = new java.awt.TextField( );
TFDate.setBounds(228,60,276,26);
add(TFDate );
TAMessage = new java.awt.TextArea( );
TAMessage.setBounds(228,96,285,164);
add(TAMessage );
OK = new java.awt.Button( );
OK.setLabel( "OK");
OK.setBounds(312,276,70,25);
OK.setBackground(new Color(12632256));
add(OK );
LError = new java.awt.Label( "Wrong number of arguments. Please rerun with 3 arguments ");
LError.setVisible(false );
LError.setBounds(12,324,601,29);
LError.setFont(new Font( "Dialog", Font.BOLD , 16));
add(LError );
setTitle( "Untitled");
//}}
//{{ REGISTER_LISTENERS
SymWindow aSymWindow = new SymWindow( );
this.addWindowListener(aSymWindow );
SymAction lSymAction = new SymAction( );
OK.addActionListener(lSymAction );
//}}
}
public MessageDisplay(String title)
{
this( );
setTitle(title );
}
public void setVisible(boolean b)
{
if(b )
{
setLocation(50, 50);
}
super.setVisible(b );
}
static public void main(String args[ ])
{
MessageDisplay myFrame = new MessageDisplay( );
myFrame.setVisible(true );
myFrame.displayMessage(args );
}
public void addNotify( )
{
// Record the size of the window prior to calling parents addNotify .
Dimension d = getSize( );
super.addNotify( );
if ( fComponentsAdjusted )
return;
// Adjust components according to the insets
setSize(insets( ).left + insets( ).right + d.width , insets( ).top + insets( ).bottom + d.height );
Component components[ ] = getComponents( );
for (int i = 0; i < components.length i++ )
{
Point p = components[i ]. getLocation( );
p.translate(insets( ).left, insets( ).top);
components[i ]. setLocation(p );
}
fComponentsAdjusted = true;
}
// Used for addNotify check.
boolean fComponentsAdjusted = false;
//{{ DECLARE_CONTROLS
java.awt.Label label1;
java.awt.Label label2;
java.awt.Label label3;
java.awt.TextField TFName
java.awt.TextField TFDate
java.awt.TextArea TAMessage
java.awt.Button OK;
java.awt.Label LError
//}}
class SymWindow extends java.awt.event.WindowAdapter
{
public void windowClosing(java.awt.event.WindowEvent event)
{
Object object = event.getSource( );
if (object == MessageDisplay.this )
MessageDisplay_WindowClosing(event );
}
}
void MessageDisplay_WindowClosing(java.awt.event.WindowEvent event)
{
setVisible(false ); // hide the Frame
}
public void displayMessage(String args[ ]){
if ( args.length < 2){
LError.setVisible(true );
LError.setText( "Wrong number of arguments. Please rerun with 2 arguments");
}
else {
LError.setVisible(false );
TFName.setText(args[0]);
TFDate.setText(args[1]);
TAMessage.setText(args[2]);
}
}
class SymAction implements java.awt.event.ActionListener
{
public void actionPerformed(java.awt.event.ActionEvent event)
{
Object object = event.getSource( );
if (object == OK)
OK_ActionPerformed(event );
}
}
void OK_ActionPerformed(java.awt.event.ActionEvent event)
{
setVisible(false );
system.exit(0)
}
}