简体   繁体   English

LS2J:从LS代理到java类的会话

[英]LS2J: get session from LS agent into java class

I have a java class that should transfer data from the current database to another server. 我有一个java类,应该将数据从当前数据库传输到另一个服务器。 To access the current database, it seems that Java needs a working Session object: 要访问当前数据库,似乎Java需要一个有效的Session对象:

public class EdgeServerConnection
{
    public EdgeServerConnection(Session session) {
        try {
            // How to get the session into here?
            Database db = session.getCurrentDatabase();
            ...
        } catch(Exception e) {
        }
    }
}

The class should be called from a LotusScript agent, somehow like this: 应该从LotusScript代理调用该类,不管怎么样:

Set session = New NotesSession
Set jsession = New JAVASESSION
Set connectionClass = jsession.GetClass("EdgeServerConnection")
Set connectionObject = connectionClass.CreateObject("(L/lotus/notes/Session;V)", session)

But this throws the error 但这会引发错误

LS2J: java constructor failed to execute LS2J:java构造函数无法执行

If I remove the Session parameter from both the constructor and the CreateObject call, the error goes away. 如果我从构造函数和CreateObject调用中删除Session参数,则错误消失。

How can I get the agent session into the java class? 如何将代理会话引入java类?

You can't work with Domino objects in Java class called by LS2J nor can you pass Domino objects as parameter. 您不能使用LS2J调用的Java类中的Domino对象,也不能将Domino对象作为参数传递。

Do all your work with Notes Domino classes in LotusScript and use Java classes for the tasks you really need to accomplish with Java only. 在LotusScript中使用Notes Domino类完成所有工作,并使用Java类来完成您真正需要使用Java完成的任务。

As an alternative, you can create an Java agent which does all the work. 作为替代方案,您可以创建一个完成所有工作的Java代理。 You can call the Java agent from LotusScript then. 您可以从LotusScript调用Java代理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM