Is it possible to start a seam conversation when accessing Restful services

187 Views Asked by At

I'm using java7 and seam jboss.

I have set up a conversation-required and no-conversation in my pages.xml to prevent bookmarks from accessing the secured pages. However the issue now is that the Restful services when accessed are always redirecting to the no-conversation-view-id because the when accessing Rest we don't start a conversation.

Is it possible for the Restful component to start a conversation? I don't want to annotate every Rest method with @Begin.

Thanks,

1

There are 1 best solutions below

1
Aadhira menon On

A context defines a namespace, a set of context variables. These work much the same as session or request attributes in the servlet spec. You may bind any value you like to a context variable, but usually we bind Seam component instances to context variables.

So, within a context, a component instance is identified by the context variable name (this is usually, but not always, the same as the component name). You may programatically access a named component instance in a particular scope via the Contexts class, which provides access to several thread-bound instances of the Context interface:

User user = (User) Contexts.getSessionContext().get("user"); You may also set or change the value associated with a name:

Contexts.getSessionContext().set("user", user); Usually, however, we obtain components from a context via injection, and put component instances into a context via outjection.

4.1.9. Context search priority

Sometimes, as above, component instances are obtained from a particular known scope. Other times, all stateful scopes are searched, in priority order. The order is as follows:

Event context Page context Conversation context Session context Business process context Application context You can perform a priority search by calling Contexts.lookupInStatefulContexts(). Whenever you access a component by name from a JSF page, a priority search occurs. Surc:Google