在WebSphere Application Server中一起实现JSF-2.3和CDI [英] implementing JSF-2.3 and CDI together in WebSphere Application Server

查看:128
本文介绍了在WebSphere Application Server中一起实现JSF-2.3和CDI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近已升级为使用 Oracle新的JSF-2.3 涉及在我使用maven时在我的pom.xml中将依赖项添加为外部库,这与之前使用WebSphere Application Server(WAS)内置的JSF-2.2功能。我想进行升级以利用新的f:websocket功能,该功能允许我将消息从服​​务器推送到客户端,以进行一些聪明的异步页面加载。

I have recently upgraded to using Oracles new JSF-2.3 which involved adding the dependency as an external library in my pom.xml as I am using maven, As opposed to previously using WebSphere Application server's (WAS) inbuilt JSF-2.2 feature. I wanted to upgrade to make use of the new f:websocket feature which allows me to push messages from server to client for some clever asynchronous page loading.

但是在我们获得之前升级后,我注意到@ManagedBean批注已被弃用。经过快速搜索之后,我发现我应该使用@Named等CDI注释,这使我进入了 JSF-2.3找不到我的@Named CDI-1.2托管Bean 问题,从中得知我无法将外部JSF库与WAS的内置CDI -1.2功能

But before we get into that, once I upgraded, I noticed that my @ManagedBean annotations were deprecated. After some quick googling I found I should be using CDI annotations like @Named etc. which led me to my JSF-2.3 not finding my @Named CDI-1.2 managed bean question, from which I learnt that I could not use an external JSF library with WAS's inbuilt CDI-1.2 feature together.

我的问题是,根据 JSF-2.3规范我需要将 PushContext注入变量在我的托管bean上使用CDI @Inject注释,如下所示:

My issue is, according to the JSF-2.3 spec on the server side I need to inject a "PushContext" into a variable on my managed bean using the CDI @Inject annotation like so:

@Inject @Push(channel="foo")
private PushContext bar;

我找不到与@Inject等效的JSF注释,该注释可以将实例注入到我的PushContext变量,并尝试使用@ManagedProperty作为示例。因此,我需要与JSF 2.3一起使用CDI的实现才能使这项工作完成。

I have been unable to find a JSF equivalent annotation to @Inject which works to inject an instance into my PushContext variable and have tried @ManagedProperty for example. So I need to get an implementation of CDI working with JSF 2.3 to make this work.


  • 我尝试使用上述问题中显示的代码在WAS中使用内置的CDI功能。

  • 我尝试不使用默认的CDI功能,并在我的pom.xml中添加 CDI-1.2依赖添加CDI作为外部库)

  • 还尝试只添加 Javax.inject库,因为我需要将@Inject批注作为依赖项而不是CDI也不能使用(值得一试)

  • I have tried using inbuilt CDI feature in WAS with the code shown in my above mentioned question.
  • I have tried not using the default CDI feature, and adding a CDI-1.2 dependency in my pom.xml (so adding CDI as an external library) which also didn't work
  • Have also tried only adding the Javax.inject library since all I needed the @Inject annotation as a dependency instead of CDI which also didn't work (was worth a try)

如果我无法获得CDI的实现,我该如何使用WAS的新JSF-2.3功能就迷茫了当然可以使用自定义JSF库我缺少了某些东西……

I am lost as to how I am supposed to make use of the new JSF-2.3 features in WAS if I can't get an implementation of CDI working with a custom JSF library, surely I am missing something...

我也听说过 cdi-enablers这些东西可以帮助我吗?他们合法吗?还是只是有人将某些东西合在一起使某些东西起作用?

I have also heard of something called "cdi-enablers" can these help me ? are they legit ? or just some hacks someone put together to make something work ?

帮助!!!

推荐答案

经过大量研究和论坛讨论,我得出的结论是,让JSF-2.3和CDI-1.2一起使用WAS中的f:websocket功能几乎是不可能的。请参阅我在IBM支持页面上的帖子证实了这一点。

After much research and forum trawling, I have concluded that getting JSF-2.3 and CDI-1.2 working together to make use of the f:websocket feature in WAS is near impossible. See my post on IBM support page which confirms this.

一种仍使用JSF-2.2的Web套接字的方法是使用Javax.websocket包,如@Gas在我的上一个问题。但是,此Web套接字实现的局限性在于,仅像使用JSF-2.3中的f:websocket一样,将SessionScoped ManagedBean中包含的数据发送到该会话的客户端并不容易,

A way to still make use of web sockets using JSF-2.2 is to use the Javax.websocket package as @Gas pointed out in my previous question. However the limitation of this web socket implementation is that it is nowhere near as easy to send data contained in a SessionScoped ManagedBean to the client of that session only as it would have been using f:websocket from JSF-2.3 as I would have liked to do.

这篇关于在WebSphere Application Server中一起实现JSF-2.3和CDI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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