Package org.impalaframework.module.bootstrap

Examples of org.impalaframework.module.bootstrap.ModuleManagementFacade


  HttpSession wrapSession(HttpSession session) {
    if (session == null) {
      return null;
    }
    ModuleManagementFacade moduleManagementFacade = ImpalaServletUtils.getModuleManagementFactory(servletContext);
    if (moduleManagementFacade != null) {
      ConfigurableApplicationContext currentModuleContext = moduleManagementFacade.getModuleStateHolder().getModule(moduleName);
     
      if (currentModuleContext != null) {
        return new ModuleAwareWrapperHttpSession(session, currentModuleContext.getClassLoader());
      } else {
        logger.warn("No module application context associated with module: " + moduleName + ". Using unwrapped session");
View Full Code Here


  public WebApplicationContext createWebApplicationContext() throws BeansException {

    // the superclass closes the modules
    final ServletContext servletContext = servlet.getServletContext();
    ModuleManagementFacade facade = ImpalaServletUtils.getModuleManagementFactory(servletContext);

    if (facade == null) {
      throw new ConfigurationException("Unable to load " + FrameworkServletContextCreator.class.getName()
          + " as no attribute '" + WebConstants.IMPALA_FACTORY_ATTRIBUTE
          + "' has been set up. Have you set up your Impala ContextLoader correctly?");
    }

    final String servletName = servlet.getServletName();
    ModuleStateHolder moduleStateHolder = facade.getModuleStateHolder();
   
    if (!initialized) {
     
      ModuleStateChangeNotifier moduleStateChangeNotifier = facade.getModuleStateChangeNotifier();
      moduleStateChangeNotifier.addListener(new ModuleStateChangeListener() {

        public void moduleStateChanged(ModuleStateHolder moduleStateHolder, ModuleStateChange change) {
          try {
            servlet.init();
View Full Code Here

  public void moduleContentsModified(ModuleChangeEvent event) {
    Set<String> modified = getModifiedModules(event);

    if (!modified.isEmpty()) {
      ModuleManagementFacade factory = ImpalaServletUtils.getModuleManagementFactory(servletContext);

      for (String moduleName : modified) {

        logger.info("Processing modified module " + moduleName);

        ModuleOperation operation = factory.getModuleOperationRegistry().getOperation(ModuleOperationConstants.ReloadNamedModuleOperation);
        ModuleOperationInput moduleOperationInput = new ModuleOperationInput(null, null, moduleName);
        operation.execute(moduleOperationInput);
      }
    }
  }
View Full Code Here

  @ManagedOperation(description = "Uses the current ModuleDefintitionSource to perform a full reload of the module hierarchy")
  public void reloadModules() {
   
    Assert.notNull(servletContext);

    ModuleManagementFacade factory = (ModuleManagementFacade) servletContext
        .getAttribute(WebConstants.IMPALA_FACTORY_ATTRIBUTE);
    if (factory == null) {
      throw new ConfigurationException(
          "No instance of "
              + ModuleManagementFacade.class.getName()
              + " found. Your context loader needs to be configured to create an instance of this class and attach it to the ServletContext using the attribue WebConstants.IMPALA_FACTORY_ATTRIBUTE");
    }

    ModuleDefinitionSource source = (ModuleDefinitionSource) servletContext
        .getAttribute(WebConstants.MODULE_DEFINITION_SOURCE_ATTRIBUTE);
    if (source == null) {
      throw new ConfigurationException(
          "No instance of "
              + ModuleDefinitionSource.class.getName()
              + " found. Your context loader needs to be configured to create an instance of this class and attach it to the ServletContext using the attribue WebConstants.MODULE_DEFINITION_SOURCE_ATTRIBUTE");

    }

    ModuleOperationInput moduleOperationInput = new ModuleOperationInput(source, null, null);
   
    ModuleOperation operation = factory.getModuleOperationRegistry().getOperation(ModuleOperationConstants.ReloadRootModuleOperation);
    operation.execute(moduleOperationInput);
  }
View Full Code Here

    return moduleName;
  }

  public static HttpServletRequest getWrappedRequest(HttpServletRequest request,
      ServletContext servletContext, String moduleName) {
    final ModuleManagementFacade moduleManagementFactory = ImpalaServletUtils.getModuleManagementFactory(servletContext);
    HttpServletRequest wrappedRequest = null;
   
    if (moduleManagementFactory != null) {
      HttpRequestWrapperFactory factory = ObjectUtils.cast(moduleManagementFactory.getBean(WebConstants.REQUEST_WRAPPER_FACTORY_BEAN_NAME), HttpRequestWrapperFactory.class);
      if (factory != null) {
        wrappedRequest = factory.getWrappedRequest(request, servletContext, moduleName);
      } else {
        wrappedRequest = request;
      }
View Full Code Here

   */
  @Override
  protected WebApplicationContext createWebApplicationContext(ServletContext servletContext, ApplicationContext parent)
      throws BeansException {

    ModuleManagementFacade facade = createModuleManagementFactory(servletContext);

    // load the parent context, which is web-independent
    ModuleDefinitionSource moduleDefinitionSource = getModuleDefinitionSource(servletContext, facade);

    // add items to servlet context
    servletContext.setAttribute(WebConstants.MODULE_DEFINITION_SOURCE_ATTRIBUTE, moduleDefinitionSource);
    servletContext.setAttribute(WebConstants.IMPALA_FACTORY_ATTRIBUTE, facade);
   
    ModuleOperationInput input = new ModuleOperationInput(moduleDefinitionSource, null, null);
    ModuleOperation operation = facade.getModuleOperationRegistry().getOperation(ModuleOperationConstants.UpdateRootModuleOperation);   
    operation.execute(input);

    ConfigurableApplicationContext context = facade.getModuleStateHolder().getRootModuleContext();

    if (context == null) {
      throw new InvalidStateException("Root application context is null");
    }
   
View Full Code Here

   */
  @Override
  public void closeWebApplicationContext(ServletContext servletContext) {

    // the superclass closes the modules
    ModuleManagementFacade facade = ImpalaServletUtils.getModuleManagementFactory(servletContext);

    if (facade != null) {

      servletContext.log("Closing modules and root application context hierarchy");

      ModuleOperation operation = facade.getModuleOperationRegistry().getOperation(ModuleOperationConstants.CloseRootModuleOperation);
      boolean success = operation.execute(null).isSuccess();

      if (!success) {
        // this is the fallback in case the rootDefinition is null
        super.closeWebApplicationContext(servletContext);
      }

      // now close the bootstrap factory
      facade.close();
    }
  }
View Full Code Here

TOP

Related Classes of org.impalaframework.module.bootstrap.ModuleManagementFacade

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.