Java Code Examples for org.eclipse.jetty.util.resource.Resource#getInputStream()

The following examples show how to use org.eclipse.jetty.util.resource.Resource#getInputStream() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JettyEmbedServer.java    From tddl5 with Apache License 2.0 6 votes vote down vote up
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!");
    }
}
 
Example 2
Source File: JettyServer.java    From DataLink with Apache License 2.0 5 votes vote down vote up
public void startup() throws Exception {
    Resource configXml = Resource.newSystemResource(DEFAULT_JETTY_CONFIG);
    XmlConfiguration configuration = new XmlConfiguration(configXml.getInputStream());
    server = (Server) configuration.configure();

    Integer port = config.getHttpPort();
    if (port != null && port > 0) {
        Connector[] connectors = server.getConnectors();
        for (Connector connector : connectors) {
            if (connector instanceof AbstractNetworkConnector) {
                ((AbstractNetworkConnector) connector).setPort(port);
            }
        }
    }

    Handler handler = server.getHandler();
    if (handler != null && handler instanceof WebAppContext) {
        WebAppContext webAppContext = (WebAppContext) handler;
        String webAppPath = System.getProperty("webapp.conf");
        logger.info("Web App Path is " + webAppPath);

        if (StringUtils.isBlank(webAppPath)) {
            webAppContext.setResourceBase(JettyServer.class.getResource("/webapp").toString());
        } else {
            webAppContext.setResourceBase(webAppPath);
        }
    }

    server.start();
    if (logger.isInfoEnabled()) {
        logger.info("##Jetty Embed Server is started.");
    }
}
 
Example 3
Source File: SslContextFactory.java    From IoTgo_Android_App with MIT License 5 votes vote down vote up
/** Set the key store resource.
 * @param resource the key store resource to set
 */
public void setKeyStoreResource(Resource resource)
{
    checkNotStarted();

    try
    {
        _keyStoreInputStream = resource.getInputStream();
    }
    catch (IOException e)
    {
         throw new InvalidParameterException("Unable to get resource "+
                 "input stream for resource "+resource.toString());
    }
}
 
Example 4
Source File: SslContextFactory.java    From IoTgo_Android_App with MIT License 5 votes vote down vote up
/** Set the trust store resource.
 * @param resource the trust store resource to set
 */
public void setTrustStoreResource(Resource resource)
{
    checkNotStarted();

    try
    {
        _trustStoreInputStream = resource.getInputStream();
    }
    catch (IOException e)
    {
         throw new InvalidParameterException("Unable to get resource "+
                 "input stream for resource "+resource.toString());
    }
}
 
Example 5
Source File: SslContextFactory.java    From IoTgo_Android_App with MIT License 5 votes vote down vote up
/** Set the key store resource.
 * @param resource the key store resource to set
 */
public void setKeyStoreResource(Resource resource)
{
    checkNotStarted();

    try
    {
        _keyStoreInputStream = resource.getInputStream();
    }
    catch (IOException e)
    {
         throw new InvalidParameterException("Unable to get resource "+
                 "input stream for resource "+resource.toString());
    }
}
 
Example 6
Source File: SslContextFactory.java    From IoTgo_Android_App with MIT License 5 votes vote down vote up
/** Set the trust store resource.
 * @param resource the trust store resource to set
 */
public void setTrustStoreResource(Resource resource)
{
    checkNotStarted();

    try
    {
        _trustStoreInputStream = resource.getInputStream();
    }
    catch (IOException e)
    {
         throw new InvalidParameterException("Unable to get resource "+
                 "input stream for resource "+resource.toString());
    }
}