Code Monkey home page Code Monkey logo

stripes-guice's People

Contributors

bgoodin avatar h3adache avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

stripes-guice's Issues

Upgrade dependencies

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

Software licencing

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?

Trouble with InjectionFactory configuration

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>

Upgrade to guice 3

Guice 3.0-rc2 has been released (with some bugs already identified) and final should be out soon.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.