當前位置: 首頁>>代碼示例>>Java>>正文


Java ServletConfig.getInitParameterNames方法代碼示例

本文整理匯總了Java中javax.servlet.ServletConfig.getInitParameterNames方法的典型用法代碼示例。如果您正苦於以下問題:Java ServletConfig.getInitParameterNames方法的具體用法?Java ServletConfig.getInitParameterNames怎麽用?Java ServletConfig.getInitParameterNames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.servlet.ServletConfig的用法示例。


在下文中一共展示了ServletConfig.getInitParameterNames方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ServletPropertiesMap

import javax.servlet.ServletConfig; //導入方法依賴的package包/類
/**
 * Constructor.
 */
ServletPropertiesMap(ServletConfig config) {
    // This implementation is very simple.
    // It is possible to avoid creation of a new structure, but this would
    // imply writing all of the Map interface.
    Enumeration e = config.getInitParameterNames();
    while (e.hasMoreElements()) {
        String key = (String) e.nextElement();
        put(key, config.getInitParameter(key));
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:14,代碼來源:ReloadableDefinitionsFactory.java

示例2: ServletPropertiesMap

import javax.servlet.ServletConfig; //導入方法依賴的package包/類
/**
 * Constructor.
 */
ServletPropertiesMap(ServletConfig config) {
    // This implementation is very simple.
    // It is possible to avoid creation of a new structure, but this need
    // imply writing all Map interface.
    Enumeration e = config.getInitParameterNames();
    while (e.hasMoreElements()) {
        String key = (String) e.nextElement();
        put(key, config.getInitParameter(key));
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:14,代碼來源:DefinitionsUtil.java

示例3: readConfigurationProperties

import javax.servlet.ServletConfig; //導入方法依賴的package包/類
protected Map<String, String> readConfigurationProperties(ServletConfig servletConfig) {
  Map<String,String> initParameters = new LinkedHashMap<>();
  Enumeration<String> initParameterNames = servletConfig.getInitParameterNames();
  while (initParameterNames.hasMoreElements()) {
    String initParameterName = initParameterNames.nextElement();
    String initParameterValue = servletConfig.getInitParameter(initParameterName);
    initParameters.put(initParameterName, initParameterValue);
  }
  return initParameters;
}
 
開發者ID:rockscript,項目名稱:rockscript,代碼行數:11,代碼來源:Servlet.java

示例4: init

import javax.servlet.ServletConfig; //導入方法依賴的package包/類
@Override
public void init(ServletConfig config) throws ServletException {
  Info info = new Info()
    .title("Swagger Server")
    .description("Create invoices, check payment and forward coins.")
    .termsOfService("")
    .contact(new Contact()
      .email(""))
    .license(new License()
      .name("")
      .url("http://unlicense.org"));

  ServletContext context = config.getServletContext();
  Swagger swagger = new Swagger().info(info);


  HashMap<String, String> params = new HashMap<>();
  //Build parameter Hashmap
  final Enumeration initParameterNames = config.getInitParameterNames();
  while(initParameterNames.hasMoreElements()){
    Object key = initParameterNames.nextElement();

    if(key instanceof String){
      params.put((String)key,config.getInitParameter((String)key));
    }
  }



  Bitcoin bitcoin = Bitcoin.getInstance();
  bitcoin.addParams(params);
  bitcoin.start();

  new SwaggerContextService().withServletConfig(config).updateSwagger(swagger);
}
 
開發者ID:IUNO-TDM,項目名稱:PaymentService,代碼行數:36,代碼來源:Bootstrap.java

示例5: setupFromServletConfig

import javax.servlet.ServletConfig; //導入方法依賴的package包/類
/**
 * Take a DefaultContainer and setup the default beans
 * @param container The container to configure
 * @param servletConfig The servlet configuration (null to ignore)
 * @throws InstantiationException If we can't instantiate a bean
 * @throws IllegalAccessException If we have access problems creating a bean
 */
public static void setupFromServletConfig(DefaultContainer container, ServletConfig servletConfig) throws InstantiationException, IllegalAccessException
{
    Enumeration en = servletConfig.getInitParameterNames();
    while (en.hasMoreElements())
    {
        String name = (String) en.nextElement();
        String value = servletConfig.getInitParameter(name);
        container.addParameter(name, value);
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:18,代碼來源:ContainerUtil.java

示例6: doGet

import javax.servlet.ServletConfig; //導入方法依賴的package包/類
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
ServletConfig config = getServletConfig();

String lname = config.getServletName();
String driver_Class = config.getInitParameter("driver_Class");
String driver_URL = config.getInitParameter("driver_URL");
String db_User_Name = config.getInitParameter("db_User_Name");
String db_Password = config.getInitParameter("db_Password");
Enumeration<String> e = config.getInitParameterNames();
String param_Names = "";
while(e.hasMoreElements()) {
param_Names = param_Names+e.nextElement()+"<br>";
}

out.println("<html>");
out.println("<body>");
out.println("<h3>Servlet Configuration Details</h3>");
out.println("<table border='1'>");
out.println("<tr><th>Parameter Names</th><th>Parameter Values</th></tr>");
out.println("<tr><td>driver_Class</td><td>"+driver_Class+"</td></tr>");
out.println("<tr><td>driver_URL</td><td>"+driver_URL+"</td></tr>");
out.println("<tr><td>db_User_Name</td><td>"+db_User_Name+"</td></tr>");
out.println("<tr><td>db_Password</td><td>"+db_Password+"</td></tr>");
out.println("<tr><td>Parameter Names</td><td>"+param_Names+"</td></tr>");
out.println("<tr><td>Servlet Logical Name</td><td>"+lname+"</td></tr>");
out.println("</table></body></html>");
}
 
開發者ID:pratikdimble,項目名稱:Servlet_Config_Interface,代碼行數:30,代碼來源:ConfigServlet.java

示例7: getInitParametersInServletConfig

import javax.servlet.ServletConfig; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private Map<String, String> getInitParametersInServletConfig(ServletConfig servletConfig) {
    Map<String , String> initParameters = new HashMap<String, String>();
    Enumeration<String> params = servletConfig.getInitParameterNames();
    while (params.hasMoreElements()) {
        String name = params.nextElement();
        String value = servletConfig.getInitParameter(name);
        initParameters.put(name, value);
    }
    return Collections.unmodifiableMap(initParameters);
}
 
開發者ID:devefx,項目名稱:validator-web,代碼行數:12,代碼來源:FakeServletConfig.java

示例8: configureFromInitParams

import javax.servlet.ServletConfig; //導入方法依賴的package包/類
/**
 * Add configurators from init params to the end of the list of
 * configurators.
 * @param container The container to configure
 * @param servletConfig The source of init parameters
 * @return true if any Configurators were read
 * @throws SAXException If the config file parse fails
 * @throws ParserConfigurationException If the config file parse fails
 * @throws IOException If the config file read fails
 */
public static boolean configureFromInitParams(Container container, ServletConfig servletConfig) throws IOException, ParserConfigurationException, SAXException
{
    Enumeration en = servletConfig.getInitParameterNames();
    boolean foundConfig = false;
    while (en.hasMoreElements())
    {
        String name = (String) en.nextElement();
        String value = servletConfig.getInitParameter(name);

        // if the init param starts with "config" then try to load it
        if (name.startsWith(INIT_CONFIG))
        {
            foundConfig = true;

            StringTokenizer st = new StringTokenizer(value, "\n,");
            while (st.hasMoreTokens())
            {
                String fileName = st.nextToken().trim();
                DwrXmlConfigurator local = new DwrXmlConfigurator();
                local.setServletResourceName(fileName);
                local.configure(container);
            }
        }
        else if (name.equals(INIT_CUSTOM_CONFIGURATOR))
        {
            foundConfig = true;

            try
            {
                Configurator configurator = (Configurator) LocalUtil.classNewInstance(INIT_CUSTOM_CONFIGURATOR, value, Configurator.class);
                configurator.configure(container);
                log.debug("Loaded config from: " + value);
            }
            catch (Exception ex)
            {
                log.warn("Failed to start custom configurator", ex);
            }
        }
    }

    return foundConfig;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:53,代碼來源:ContainerUtil.java

示例9: init

import javax.servlet.ServletConfig; //導入方法依賴的package包/類
@Override
public void init(ServletConfig servletConfig) throws javax.servlet.ServletException {
	super.init(servletConfig);

	if (log.isDebugEnabled()) {
		log.debug("initializing DwrServlet Extension");
	}

	try {
		Enumeration en = servletConfig.getInitParameterNames();
		
		boolean skipDefaultConfig = false;
		
		while (en.hasMoreElements()) {
			
			String paramName = (String) en.nextElement();
			String paramValue = servletConfig.getInitParameter(paramName);

			// meta-config
			if (paramName.startsWith("meta-config") && paramValue != null && !"".equals(paramValue.trim())) {
				PathMatchingResourcePatternResolver resolver = OrderedPathMatchingResourcePatternResolver.getInstance();
				resources = resolver.getResources(paramValue);
			}

			// skipDefaultConfig
			if (paramName.startsWith("skipDefaultConfig") && paramValue != null && !"".equals(paramValue.trim())) {
				skipDefaultConfig = Boolean.parseBoolean(paramValue);
			}
			
		}
		
		/*
		 * Nothing will get loaded into dwr container, since no resources
		 * found in classpath and default config got skipped.
		 */
		if ((resources == null || resources.length == 0) && skipDefaultConfig) {
			throw new IOException(Messages.getString("DwrXmlConfigurator.MissingConfigFile",new String[] { "jar!META-INF/dwr.xml" }));
		}

		/*
		 * When there is no resources found under meta-inf and the
		 * skipDefaultConfig set to false then the validation handled for
		 * default config and the default config will get load into
		 * container by super class.
		 */
		if (resources == null && !skipDefaultConfig) {
			return;
		}
		org.jaffa.dwr.util.ContainerUtil.configureFromResource(getContainer(), servletConfig, resources);
		ContainerUtil.publishContainer(getContainer(), servletConfig);

	} catch (IOException | ParserConfigurationException | SAXException e) {
		throw new ServletException(e);
	}
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:56,代碼來源:DwrServlet.java


注:本文中的javax.servlet.ServletConfig.getInitParameterNames方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。