This is specific to Weld (the implementation), not to CDI (the API). There's in the current Weld 2.2.x version no simple nor native way to disable it. Weld however allows you changing the request parameter name cid
to something else via HttpConversationContext#setParameterName()
. You could set it to e.g. an java.util.UUID
value during application's startup.
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ApplicationScoped;
import org.jboss.weld.context.http.HttpConversationContext;
@ManagedBean(eager=true)
@ApplicationScoped
public class Application {
@Inject
private HttpConversationContext conversationContext;
@PostConstruct
public void init() {
hideConversationScope();
}
/**
* "Hide" conversation scope by replacing its default "cid" parameter name
* by something unpredictable.
*/
private void hideConversationScope() {
conversationContext.setParameterName(UUID.randomUUID().toString());
}
}
Unfortunately, CDI doesn't have any equivalent for eager=true
. Alternative is, if you've EJB at hands:
import javax.ejb.Startup;
import javax.ejb.Singleton;
@Startup
@Singleton
public class Application {
(you might want to add @TransactionAttribute(NOT_SUPPORTED)
to turn off unnecessary DB transaction management around it)
Or, if you've OmniFaces at hands:
import org.omnifaces.cdi.Startup;
@Startup
public class Application {
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…