Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket Spec does not define the activation requirements of CDI Contexts #196

Open
glassfishrobot opened this issue May 7, 2013 · 9 comments
Labels
API (Server) enhancement Adding a new feature or improving an existing one
Milestone

Comments

@glassfishrobot
Copy link

Currently, a few issues are floating around regarding WebSocket spec and the activation (or lack there of) of CDI contexts. As was the case for the JMS spec & the JSF spec, the WebSocket spec must define what the activation is for CDI contexts when it comes to its methods. For example, "managed bean" is only mentioned once in the PFD however its notion is ambiguous:

Some of the non-api features of the Java WebSocket API are optional when the API is not implemented as part of the full Java EE platform, for example, the requirement that websocket endpoints be non-contextual managed beans (see Chapter 7). Such Java EE only features are clearly marked where they are described.

There is nothing in Chapter 7 that mentions "managed bean" as indicated in this chapter. So in my opinion, I think it's needed for the WebSocket spec to spell out that it expects Request Scope to be enabled during an @OnMessage method, and as a result must ensure that the context is initialized when the method is called.

Affected Versions

[1.0]

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
Reported by genomeprjct

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
Issue-Links:
blocks
TYRUS-260
is related to
JMS_SPEC-121
TYRUS-281

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
ggam said:
Any chance to get a MR for Java EE 8 clarifying CDI integration?

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
@pavelbucek said:
Can you please start this thread at [email protected] instead of here?

Thanks!
Pavel

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
ggam said:
Done! My email is now waiting for editor's approval

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
This issue was imported from java.net JIRA WEBSOCKET_SPEC-196

@glassfishrobot
Copy link
Author

@mrts Commented
@pavelbucek I think it's a high time to discuss this now that Java EE 8 spec is taking shape. Where should the discussion happen now that java.net is retired?

It's especially confusing that there is no clearly defined relation to @SessionScoped beans and security context propagation, see related issues: #197, #238, #215 and https://issues.jboss.org/browse/WELD-2028, vaadin/cdi#88, vaadin/framework#8967, question in StackOverflow.

Would the following example serve as acceptance criteria?

// -- UserPreferences.java
@SessionScoped
class UserPreferences {
    ...
}

// -- QuoteEJB.java
@Stateless
@RolesAllowed("users")
public class QuoteEJB {
    ...
}

// -- QuoteWebSocketServer.java
import javax.websocket.server.ServerEndpoint;
import javax.annotation.security.RolesAllowed;
    
@ServerEndpoint("/actions")
@RolesAllowed("users") // Doesn't actually work
class QuoteWebSocketServer {

    @Inject // Doesn't actually work
    private UserPreferences userPreferences;

    @EJB // Doesn't actually work
    private QuoteEJB quoteEJB;

    @OnMessage
    public void handleMessage(String message, Session session) {
        final List<Topic> topics = userPreferences.getSubscribedTopics();
        final List<Quote> quotes = quoteEJB.getQuotesForTopics(topics);
        ...
    }
}

@glassfishrobot
Copy link
Author

@glassfishrobot
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API (Server) enhancement Adding a new feature or improving an existing one
Projects
None yet
Development

No branches or pull requests

2 participants