当前位置: 首页>>代码示例>>Java>>正文


Java XmlConfiguration类代码示例

本文整理汇总了Java中org.eclipse.jetty.xml.XmlConfiguration的典型用法代码示例。如果您正苦于以下问题:Java XmlConfiguration类的具体用法?Java XmlConfiguration怎么用?Java XmlConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XmlConfiguration类属于org.eclipse.jetty.xml包,在下文中一共展示了XmlConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import org.eclipse.jetty.xml.XmlConfiguration; //导入依赖的package包/类
public void start() throws Exception {
    Resource configXml = Resource.newSystemResource(config);
    XmlConfiguration configuration = new XmlConfiguration(configXml.getInputStream());
    server = (Server) configuration.configure();

    //        Integer port = getPort();
    //        if (port != null && port > 0) {
    //            Connector[] connectors = server.getConnectors();
    //            for (Connector connector : connectors) {
    //                connector.setPort(port);
    //            }
    //        }
    Handler handler = server.getHandler();
    if (handler != null && handler instanceof WebAppContext) {
        WebAppContext webAppContext = (WebAppContext) handler;
        webAppContext.setResourceBase(JettyEmbedServer.class.getResource("/webapp").toString());
    }
    server.start();
    if (logger.isInfoEnabled()) {
        logger.info("##Jetty Embed Server is startup!");
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:23,代码来源:JettyEmbedServer.java

示例2: afterPropertiesSet

import org.eclipse.jetty.xml.XmlConfiguration; //导入依赖的package包/类
public void afterPropertiesSet() throws Exception {
    Resource configXml = Resource.newSystemResource(config);
    XmlConfiguration configuration = new XmlConfiguration(configXml.getInputStream());
    server = (Server) configuration.configure();
    Integer port = getPort();
    if (port != null && port > 0) {
        Connector[] connectors = server.getConnectors();
        for (Connector connector : connectors) {
            connector.setPort(port);
        }
    }

    Handler handler = server.getHandler();
    if (handler != null && handler instanceof ServletContextHandler) {
        ServletContextHandler servletHandler = (ServletContextHandler) handler;
        servletHandler.getInitParams().put("org.eclipse.jetty.servlet.Default.resourceBase", htdocsDir);
    }

    server.start();
    if (logger.isInfoEnabled()) {
        logger.info("##Jetty Embed Server is startup!");
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:24,代码来源:JettyEmbedServer.java

示例3: main

import org.eclipse.jetty.xml.XmlConfiguration; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
    Resource jetty_xml = Resource.newSystemResource("jetty/jetty.xml");
    XmlConfiguration configuration = new XmlConfiguration(jetty_xml.getInputStream());
    Server server = (Server) configuration.configure();
    int port = 8081;
    Connector[] connectors = server.getConnectors();
    for (Connector connector : connectors) {
        connector.setPort(port);
    }

    Handler handler = server.getHandler();
    if (handler != null && handler instanceof ServletContextHandler) {
        ServletContextHandler servletHandler = (ServletContextHandler) handler;
        servletHandler.getInitParams().put("org.eclipse.jetty.servlet.Default.resourceBase", "/tmp/");
    }

    server.start();
    server.join();
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:20,代码来源:JettyEmbedIntegration.java

示例4: configure

import org.eclipse.jetty.xml.XmlConfiguration; //导入依赖的package包/类
/**
 * Configure the server from properties and XML.
 */
private InputStream configure(final String jettyPropertiesFile) throws Exception {
	final InputStream propertiesInput = Thread.currentThread().getContextClassLoader().getResourceAsStream(jettyPropertiesFile);
	if (propertiesInput == null) {
		log.error("Unable to find jetty properties file : " + jettyPropertiesFile);
	} else {

		// Copy the properties
		copyProperties(propertiesInput);

		// Configure the server
		new XmlConfiguration(
				Thread.currentThread().getContextClassLoader().getResource(System.getProperty("jetty.xml", "META-INF/jetty/jetty.xml")))
						.configure(server);
	}
	return propertiesInput;
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:20,代码来源:Main.java

示例5: XmlConfiguration

import org.eclipse.jetty.xml.XmlConfiguration; //导入依赖的package包/类
public void	init() throws Exception {
       
	Log.info("**************************************************");
	Log.info("Welcome to Mentor {}...", MentorProperties.get().getVersion());
	Log.info("**************************************************");

	eventBus = MentorInjector.get().getInstance(MentorEventBus.class);
	scheduler = MentorInjector.get().getInstance(Scheduler.class);
	
	try (InputStream istream = ClassLoader.getSystemResourceAsStream("jetty.xml")) {
		XmlConfiguration jettyConf = new XmlConfiguration(istream);
		server = Server.class.cast(jettyConf.configure());
	}
	Log.info("Jetty initialized");

	eventBus.post(new MentorInitEvent(this));
	
}
 
开发者ID:vsite-hr,项目名称:mentor,代码行数:19,代码来源:Mentor.java

示例6: start

import org.eclipse.jetty.xml.XmlConfiguration; //导入依赖的package包/类
public void start() throws Exception {
    Resource configXml = Resource.newSystemResource(config);
    XmlConfiguration configuration = new XmlConfiguration(configXml.getInputStream());
    server = (Server) configuration.configure();

    // Integer port = getPort();
    // if (port != null && port > 0) {
    // Connector[] connectors = server.getConnectors();
    // for (Connector connector : connectors) {
    // connector.setPort(port);
    // }
    // }
    Handler handler = server.getHandler();
    if (handler != null && handler instanceof WebAppContext) {
        WebAppContext webAppContext = (WebAppContext) handler;
        webAppContext.setResourceBase(JettyEmbedServer.class.getResource("/webapp").toString());
    }
    server.start();
    if (logger.isInfoEnabled()) {
        logger.info("##Jetty Embed Server is startup!");
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:23,代码来源:JettyEmbedServer.java

示例7: init

import org.eclipse.jetty.xml.XmlConfiguration; //导入依赖的package包/类
/**
 * Inits the system by creating a new server and handler
 */
private void init() {
    try {
        if (useConfigFile) {
            Resource resource = Resource.newSystemResource(_configFile);

            XmlConfiguration config = new XmlConfiguration(resource.getInputStream());
            _server = (Server) config.configure();

            _handler = new HttpHandler();
            _server.setHandler(_handler);
        } else {
            _server = new Server();
            _handler = new HttpHandler();
            _server.setHandler(_handler);
        }
    } catch(Exception e){
        throw new RuntimeException("Server unable to start: " + e.getMessage());
    }
}
 
开发者ID:tOgg1,项目名称:WS-Nu,代码行数:23,代码来源:ApplicationServer.java

示例8: parseArgs

import org.eclipse.jetty.xml.XmlConfiguration; //导入依赖的package包/类
/**
 *  Modified from XmlConfiguration.main()
 */
public void parseArgs(String[] args) throws Exception {
    Properties properties=new Properties();
    XmlConfiguration last=null;
    InputStream in = null;
    for (int i = 0; i < args.length; i++) {
        if (args[i].toLowerCase().endsWith(".properties")) {
            in = Resource.newResource(args[i]).getInputStream();
            properties.load(in);
            in.close();
        } else {
            XmlConfiguration configuration = new XmlConfiguration(Resource.newResource(args[i]).getURL());
            if (last!=null)
                configuration.getIdMap().putAll(last.getIdMap());
            if (properties.size()>0) {
                // to avoid compiler errror
                Map foo = configuration.getProperties();
                foo.putAll(properties);
            }
            Object o = configuration.configure();
            if (o instanceof LifeCycle)
                _jettys.add((LifeCycle)o);
            last=configuration;
        }
    }
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:29,代码来源:JettyStart.java

示例9: onInit

import org.eclipse.jetty.xml.XmlConfiguration; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void onInit() {
    final File jettyXml = new File(System.getProperty("opennms.home") + File.separator + "etc" + File.separator + "jetty.xml");
    InputStream jettyXmlStream = null;

    try {
        m_server = new Server();
        if (jettyXml.exists()) {
            jettyXmlStream = jettyXml.toURI().toURL().openStream();
        } else {
            jettyXmlStream = getClass().getResourceAsStream("jetty.xml");
        }
        if (jettyXmlStream == null) {
            throw new RuntimeException("Unable to locate jetty.xml in the classpath!");
        }
        final XmlConfiguration xmlConfiguration = new XmlConfiguration(jettyXmlStream);
        xmlConfiguration.configure(m_server);
    } catch (final Exception ioe) {
        throw new RuntimeException(ioe);
    }

    m_server.setStopAtShutdown(true);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:25,代码来源:JettyServer.java

示例10: main

import org.eclipse.jetty.xml.XmlConfiguration; //导入依赖的package包/类
/**
 * Main function, starts the jetty server. The first parameter can be the jetty.xml configuration file.
 * 
 * @param args
 *            Alternative location of jetty configuration file
 */
public static void main(String[] args) {
	Server server = null;
	try {
		URL configUrl;

		// Jetty configuration file is the only param allowed
		if (args != null && args.length != 1) {
			System.err.println("Usage java " + Main.class.getName() + " [URL path to jetty xml conf]");
			System.exit(1);
		}

		String jettyXmlUrl = args[0];
		configUrl = getConfigUrl(jettyXmlUrl);

		XmlConfiguration xmlConfiguration = new XmlConfiguration(configUrl);
		server = new Server();
		xmlConfiguration.configure(server);

		// Start Jetty
		server.start();
		server.join();
	} catch (Exception e) {
		System.err.println("Could not start the Jetty server: " + e);
		e.printStackTrace();
		if (server != null) {
			try {
				server.stop();
			} catch (Exception e1) {
				System.err.println("Unable to stop the jetty server: " + e1);
			}
		}
	}
}
 
开发者ID:LeonanCarvalho,项目名称:testcube-server,代码行数:40,代码来源:Main.java

示例11: readXmlConfig

import org.eclipse.jetty.xml.XmlConfiguration; //导入依赖的package包/类
private void readXmlConfig(final String configPath) {
    try {
        final XmlConfiguration configuration = new XmlConfiguration(new FileInputStream(configPath));
        configuration.configure(this);
    } catch (final Throwable e) {
        throw new ReadXMLException(e.getMessage(), e);
    }
}
 
开发者ID:nano-projects,项目名称:nano-framework,代码行数:9,代码来源:JettyCustomServer.java

示例12: doStart

import org.eclipse.jetty.xml.XmlConfiguration; //导入依赖的package包/类
@Override
protected void doStart() throws Exception {
  
  Resource resource = Resource.newResource(webapp);
  File file = resource.getFile();
  if (!resource.exists())
      throw new IllegalStateException("WebApp resouce does not exist "+resource);

  String lcName=file.getName().toLowerCase(Locale.ENGLISH);

  if (lcName.endsWith(".xml")) {
      XmlConfiguration xmlc = new XmlConfiguration(resource.getURI().toURL());
      xmlc.getIdMap().put("Server", contexts.getServer());
      xmlc.getProperties().put("jetty.home",System.getProperty("jetty.home","."));
      xmlc.getProperties().put("jetty.base",System.getProperty("jetty.base","."));
      xmlc.getProperties().put("jetty.webapp",file.getCanonicalPath());
      xmlc.getProperties().put("jetty.webapps",file.getParentFile().getCanonicalPath());
      xmlc.getProperties().putAll(properties);
      handler = (ContextHandler)xmlc.configure();
  } else {
    WebAppContext wac=new WebAppContext();
    wac.setWar(webapp);
    wac.setContextPath("/");
  }
  
  contexts.addHandler(handler);
  if (contexts.isRunning())
    handler.start();
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:30,代码来源:VmRuntimeWebAppDeployer.java

示例13: performCustomConfiguration

import org.eclipse.jetty.xml.XmlConfiguration; //导入依赖的package包/类
private void performCustomConfiguration() throws Exception {
    File jettyConfig = systemEnvironment.getJettyConfigFile();
    if (jettyConfig.exists()) {
        replaceJettyXmlIfItBelongsToADifferentVersion(jettyConfig);
        LOG.info("Configuring Jetty using {}", jettyConfig.getAbsolutePath());
        FileInputStream serverConfiguration = new FileInputStream(jettyConfig);
        XmlConfiguration configuration = new XmlConfiguration(serverConfiguration);
        configuration.configure(server);
    } else {
        String message = String.format(
                "No custom jetty configuration (%s) found, using defaults.",
                jettyConfig.getAbsolutePath());
        LOG.info(message);
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:16,代码来源:Jetty9Server.java

示例14: configureWebApplication

import org.eclipse.jetty.xml.XmlConfiguration; //导入依赖的package包/类
/**
 * Subclasses should invoke this to setup basic info
 * on the webapp
 *
 * @throws MojoExecutionException
 */
public void configureWebApplication () throws Exception
{
    //As of jetty-7, you must use a <webAppConfig> element
    if (webAppConfig == null)
        webAppConfig = new JettyWebAppContext();

    //Apply any context xml file to set up the webapp
    //CAUTION: if you've defined a <webAppConfig> element then the
    //context xml file can OVERRIDE those settings
    if (webAppXml != null)
    {
        File file = FileUtils.getFile(webAppXml);
        XmlConfiguration xmlConfiguration = new XmlConfiguration(file.toURL());
        getLog().info("Applying context xml file "+webAppXml);
        xmlConfiguration.configure(webAppConfig);
    }


    //If no contextPath was specified, go with our default
    String cp = webAppConfig.getContextPath();
    if (cp == null || "".equals(cp))
    {
        webAppConfig.setContextPath((contextPath.startsWith("/") ? contextPath : "/"+ contextPath));
    }

    //If no tmp directory was specified, and we have one, use it
    if (webAppConfig.getTempDirectory() == null && tmpDirectory != null)
    {
        if (!tmpDirectory.exists())
            tmpDirectory.mkdirs();

        webAppConfig.setTempDirectory(tmpDirectory);
    }

    getLog().info("Context path = " + webAppConfig.getContextPath());
    getLog().info("Tmp directory = "+ (webAppConfig.getTempDirectory()== null? " determined at runtime": webAppConfig.getTempDirectory()));
    getLog().info("Web defaults = "+(webAppConfig.getDefaultsDescriptor()==null?" jetty default":webAppConfig.getDefaultsDescriptor()));
    getLog().info("Web overrides = "+(webAppConfig.getOverrideDescriptor()==null?" none":webAppConfig.getOverrideDescriptor()));
}
 
开发者ID:pister,项目名称:wint,代码行数:46,代码来源:AbstractJettyRunMojo.java

示例15: applyJettyXml

import org.eclipse.jetty.xml.XmlConfiguration; //导入依赖的package包/类
public void applyJettyXml() throws Exception
{
    if (getJettyXmlFiles() == null)
        return;

    for ( File xmlFile : getJettyXmlFiles() )
    {
        getLog().info( "Configuring Jetty from xml configuration file = " + xmlFile.getCanonicalPath() );
        XmlConfiguration xmlConfiguration = new XmlConfiguration(xmlFile.toURI().toURL());
        xmlConfiguration.configure(this.server);
    }
}
 
开发者ID:pister,项目名称:wint,代码行数:13,代码来源:WintJettyRunMojoBase.java


注:本文中的org.eclipse.jetty.xml.XmlConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。