Miscellaneous Features

This chapter describes miscellaneous X-UP features that were not covered in the previous chapters.

X-UP Global Event

This section describes X-UP's global events that can be used in all models and invokes.

X-UP applies aspect-oriented programming (AOP) ideas to provide join points for method execution. For targets to be run, events can be configured for models being developed.

The following tasks can be handled using X-UP global events:

X-UP global event are applied per-domain.

The following example describes how to apply X-UP global events by logging when executing a model. The development stages are as follows:

The model created in Model Development Using SAP RFC Invoke is used in this section.

X-UP Global Event Creation

  1. Click the [Create Global Event] button or select [X-UP > Create Global Event] from the menu to create a global event.

  1. Click [OK] on the confirmation window.

  1. The following screen is displayed when a global event is generated.

Event Target Setup

X-UP Global Event 설정항목

Name

Description

ID

Unique identifier for each global event.

TagetClass

Target for event application. Automation models, per-invoke flow events, and datasource events (for datasource connection) are possible targets in X-UP.

TargetMethod

Designate a method for the target to which an event will be applied. The applicable target-specific events are as follows:

TargetClass

TargetMethod

Description

AutomationLogic

start

An event that's applicable when a model is started.

end

An event that's applicable just before a model is terminated.

XXXFlowEvent

onBegin

An event that's applicable when an invoke is started.

onEnd

An event that's applicable just before an invoke is terminated.

onExceptionOccured

An event that's applicable when an exception occurs while a invoke is running.

XXXDataSourceEvent

onBeforeExecute

An event that's applicable just before a legacy connection is established through a data source.

onAfterExecute

An event that's applicable just after a legacy connection is established through a data source.

UserClass

Insert a business logic to be applied to an event.

Classes can be created or selected per TargetClass.

The TargetClass and TargetMethod settings are subject to change depending on the package configuration.

  1. To set a global event, click the [Add] button and select an event to be applied.

  2. To apply the event to all models, select AutomationLogic as the TargetClass, and select start as the TargetMethod.

  3. Create a UserClass to insert a business logic.

  4. Enter a class name to be created, and then click the [Class] button to create the class.

  1. The generated UserClass is as follows:

package user.globalEvent; 
 
import com.tobesoft.xup.aop.intercept.interceptor.AutomationModelInterceptor; 
import com.tobesoft.xup.ParameterSet; 
import com.tobesoft.xup.component.automation.AutomationFailException; 
 
public class AutomationModelTracer extends AutomationModelInterceptor { 
                                                                                   
  public void start(ParameterSet globalParameterSet) throws AutomationFailException{ 

  }

}

The generated class, method, and input argument names must not be changed.

Interceptor Class Creation

  1. Add the following code in the start method for data logging.

log("DEBUG", "AutomationModel start. data=["+globalParameterSet.getDebugInfo()+"]");

The available methods are different for each applicable event.

Testing

  1. Run the model to test whether a global event was successfully applied.

  1. The logged data can be viewed a test is performed.

Session Handling

This section describes the session handling method in X-UP.

X-UP provides a UserSession object for session handling.

UserSession is an objected that wraps an httpSession object. This section describes how to use the UserSession object to create sample models (session creation, session value check, session termination functions; login, user information import, and login session termination) and verify the results.

The development stages for a session handling service are as follows:

X-UP Project Creation

  1. Go to [File > New > X-UP Project] and run the New X-UP Project Wizard.

  2. Enter the desired name into the [Project Name] field and click the [Finish] button.

  1. Verify that the X-UP project was created as shown in the image below.

Automation Model Creation

  1. Go to [File > New > X-UP Automation Model] and run the New Model Wizard.

  2. Enter the desired name into the [Model Name] field and click the [OK] button.

  1. The below screen will be displayed when the New Model Wizard is completed.

UserMethod Creation

  1. Double-click the UserMethod and enter the following source code.

// Create session
UserSession session = this.getUserSession();
session.setAttribute("USER_ID","test");
session.setAttribute("USER_PW","1234");

Session Value Check Automation Model Creation

  1. Go to [File > New > X-UP Automation Model] and run the New Model Wizard.

  2. Enter the desired name into the [Model Name] field and click the [OK] button.

  1. The below screen will be displayed when the New Model Wizard is completed.

