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:
Automation model start and termination handling. (Logging, session handling, performance measurement, etc.)
Data source connection-related handling when calling a model.
Invoke start and termination handling.
Exception handling.
Session handling.
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:
X-UP Global Event Creation
Event Target Setup
Interceptor Class Creation
Testing
The model created in Model Development Using SAP RFC Invoke is used in this section.
X-UP Global Event Creation
Click the [Create Global Event] button or select [X-UP > Create Global Event] from the menu to create a global event.
Click [OK] on the confirmation window.
The following screen is displayed when a global event is generated.
Event Target Setup
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.
To set a global event, click the [Add] button and select an event to be applied.
To apply the event to all models, select AutomationLogic as the TargetClass, and select start as the TargetMethod.
Create a UserClass to insert a business logic.
Enter a class name to be created, and then click the [Class] button to create the class.
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
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
Run the model to test whether a global event was successfully applied.
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
Login Automation Model Creation
UserMethod Creation
Session Value Check Automation Model Creation
User_id and User_pw Parameters and UserMethod Creation
Session Termination Automation Model Creation
UserMethod Creation
Model Testing
X-UP Project Creation
Go to [File > New > X-UP Project] and run the New X-UP Project Wizard.
Enter the desired name into the [Project Name] field and click the [Finish] button.
Verify that the X-UP project was created as shown in the image below.
Automation Model Creation
Go to [File > New > X-UP Automation Model] and run the New Model Wizard.
Enter the desired name into the [Model Name] field and click the [OK] button.
The below screen will be displayed when the New Model Wizard is completed.
UserMethod Creation
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
Go to [File > New > X-UP Automation Model] and run the New Model Wizard.
Enter the desired name into the [Model Name] field and click the [OK] button.
The below screen will be displayed when the New Model Wizard is completed.
User_id and User_pw Parameters and UserMethod Creation
Declare two variable parameters and name them user_id and user_pw.
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"));
Connect the user_id and user_pw variables to userMethod as output parameters.
Session Termination Automation Model Creation
Go to [File > New > X-UP Automation Model] and run the New Model Wizard.
Enter the desired name into the [Model Name] field and click the [OK] button.
The below screen will be displayed when the New Model Wizard is completed.
UserMethod Creation
Double-click the UserMethod component and enter the following source code.
// Terminate session UserSession session = this.getUserSession(); session.invalidate(true);
Testing
Deploy the three models created above to a server.
Call the UserLogin model.
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.
Verify that the user_id and user_pw values are properly output.
After verifying the results, call the UserLogout model to terminate the session. When called, the previously-created session information are lost.
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
Automation Model Creation
Header Parameter and UserMethod Creation
UserMethod Logic Implementation and Output Parameter Setup
Model Testing
X-UP Project Creation
Go to [File > New > X-UP Project] and run the New X-UP Project Wizard.
Enter the desired name into the [Project Name] field and click the [Finish] button.
Verify that the X-UP project was created as shown in the image below.
Automation Model Creation
Go to [File > New > X-UP Automation Model] and run the New Model Wizard.
Enter the desired name into the [Model Name] field and click the [OK] button.
The below screen will be displayed when the New Model Wizard is completed.
Header Parameter and UserMethod Creation
Add a header parameter, and enter "cookie" for the name and schema.
After adding a UserMethod, connect the cookie as an inputparameter.
UserMethod Logic Implementation and Output Parameter Setup
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);
Add a header parameter, and enter "out_cookie" for the name, "set_cookie" for the schema, and "out" for the InOut type.
Connect the generated out_cookie parameter to the UserMethod.
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.
Run UX-Studio and create a form screen named header_Form.
Create a variable in GlobalVariables as follows:
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); }
Run the form screen and click the button.
Verify that the initial cookie value is output as an empty value.
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
Automation Model Creation
File Parameter and UserMethod Creation
UserMethod Logic Implementation and Test Parameter Setup
Modify and Select Invoke Creation and Output Logic Setup
Model Testing
X-UP Project Creation
Go to [File > New > X-UP Project] and run the New X-UP Project Wizard.
Enter the desired name into the [Project Name] field and click the [Finish] button.
Verify that the X-UP project was created as shown in the image below.
Automation Model Creation
Go to [File > New > X-UP Automation Model] and run the New Model Wizard.
Enter the desired name into the [Model Name] field and click the [OK] button.
The below screen will be displayed when the New Model Wizard is completed.
File Parameter and UserMethod Creation
Add a file parameter, and enter "file" for the name and "text/xml" for the schema.
After adding a UserMethod, connect the file parameter from the previous step as an input parameter.
UserMethod Logic Implementation and Test Parameter Setup
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);
Add a dataset, enter "dataset1" for the name, and define the schema as follows:
Name | Type | Size |
---|---|---|
NAME | string | 20 |
PATH | string | 100 |
Connect dataset1 to the UserMethod as an output parameter.
Modify and Select Invoke Creation and Output Logic Setup
Add a modify invoke.
The target dataset is dataset1. Connect the dataset to the modify invoke as an input parameter.
Double-click the modify invoke and enter the following into the insert query.
insert into FILETEST (NAME, PATH) values (#dataset1.NAME#, #dataset1.PATH#)
Click the [Test] button.
Delete the automatically-generated “RESULT0” output parameter after the test.
Add a select invoke and enter the following query in the Invoke Select SQL window.
select
NAME,
PATH
from FILETEST
Click the [Test] button, and then click the [OK] button.
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:
Distributed Transaction Processing
Transaction start: The point at which X-UP receives a user request to begin processing.
Transaction end: The point at which X-UP outputs a user response.
Commit and rollback for legacy connections, such as DB and SAP JCo, are determined according to the following policies:
Commit
When processing is completed normally to the end point without throwing an exception.
When an ErrorCode does not exist in the output parameters, or the value is 0 or positive even if it does exist.
Rollback
When an exception is thrown.
When an ErrorCode does exist in the output parameters and the value is negative.
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.
Pass data requested to and received from a dataset to a client in the same character set as that contained in the client request.
If the character set of client request is different from the character set in the data collected from a data source, the data's character set is passed to the client as-is.
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.
Obtain the character set specified in the data itself. (e.g. xml)
If none exists, obtain the character set from the request if it was an HttpRequest.
Obtain the character set contained in the header's CONTENT-TYPE.
If none exists, obtain the character set contained in the header's ACCEPT-CHARSET.
If none exists, obtain the character set with the language contained in the header's ACCEPT-LANUAGE.
If none exists, use the character set defined in the model.
Obtain the character set defined in the model's metadata.
If none exists, obtain the character set defined in the datasource used by the model.
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
Select a model for testing.
Click the [] button on the development toolbar.
Verify that a JUnit test class was generated in the logics folder with "_junit" following the original class name.
Alternatively, you can select [Common > generate Junit Test Class] from the menu bar.
To create a JUnit test class for every model in a project, select the desired project and select [Common > generate All Junit Test Class].
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
Select a model for testing.
Click the [] button on the development toolbar.
Verify that a Remote Test Source class was generated in the logics folder with "_remote" following the original class name.
Alternatively, you can select [Common > generate Remote Test Source] from the menu bar.