dimanche 22 février 2015

Embedded Jetty and set default attributes on the ServletContext



I would like to embed Jetty into a server app that I am writing. The Embbeded Jetty engine will be used to host various web apps that will directly integrate with the server applications internals. I would like to package the web apps into separate WAR files and write them so they are independent of the server. Sharing only the code that they use in common with the server.


How can a configure each ServletContext with the objects from the server without the Web App needing to know how to acquire them from the process Jetty is embedded in?


Example Outline of Server process life cycle:



  1. Boot and load config

  2. Setup internal objects that live for the entire process

  3. Create handles the web apps can use to access internal state

  4. Launch Embedded Jetty Engine

  5. Expose the handles that the web app has requested via some form of configuration. (how can i do this??)

  6. Handle incoming connections

  7. Wait for termination/shutdown single

  8. Clean up resources

  9. Exit


The idea is to deploy the web apps in Jetty. When the web apps are initialized the server will read some config for the web app and then expose the handles need to access the data they are interested in.


The problem is that the server is not a J2EE application so EJB's are out.




Aucun commentaire:

Enregistrer un commentaire