}
public PortletInvocationResponse invoke(PortletInvocation invocation) throws IllegalArgumentException, PortletInvokerException
{
PortletContext portletContext = invocation.getTarget();
RegistrationSPI registration = getRegistrationAsSPI();
if (registration != null)
{
checkOperationIsAllowed(portletContext, registration, "invoke");
PortletInvocationResponse response = super.invoke(invocation);
// we need to check if the instance context was modified (for example, if an implicit cloned happened) to remember the new one and associate it with the current Registration
InstanceContext instanceContext = invocation.getInstanceContext();
if (instanceContext instanceof WSRPInstanceContext)
{
WSRPInstanceContext wsrpIC = (WSRPInstanceContext)instanceContext;
PortletContext responseContext = wsrpIC.getPortletContext();
if (wsrpIC.wasModified() && !responseContext.getId().equals(portletContext.getId()))
{
try
{
registration.addPortletContext(responseContext);
}