gpt4 book ai didi

org.mortbay.xml.XmlConfiguration类的使用及代码示例

转载 作者:知者 更新时间:2024-03-24 12:57:05 25 4
gpt4 key购买 nike

本文整理了Java中org.mortbay.xml.XmlConfiguration类的一些代码示例,展示了XmlConfiguration类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlConfiguration类的具体详情如下:
包路径:org.mortbay.xml.XmlConfiguration
类名称:XmlConfiguration

XmlConfiguration介绍

[英]Configure Objects from XML. This class reads an XML file conforming to the configure.dtd DTD and uses it to configure and object by calling set, put or other methods on the object.
[中]从XML配置对象。该类读取符合配置的XML文件。dtd dtd,并使用它通过调用对象上的set、put或其他方法来配置和对象。

代码示例

代码示例来源:origin: apache/chukwa

public void run() {
 server = new Server();
 XmlConfiguration configuration;
 try {
  configuration = new XmlConfiguration(serverConf);
  configuration.configure(server);
  server.start();
 } catch (Exception e) {
  log.error(ExceptionUtil.getStackTrace(e));
 }     
}

代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server

set(obj, node);
else if ("Put".equals(tag))
  put(obj, node);
else if ("Call".equals(tag))
  call(obj, node);
else if ("Get".equals(tag))
  get(obj, node);
else if ("New".equals(tag))
  newObj(obj, node);
else if ("Array".equals(tag))
  newArray(obj, node);
else if ("Ref".equals(tag))
  refObj(obj, node);
else if ("Property".equals(tag))
  propertyObj(obj, node);
else
  throw new IllegalStateException("Unknown tag: " + tag);

代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server

/**
 * Configure an object. If the object is of the approprate class, the XML configuration script
 * is applied to the object.
 *
 * @param obj The object to be configured.
 * @exception Exception
 */
public void configure(Object obj) throws Exception
{
  //Check the class of the object
  Class oClass = nodeClass(_config);
  if (!oClass.isInstance(obj))
      throw new IllegalArgumentException("Object is not of type " + oClass);
  configure(obj, _config, 0);
}

代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server

private Object itemValue(Object obj, Object item) throws Exception
{
  // String value
  if (item instanceof String) return item;
  XmlParser.Node node = (XmlParser.Node) item;
  String tag = node.getTag();
  if ("Call".equals(tag)) return call(obj, node);
  if ("Get".equals(tag)) return get(obj, node);
  if ("New".equals(tag)) return newObj(obj, node);
  if ("Ref".equals(tag)) return refObj(obj, node);
  if ("Array".equals(tag)) return newArray(obj, node);
  if ("Map".equals(tag)) return newMap(obj, node);
  if ("Property".equals(tag)) return propertyObj(obj,node);
  if ("SystemProperty".equals(tag))
  {
    String name = node.getAttribute("name");
    String defaultValue = node.getAttribute("default");
    return System.getProperty(name, defaultValue);
  }
  
  Log.warn("Unknown value tag: " + node, new Throwable());
  return null;
}

代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server

/**
 * Create a WebAppContext for the webapp being hot deployed, then apply the
 * xml config file to it to configure it.
 * 
 * @param filename
 *            the config file found in the hot deploy directory
 * @return
 * @throws Exception
 */
private ContextHandler createContext(String filename) throws Exception
{
  // The config file can call any method on WebAppContext to configure
  // the webapp being deployed.
  File hotDeployXmlFile=new File(filename);
  if (!hotDeployXmlFile.exists())
    return null;
  XmlConfiguration xmlConfiguration=new XmlConfiguration(hotDeployXmlFile.toURL());
  HashMap properties = new HashMap();
  properties.put("Server", _contexts.getServer());
  if (_configMgr!=null)
    properties.putAll(_configMgr.getProperties());
      xmlConfiguration.setProperties(properties);
  ContextHandler context=(ContextHandler)xmlConfiguration.configure();
  return context;
}

代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server

XmlConfiguration configuration = new XmlConfiguration(Resource.newResource(args[i]).getURL());
if (last!=null)
  configuration.getIdMap().putAll(last.getIdMap());
if (properties.size()>0)
  configuration.setProperties(properties);
obj[i] = configuration.configure();
last=configuration;

代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server

private Object call(Object obj, XmlParser.Node node) throws Exception
  Class oClass = nodeClass(node);
  if (oClass != null)
    obj = null;
    arg[j++] = value(obj, (XmlParser.Node) o);
      configure(n, node, argi);
      return n;

代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server

private Object refObj(Object obj, XmlParser.Node node) throws Exception
{
  String id = node.getAttribute("id");
  obj = _idMap.get(id);
  if (obj == null) throw new IllegalStateException("No object for id=" + id);
  configure(obj, node, 0);
  return obj;
}

代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server

/**
 * Configure an object.  If the configuration has an ID, an object is looked up
 * by ID and it's type check.  Otherwise a new object is created.
 * 
 * @return The newly created configured object.
 * @exception Exception
 */
public Object configure() throws Exception
{
  Class oClass = nodeClass(_config);
  
  String id = _config.getAttribute("id");
  Object obj = id==null?null:_idMap.get(id);
  
  if (obj==null && oClass !=null)
    obj = oClass.newInstance();
  
  if (oClass!=null && !oClass.isInstance(obj))
    throw new ClassCastException(oClass.toString());
  
  configure(obj, _config, 0);
  return obj;
}

代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server

private Object newObj(Object obj, XmlParser.Node node) throws Exception
  Class oClass = nodeClass(node);
  String id = node.getAttribute("id");
  int size = 0;
    arg[j++] = value(obj, (XmlParser.Node) o);
      configure(n, node, argi);
      return n;

代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server

private Object propertyObj(Object obj, XmlParser.Node node) throws Exception
{
  String id = node.getAttribute("id");
  String name = node.getAttribute("name");
  Object defval = node.getAttribute("default");
  Object prop=null;
  if (_propertyMap!=null && _propertyMap.containsKey(name))
  {
    prop=_propertyMap.get(name);
  }
  else if (defval != null)
    prop=defval;
  if (id != null) 
    _idMap.put(id, prop);
  if (prop!=null)
    configure(prop, node, 0);
  return prop;
}

代码示例来源:origin: org.mortbay.jetty/jetty-embedded

XmlConfiguration configuration = new XmlConfiguration(server_config); 
configuration.configure(server);
configuration = new XmlConfiguration(context_config); 
ContextHandler context = (ContextHandler)configuration.configure();

代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server

private Object get(Object obj, XmlParser.Node node) throws Exception
  Class oClass = nodeClass(node);
  if (oClass != null)
    obj = null;
        + name.substring(1), (java.lang.Class[]) null);
    obj = method.invoke(obj, (java.lang.Object[]) null);
    configure(obj, node, 0);
      configure(obj, node, 0);

代码示例来源:origin: feroult/yawp

protected WebAppContext createWebAppContext() {
  try {
    Resource jettyEnv = Resource.newResource(String.format("%s/WEB-INF/jetty-env.xml", mojo.getAppDir()));
    XmlConfiguration conf = new XmlConfiguration(jettyEnv.getInputStream());
    WebAppContext webapp = (WebAppContext) conf.configure();
    webapp.setWar(mojo.getAppDir());
    System.setProperty("java.naming.factory.url.pkgs", "org.mortbay.naming");
    System.setProperty("java.naming.factory.initial", "org.mortbay.naming.InitialContextFactory");
    return webapp;
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: eclipse-jetty/eclipse-jetty-plugin

XmlConfiguration configuration = new XmlConfiguration(in);
  configuration.configure(server);
      configuration.configure(handler);
  configuration.configure(handler);

代码示例来源:origin: org.sonatype.plexus/plexus-jetty6

new XmlConfiguration( tempJettyXml.toURL() ).configure( server );

代码示例来源:origin: apache/chukwa

XmlConfiguration configuration;
try {
 configuration = new XmlConfiguration(serverConf);
 configuration.configure(server);
 server.start();
 server.setStopAtShutdown(true);

代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server

if(Log.isDebugEnabled())
  Log.debug("Configure: "+jetty);
XmlConfiguration jetty_config=new XmlConfiguration(jetty.getURL());
jetty_config.configure(getWebAppContext());

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com