<p>Binds ServletHolder to URL, this allows creation of REST APIs, etc</p>
<p>PLUGINS: Plugin servlets should have url's like /__jwwf/myplugin/stuff</p>

@param servlet Servlet holder
@param url     URL to bind servlet to
@return This JwwfServer
436497
public JwwfServer bindServlet(Servlet servlet, String url) {
		context.addServlet(new ServletHolder(servlet), url);
		return this;
	}
728169
public static Deployment of(final URL url) {
        final DeploymentContent deploymentContent = DeploymentContent.of(Assert.checkNotNullParam("url", url));
        return new Deployment(deploymentContent, null);
    }
562110
public static URL url(final String url) {
        if (url == null) {
            return null;
        }
        try {
            if (url.startsWith("classpath:")) {
                return new URL(null, url, new ClasspathURLStreamHandler());
            }
            return new URL(url);
        } catch (final MalformedURLException ex) {
            throw new IllegalArgumentException("Invalid URL: " + url, ex);
        }
    }
650438
public static void initServletRequest(ServletRequest servletRequest, TemplatedURLFormatter formatter)
    {
        assert servletRequest != null : "The ServletRequest cannot be null.";

        if (servletRequest == null) {
            throw new IllegalArgumentException("The ServletRequest cannot be null.");
        }

        servletRequest.setAttribute(TEMPLATED_URL_FORMATTER_ATTR, formatter);
    }
531739
public SC registerServlet(Class<? extends HttpServlet> servletClass, String urlPattern) {
        __throwIfInitialized();

        if (servletMap.containsKey(urlPattern) && servletMap.get(urlPattern) != servletClass)
            throw new IllegalArgumentException(String.format("URL pattern is already associated with another servlet class: %s => %s", urlPattern, servletMap.get(urlPattern)));

        servletMap.put(urlPattern, servletClass);
        return (SC) this;
    }
1233791
public void setUrl(String url) {
        this.url = url;
        
        if (clazz == null && url != null) {
            setClazz(ElementPlugin.class);
        }
    }
580516
public static String getUrl(final String url) throws Exception {
        return getUrl(new URL(url), null, null);
    }
184507
public static Repository repositoryFromUrl(String url) throws MalformedURLException {
        URL parsedUrl = new URL(url);

        StringBuffer id = new StringBuffer(parsedUrl.getHost());
        String path = parsedUrl.getPath();
        if (path.length() > 0) {
            path = path.replaceFirst("/", "").replaceAll("/", "-").replaceAll(":", "-");
            id.append("-");
            id.append(path);
        }

        if (parsedUrl.getPort() > -1) {
            id.append("-");
            id.append(parsedUrl.getPort());
        }

        Repository repo = new Repository();
        repo.setId( id.toString() );
        repo.setName( parsedUrl.getHost() );
        repo.setUrl( url );
        
        return repo;
    }
97539
public static RequestWrapper create(HttpServletRequest request) {

		HttpSession session = request.getSession();
		AppContextWrapper acw = new ServletContextWrapper(session.getServletContext());
		SessionWrapper sw = new HttpSessionWrapper(session);
		ContextHolder contextHolder = new ContextHolder(acw, sw);

		return new HttpServletRequestWrapper(request, contextHolder);
	}
153448
public ServletHolder newServletHolder(String name,
                                          String servletClass,
                                          String forcedPath)
    {
        if (_nameMap.containsKey(name))
            throw new IllegalArgumentException("Named servlet already exists: "+name);
        
        ServletHolder holder = new ServletHolder(this,name,servletClass,forcedPath);
        addServletHolder(holder);
        
        return holder;
    }
781741
@Override
  public void addHttpHandler(final HttpHandler httpHandler) {
    LOG.log(Level.INFO, "addHttpHandler: {0}", httpHandler.getUriSpecification());
    jettyHandler.addHandler(httpHandler);
  }
244503
public ApplicationResource addJsUrl(final String url) {
		if (Util.empty(url)) {
			throw new IllegalArgumentException("A URL must be provided.");
		}
		ApplicationResource res = new ApplicationResource(url);
		addJsResource(res);
		return res;
	}
429591
public static LinkedBindingBuilder<HttpClientObserver> bindNewObserver(final Binder binder, final Annotation annotation)
    {
        return Multibinder.newSetBinder(binder, HttpClientObserver.class, annotation).addBinding();
    }
593869
public static URLTemplatesFactory getURLTemplatesFactory( ServletContext servletContext )
    {
        assert servletContext != null : "The ServletContext cannot be null.";

        if ( servletContext == null )
        {
            throw new IllegalArgumentException( "The ServletContext cannot be null." );
        }

        return ( URLTemplatesFactory ) servletContext.getAttribute( URL_TEMPLATE_FACTORY_ATTR );
    }
552698
public static boolean isJarURL(URL url) {
        String protocol = url.getProtocol();
        return (URL_PROTOCOL_JAR.equals(protocol) || URL_PROTOCOL_ZIP.equals(protocol) ||
                URL_PROTOCOL_VFSZIP.equals(protocol) || URL_PROTOCOL_WSJAR.equals(protocol));
    }
170528
@SuppressWarnings("unchecked")
    private void loadServlets(Map<String, ServletConfiguration> servlets, Environment environment) throws ClassNotFoundException {
        if (servlets != null) {
            for (Map.Entry<String, ServletConfiguration> servletEntry : servlets.entrySet()) {
                ServletConfiguration servlet = servletEntry.getValue();

                // Create servlet holder
                ServletHolder servletHolder = new ServletHolder((Class<? extends Servlet>) Class.forName(servlet.getClazz()));

                // Set name of servlet
                servletHolder.setName(servletEntry.getKey());

                // Set params
                if (servlet.getParam() != null) {
                    for (Map.Entry<String, String> entry : servlet.getParam().entrySet()) {
                        servletHolder.setInitParameter(entry.getKey(), entry.getValue());
                    }
                }

                // Add servlet
                environment.getApplicationContext().addServlet(servletHolder, servlet.getUrl());
            }
        }
    }
469509
@Override
	public void registerServlet(final String alias, final Servlet servlet,
								@SuppressWarnings("rawtypes") final Dictionary initParams,
								final HttpContext httpContext) throws ServletException,
			NamespaceException {
		synchronized (lock) {
			this.registerServlet(alias, servlet, initParams, null, null,
					httpContext);
		}
	}