示例#1
0
 /**
  * Hack trigger of a Seam component that will trigger reset of most Seam components caches, only
  * if dev mode is enabled
  *
  * <p>This is handled here to be done very early, before response is constructed.
  *
  * @since 5.6
  * @see Framework#isDevModeSet()
  */
 protected void resetHotReloadContext(FacesContext facesContext) {
   if (Framework.isDevModeSet()) {
     try {
       ExpressionFactory ef = facesContext.getApplication().getExpressionFactory();
       ELContext context = facesContext.getELContext();
       String actionBinding = SEAM_HOTRELOAD_TRIGGER_ACTION;
       MethodExpression action =
           ef.createMethodExpression(
               context, actionBinding, String.class, new Class[] {DocumentView.class});
       action.invoke(context, new Object[0]);
     } catch (ELException | NullPointerException e) {
       String msg =
           "Error while trying to flush seam context after a reload, executing method expression '"
               + SEAM_HOTRELOAD_TRIGGER_ACTION
               + "'";
       log.error(msg, e);
     }
   }
 }
示例#2
0
 @Override
 public void encodeBegin(FacesContext context) throws IOException {
   if (Framework.isDevModeSet()) {
     // sanity check before checking for nested forms: issue an error if
     // there is a parent container that is a form
     UIComponent parent = getParent();
     while (parent != null) {
       if (parent instanceof NXHtmlForm) {
         log.error(
             String.format(
                 "Form component with id '%s' is already surrounded" + " by a form with id '%s'",
                 getId(), parent.getId()));
         break;
       }
       parent = parent.getParent();
     }
   }
   super.processDecodes(context);
 }
 @Override
 public void handleEvent(Event event) {
   if (!Framework.isDevModeSet()) {
     log.info("Do not flush the directory caches: dev mode is not set");
     return;
   }
   if (!ReloadEventNames.RELOAD_EVENT_ID.equals(event.getId())) {
     return;
   }
   try {
     RepositoryManager rm = Framework.getService(RepositoryManager.class);
     // Transaction management
     final boolean txStarted =
         !TransactionHelper.isTransactionActive() && TransactionHelper.startTransaction();
     boolean txSucceed = false;
     try {
       new UnrestrictedSessionRunner(rm.getDefaultRepositoryName()) {
         @Override
         public void run() {
           DocumentRoutingService service =
               Framework.getLocalService(DocumentRoutingService.class);
           service.importAllRouteModels(session);
         }
       }.runUnrestricted();
       txSucceed = true;
     } finally {
       if (txStarted) {
         if (!txSucceed) {
           TransactionHelper.setTransactionRollbackOnly();
           log.warn("Rollbacking import of route models");
         }
         TransactionHelper.commitOrRollbackTransaction();
       }
     }
   } catch (NuxeoException e) {
     log.error("Error while reloading the route models", e);
   }
 }