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


Java XmlConfiguration.configure方法代码示例

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


在下文中一共展示了XmlConfiguration.configure方法的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: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: createServer

import org.eclipse.jetty.xml.XmlConfiguration; //导入方法依赖的package包/类
protected Server createServer() throws Exception {
    ClassLoader serverClassLoader = Thread.currentThread().getContextClassLoader();
    ClassLoader sharedClassLoader = new URLClassLoader(pathsToURLs(serverClassLoader, SHARED_CLASS_PATH_IN_JAR), serverClassLoader);
    Server server;
    if (jettyConfUrl != null) {
        XmlConfiguration xmlConfiguration = new XmlConfiguration(jettyConfUrl);
        server = (Server) xmlConfiguration.configure();
    } else {
        server = new Server(port);
    }
    server.setStopAtShutdown(true);
    List<Handler> handlers = new ArrayList<>();
    if (CubaJettyUtils.hasCoreApp(serverClassLoader)) {
        String coreContextPath = contextPath;
        if (isSingleJar(serverClassLoader)) {
            if (PATH_DELIMITER.equals(contextPath)) {
                coreContextPath = PATH_DELIMITER + "app-core";
            } else {
                coreContextPath = contextPath + "-core";
            }
        }
        handlers.add(createAppContext(serverClassLoader, sharedClassLoader, CORE_PATH_IN_JAR, coreContextPath));
    }
    if (hasWebApp(serverClassLoader)) {
        handlers.add(createAppContext(serverClassLoader, sharedClassLoader, WEB_PATH_IN_JAR, contextPath));
    }
    if (hasPortalApp(serverClassLoader)) {
        String portalContextPath = contextPath;
        if (isSingleJar(serverClassLoader)) {
            portalContextPath = this.portalContextPath;
        }
        handlers.add(createAppContext(serverClassLoader, sharedClassLoader, PORTAL_PATH_IN_JAR, portalContextPath));
    }
    if (hasFrontApp(serverClassLoader)) {
        handlers.add(createFrontAppContext(serverClassLoader, sharedClassLoader));
    }

    HandlerCollection handlerCollection = new HandlerCollection();
    handlerCollection.setHandlers(handlers.toArray(new Handler[handlers.size()]));
    server.setHandler(handlerCollection);

    return server;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:44,代码来源:CubaJettyServer.java

示例15: doStart

import org.eclipse.jetty.xml.XmlConfiguration; //导入方法依赖的package包/类
private void doStart(boolean waitForServer, @Nullable final Runnable callback) throws Exception {
  if (thread != null) {
    throw new IllegalStateException("Already started");
  }

  log.info("Starting");

  List<LifeCycle> components = new ArrayList<>();

  PropertyMap props = new PropertyMap();
  props.putAll(JettyServer.this.properties);

  // For all arguments, load properties or parse XMLs
  XmlConfiguration last = null;
  for (String arg : args) {
    URL url = Resource.newResource(arg).getURL();

    if (url.getFile().toLowerCase(Locale.ENGLISH).endsWith(".properties")) {
      log.info("Loading properties: {}", url);

      props.load(url);
    }
    else {
      log.info("Applying configuration: {}", url);

      XmlConfiguration configuration = new XmlConfiguration(url);
      if (last != null) {
        configuration.getIdMap().putAll(last.getIdMap());
      }
      if (!props.isEmpty()) {
        configuration.getProperties().putAll(props);
      }
      Object component = configuration.configure();
      if (component instanceof LifeCycle) {
        components.add((LifeCycle) component);
      }
      last = configuration;
    }
  }

  // complain if no components configured
  if (components.isEmpty()) {
    throw new Exception("Failed to configure any components");
  }

  Server server = null;
  for (Object object : components) {
    if (object instanceof Server) {
      server = (Server) object;
      break;
    }
  }

  connectorManager = new ConnectorManager(server, last.getIdMap());

  thread = new JettyMainThread(components, callback);
  thread.setContextClassLoader(classLoader);
  thread.startComponents(waitForServer);
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:60,代码来源:JettyServer.java


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