User_id and User_pw Parameters and UserMethod Creation

  1. Declare two variable parameters and name them user_id and user_pw.

  2. Double-click the UserMethod component and enter the following source code.

// Create session
UserSession session = this.getUserSession();
globalParameterSet.add("user_id",session.getAttribute("USER_ID"));
globalParameterSet.add("user_pw",session.getAttribute("USER_PW"));
  1. Connect the user_id and user_pw variables to userMethod as output parameters.

Session Termination Automation Model Creation

  1. Go to [File > New > X-UP Automation Model] and run the New Model Wizard.

  2. Enter the desired name into the [Model Name] field and click the [OK] button.

  1. The below screen will be displayed when the New Model Wizard is completed.

UserMethod Creation

  1. Double-click the UserMethod component and enter the following source code.

// Terminate session
UserSession session = this.getUserSession();
session.invalidate(true);

Testing

  1. Deploy the three models created above to a server.

  1. Call the UserLogin model.

  1. If the above model is called, the UserCheck model is also called.

    If the UserLogin model is successfully called, the user_id and user_pw values will be assigned to the session values.

  1. Verify that the user_id and user_pw values are properly output.

  1. After verifying the results, call the UserLogout model to terminate the session. When called, the previously-created session information are lost.

  2. After performing the above step, call the UserCheck model and verify that the previously-stored session value is null.

Cookie Handling

A cookie is a text sent from a web server to a client. It's stored on the client, and values are automatically sent to the server in a key=value format in the request header each time the same web server is accessed.

This section describes how cookie handling method in X-UP. The header values sent from a client are read using X-UP's header parameters, and the cookie values in the data are changed.

The model development stages described in this section are as follows:

X-UP Project Creation

  1. Go to [File > New > X-UP Project] and run the New X-UP Project Wizard.

  2. Enter the desired name into the [Project Name] field and click the [Finish] button.

  1. Verify that the X-UP project was created as shown in the image below.

Automation Model Creation

  1. Go to [File > New > X-UP Automation Model] and run the New Model Wizard.

  2. Enter the desired name into the [Model Name] field and click the [OK] button.

  1. The below screen will be displayed when the New Model Wizard is completed.

Header Parameter and UserMethod Creation

  1. Add a header parameter, and enter "cookie" for the name and schema.

  2. After adding a UserMethod, connect the cookie as an inputparameter.

UserMethod Logic Implementation and Output Parameter Setup

  1. Double-click the UserMethod and enter the following source code.

// Get cookie values from the header received from a client.
MashupHeader cookie= globalParameterSet.getHeader("cookie");
// Parse values in a key=value format.
String [] arrCookie = cookie.getValue().trim().split(";");
String cookieFullValue = "";
for(int iKey = 0; iKey < arrCookie.length; iKey++) {
	String[] cookieKeyVal = arrCookie[iKey].trim().split("=");
	String key = "";
	String value = "";
	if(cookieKeyVal.length == 1) {
		key = cookieKeyVal[0];
		value = "";
	} else {
		key = cookieKeyVal[0];
		value = cookieKeyVal[1];
	}
	if(key.equals("g_emp_no")) {
		value = "54321";
	}
	cookieFullValue += key+"="+value+"; ";
}
MashupHeader cookie1= globalParameterSet.getHeader("out_cookie");
cookie1.setValue(cookieFullValue);
  1. Add a header parameter, and enter "out_cookie" for the name, "set_cookie" for the schema, and "out" for the InOut type.

  2. Connect the generated out_cookie parameter to the UserMethod.

  1. Connect all components created above including the start and end nodes.

Test Screen Creation

Explanations are omitted for form screen and project creation in UX-Studio.

  1. Run UX-Studio and create a form screen named header_Form.

  2. Create a variable in GlobalVariables as follows:

  1. Add a button to the generated screen. Double-click the button and input the following function script.

