result.setConverterName(getInitParameter(NAME_CONVERTER_CLASS, NAME_CONVERTER_CLASS_DEFAULT));
	public HttpServer getServer(HttpServletRequest request)	{		HttpServer result = this.server;		if (result == null)		{			synchronized (ServerServlet.class)			{				// Find the attribute name to use to store the server reference				String serverAttributeName = getInitParameter(NAME_SERVER_ATTRIBUTE, NAME_SERVER_ATTRIBUTE_DEFAULT);				// Look up the attribute for a target				result = (HttpServer) getServletContext().getAttribute(serverAttributeName);								if (result == null)				{					result = new HttpServer();					result.setConverterName(getInitParameter(NAME_CONVERTER_CLASS, NAME_CONVERTER_CLASS_DEFAULT));					getServletContext().setAttribute(NAME_SERVER_ATTRIBUTE, result);										// Try to instantiate a new target					// First, find the target class name					String targetClassName = getInitParameter(NAME_TARGET_CLASS, null);					if (targetClassName != null)					{						try						{							// Load the target class using the given class name							Class targetClass = Class.forName(targetClassName);							Object target = null;							// Create a new instance of the target class							// and store it for reuse by other ServerServlets.							try							{								target = targetClass.getConstructor(Context.class)										.newInstance((Context) null);							}							catch (NoSuchMethodException nsme)							{								target = targetClass.newInstance();							}							// First, let's locate the closest component							Container container = null;							if (target instanceof Container)							{								// The target is probably a Container or an Application								container = (Container) target;							}							else if(target instanceof Restlet)							{								// The target is probably a standalone Restlet or Filter or Router								// Try to get its parent, even if chances to find one are low								container = new Container(null);								container.setRoot((Restlet)target);							}														if (container != null)							{								// Add the HTTP server connector adapting the Servlet requests 								container.getServers().add(result);																// Create a local client and add it to the container								container.getClients().add(										new ServletLocalClient(getServletContext()));								// Create the context based on the Servlet's context								// and set it on the container and optionally the target Restlet								container.setContext(new ServletContext(this, container));								result.setContext(container.getContext());								if (target != container) ((Restlet)target).setContext(container.getContext());								// Set if a context path needs to be transmitted								String initContextPathName = getInitParameter(NAME_TARGET_INIT_CONTEXTPATH);								if (initContextPathName != null)								{									// Provide the context path as an init parameter									String scheme = request.getScheme();									String hostName = request.getServerName();									int hostPort = request.getServerPort();									String servletPath = request.getContextPath()											+ request.getServletPath();									String contextPath = Reference.toString(scheme, hostName,											hostPort, servletPath, null, null);									container.getContext().getParameters().add(											initContextPathName, contextPath);									log("[Noelios Restlet Engine] - This context path has been provided to the target's init parameter \""											+ initContextPathName + "\": " + contextPath);								}								// Starts the target Restlet								result.start();							}							else							{								log("[Noelios Restlet Engine] - The Restlet container couldn't be instantiated.");							}						}						catch (ClassNotFoundException e)						{							log(									"[Noelios Restlet Engine] - The ServerServlet couldn't find the target class. Please check that your classpath includes "											+ targetClassName, e);						}						catch (InstantiationException e)						{							log(									"[Noelios Restlet Engine] - The ServerServlet couldn't instantiate the target class. Please check this class has an empty constructor "											+ targetClassName, e);						}						catch (IllegalAccessException e)						{							log(									"[Noelios Restlet Engine] - The ServerServlet couldn't instantiate the target class. Please check that you have to proper access rights to "											+ targetClassName, e);						}						catch (Exception e)						{							log(									"[Noelios Restlet Engine] - The ServerServlet couldn't start the target Restlet.",									e);						}					}					else					{						log("[Noelios Restlet Engine] - The ServerServlet couldn't find the target class name. Please set the initialization parameter called "								+ NAME_TARGET_CLASS);					}				}				this.server = result;			}		}		return result;	}