CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-com-liferay-portal--com-liferay-portal-impl

Core implementation module containing the fundamental services, utilities, and infrastructure components for the Liferay Digital Experience Platform.

Pending
Overview
Eval results
Files

lifecycle-events.mddocs/

Lifecycle Events & Actions

Event-driven system handling portal startup, shutdown, authentication, session management, and service request processing with comprehensive lifecycle hooks and extensibility points.

Capabilities

Startup and Shutdown Events

Portal-wide and application-level lifecycle management with comprehensive initialization and cleanup procedures.

/**
 * Global portal startup action executed during portal initialization
 */
public class GlobalStartupAction extends Action {
    
    /**
     * Executes global startup procedures
     * @param request HTTP servlet request
     * @param response HTTP servlet response
     * @throws ActionException if startup fails
     */
    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException;
}

/**
 * Global portal shutdown action executed during portal termination
 */
public class GlobalShutdownAction extends Action {
    
    /**
     * Executes global shutdown procedures and cleanup
     * @param request HTTP servlet request
     * @param response HTTP servlet response
     * @throws ActionException if shutdown fails
     */
    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException;
}

/**
 * Application-level startup action for individual applications
 */
public class AppStartupAction extends Action {
    
    /**
     * Executes application-specific startup procedures
     * @param request HTTP servlet request
     * @param response HTTP servlet response
     * @throws ActionException if startup fails
     */
    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException;
}

/**
 * Application-level shutdown action for individual applications
 */
public class AppShutdownAction extends Action {
    
    /**
     * Executes application-specific shutdown procedures
     * @param request HTTP servlet request
     * @param response HTTP servlet response
     * @throws ActionException if shutdown fails
     */
    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException;
}

Startup and Shutdown Utilities

Helper utilities providing common functionality for startup and shutdown procedures.

/**
 * Utility class providing startup helper methods
 */
public class StartupHelperUtil {
    
    /**
     * Performs common startup initialization tasks
     * @param servletContext the servlet context
     */
    public static void initialize(ServletContext servletContext);
    
    /**
     * Sets up portal configuration during startup
     */
    public static void setupConfiguration();
    
    /**
     * Initializes portal services during startup
     */
    public static void initializeServices();
}

/**
 * Utility class providing shutdown helper methods
 */
public class ShutdownHelperUtil {
    
    /**
     * Performs common shutdown cleanup tasks
     * @param servletContext the servlet context
     */
    public static void cleanup(ServletContext servletContext);
    
    /**
     * Shuts down portal services gracefully
     */
    public static void shutdownServices();
    
    /**
     * Releases portal resources during shutdown
     */
    public static void releaseResources();
}

Authentication Events

Comprehensive authentication lifecycle management with pre and post processing hooks.

/**
 * Pre-login action executed before user authentication
 */
public class LoginPreAction extends Action {
    
    /**
     * Executes pre-login processing and validation
     * @param request HTTP servlet request containing login credentials
     * @param response HTTP servlet response
     * @throws ActionException if pre-login processing fails
     */
    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException;
}

/**
 * Post-login action executed after successful user authentication
 */
public class LoginPostAction extends Action {
    
    /**
     * Executes post-login processing and setup
     * @param request HTTP servlet request with authenticated user
     * @param response HTTP servlet response
     * @throws ActionException if post-login processing fails
     */
    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException;
}

/**
 * Pre-logout action executed before user logout
 */
public class LogoutPreAction extends Action {
    
    /**
     * Executes pre-logout processing and cleanup preparation
     * @param request HTTP servlet request with user session
     * @param response HTTP servlet response
     * @throws ActionException if pre-logout processing fails
     */
    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException;
}

/**
 * Post-logout action executed after user logout
 */
public class LogoutPostAction extends Action {
    
    /**
     * Executes post-logout cleanup and finalization
     * @param request HTTP servlet request after logout
     * @param response HTTP servlet response
     * @throws ActionException if post-logout processing fails
     */
    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException;
}

