context.setInitParameter(e.getKey(), e.getValue());
@Nonnull private static WebappContext _createContext (final URI u, final Class <? extends Servlet> aServletClass, final Servlet aServlet, final Map <String, String> aInitParams, final Map <String, String> aContextInitParams) { String path = u.getPath (); if (path == null) throw new IllegalArgumentException ("The URI path, of the URI " + u + ", must be non-null"); if (path.isEmpty ()) throw new IllegalArgumentException ("The URI path, of the URI " + u + ", must be present"); if (path.charAt (0) != '/') throw new IllegalArgumentException ("The URI path, of the URI " + u + ". must start with a '/'"); path = String.format ("/%s", UriComponent.decodePath (u.getPath (), true).get (1).toString ()); final WebappContext aContext = new WebappContext ("GrizzlyContext", path); ServletRegistration aRegistration; if (aServletClass != null) aRegistration = aContext.addServlet (aServletClass.getName (), aServletClass); else aRegistration = aContext.addServlet (aServlet.getClass ().getName (), aServlet); aRegistration.addMapping ("/*"); if (aContextInitParams != null) for (final Map.Entry <String, String> e : aContextInitParams.entrySet ()) aContext.setInitParameter (e.getKey (), e.getValue ()); if (aInitParams != null) aRegistration.setInitParameters (aInitParams); return aContext; }
@Nonnull private static WebappContext _createContext (final URI u, final Class <? extends Servlet> aServletClass, final Servlet aServlet, final Map <String, String> aInitParams, final Map <String, String> aContextInitParams) { String path = u.getPath (); if (path == null) throw new IllegalArgumentException ("The URI path, of the URI " + u + ", must be non-null"); if (path.isEmpty ()) throw new IllegalArgumentException ("The URI path, of the URI " + u + ", must be present"); if (path.charAt (0) != '/') throw new IllegalArgumentException ("The URI path, of the URI " + u + ". must start with a '/'"); path = String.format ("/%s", UriComponent.decodePath (u.getPath (), true).get (1).toString ()); final WebappContext aContext = new WebappContext ("GrizzlyContext", path); ServletRegistration aRegistration; if (aServletClass != null) aRegistration = aContext.addServlet (aServletClass.getName (), aServletClass); else aRegistration = aContext.addServlet (aServlet.getClass ().getName (), aServlet); aRegistration.addMapping ("/*"); if (aContextInitParams != null) for (final Map.Entry <String, String> e : aContextInitParams.entrySet ()) aContext.setInitParameter (e.getKey (), e.getValue ()); if (aInitParams != null) aRegistration.setInitParameters (aInitParams); return aContext; }