cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing container object inside Java mapping

minal_vaidya2
Explorer
0 Kudos

Hello

My requirement is to call a existing UDF inside a Java mapping. The UDF has only one input variable that is Container, when I am calling this UDF inside Java map, I am getting error as container can not be resolved to a variable. I tried declaring it as Container container but its throwing initialization error.

Below is the UDF call.


FL_HR_Workday fl_hr_workday = new FL_HR_Workday();

String wsse_Header = fl_hr_workday.getWSSE_SecurityHeader(container);

Is there any way to access existing container object and pass it to udf?

We are using PI7.4 dual stack.

Thanks,

Minal

Accepted Solutions (1)

Accepted Solutions (1)

bhavesh_kantilal
Active Contributor
0 Kudos

Is this a User Define Function within a Graphical Mapping? If yes, I am not sure I understand why you would want to access a Graphical Mapping UDF from a Java Mapping. Is that even possible?

Could you let us know more on the requirement or am I completely off track?

Regards

Bhavesh

minal_vaidya2
Explorer
0 Kudos

@Inaki Vila,

I have checked the API but didnt find anything specific to this requirement.

@Bhavesh,

Requirement is to call UDF which is a part of Function Library in Java mapping.This UDF is a common UDF used across multiple mappings, the information stored in this UDF is required in Java mapping.

So I have written below code to access the UDF in Java mapping.


FL_HR_Workday fl_hr_workday = new FL_HR_Workday();

String wsse_Header = fl_hr_workday.getWSSE_SecurityHeader(container);


If container is initialized as NULL as mentioned by Eng Swee Yeoh then I am able to call the UDF. This is working when container object is not used in the UDF.

Container container = NULL;

FL_HR_Workday fl_hr_workday = new FL_HR_Workday();

String wsse_Header = fl_hr_workday.getWSSE_SecurityHeader(container);


However if I use container for ex. for getting trace inside UDF then the java map is throwing error, since container is initialized as NULL in it.

So I believe only way to make this work is to get container for java map and pass it to UDF (without passing it as NULL).

Please let me know if thats possible.

engswee
Active Contributor
0 Kudos

Minal

I asked earlier if container is used in the UDF logic and you said no. Now you are saying you want to use the container in the existing UDF for trace. However, that means will indicate that you will change the UDF in a Function Library that is may already be used by other mappings etc. Is that what you are planning to do?

Regards

Eng Swee

minal_vaidya2
Explorer
0 Kudos

Hi Eng Swee,

Currently we are not using container in UDF. But going forward, If required we might add it in the UDF.

Null works when container is not used. But if we have to use it then is there a way to pass something from java map ?

Thanks

Minal

engswee
Active Contributor
0 Kudos

Hi Minal

AFAIK, there is no access to the Container object from a Java mapping. Container is only available from Graphical Mapping.

Maybe you might want to change the approach of your reusable methods/libraries. Instead of putting the core logic in a Function Library's UDF, develop them as classes externally, then import them as JAR files for reference. With this approach, they can be used by both UDFs or Java mapping

- UDF - can call the methods in the JAR file as long as the relevant import statement is included

- Java mapping - can include the JAR file in the build path

Regards

Eng Swee

minal_vaidya2
Explorer
0 Kudos

Thanks Eng Swee Yeoh for the help.

Its not possible to access container inside Java map. We finally changed our approach to multiple Java classes. Called the required functionality through another java class inside the main java mapping.

Answers (1)

Answers (1)

engswee
Active Contributor
0 Kudos

Hi Minal

In the UDF logic, is the container used? If not, then just pass in null from your Java mapping.

Regards

Eng Swee

minal_vaidya2
Explorer
0 Kudos

Thanks for the reply.

We are not using it in UDF, its just a default argument of that UDF.

Is there any way to get the container of Java map and pass it to UDF ?

engswee
Active Contributor
0 Kudos

If it's not being used in the UDF, then you can just pass in null when you call the UDF from Java mapping. You don't need to get the container in Java mapping.

iaki_vila
Active Contributor
0 Kudos

Hi Minal,

Have you checked the API Container?

Regards.