AbstractWebApplicationModule.java :  » MVC » simpleframework » net » simpleframework » web » Java Open Source

Java Open Source » MVC » simpleframework 
simpleframework » net » simpleframework » web » AbstractWebApplicationModule.java
package net.simpleframework.web;

import java.lang.reflect.Field;

import net.simpleframework.core.AbstractApplicationModule;
import net.simpleframework.core.IInitializer;
import net.simpleframework.organization.IJob;
import net.simpleframework.util.StringUtils;
import net.simpleframework.web.page.PageRequestResponse;

/**
 * LGPLv3
 * 
 * @author (cknet@126.com, 13910090885)
 *         http://code.google.com/p/simpleframework/
 *         http://www.simpleframework.net
 */
public abstract class AbstractWebApplicationModule extends AbstractApplicationModule implements
    IWebApplicationModule {
  @Override
  public IWebApplication getApplication() {
    return (IWebApplication) super.getApplication();
  }

  @Override
  public String getManager(final PageRequestResponse requestResponse) throws Exception {
    return IJob.sj_manager;
  }

  private String applicationUrl;

  @Override
  public String getApplicationUrl(final PageRequestResponse requestResponse) throws Exception {
    return applicationUrl;
  }

  public void setApplicationUrl(final String applicationUrl) {
    this.applicationUrl = applicationUrl;
  }

  private String skin;

  @Override
  public String getSkin(final PageRequestResponse requestResponse) throws Exception {
    return StringUtils.text(skin, WebUtils.getSkin(requestResponse));
  }

  public void setSkin(final String skin) {
    this.skin = skin;
  }

  protected void doInit(final Class<?> utilClazz, final String deployName) throws Exception {
    final Field applicationModule = utilClazz.getField("applicationModule");
    if (applicationModule != null) {
      applicationModule.set(null, this);
    }

    final IWebApplication application = getApplication();
    IInitializer.Utils.deployResource(utilClazz, application, deployName);

    final Field deployPath = utilClazz.getField("deployPath");
    if (deployPath != null) {
      deployPath.set(null, IInitializer.Utils.getApplicationDeployPath(application, deployName));
    }
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.