blob: 8ffb50da93950fa241ec2b5f01c036e102761a0b [file] [log] [blame]
// ========================================================================
// Copyright (c) Webtide LLC
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.apache.org/licenses/LICENSE-2.0.txt
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
package org.eclipse.jetty.deploy.providers;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.jetty.deploy.App;
import org.eclipse.jetty.deploy.DeploymentManager;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.util.AttributesMap;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.xml.XmlConfiguration;
public class ConfiguredContextApp implements App
{
private String filename;
private ContextHandler handler;
public ConfiguredContextApp(String filename)
{
this.filename = filename;
}
public File getDir()
{
// TODO Auto-generated method stub
return null;
}
@SuppressWarnings("unchecked")
public ContextHandler getContextHandler(DeploymentManager deploymgr) throws Exception
{
if (handler == null)
{
Resource resource = Resource.newResource(filename);
if (!resource.exists())
{
return null;
}
XmlConfiguration xmlc = new XmlConfiguration(resource.getURL());
Map props = new HashMap();
props.put("Server",deploymgr.getServer());
if (deploymgr.getConfigurationManager() != null)
{
props.putAll(deploymgr.getConfigurationManager().getProperties());
}
xmlc.setProperties(props);
this.handler = (ContextHandler)xmlc.configure();
this.handler.setAttributes(new AttributesMap(deploymgr.getContextAttributes()));
}
return handler;
}
public String getId()
{
return null;
}
public String getName()
{
// TODO Auto-generated method stub
return null;
}
public String getOrigin()
{
// TODO Auto-generated method stub
return null;
}
public File getWorkDir()
{
// TODO Auto-generated method stub
return null;
}
}