/**
 * Secure request action for security processing
 */
public class SecureRequestAction extends Action {
    
    /**
     * Processes security-related request handling
     * @param request HTTP servlet request requiring security processing
     * @param response HTTP servlet response
     * @throws ActionException if security processing fails
     */
    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException;
}

Session Management Events

HTTP session lifecycle management with creation and destruction event handling.

/**
 * Session creation action executed when new HTTP sessions are created
 */
public class SessionCreateAction extends SessionAction {
    
    /**
     * Handles new session creation and initialization
     * @param session the newly created HTTP session
     * @throws ActionException if session creation processing fails
     */
    public void run(HttpSession session) throws ActionException;
}

/**
 * Session destruction action executed when HTTP sessions are destroyed
 */
public class SessionDestroyAction extends SessionAction {
    
    /**
     * Handles session destruction and cleanup
     * @param session the HTTP session being destroyed
     * @throws ActionException if session destruction processing fails
     */
    public void run(HttpSession session) throws ActionException;
}

/**
 * Session ID logging action for audit and debugging purposes
 */
public class LogSessionIdAction extends SessionAction {
    
    /**
     * Logs session ID information for auditing
     * @param session the HTTP session to log
     * @throws ActionException if logging fails
     */
    public void run(HttpSession session) throws ActionException;
}

Service Request Events

Service layer request processing with pre and post hooks for cross-cutting concerns.

/**
 * Pre-service action executed before service method calls
 */
public class ServicePreAction extends Action {
    
    /**
     * Executes pre-service processing such as validation and setup
     * @param request HTTP servlet request for service call
     * @param response HTTP servlet response
     * @throws ActionException if pre-service processing fails
     */
    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException;
}

/**
 * Post-service action executed after service method calls
 */
public class ServicePostAction extends Action {
    
    /**
     * Executes post-service processing such as cleanup and logging
     * @param request HTTP servlet request after service call
     * @param response HTTP servlet response
     * @throws ActionException if post-service processing fails
     */
    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException;
}

/**
 * Theme-specific pre-service action for theme processing
 */
public class ThemeServicePreAction extends Action {
    
    /**
     * Executes theme-specific pre-processing for service requests
     * @param request HTTP servlet request with theme context
     * @param response HTTP servlet response
     * @throws ActionException if theme processing fails
     */
    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException;
}

Monitoring and Utility Events

System monitoring, resource management, and utility actions for portal maintenance.

/**
 * Memory usage logging action for system monitoring
 */
public class LogMemoryUsageAction extends Action {
    
    /**
     * Logs current memory usage statistics
     * @param request HTTP servlet request
     * @param response HTTP servlet response
     * @throws ActionException if memory logging fails
     */
    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException;
}

/**
 * Thread count logging action for system monitoring
 */
public class LogThreadCountAction extends Action {
    
    /**
     * Logs current thread count and threading statistics
     * @param request HTTP servlet request
     * @param response HTTP servlet response
     * @throws ActionException if thread logging fails
     */
    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException;
}

/**
 * Garbage collection action for memory management
 */
public class GarbageCollectorAction extends Action {
    
    /**
     * Triggers garbage collection and memory cleanup
     * @param request HTTP servlet request
     * @param response HTTP servlet response
     * @throws ActionException if garbage collection fails
     */
    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException;
}

/**
 * Random layout assignment action for testing and development
 */
public class RandomLayoutAction extends Action {
    
    /**
     * Assigns random layouts for testing purposes
     * @param request HTTP servlet request
     * @param response HTTP servlet response
     * @throws ActionException if layout assignment fails
     */
    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException;
}

/**
 * Random look and feel assignment action for UI testing
 */
public class RandomLookAndFeelAction extends Action {
    
    /**
     * Assigns random themes and look-and-feel for testing
     * @param request HTTP servlet request
     * @param response HTTP servlet response  
     * @throws ActionException if theme assignment fails
     */
    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException;
}

Usage Examples

