Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





#Java - Code Snippets for '#Org.osgi.service.http.HttpService' - 1 code snippet(s) found

 Sample 1. Code Sample / Example / Snippet of org.osgi.service.http.HttpService

    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);

}

}

}


   Like      Feedback      org.osgi.service.http.HttpService



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner