You can do it with DeltaSpike - just inject WindowContext and use/restore whatever window-id you like via the method activateWindow. Afterwards the conversation-scope provided by DeltaSpike (@GroupedConversationScoped) can be used without any further initialization as described in the documentation.
If you have e.g. a JSF application in combination with the JSF-module of DeltaSpike which renders the window-id as 'dswid', you can use the following Servlet-Filter to restore and activate the same window for any Servlet-based technology like JAX-RS,... (don't forget the mapping for the Servlet-Filter).
With JSF don't forget to add the tag to your page-template (as described in the documentation). If you need to create a manual link you can get the current window-id via:
dswid=#{dsWindowContext.currentWindowId}
If you don't like to use 'dswid', just use and extract the information as with any other custom parameter (or use a lib like prettyfaces/rewrite).
If you don't use JSF, you need to render the window-id on your own and ensure that it gets sent back to the server as request-parameter (as with any other parameter you are using).
In your code which finally handles the request, you can just inject any grouped-conversation-scoped bean (or do a lookup via BeanProvider).
public class WindowIdFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
String windowId = request.getParameter("dswid");
if (windowId != null) {
WindowContext windowContext = BeanProvider.getContextualReference(WindowContext.class);
windowContext.activateWindow(windowId);
}
chain.doFilter(request, response);
}
@Override
public void destroy() {
}
}