Portal Startup Configuration:

// Custom global startup action
public class CustomGlobalStartupAction extends GlobalStartupAction {
    @Override
    public void run(HttpServletRequest request, HttpServletResponse response) 
            throws ActionException {
        
        // Initialize custom services
        initializeCustomServices();
        
        // Setup custom configuration
        setupCustomConfiguration();
        
        // Call parent startup logic
        super.run(request, response);
    }
    
    private void initializeCustomServices() {
        // Custom service initialization logic
    }
    
    private void setupCustomConfiguration() {
        // Custom configuration setup
    }
}

Authentication Event Handling:

// Custom login processing
public class CustomLoginPreAction extends LoginPreAction {
    @Override
    public void run(HttpServletRequest request, HttpServletResponse response) 
            throws ActionException {
        
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        
        // Custom authentication validation
        if (!validateCustomCriteria(username, password)) {
            throw new ActionException("Custom validation failed");
        }
        
        // Additional security checks
        performSecurityChecks(request);
        
        // Call parent login logic
        super.run(request, response);
    }
}

// Custom post-login setup
public class CustomLoginPostAction extends LoginPostAction {
    @Override
    public void run(HttpServletRequest request, HttpServletResponse response) 
            throws ActionException {
        
        // Setup user preferences
        setupUserPreferences(request);
        
        // Initialize user session data
        initializeSessionData(request);
        
        // Log login event
        logLoginEvent(request);
        
        super.run(request, response);
    }
}

Session Management:

// Custom session creation handling
public class CustomSessionCreateAction extends SessionCreateAction {
    @Override
    public void run(HttpSession session) throws ActionException {
        
        // Initialize session attributes
        session.setAttribute("createdTime", System.currentTimeMillis());
        session.setAttribute("customData", new HashMap<>());
        
        // Setup session tracking
        setupSessionTracking(session);
        
        super.run(session);
    }
}

Service Request Processing:

// Custom service pre-processing
public class CustomServicePreAction extends ServicePreAction {
    @Override
    public void run(HttpServletRequest request, HttpServletResponse response) 
            throws ActionException {
        
        // Request validation
        validateRequest(request);
        
        // Security checks
        performSecurityValidation(request);
        
        // Setup request context
        setupRequestContext(request);
        
        super.run(request, response);
    }
}

Integration with Portal Framework

The lifecycle events system provides extensive integration points:

  • Extension Points - Custom actions can be plugged in at any lifecycle stage
  • Cross-cutting Concerns - Logging, security, monitoring can be applied consistently
  • Portal Services - Events can trigger portal service operations
  • Plugin Integration - Plugins can register custom lifecycle actions
  • Theme Integration - Theme-specific processing during request lifecycle
  • Session Management - Comprehensive session lifecycle control

Event Configuration

Events are typically configured through portal properties or Spring configuration:

# Login events
login.events.pre=com.company.CustomLoginPreAction
login.events.post=com.company.CustomLoginPostAction

# Startup events  
global.startup.events=com.company.CustomGlobalStartupAction

# Service events
servlet.service.events.pre=com.company.CustomServicePreAction
servlet.service.events.post=com.company.CustomServicePostAction

Error Handling

Lifecycle events should handle errors gracefully:

  • ActionException - Standard exception for action processing failures
  • Graceful Degradation - Non-critical events should not block portal operation
  • Error Logging - Comprehensive logging for debugging and monitoring
  • Rollback Procedures - Cleanup procedures for failed operations
  • Event Chain Management - Proper handling when event chains are interrupted

Best practices include implementing proper exception handling, comprehensive logging, and ensuring that critical system events (startup/shutdown) have appropriate fallback mechanisms.

Install with Tessl CLI

npx tessl i tessl/maven-com-liferay-portal--com-liferay-portal-impl

docs

bean-management.md

database-orm.md

database-upgrades.md

framework-integration.md

index.md

lifecycle-events.md

portlet-framework.md

service-layer.md

template-processing.md

utility-services.md

web-security.md

tile.json