GlassFish 应用程序客户端容器
我正在尝试使用 嵌入式 Glassfish 应用程序客户端容器。 我能找到的唯一资源是上面提到的 javadoc,其中包含这个诱人的代码片段
import org.glassfish.appclient.client.acc.AppClientContainer;
import org.glassfish.appclient.client.acc.config.TargetServer;
AppClientContainerBuilder builder = AppClientContainer.newBuilder(
new TargetServer("localhost", 3700));
AppClientContainer acc = builder.newContainer(new File("myAC.jar").toURI());
(或者,),
AppClientContainer acc = builder.newContainer(MyClient.class);
然后,
acc.startClient(clientArgs);
// The newContainer method returns as soon as the client's main method returns,
// even if the client has started another thread or is using the AWT event
// dispatcher thread
// At some later point, the program can synchronize with the app client in
// a user-specified way at which point it could invoke
acc.stop();
这看起来非常棒,但我尝试让它运行几次,并出现各种不同的错误。
有没有人有使用此功能的经验,或者他们可以向我指出一些解释如何使用此功能的资源的方向吗?
I'm trying to work with the Embeddable Glassfish app client container.
The only resources I can find are the above mentioned javadocs which contain this tantalising code snippet
import org.glassfish.appclient.client.acc.AppClientContainer;
import org.glassfish.appclient.client.acc.config.TargetServer;
AppClientContainerBuilder builder = AppClientContainer.newBuilder(
new TargetServer("localhost", 3700));
AppClientContainer acc = builder.newContainer(new File("myAC.jar").toURI());
(or, alternatively)
AppClientContainer acc = builder.newContainer(MyClient.class);
then,
acc.startClient(clientArgs);
// The newContainer method returns as soon as the client's main method returns,
// even if the client has started another thread or is using the AWT event
// dispatcher thread
// At some later point, the program can synchronize with the app client in
// a user-specified way at which point it could invoke
acc.stop();
This looks pretty awesome, but I've tried to get this to run a couple of times with various different errors.
Has anybody got any experience using this, or could they point me in the direction of some resources that explain how to work with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
关于使用开发客户端似乎有相当多的文档Oracle 网站上的 ACC。
There seems to be a decent bit of documentation around developing clients using the ACC on Oracle's site.
我将其与 Glassfish 3.1.2 和一个简单的 Java Swing UI 应用程序一起使用。
TargetServer 指定的主机/端口似乎被忽略,我必须设置系统属性:
才能获得连接,因为我没有在默认端口上运行。
要全部编译,如果 Oracle 记录 AppClientContainer 等位于包中,将会有所帮助:
然后您可以找到编译所需的 .jar,它们是:
AppClientContainer.startClient 尝试调用一个方法:
在 MyClient.class 上,这可能不完全是您想要的;就我而言,我的目标是使其与基于 Eclipse 的应用程序一起工作,该应用程序也希望“拥有”启动权。此外,我需要的 OSGI 环境似乎与 Glassfish ACC 完全不一致,它有自己不兼容的类加载机制。
尽管 startClient 调用需要它,但 main 方法似乎没有在单独的线程或任何特殊的东西中被调用。我发现我可以简单地提供一个虚拟主函数,它不执行任何操作,并且在 startClient 调用返回后立即拥有所有应用程序代码。
整个 ACC 实现似乎是将独立客户端连接到 Glassfish 3 上运行的应用程序的唯一受支持的方式。与 v2 的简单性相比,它相当不令人满意。庞大的 .jar 列表包含了我根本不感兴趣的各种内容,实际上在启动时我看到了这条消息:
Also Oracle has dumped an SLF4J logger implementation in bean-validator.jar which is colliding with my own favorite实施,导致进一步的错误消息。
Glassfish EJB 常见问题解答位于 http://glassfish.java.net/javaee5/ejb/EJB_FAQ。 html 已更新为 v3,也有一些帮助。
I have this working with Glassfish 3.1.2 and a simple Java Swing UI application.
The host/port specified by TargetServer appears to be ignored, I had to set the system properties:
to get a connection as I am not running on the default ports.
To get it all to compile, it would help if Oracle documented that AppClientContainer etc. are in package:
then you can find which .jars are needed for compilation, which were:
The AppClientContainer.startClient attempts to invokes a method:
on MyClient.class, which might not be exactly what you want; In my case my goal is to make this work with an Eclipse-based application, which would also like to "own" the launch. In addition the OSGI environment I need seems to be completely at odds with the Glassfish ACC, having its own incompatible classloading mechanism.
Although it's needed for the startClient call, the main method doesn't seem to get called in a separate Thread or anything special. I found I can simply supply a dummy main which does nothing and have all my application code straight after the startClient call returns.
This whole ACC implementation seems to be the only supported way of connecting a standalone client to an application running on Glassfish 3. It is rather unsatisfactory compared to the simplicity available with v2. The huge list of .jars includes all sorts of things that are of no interest to me at all, indeed at startup I see this message:
Also Oracle have dumped an SLF4J logger implementation in bean-validator.jar which is colliding with my own preferred implementation, causing a further error message.
The Glassfish EJB FAQ at http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html has been updated for v3 and is also of some help.