本文整理汇总了Java中org.eclipse.jetty.util.resource.Resource.getInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.getInputStream方法的具体用法?Java Resource.getInputStream怎么用?Java Resource.getInputStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.util.resource.Resource
的用法示例。
在下文中一共展示了Resource.getInputStream方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的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!");
}
}
示例2: afterPropertiesSet
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的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!");
}
}
示例3: main
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的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();
}
示例4: append
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
protected Resource append(HttpServletRequest request, Resource resource, String path) throws IOException {
InputStream input = resource.getInputStream();
ByteArrayOutputStream output = new ByteArrayOutputStream();
int i = -1;
while ((i = input.read()) != -1) {
output.write(i);
}
input.close();
String content = output.toString();
StringBuffer sb = new StringBuffer(content);
resourceAppender.append(request, path, sb);
Resource resource2 = new StringResource(sb.toString());
// /js/jquery.min.js
// System.err.println("HostResourceHandler getResource:");
return resource2;
}
示例5: start
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的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!");
}
}
示例6: init
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的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());
}
}
示例7: setKeyStoreResource
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
/** 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());
}
}
示例8: setTrustStoreResource
import org.eclipse.jetty.util.resource.Resource; //导入方法依赖的package包/类
/** 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());
}
}