public synchronized void addServlet(ServiceReference<Servlet> ref) {
String endpoint = (String) ref.getProperty(HttpConstants.ENDPOINT);
m_servlets.put(ref, endpoint);
Servlet servlet = m_context.getService(ref);
Dictionary<String, Object> initParams = getInitParams(ref);
for (ServiceReference<HttpService> reference : m_httpServices) {
HttpService httpService = m_context.getService(reference);
try {
if ((httpService != null) && (endpoint != null) && (servlet != null)) {
httpService.registerServlet(endpoint, servlet, initParams, null);
}
else {
m_log.log(LogService.LOG_WARNING, "Unable to register servlet with endpoint '" + endpoint + "'");
}
}
catch (Exception e) {
m_log.log(LogService.LOG_WARNING, "Already registered under existing endpoint", e);
}
}
}
|