bgoodin / stripes-guice Goto Github PK
View Code? Open in Web Editor NEWGuice DI for the Stripes web framework
Home Page: http://bgoodin.github.com/stripes-guice
Guice DI for the Stripes web framework
Home Page: http://bgoodin.github.com/stripes-guice
Code is not very well covered ATM and is really test by using. :P
The following dependencies need to be upgraded.
[INFO] org.slf4j:slf4j-api .................................. 1.5.11 -> 1.7.5
[INFO] ch.qos.logback:logback-classic ...................... 0.9.19 -> 1.0.13
[INFO] com.google.guava:guava ............................... r08 -> 16.0-rc1
[INFO] com.intellij:annotations ............................... 9.0.4 -> 12.0
[INFO] junit:junit ............................................ 4.8.2 -> 4.11
[INFO] net.sourceforge.stripes:stripes ....................... 1.5.6 -> 1.5.7
I'd like to use this library in a commercial project I'm working on at the moment. The library does not appear to have a software licence associated with the source code. Can I use it in a commercial web application?
http://bgoodin.github.com/stripes-guice/howto.html contains the following non-well-formed-xml typo in the example web.xml config...
<parcom.silvermindsoftware.sg.config.GuiceRuntimeConfiguration
Unfortunately I find that the use of type-unsafe XML by the stripes-guice framework has re-introduced some of the same issues which I hoped Guice, (and especially guice-servlets) would take away from my development process.
The scenario I'm struggling with is that I'm using Guice as a dependency injection framework before the first servlet is loaded, and battling hard against the assumption built into stripes-guice that it will construct either the InjectionFactory or Injector, since in my case the Injector is already loaded and running.
Specifically I'm using Guice to configure various things about the Jetty server as it loads, (it is explicitly triggered, using org.eclipse.jetty.server.Server#start() )
Basically the requirement to use a (type-unsafe) string classname in the web.xml file to specify an InjectionFactory is problematic. If I could create the instance of the InjectionFactory, I can pass the pre-existing injector (which has already configured and launched the server) into stripes-guice, but if stripes-guice is going to insist on constructing the InjectionFactory itself from a no-arg constructor by introspecting a string in an XML file, I can't do this.
As a workaround I've created a singleton class which loads the global DI configuration (embedded in a single module) which allows me to access the same injector instance both when creating the Jetty server and for stripes-guice to use. However, this is already pretty hacky since it implies no preconfiguration of the Module (for example from command-line arguments) and makes the injector public.
Being able to actually construct the GuiceContextListener with an Injector constructor argument would be preferred. In the case of Guice-Servlets this then means there's no XML in the app at all.
WORKAROUND
public class StandaloneSingletonInjector implements GuiceInjectorFactory {
/** Create global static injector */
public static final Injector injector = Guice.createInjector(new StandaloneConfigModule());
public Injector getInjector(ServletContext aServletContext) {
return injector;
}
}
and mapped it into web.xml with...
<context-param>
<param-name>GuiceInjectorFactory.Class</param-name>
<param-value>com.cefn.makeastand.app.StandaloneSingletonInjector</param-value>
</context-param>
Guice 3.0-rc2 has been released (with some bugs already identified) and final should be out soon.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.