Coder Social home page Coder Social logo

loginject's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

theangrydev

loginject's Issues

Simplify the loginject API so that it no longer requires a class object for the Logger class

Instead of

loginject(Logger.class, LogManager::getLogger, currentClass())

one should be able to write

loginject(LogManager::getLogger, currentClass())

By calling the supplied method reference, it is possible to obtain a logger instance and to determine its class.
The only problem is that many logging frameworks use logger interfaces that are implemented by internal classes. loginject needs to determine interface candidates and provide bindings for all of them.

Non-static method cannot be referenced from a static context

Hi,
I wanted to use your guice extension it seems really good but sadly I can't instanciate it.

Module module = loginject(Logger.class, LogManager::getLogger, currentClass()).as(Module.class);

I have a compilation error :

Non-static method cannot be referenced from a static context

any idea ?

Thank you for your answer

Support correct injection for subclasses

static class TestClass
{
    @Inject
    Logger injectedLogger;
}

static class SubClass1 extends TestClass {}

static class SubClass2 extends TestClass {}

Currently, for the above scenario, a Logger for TestClass is injected into SubClass1 and SubClass2.
Instead, the subclasses should have their own loggers specific to the type.

This feature can definitely be implemented for Guice and HK2, but most likely not for Dagger (maybe via some trickery with MembersInjector, but Dagger's static nature makes these sort of injections difficult).

Enforce coding standards

Coding standards could be enforced in a number of different ways:

  • Checkstyle
  • Using Eclipse JDT compiler

Support Guice 3.0

Though Guice 3.0 is nowadays long out-of-date, a number of projects are still "stuck" on this old version of Guice (the most notable one probably being Xtext).
LogInject's Guice (4.x) implementation leverages the com.google.inject.spi.ProvisionListener, which is not present in Guice 3.0.
If Guice 3.0 has a similar mechanism, it would be nice to offer a loginject adapter for Guice 3.0 as well.

Spring Injection Service breaks resolution of other Spring dependencies

As it turns out, just returning an AutowireCandidateResolver that handles just loginject dependencies and returns null for all other dependencies does not quite work.
I recently tried to use loginject in the following manner on Spring 5.3.19:

class Configuration
{
  @Value("${host.url}")
  String hostUrl;

  @Inject
  Logger logger;
}

If I added loginject to the Spring configuration injection of the field annotated with @Value no longer worked.

Restructure tests

Having test projects that are specific to a particular logging system and test all DI framework adapters (e.g., loginject-test-log4j) is a problematic approach for a number of reasons. For example, Dagger and Dagger 2 use the same package name, so it is not possible to have both DI frameworks on the classpath at the same time. Also, in the DI-specific tests that are part of each DI adapter, there is a considerable amount of code duplication for setting up the test scenarios.

Ideas:

  • Have a common project as a test dependency that contains all test scenarios (without bindings)
  • Each DI adapter provides bindings for the test scenario
  • Maybe introduce an abstraction to the various instantiation APIs, so that shared tests can be run for each DI adapter, provided that there is a binding and an instantiation adapter implementation
  • The shared test scenario project could depend on all tested logging frameworks
  • Utilize JUnit parameterized testing to support Cartesian product of (all DI adapters) x (all logging frameworks)

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.