Configuring Java Global Instance Shared Resource

You can configure Java global instance shared resource for an activity according to your own environment.

Prerequisites

Ensure that you have created a process to include the activity that contains the created Java global instance shared resource, as described in Creating a Process.

Procedure

  1. In the General tab of your created activity, click to create or choose a default resource.
    1. In the Select JavaGlobalInstanceResource Resource Template dialog, click Create Shared Resource.
    2. In the Java Global Instance Resource dialog, review the detailed information, and click Finish.
  2. In the Project Explorer view, expand project name, right-click the src folder, and select New > Class.
    Note: You have to select the Use Java configuration check box when you create the project, and then the src folder can be created.
  3. In the Java Class dialog, specify values in the Package and Name fields. Click Finish.
  4. In the new .java file, add your own code logic, and save the file.

    This is an example:

    package com.test;
    
    public class Person {	
        private String name;	
        private String age;	
    
        public Person(String name, String age) {		
            this.name = name;		
            this.age = age;	
        }	
    
        public void setName(String name) {	
       	    this.name = name;	
        }	
    
        public String getName() {		
            return name;	
        }	
    
        public void setAge(String age) {		
            this.age = age;	
        }	
    
        public String getAge() {		
            return age;	
        } 
    }
  5. In the Project Explorer view, expand project name > Resources > project name > JavaGlobalInstanceResource.javaGlobalInstanceResource.
  6. In the JavaGlobalInstanceResource.javaGlobalInstanceResource file, find the Java Global Instance tab.
    1. Click Browse to find the .java file that created in Step 4. In the Class Selection dialog, enter the .java file name to find the created file. Select the file in the Matching items field, and click OK.
    2. From the Method list, select the constructor of the class.
    3. In the Parameter Input area, specify a value in the Value field for the parameter. For example, default.
  7. In the Advanced Configuration tab, select the Invoke Cleanup Method check box, and select clean() from the Cleanup Method list. Save your configurations.
  8. In the Project Explorer view, expand com.company_name.bw.palette.palette_name.runtime > src > com.company_name.bw.palette.palette_name.runtime > activity_nameactivity_type.java.
  9. Double-click the .java file, you can see the code changes of the created Java global instance shared resource.
    /**
     * 
     *
     * 
     * @generated
     */
    @Property(name = "JavaGlobalInstanceName")
    public JavaGlobalInstanceResource javaGlobalInstanceResource;