On 18/10/2018 08:44, Matjaz Premerl wrote:
> Please correct me if I understand wrong. With calling Java function directly 
> in datasets you mean that I could prepare some custom Java class e.g. XX with 
> some methods in it and package it as jar file.
> Then I could copy such jar file to the place of other jar files, to e.g. 
> /usr/lib/lsc. Then within lsc.xml configuration I can call those java method 
> directly like.
> var x = <name of custom Classs>.<NameOfMethod> with some e.g. parameters? Is 
> this possible like that?

Hi Matjaz,

Yes this is the way, I've just tested it with this steps :

1. Create jar file with your class in it;

- in a folder, create folder path com/myjar
- Add a file Utils.java in myjar folder, containing :
package com.myjar;
public class Utils {
        public static String helloWorld() {
                return "hello world";
        }
}
- compile : javac com/myjar/Utils.java
- package : jar cfv myjar.jar com.myjar.Utils com/myjar/Utils.class

2. Place myjar.jar file into your %lsc_home%/libs folder;

3. Add this in your lsc.xml :

        <dataset>
           <name>sn</name>
           <forceValues>
            <string>js:importPackage(com.myjar);Utils.helloWorld();</string>
           </forceValues>
        </dataset>


=> Result : The sn attributes of users are all populated with string "hello 
world".

Regards,
-- 
Soisik
_______________________________________________________________
Ldap Synchronization Connector (LSC) - http://lsc-project.org

lsc-users mailing list
[email protected]
https://lists.lsc-project.org/cgi-bin/mailman/listinfo/lsc-users

Reply via email to