Giter Club home page Giter Club logo

guice's Introduction

Guice

Overview

Put simply, Guice alleviates the need for factories and the use of new in your Java code. Think of Guice's @Inject as the new new. You will still need to write factories in some cases, but your code will not depend directly on them. Your code will be easier to change, unit test and reuse in other contexts.

Guice embraces Java's type safe nature. You might think of Guice as filling in missing features for core Java. Ideally, the language itself would provide most of the same features, but until such a language comes along, we have Guice.

Guice helps you design better APIs, and the Guice API itself sets a good example. Guice is not a kitchen sink. We justify each feature with at least three use cases. When in doubt, we leave it out. We build general functionality which enables you to extend Guice rather than adding every feature to the core framework.

Guice aims to make development and debugging easier and faster, not harder and slower. In that vein, Guice steers clear of surprises and magic. You should be able to understand code with or without tools, though tools can make things even easier. When errors do occur, Guice goes the extra mile to generate helpful messages.

For an introduction to Guice and a comparison to new and the factory pattern, see Bob Lee's video presentation. After that, check out our user's guide.

We've been running Guice in mission critical applications since 2006, and now you can, too. We hope you enjoy it as much as we do.

Installation Instructions

Guice Core (Maven)

<dependency>
  <groupId>com.google.inject</groupId>
  <artifactId>guice</artifactId>
  <!-- {version} can be 6.0.0, 7.0.0, etc. -->
  <version>{version}</version>
</dependency>

Guice Extension (Maven)

<dependency>
  <groupId>com.google.inject.extensions</groupId>
  <!-- {extension-name} can be one of: assistedinject, dagger-adapter,
       grapher, jmx, jndi, persist, spring, testlib or throwingproviders -->
  <artifactId>guice-{extension-name}</artifactId>
  <!-- {version} must match the guice core version. -->
  <version>{version}</version>
</dependency>

See Maven Central for more details, including snippets for other build systems such as Gradle, Ivy, sbt, and more.


jolt award

guice's People

Contributors

ad-fu avatar cgdecker avatar cgruber avatar cpovirk avatar cushon avatar dhanji avatar dimo414 avatar dorireuv avatar hanneswell avatar iflan avatar java-team-github-bot avatar jccarrillo avatar jiangji avatar kashike avatar kluever avatar lukesandberg avatar magnayn avatar markmarch avatar mcculls avatar natmack avatar netdpb avatar nick-someone avatar paulcreates avatar ronshapiro avatar sameb avatar sumitbhagwani avatar tavianator avatar timofeyb avatar tlantz avatar vlsi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

guice's Issues

binder.install() should possibly be safe from RuntimeExceptions

From kevinb9n on February 27, 2007 02:59:57

if anything is thrown out of Module.configure(), the binder might want to
catch that and record it with addError() instead of bombing out completely.
 However, this may not be so great either as there could be a ripple effect
of other errors that happen only because of the missing bindings from this
module.

Original issue: http://code.google.com/p/google-guice/issues/detail?id=33

Spring integration

From crazyboblee on February 28, 2007 15:51:22

Let's make Spring integration trival, so it's easy to share or migrate.
Here's how it will work:

The user must provide a binding to Spring's BeanFactory.

Then, we'll have the following class:

class SpringIntegration {

  static <T> Provider<T> fromSpring(Class<T> type, String name) {
    ...
  }
}

The returned provider will look up the Bean with the given name in the
bound BeanFactory.

Original issue: http://code.google.com/p/google-guice/issues/detail?id=47

Multibindings

From kevinb9n on February 27, 2007 03:21:14

It would be good if certain keys could be multivalued; where multiple
modules could append one or more bindings each, and these could all be
injected as a Collection<Foo> or something.  This would be useful for some
things Laura is doing, and for replacing excalibur, and for
AdWordsPaymentOptions, and . . .

I'm going ahead and calling this priority "high" for now.

Original issue: http://code.google.com/p/google-guice/issues/detail?id=37

Configuration scope

From kevinb9n on February 28, 2007 15:51:25

This would be a scope that anything that reads from modifiable
configuration sources (database, xml/props file, etc.) could live at.  Then
we'd provide a means by which an administrator can send a reload message to
a running server (JMX, perhaps?).  When the message is received, the
current configuration scope would become a "lame duck" while the objects
for the next configuration scope are all reconstructred; when
reconstruction is finished we'd invalidate the old configuration scope and
start serving requests out of the new.

I wonder if we'd have to be careful that each single request scope uses
only one configuration instance and never a mixture of old and new.

This is the rough idea though; comments?

Original issue: http://code.google.com/p/google-guice/issues/detail?id=48

Possibly find a way to separate out the advanced Binder methods

From kevinb9n on February 28, 2007 15:40:58

I'm a little concerned about Binder, in that 90% of what newbies want to
use it for is simply binding types to classes, instances and providers.
But when they go to look at it (Binder) they're confronted with all this
stuff about interceptors and binding their own custom scopes and installing
other modules and more.  Is there anything we can do about this?

Bob and I already thought about this and came up with nothing good but I
thought it wouldn't hurt to put it here in case someone from the group at
large will give us some ideas.

Original issue: http://code.google.com/p/google-guice/issues/detail?id=46

Guice should never ever inject a null value

From kevinb9n on February 27, 2007 14:58:17

Right now you can have a custom provider return null and I think guice will
inject the null value.  We should add sanity checking to make sure guice
never injects null.  This way people do not need to check for it in their
constructors etc., which in turn allows them to use null when they want
to in their unit tests (which is quite a helpful ability to have).

Original issue: http://code.google.com/p/google-guice/issues/detail?id=41

Hide implementation details from the public API using OSGi

From limpbizkit on February 14, 2007 19:06:44

Guice makes classes like util/Objects available in its public API, even
though they are implementation details.

If you think it's worthwhile, the .jar for Guice could hide these classes
from OSGi-compliant tools like Eclipse. Here's a sample Ant task that
creates the necessary meta information for the .jar file:

  <taskdef name="osgiBundleInfo"
classname="org.knopflerfish.ant.taskdefs.bundle.BundleInfoTask"
classpath="tools/OSGiBundleInfo.jar"/>
  <osgiBundleInfo exports="packagelist">
     <fileset dir="${basedir}">
        <include name="/source//.java"/>
        <exclude name="/util//
.java"/>
     </fileset>
  </osgiBundleInfo>

Original issue: http://code.google.com/p/google-guice/issues/detail?id=17

Consider removing Injector.getProvider()

From kevinb9n on February 27, 2007 03:35:57

This may be a long shot.  Just floating it out there.

Theoretically it's possible no one would ever need
Container.getProvider() because they can always write a nested class with
the @Injections they need and use Container.injectMembers().  The appeal of
this is that they're then specifying the binding they want in the "usual"
way, not with some crappy "Key.get(Foo.class, new
AnnotationImpl(god_knows_what?))" syntax.  There's less for people to learn
and stuff.

...

Original issue: http://code.google.com/p/google-guice/issues/detail?id=39

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.