在Domino Java Agent中使用枚举单例编码模式 [英] Using enum singleton coding pattern in a Domino Java Agent

查看:168
本文介绍了在Domino Java Agent中使用枚举单例编码模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以这是我想要运行的非常简化的Lotus Domino Java代理代码...

So this is the very simplified Lotus Domino Java agent code I am trying to run...

import lotus.domino.*;

enum SingletonTest { 
    INSTANCE;

    public void helloWorld() {
        System.out.println("Hello World");
    }
}

public class JavaAgent extends AgentBase {

    public void NotesMain() {

        try {
            System.out.println("Started");
            SingletonTest.INSTANCE.helloWorld();
            System.out.println("Done");

        } catch(Exception e) {
            e.printStackTrace();
        }
    }
}

但是当我尝试跑步时这就是Java控制台上出现的内容......

But when I try to run it this is what appears on the Java Console...

Started
Exception in thread "AgentThread: JavaAgent" java.lang.VerifyError: JVMCFRE028 ldc* bytecode must reference a constant; class=, method=valueOf(Ljava/lang/String;)LSingletonTest;, pc=0
    at java.lang.ClassLoader.defineClassImpl(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:275)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:212)
    at lotus.domino.AgentLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:626)
    at JavaAgent.NotesMain(JavaAgent.java:17)
    at lotus.domino.AgentBase.runNotes(Unknown Source)
    at lotus.domino.NotesThread.run(Unknown Source)

我正在为我的代理人使用Java 1.6。我使用的是v8.5.3 FP3,在我的notes.ini中我有..

I am using Java 1.6 for my agent. I am using v8.5.3 FP3 and in my notes.ini I have..

JavaCompilerTarget = CurrentJavaVersion

JavaCompilerTarget=CurrentJavaVersion

那么我做错了什么?

使用包含代码的枚举的IBM Java版本加载器是否存在问题?

Is there a problem with the IBM Java version class loader using an enum that contains code?

这是我试图遵循的单例编码模式...

This is the singleton coding pattern I have tried to follow...

https://stackoverflow.com/a/71399/2530065

编辑:
我可能应该添加我正在运行此作为Notes客户端代理,具有触发:在事件:操作菜单选择和目标:无。

edit: I probably should add I am running this as a Notes client agent with "Trigger:On event:Action Menu selection" and "Target:None".

edit2:
所以我已经测试了这个使用相同的IBM JRE / JVM的独立Java程序中的代码,代码完美无缺。我似乎无法让它作为Notes客户端中的Java代理工作。

edit2: So I have tested this exact code in a standalone Java program using the same IBM JRE/JVM and the code works perfectly without any issues. I just can't seem to get it to work as a Java agent within the Notes client.

推荐答案

最后我发现更改了NOTES.INI设置 JavaCompilerTarget 来自...

In the end I found changing the NOTES.INI setting JavaCompilerTarget from...

JavaCompilerTarget = CurrentJavaVersion

JavaCompilerTarget=CurrentJavaVersion

... to ...

...to...

JavaCompilerTarget = 1.6

JavaCompilerTarget=1.6

并从头开始重新创建代理修复了问题。

and recreating the agent from scratch fixed the problem.

对于Java代理,似乎代理doc上有两个控制源和目标Java版本的字段。

For Java agents it looks like there are two fields on the agent doc which control source and target Java versions.

这些是$ JavaCompilerSource和$ JavaCompilerTarget。

These are $JavaCompilerSource and $JavaCompilerTarget.

它们是在创建Java代理时设置的。这些字段的值取决于创建代理时NOTES.INI JavaCompilerTarget条目的值。在创建代理程序并编辑或重新编译代理程序后更改NOTES.INI条目无效。

They are set when a Java agent is created. The value of these fields depends on the value of the NOTES.INI JavaCompilerTarget entry when the agent was created. Changing the NOTES.INI entry after the agent is created and editing or recompiling the agent has no effect.

如果我在NOTES.INI变量JavaCompilerTarget时创建Java代理程序设置为CurrentJavaVersion,字段$ JavaCompilerTarget设置为值CurrentJ,字段$ JavaCompilerSource设置为值1.6。

If I create a Java agent when the NOTES.INI variable "JavaCompilerTarget" is set to "CurrentJavaVersion", the field "$JavaCompilerTarget" gets set to the value "CurrentJ" and the field "$JavaCompilerSource" gets set to the value "1.6".

如果我在NOTES.INI变量JavaCompilerTarget设置为1.6时创建Java代理,则字段$ JavaCompilerTarget设置为值1.6,字段$ JavaCompilerSource设置为值1.6。

If I create a Java agent when the NOTES.INI variable "JavaCompilerTarget" is set to "1.6" then the field "$JavaCompilerTarget" gets set to the value "1.6" and the field "$JavaCompilerSource" gets set to the value "1.6".

如果此特定代理的$ JavaCompilerTarget字段的值为CurrentJ,那么我将获得异常。

If this particular agent's "$JavaCompilerTarget" field has a value of "CurrentJ" then I get the exception.

然而,如果我重新创建相同的代理并且其$ JavaCompilerTarget字段的值为1.6,那么我不会得到异常。

Whereas if I recreate the same agent and its "$JavaCompilerTarget" field has a value of "1.6", I do not get the exception.

如果我在NOTES.INI变量设置为1.5时重新创建此代理,则两个代理字段值都设置为1.5,代理运行时没有任何错误。

If I recreate this agent when the NOTES.INI variable is set to "1.5" then both the agent field values are set to "1.5" and the agent runs without any errors.

如果我使用ytria scanEZ更改损坏的代理(具有字段$ JavaCompilerTarget =CurrentJ的代理),那么值为1.6,然后我打开并且在设计器中重新保存代理,它不再抛出异常。如果我将字段值更改回CurrentJ并重新保存代理,它会再次抛出异常。

If I use ytria scanEZ to change the broken agent (the one that has the field $JavaCompilerTarget="CurrentJ") so that the value is "1.6" instead, and I then open and re-save the agent in designer, it no longer throws an exception. If I change the field value back to "CurrentJ" and re-save the agent it throws the exception again.

所以它似乎有一个Java代理字段$ JavaCompilerTarget =当你有一个JavaCompilerTarget = CurrentJavaVersion的NOTES.INI条目时,CurrentJ就不好了。

So it seems having a Java agent field $JavaCompilerTarget="CurrentJ" is not good and this happens when you have a NOTES.INI entry of JavaCompilerTarget=CurrentJavaVersion.

我不知道为什么这会改变JVM的行为,但它会我在8.5.3 FP3。

I have no idea why this changes the JVM behaviour but it does for me on 8.5.3 FP3.

这篇关于在Domino Java Agent中使用枚举单例编码模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