/** {@inheritDoc} */ @Override @Nullable public String apply(@Nullable final ProfileRequestContext input) { if (input == null) { return null; } final SpringRequestContext springRequestContext = input.getSubcontext(SpringRequestContext.class, false); if (springRequestContext == null) { return null; } final RequestContext requestContext = springRequestContext.getRequestContext(); if (requestContext == null) { return null; } final FlowExecutionContext flowExecutionContext = requestContext.getFlowExecutionContext(); if (flowExecutionContext == null) { return null; } if (!flowExecutionContext.isActive()) { return null; } final FlowDefinition flowDefinition = requestContext.getActiveFlow(); final String flowId = flowDefinition.getId(); log.debug("Current flow id is '{}'", flowId); return flowId; }
@Override public void paused(RequestContext context) { if (isPersistenceContext(context.getActiveFlow())) { final EntityManager em = getEntityManager(context.getFlowExecutionContext().getActiveSession()); /* * we were not be able to determine if entityManager has opened * connections, then the commit statement is always executed when * flow is paused */ transactionTemplate.execute( new TransactionCallbackWithoutResult() { protected void doInTransactionWithoutResult(TransactionStatus status) { /* * Commit using the same connection retrieved by hibernate * lazy load,if exists, otherwise another connection will be * requested from pool */ em.joinTransaction(); } }); } super.paused(context); }
protected void doRender(Map<String, ?> model) throws Exception { RequestContext context = getRequestContext(); ExternalContext externalContext = context.getExternalContext(); View view = getView(); PortletContext portletContext = (PortletContext) externalContext.getNativeContext(); PortletRequest request = (PortletRequest) externalContext.getNativeRequest(); MimeResponse response = (MimeResponse) externalContext.getNativeResponse(); if (response.getContentType() == null) { // No Portlet content type specified yet -> use the view-determined type. // (The Portlet spec requires the content type to be set on the RenderResponse) String contentType = view.getContentType(); if (contentType != null) { response.setContentType(contentType); } } request.setAttribute(ViewRendererServlet.VIEW_ATTRIBUTE, view); request.setAttribute(ViewRendererServlet.MODEL_ATTRIBUTE, model); request.setAttribute( org.springframework.web.servlet.support.RequestContext.WEB_APPLICATION_CONTEXT_ATTRIBUTE, context.getActiveFlow().getApplicationContext()); portletContext .getRequestDispatcher(DispatcherPortlet.DEFAULT_VIEW_RENDERER_URL) .include(request, response); }