简体   繁体   English

在WebSphere Application Server中一起实现JSF-2.3和CDI

[英]implementing JSF-2.3 and CDI together in WebSphere Application Server

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

But before we get into that, once I upgraded, I noticed that my @ManagedBean annotations were deprecated. 但是在进行此操作之前,一旦我进行了升级,我注意到@ManagedBean批注已被弃用。 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. 快速搜索之后,我发现我应该使用@Named等CDI注释,这导致我的JSF-2.3找不到我的@Named CDI-1.2托管bean问题,从中我得知我无法使用外部JSF库与WAS的内置CDI-1.2功能一起使用。

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: 我的问题是,根据服务器端的JSF-2.3规范 ,我需要使用CDI @Inject注释将“ PushContext”注入到托管bean的变量中,如下所示:

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

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. 我一直找不到与@Inject等效的JSF注释,该注释可以将实例注入到我的PushContext变量中,并且尝试了例如@ManagedProperty。 So I need to get an implementation of CDI working with JSF 2.3 to make this work. 因此,我需要使用JSF 2.3来实现CDI的实现,才能完成这项工作。

Things I have tried: 我尝试过的事情:

  • I have tried using inbuilt CDI feature in WAS with the code shown in my above mentioned question. 我尝试将WAS中的内置CDI功能与上述问题中显示的代码一起使用。
  • 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 我尝试不使用默认的CDI功能,并在pom.xml中添加CDI-1.2依赖项 (因此将CDI添加为外部库)也无法正常工作
  • 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) 还尝试过仅添加Javax.inject库,因为我只需要@Inject注释作为依赖项而不是CDI也不能用 (值得一试)

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... 如果我无法使用自定义JSF库来实现CDI的实现,我将迷失在WAS中应该如何利用新的JSF-2.3功能的方式,我肯定会丢失一些东西...

I have also heard of something called "cdi-enablers" can these help me ? 我还听说过“ cdi-enablers”可以帮助我吗? are they legit ? 他们合法吗? or just some hacks someone put together to make something work ? 还是只是有人将某些技巧合在一起才能使某些东西起作用?

help !!! 救命 !!!

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. 经过大量研究和论坛讨论,我得出的结论是,几乎不可能使JSF-2.3和CDI-1.2一起使用WAS中的f:websocket功能。 See my post on IBM support page which confirms this. 请参阅在IBM支持页面上的帖子 ,以确认这一点。

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 . 仍然使用JSF-2.2使用Web套接字的一种方法是使用Javax.websocket软件包,如@Gas在我之前的问题中指出的那样。 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. 但是,此Web套接字实现的局限性在于,仅像使用JSF-2.3中的f:websocket一样,将SessionScoped ManagedBean中包含的数据发送到该会话的客户端并不容易,做。

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

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