package com.ngMAT.appl.genericservlet; import java.net.InetAddress; import java.text.DecimalFormat; import java.util.Properties; import java.util.Vector; import com.ngMAT.Common.Log; import com.ngMAT.HTML.HTMLTemplate; import com.ngMAT.servlet.EZServletConfig; import com.ngMAT.appl.GenericApplicationConfig; import com.ngMAT.appl.GenericConstants; public abstract class GenericServletConfig extends EZServletConfig implements GenericApplicationConfig { public String my_hostname = null; public String db_connection_name = null; public String not_ready_page_url = "/"; public String not_available_template_name = null; public HTMLTemplate not_available_template = null; public static DecimalFormat price_format = new DecimalFormat ("#,###,##0"); public static com.ngMAT.Common.Log debug_log = null; private Vector uri_roll_maps = null; private Properties roll_managed_uris = new Properties(); public boolean login_required = false; public boolean auth_required = false; public String login_url = null; public boolean use_database = false; /** * アプリケーション領域:一般("PUBLIC") */ public final static String AD_PUBLIC_DOMAIN = "PUBLIC"; /** * アプリケーション領域:管理系("MC") */ public final static String AD_MANAGEMENT_CONSOLE_DOMAIN = "MC"; private String application_domain = AD_PUBLIC_DOMAIN; /** * 一般領域のアプリケーションである場合true */ public boolean isPublicApplicationDomain() { return application_domain.equalsIgnoreCase (AD_PUBLIC_DOMAIN); } /** * 管理系領域のアプリケーションである場合true */ public boolean isManagementConsoleApplicationDomain() { return application_domain.equalsIgnoreCase (AD_MANAGEMENT_CONSOLE_DOMAIN); } public final void init() { my_hostname = getLocalHostName(); db_connection_name = getProperty (GenericConstants.PN.DBConnectionName); String s = null; s = getProperty (GenericConstants.PN.NotReadyPageURL); if (s != null) not_ready_page_url = s; not_available_template_name = getProperty (GenericConstants.PN.NotAvailableTemplateName); not_available_template = getTemplate (not_available_template_name); s = getProperty("Common.DebugLog"); if (s != null) { debug_log = new Log (s, true); debug_log.setApplicationName (ApplicationName); s = getProperty("Common.DebugLog.ClipNodename"); if (s != null && s.equalsIgnoreCase ("true")) debug_log.clipNodename(); } s = getProperty ("GenericServlet.Control.LoginRequired"); if (s != null) login_required = s.equalsIgnoreCase ("true"); s = getProperty ("GenericServlet.Control.AuthRequired"); if (s != null) auth_required = s.equalsIgnoreCase ("true"); s = getProperty ("GenericServlet.Control.Login.URL"); if (s != null) login_url = s; s = getProperty ("GenericServlet.Database.Use"); if (s != null) use_database = s.equalsIgnoreCase ("true"); s = getProperty ("APPL_DOMAIN"); if (s != null) application_domain = s; initialize(); } public abstract void initialize(); private static String getLocalHostName() { String n = null; try { n = InetAddress.getLocalHost().getHostName(); } catch (Exception e) { e.printStackTrace(); throw new GenericServletException (e); } return n; } }