Package com.opensymphony.module.sitemesh

Source Code of com.opensymphony.module.sitemesh.Factory

// Decompiled by DJ v3.11.11.95 Copyright 2009 Atanas Neshkov  Date: 17/4/2011 22:58:40
// Home Page: http://members.fortunecity.com/neshkov/dj.html  http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name:   Factory.java

package com.opensymphony.module.sitemesh;

import java.lang.reflect.Constructor;

import com.opensymphony.module.sitemesh.factory.FactoryException;
import com.opensymphony.module.sitemesh.util.ClassLoaderUtil;

// Referenced classes of package com.opensymphony.module.sitemesh:
//            Config, PageParserSelector, DecoratorMapper, PageParser

public abstract class Factory implements PageParserSelector {

  public Factory() {
  }

  @SuppressWarnings({ "rawtypes", "unchecked" })
  public static Factory getInstance(Config config) {
    Factory instance = (Factory) config.getServletContext().getAttribute(
        "sitemesh.factory");
    if (instance == null) {
      String factoryClass = getEnvEntry("sitemesh.factory",
          "com.opensymphony.module.sitemesh.factory.DefaultFactory");
      try {
        Class cls = ClassLoaderUtil.loadClass(factoryClass,
            config.getClass());
        Constructor con = cls
            .getConstructor(new Class[] { com.opensymphony.module.sitemesh.Config.class });
        instance = (Factory) con.newInstance((Object[])new Config[] { config });
        config.getServletContext().setAttribute("sitemesh.factory",
            instance);
      } catch (Exception e) {
        throw new FactoryException("Cannot construct Factory : "
            + factoryClass, e);
      }
    }
    instance.refresh();
    return instance;
  }

  public abstract void refresh();

  public abstract DecoratorMapper getDecoratorMapper();

  public abstract PageParser getPageParser(String s);

  public abstract boolean shouldParsePage(String s);

  public abstract boolean isPathExcluded(String s);

  private static String getEnvEntry(String envEntry, String defaultValue) {
    return defaultValue;
  }

}
TOP

Related Classes of com.opensymphony.module.sitemesh.Factory

TOP
Copyright © 2018 www.massapi.com. 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.