@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.book_data);

    context = this;
    back = (Button) findViewById(R.id.backToContainerView);
    bookname = (TextView) findViewById(R.id.bookname);
    Intent intent = getIntent();
    if (intent.getFlags() == Intent.FLAG_ACTIVITY_NEW_TASK) {
      Bundle extras = intent.getExtras();
      if (extras != null) {
        String value = extras.getString(Constants.BOOK_NAME);
        bookname.setText(value);
        container = ContainerHolder.getInstance().get(extras.getLong(Constants.CONTAINER_ID));
        if (container == null) {
          finish();
          return;
        }
      }
    }

    initMetadata();
    initPageList();
    initBookmark();

    initListener();
  }
Example #2
0
 /**
  * Removes all the files created by MultiPartRequestWrapper.
  *
  * @param request the HttpServletRequest object.
  * @see org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper
  */
 public void cleanUpRequest(HttpServletRequest request) {
   ContainerHolder.clear();
   if (!(request instanceof MultiPartRequestWrapper)) {
     return;
   }
   MultiPartRequestWrapper multiWrapper = (MultiPartRequestWrapper) request;
   multiWrapper.cleanUp();
 }
Example #3
0
  /** Releases all instances bound to this dispatcher instance. */
  public void cleanup() {

    // clean up ObjectFactory
    ObjectFactory objectFactory = getContainer().getInstance(ObjectFactory.class);
    if (objectFactory == null) {
      if (LOG.isWarnEnabled()) {
        LOG.warn(
            "Object Factory is null, something is seriously wrong, no clean up will be performed");
      }
    }
    if (objectFactory instanceof ObjectFactoryDestroyable) {
      try {
        ((ObjectFactoryDestroyable) objectFactory).destroy();
      } catch (Exception e) {
        // catch any exception that may occurred during destroy() and log it
        LOG.error(
            "exception occurred while destroying ObjectFactory [#0]", e, objectFactory.toString());
      }
    }

    // clean up Dispatcher itself for this thread
    instance.set(null);

    // clean up DispatcherListeners
    if (!dispatcherListeners.isEmpty()) {
      for (DispatcherListener l : dispatcherListeners) {
        l.dispatcherDestroyed(this);
      }
    }

    // clean up all interceptors by calling their destroy() method
    Set<Interceptor> interceptors = new HashSet<Interceptor>();
    Collection<PackageConfig> packageConfigs =
        configurationManager.getConfiguration().getPackageConfigs().values();
    for (PackageConfig packageConfig : packageConfigs) {
      for (Object config : packageConfig.getAllInterceptorConfigs().values()) {
        if (config instanceof InterceptorStackConfig) {
          for (InterceptorMapping interceptorMapping :
              ((InterceptorStackConfig) config).getInterceptors()) {
            interceptors.add(interceptorMapping.getInterceptor());
          }
        }
      }
    }
    for (Interceptor interceptor : interceptors) {
      interceptor.destroy();
    }

    // Clear container holder when application is unloaded / server shutdown
    ContainerHolder.clear();

    // cleanup action context
    ActionContext.setContext(null);

    // clean up configuration
    configurationManager.destroyConfiguration();
    configurationManager = null;
  }
Example #4
0
 /**
  * Expose the dependency injection container.
  *
  * @return Our dependency injection container
  */
 public Container getContainer() {
   if (ContainerHolder.get() != null) {
     return ContainerHolder.get();
   }
   ConfigurationManager mgr = getConfigurationManager();
   if (mgr == null) {
     throw new IllegalStateException("The configuration manager shouldn't be null");
   } else {
     Configuration config = mgr.getConfiguration();
     if (config == null) {
       throw new IllegalStateException("Unable to load configuration");
     } else {
       Container container = config.getContainer();
       ContainerHolder.store(container);
       return container;
     }
   }
 }
  @Override
  public void onBackPressed() {
    super.onBackPressed();
    if (container != null) {
      ContainerHolder.getInstance().remove(container.getNativePtr());

      // Close book (need to figure out if this is the best place...)
      EPub3.closeBook(container);
    }
  }
Example #6
0
  private Container init_PreloadConfiguration() {
    Configuration config = configurationManager.getConfiguration();
    Container container = config.getContainer();

    boolean reloadi18n =
        Boolean.valueOf(container.getInstance(String.class, StrutsConstants.STRUTS_I18N_RELOAD));
    LocalizedTextUtil.setReloadBundles(reloadi18n);

    ContainerHolder.store(container);

    return container;
  }
Example #7
0
 /**
  * Modify the ConfigurationManager instance
  *
  * @param mgr The configuration manager
  * @deprecated should be removed as is used only in tests
  */
 public void setConfigurationManager(ConfigurationManager mgr) {
   ContainerHolder.clear();
   this.configurationManager = mgr;
 }
Example #8
0
 /** Cleanup any resources used to initialise Dispatcher */
 public void cleanUpAfterInit() {
   if (LOG.isDebugEnabled()) {
     LOG.debug("Cleaning up resources used to init Dispatcher");
   }
   ContainerHolder.clear();
 }