java - Jetty: load a context from another jar -


I have created an application that loads multiple plugins on SPI. Each plugin has the framework plugin interface To implement.

  Public Interface Framework plugin {... ContextHandler getWebContent (); String getPluginID (); ...}  

An example implementation will be

  ... ContextHandler getWebContent () {WebAppContext wac = new WebAppContext (); Wac.setBaseResource (New Resource Calculus (new string [] {"./src/main/webapp"})); Return wac; } ...  

The main-project runs a single jetty instance, which should be used by all the plugin providing web-based services. A plugin should be able to configure the personal environment in its own context, except for the original URL, which is managed by the main project.

  ... for (FrameworkPlugin p: PLUGINS) {ContextHandler h = p.getWebContent (); H.setContextPath (. "/ Plugin /" + p.getPluginID () toString ()); Collection.addHandler (h); } JT Instance. SetHandler (collection); ...  

So in principle, plugins should be / plugin / & lt; Id & gt; Should be accessible under . Unfortunately Jetty throws an illegal arcagram exception, because the set of plugins sets ./ src / main / webapp as the resource base, which is not present in the main project.

Then a context handles via the plugin interface?

Planning WARs is not an option, because the loading mechanism can not be changed. Using the plugin interface will do everything.

If this is not a war based project, then use the WebAppContext Quit completely, and use only the handler system in Jetty.

WebAppContext is a special handler which means to use it with full full and full web application, which happens after the servlet spec. In previous versions of Black Art (Per Element Descriptor Order Lookup and Override) for compulsive behavior (WebApp Classloader Isolation) mandatory behavior is mandatory from worldly space.

The system may have jettie 1..n handler , in a tree (via medium), sometimes, with, and all the same as the server on the classloader Exists in (if you want it). Regex, or feel free to map the URL with your own implementation, completely depend on you what you want to do with it. You have to make several pre-made handlers and base handlers.

You will be processing with async, with standard HttpServletRequest and HttpServletResponse and I / O that they provide. But you will also have access to raw internal objects which provides more features at HttpServletRequest .

Incidentally, many servlet-based applications support plugin. Most complete it by using the circular services of the circuits, or using filter or manipulation.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -