Code Monkey home page Code Monkey logo

glassfish-hk2's Introduction

hk2

A light-weight and dynamic dependency injection framework

glassfish-hk2's People

Contributors

ankathur avatar arjantijms avatar bushwakko avatar cousjava avatar jgauravgupta avatar jwells131313 avatar mbooth101 avatar pdudits avatar romain-grecourt avatar smillidge avatar svendiedrichsen avatar udalov avatar

Watchers

 avatar

glassfish-hk2's Issues

Support Injection of ServiceHandles

Users should be able to @Inject ServiceHandles directly. This is useful if you are injecting PerLookup objects that don't need to survive the object's constructor.

@Inject
public FooService(ServiceHandle<Calculator> calculator) {
   try (calculator) {
     this.result = calculator.getService().doExpensiveCalculation();
   }
}

Here the Calculator service is a PerLookup service that is no longer needed at all once the FooService has used it to do an expensive calculation.

Even if the Calculator service later becomes a Singleton this code still makes sense as FooService can trigger the immediate destruction of a service that's no longer needed.

ServiceHandle should implement AutoCloseable

It would be nice if ServiceHandle implemented AutoCloseable and could be used in try-with-resources, eg:

try (ServiceHandle<Foo> foo = serviceLocator.getServiceHandle(Foo.class) {
 ...
}

On workaround would be to create a wrapper object, called ServiceInstance.

try (ServiceInstance<Foo> foo = ServiceInstance.of(serviceLocator.getServiceHandle(Foo.class)) {
 ...
}

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.