use of org.apache.catalina.deploy.ContextHandler in project tomcat70 by apache.
the class SetOverrideRule method body.
/**
* Process the body text of this element.
*
* @param namespace the namespace URI of the matching element, or an
* empty string if the parser is not namespace aware or the element has
* no namespace
* @param name the local name if the parser is namespace aware, or just
* the element name otherwise
* @param text The body text of this element
*/
@Override
public void body(String namespace, String name, String text) throws Exception {
String namespaceuri = null;
String localpart = text;
int colon = text.indexOf(':');
if (colon >= 0) {
String prefix = text.substring(0, colon);
namespaceuri = digester.findNamespaceURI(prefix);
localpart = text.substring(colon + 1);
}
ContextHandler contextHandler = (ContextHandler) digester.peek();
contextHandler.addSoapHeaders(localpart, namespaceuri);
}
use of org.apache.catalina.deploy.ContextHandler in project tomcat70 by apache.
the class NamingContextListener method addService.
/**
* Set the specified web service in the naming context.
*/
public void addService(ContextService service) {
if (service.getWsdlfile() != null) {
URL wsdlURL = null;
try {
wsdlURL = new URL(service.getWsdlfile());
} catch (MalformedURLException e) {
// Ignore and carry on
}
if (wsdlURL == null) {
try {
wsdlURL = ((Context) container).getServletContext().getResource(service.getWsdlfile());
} catch (MalformedURLException e) {
// Ignore and carry on
}
}
if (wsdlURL == null) {
try {
wsdlURL = ((Context) container).getServletContext().getResource("/" + service.getWsdlfile());
logger.debug(" Changing service ref wsdl file for /" + service.getWsdlfile());
} catch (MalformedURLException e) {
logger.error(sm.getString("naming.wsdlFailed", e));
}
}
if (wsdlURL == null)
service.setWsdlfile(null);
else
service.setWsdlfile(wsdlURL.toString());
}
if (service.getJaxrpcmappingfile() != null) {
URL jaxrpcURL = null;
try {
jaxrpcURL = new URL(service.getJaxrpcmappingfile());
} catch (MalformedURLException e) {
// Ignore and carry on
}
if (jaxrpcURL == null) {
try {
jaxrpcURL = ((Context) container).getServletContext().getResource(service.getJaxrpcmappingfile());
} catch (MalformedURLException e) {
// Ignore and carry on
}
}
if (jaxrpcURL == null) {
try {
jaxrpcURL = ((Context) container).getServletContext().getResource("/" + service.getJaxrpcmappingfile());
logger.debug(" Changing service ref jaxrpc file for /" + service.getJaxrpcmappingfile());
} catch (MalformedURLException e) {
logger.error(sm.getString("naming.wsdlFailed", e));
}
}
if (jaxrpcURL == null)
service.setJaxrpcmappingfile(null);
else
service.setJaxrpcmappingfile(jaxrpcURL.toString());
}
// Create a reference to the resource.
Reference ref = new ServiceRef(service.getName(), service.getInterface(), service.getServiceqname(), service.getWsdlfile(), service.getJaxrpcmappingfile());
// Adding the additional port-component-ref, if any
Iterator<String> portcomponent = service.getServiceendpoints();
while (portcomponent.hasNext()) {
String serviceendpoint = portcomponent.next();
StringRefAddr refAddr = new StringRefAddr(ServiceRef.SERVICEENDPOINTINTERFACE, serviceendpoint);
ref.add(refAddr);
String portlink = service.getPortlink(serviceendpoint);
refAddr = new StringRefAddr(ServiceRef.PORTCOMPONENTLINK, portlink);
ref.add(refAddr);
}
// Adding the additional parameters, if any
Iterator<String> handlers = service.getHandlers();
while (handlers.hasNext()) {
String handlername = handlers.next();
ContextHandler handler = service.getHandler(handlername);
HandlerRef handlerRef = new HandlerRef(handlername, handler.getHandlerclass());
Iterator<String> localParts = handler.getLocalparts();
while (localParts.hasNext()) {
String localPart = localParts.next();
String namespaceURI = handler.getNamespaceuri(localPart);
handlerRef.add(new StringRefAddr(HandlerRef.HANDLER_LOCALPART, localPart));
handlerRef.add(new StringRefAddr(HandlerRef.HANDLER_NAMESPACE, namespaceURI));
}
Iterator<String> params = handler.listProperties();
while (params.hasNext()) {
String paramName = params.next();
String paramValue = (String) handler.getProperty(paramName);
handlerRef.add(new StringRefAddr(HandlerRef.HANDLER_PARAMNAME, paramName));
handlerRef.add(new StringRefAddr(HandlerRef.HANDLER_PARAMVALUE, paramValue));
}
for (int i = 0; i < handler.getSoapRolesSize(); i++) {
handlerRef.add(new StringRefAddr(HandlerRef.HANDLER_SOAPROLE, handler.getSoapRole(i)));
}
for (int i = 0; i < handler.getPortNamesSize(); i++) {
handlerRef.add(new StringRefAddr(HandlerRef.HANDLER_PORTNAME, handler.getPortName(i)));
}
((ServiceRef) ref).addHandler(handlerRef);
}
try {
if (logger.isDebugEnabled()) {
logger.debug(" Adding service ref " + service.getName() + " " + ref);
}
createSubcontexts(envCtx, service.getName());
envCtx.bind(service.getName(), ref);
} catch (NamingException e) {
logger.error(sm.getString("naming.bindFailed", e));
}
}
Aggregations