function Button00_onclick(obj:Button, e:ClickEventInfo)
{
	alert(g_emp_no);
	var svcID = "testService";
	var svcparam = "domain=XupCOMM" // X-UP domain name
		+"&model=header_sample&service=xupservice" // X-UP model name
		+"&format=xml"
		+"&version=xplatform";

	var svcurl = "SERVER::xupservice.do?" + svcparam;
	var inputDataset = "";
	var outputDataset = "";
	var strArgument = "";
	transaction(svcID, svcurl, inputDataset, outputDataset, strArgument, 	
		"CallbackFunc",false);
}

function CallbackFunc(strSvcID, nErrorCode, strErrorMag)
{
	if (nErrorCode != 0)
	{
		alert(nErrorCode + " : " + strErrorMag);
		return;
	}
	alert(g_emp_no);
}
  1. Run the form screen and click the button.

  2. Verify that the initial cookie value is output as an empty value.

  1. Click the [OK] button and verify that the modified cookie value is input.

File Handling

This section describes model development using a file parameter.

Refer to the Sample DB Table Creation Script for database table information used in this section.

The development stages described in this section for an automation model that uses a file parameter are as follows:

X-UP Project Creation

  1. Go to [File > New > X-UP Project] and run the New X-UP Project Wizard.

  2. Enter the desired name into the [Project Name] field and click the [Finish] button.

  1. Verify that the X-UP project was created as shown in the image below.

Automation Model Creation

  1. Go to [File > New > X-UP Automation Model] and run the New Model Wizard.

  2. Enter the desired name into the [Model Name] field and click the [OK] button.

  1. The below screen will be displayed when the New Model Wizard is completed.

File Parameter and UserMethod Creation

  1. Add a file parameter, and enter "file" for the name and "text/xml" for the schema.

  2. After adding a UserMethod, connect the file parameter from the previous step as an input parameter.

UserMethod Logic Implementation and Test Parameter Setup

  1. Double-click the UserMethod and enter the following source code.

MashupFile file = globalParameterSet.getParameter("file").getFile();

String name = file.getName();
String path = file.getPath();

DataSet dataset1 = globalParameterSet.getDataSet("dataset1");

int row = dataset1.newRow();
dataset1.set(row, "NAME", name);
dataset1.set(row, "PATH", path);

globalParameterSet.add("dataset1", dataset1);
  1. Add a dataset, enter "dataset1" for the name, and define the schema as follows:

Name

Type

Size

NAME

string

20

PATH

string

100

  1. Connect dataset1 to the UserMethod as an output parameter.

Modify and Select Invoke Creation and Output Logic Setup

  1. Add a modify invoke.

  2. The target dataset is dataset1. Connect the dataset to the modify invoke as an input parameter.

  1. Double-click the modify invoke and enter the following into the insert query.

