本文整理汇总了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));
}
}
示例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));
}
}
示例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;
}
示例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);
}
示例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);
}
}
示例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>");
}
示例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);
}
示例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;
}
示例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);
}
}