You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
« Previous
Version 2
Next »
SPI
Customize conversation implementations
If it's required to change or intercept the default implementation of EditableConversation
, it's possible to provide a custom ConversationFactory
.
@Decorator
public class CustomConversationFactory implements ConversationFactory
{
private static final long serialVersionUID = -3654734112338281151L;
@Inject
@Delegate
@Any
private ConversationFactory conversationFactory;
public EditableConversation createConversation(ConversationKey conversationKey, ConversationConfig configuration)
{
EditableConversation conversation = this.conversationFactory.createConversation(conversationKey, configuration);
//example for just changing the behaviour of the view-access scope
if(!ViewAccessScoped.class.isAssignableFrom(conversationKey.getScope()))
{
return conversation;
}
return new InterceptedConversationImpl(conversation); //wrap the default implementation or create an instance before delegating to the wrapped ConversationFactory
}
}
class InterceptedConversationImpl implements EditableConversation
{
private static final long serialVersionUID = 283349344155364553L;
private final EditableConversation wrapped;
public InterceptedConversationImpl(EditableConversation wrapped)
{
this.wrapped = wrapped;
}
//delegate methods to this.wrapped and intercept the need methods or change the behaviour completely
}
<beans>
<decorators>
<class>mypackage.CustomConversationFactory</class>
</decorators>
</beans>