insert into FILETEST (NAME, PATH) values (#dataset1.NAME#, #dataset1.PATH#)

  1. Click the [Test] button.

  2. Delete the automatically-generated “RESULT0” output parameter after the test.

  3. Add a select invoke and enter the following query in the Invoke Select SQL window.

select
	NAME,
	PATH
from FILETEST

  1. Click the [Test] button, and then click the [OK] button.

  2. Connect the start and end nodes to all components created above.

Model Testing

Right-click on the model editor to display a popup menu. Select [Test] from the popup menu to test a model.

The test results are displayed in the Result ParameterSet window when completed.

User Library Handling

When creating an X-UP model, the user can add a library to use user-defined functions in addition to the X-UP functions provided in the editor.

The user library is registered in the project to be used in the Import User Library Dialog when developing an X-UP model.

Go to [Select project > mouse right-click > import > X-UP > User Libraries] to run the Import User Library Dialog.

Select a user library and click [Finish]. If a userlib folder does not already exist in the project, then it is automatically generated, and the selected .jar file is copied into the folder. In addition, the .jar file is automatically registered in the class path.

The user library can be excluded from the build path as follows:

Select the target library for deletion, and then select [Build Path > Remove from Build Path].

If you select [Remove from Build Path], the respective file is excluded from the build path and displayed under userlib folder. The file can be permanently deleted or added back to the build path at a later time.

The user library can re-added to the build path as follows:

Select the target library, and then select [Build Path > Add to Build Path].

The user library that was excluded from the build path can be deleted from a project as follows:

Select the target library for deletion, and then click [Delete].

X-UP Server Management

Start and Stop

X-UP operates as a web application on a web application server (WAS). Therefore, the X-UP's operation is dependent on the operation of the server on which it is installed.

Project Reporting

X-UP Builder provides the Export Project Report Dialog, a feature that allows the details of X-UP models to be exported to a document for convenient viewing. Go to [Select Project > mouse right-click > Export > X-UP > Project Report] to run the X-UP Project Report Dialog.

Click the [Next] button and proceed as follows:


Name

Description

1

Project Select List

Project select list.

2

Model Select List

Model select list.

3

File Format

File format. (docx / xlsx / html / text)

4

Target Directory

Target path for saving project report files.

5

Browse

Edit target path for saving project report files.

6

Finish

Create a project report file.

Select the target model for project reporting, and then select the desired export file format. Four file formats are available: MS Word (docx), MS Excel (xlsx), HTML (html), and Text (txt). Set the desired project report export directory in Target Directory. Click the [Finish] button to create a project report in the desired format.

Filtering

Before an action (insert, update, delete) is performed in X-UP with respect to a certain row, filtering allows a row to be filtered without execution if it satisfied a specific rule.

The following is a filtering example.

Name

Description

Rule Name

This value is used to differentiate multiple rules. Enter a value that does not overlap with another rule.

Parameter

Set an input parameter to be used in the rule.

Comparator

Set an input parameter condition.

Value

Enter a conditional constant if the value set in the comparator is not not empty, empty, or custom.

Filtering is only applied to a modify invoke. Please refer to the section Model Development Using Modify Invoke for a detailed example.

Distributed Transaction

We recommend that users do not explicitly perform commit and rollback in X-UP. Transaction control is already processed in X-UP as follows:

Commit and rollback for legacy connections, such as DB and SAP JCo, are determined according to the following policies:

To perform a rollback for the legacy connection, an exception is thrown or an error code parameter is generated and a negative value is set with respect to the corresponding request.

Multi-lingual Handling

X-UP handles multiple languages according to the following rules.

For example, if the character set of a client request is euc-kr, the same character set is used to collect data from a data source. Then, the collected and processed data is sent with euc-kr encoding in a response to the client. However, if the data collected from a data source is UTF-8, the data is sent to the client in its original character set without re-encoding to euc-kr.

The following is a logic that determines the character set of a client request.

  1. Obtain the character set specified in the data itself. (e.g. xml)

  2. If none exists, obtain the character set from the request if it was an HttpRequest.

    1. Obtain the character set contained in the header's CONTENT-TYPE.

    2. If none exists, obtain the character set contained in the header's ACCEPT-CHARSET.

    3. If none exists, obtain the character set with the language contained in the header's ACCEPT-LANUAGE.

  3. If none exists, use the character set defined in the model.

    1. Obtain the character set defined in the model's metadata.

    2. If none exists, obtain the character set defined in the datasource used by the model.

  4. If none exists, define UTF-8 as the character set.

JUnit & Remote Class Creation

To provide users with convenient debugging, X-UP provides a feature to automatically generate JUnit and Remote classes.

When a user selects a model for testing and clicks one of the menu items below, a simple JUnit class and Remote class are generated.

Name

Description

generate Remote Test Source

Create a test class for remote testing based on the selected model.

generate Junit Test Class

Create a simple JUnit test case that can test the selected model.

generate All Junit Test Class

Create a JUnit test case for all models that exist in the selected project.

JUnit Test Class Creation

  1. Select a model for testing.

  2. Click the [] button on the development toolbar.

  3. Verify that a JUnit test class was generated in the logics folder with "_junit" following the original class name.

  1. Alternatively, you can right-click on a selected project and select [X-UP > Generate All Junit Test Class].

Run debug mode after creating a JUnit test class.

To debug a model after adding a breakpoint, create a Java test case file (using auto-generate Junit Test Case menu) for the respective model and run in Java debug mode.

The subsequent steps are identical to regular Java debug.

Remote Test Source Creation

  1. Select a model for testing.

  2. Click the [] button on the development toolbar.

  3. Verify that a Remote Test Source class was generated in the logics folder with "_remote" following the original class name.