GithubHelp home page GithubHelp logo

feather's People

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

feather's Issues

Would Feather work with Kotlin classes?

Hi. Hope all is well.

I'm thinking of using Feather to implement DI under a test project using ktor. I'm just wondering if there might be any obvious pitfalls to watch out for. For example, in Spring Boot, most @Component classes need to be declared as open if they are written in Kotlin in order for Spring to be able to create proxies for them.

Thanks for the framework! ๐Ÿ‘

Bug: inject or instantiate Feather class does not work

Hello feather team,

your DI framework fits very well for my use case. But unfortunately there is a bug which makes it unusable for me.

Could you please fix this issue?! Thank you.

import org.codejargon.feather.Feather;
import org.codejargon.feather.Provides;
import org.junit.Test;

import static org.codejargon.feather.Feather.with;
import static org.junit.Assert.assertEquals;

public class FeatherTest {

    @Test
    public void injectFeatherShouldWork() {
        Feather feather = with(new Object() {
            @Provides
            public String createString(Feather feather) {
                return feather.toString();
            }
        });

        assertEquals(feather.toString(), feather.instance(String.class));
    }

    @Test
    public void instantiateFeatherShouldWork() {
        Feather feather = with();
        assertEquals(feather, feather.instance(Feather.class));
    }

}

Best regards,
Stefan

Feather instance is not properly provided to modules

The following unit test fails to excute due to a "java.lang.ClassCastException: org.codejargon.feather.Feather$1 cannot be cast to org.codejargon.feather.Feather
"

I think line 32 of Feather.java should be "return Feather.this;" instead of "return this;"

Content of InjectedFeatherTest.java

package org.codejargon.feather;

import static org.junit.Assert.*;

import javax.inject.Inject;
import javax.inject.Provider;

import org.junit.Test;

public class InjectedFeatherTest {

@Test
public void featherProviderInjection() {
    Feather feather = Feather.with();

    InjectedFeatherProvider injected = feather
            .instance(InjectedFeatherProvider.class);

    assertEquals(feather, injected.feather());
}

@Test
public void featherInjection() {
    Feather feather = Feather.with();

    InjectedFeather injected = feather.instance(InjectedFeather.class);

    assertEquals(feather, injected.feather());
}

@Test
public void featherInjectionThroughModule() {
    Feather feather = Feather.with(new Module());

    InjectedFeather injected1 = feather.instance(InjectedFeather.class);

    assertEquals(feather, injected1.feather());

    InjectedFeatherProvider injected2 = feather
            .instance(InjectedFeatherProvider.class);

    assertEquals(feather, injected2.feather());
}

// ------------------------------------------------------------------

public static class InjectedFeatherProvider {
    private final Feather injected;

    @Inject
    public InjectedFeatherProvider(Provider<Feather> f) {
        injected = f.get();
    }

    Feather feather() {
        return injected;
    }
}

public static class InjectedFeather {
    private final Feather injected;

    @Inject
    public InjectedFeather(Feather f) {
        injected = f;
    }

    Feather feather() {
        return injected;
    }
}

public static class Module {
    @Provides
    public InjectedFeather providesInjectedFeather(Feather f) {
        return new InjectedFeather(f);
    }

    @Provides
    public InjectedFeatherProvider providesInjectedFeatherProvider(
            Provider<Feather> f) {
        return new InjectedFeatherProvider(f);
    }

}

}

Use named Provides if no unnamed exists

Hi. I want to use feather in a project that will use plugins. This means I will have interfaces the user can implement and inject into the system. However there are also defaults provided for the essential parts.
Now my problem is, that I want a named provider to be injected into an unnamed inject - WHEN there is no unnamed and no other named provides available (ie it's the only one with the right type).

I'm trying to achieve that you don't have to use "Named" annotations on parameters/fields when "overriding" the default provider. If you provide your own, unnamed provider, it will be chosen instead of the named one (this is already working). If you don't provide an unnamed one, the named default one should be used as fallback.

Any chance you will do this? Otherwise i need to hack it in myself.

@PostConstruct

Just a small question: Is it true, that this part of JSR330 is simply not implemented yet?
I just started to add the web integration part of dinistiq and the modules stuff from the Google Guice integration of a web framework of mine, since you are using a similar modules approach, to obtain all the functionality I would need from a small DI solution.

Besides that missing bit, the JSR330 feather looks quite promising to get the whole thing up and running.

Compile at JDK 1.6

Hello, looking to use feather in a legacy project of mine and unfortunately we won't be upgrading to JDK 1.8 until later this year and am currently stuck on JDK 1.6 for the time being.

I noticed in the project you are compiling at JDK 1.7 and when I cloned the project and built it locally it seems to work fine for JDK 1.6.

Is it possible to change these in the root pom:
<maven.compiler.source>1.6</maven.compiler.source> <maven.compiler.target>1.6</maven.compiler.target>

Recursive instantiation?

Hi,

If class C is using @Inject B b; and class B is using @Inject A a ...
C c = feather.instance(C.class);
feather.injectFields(c);

If I don't call injectFields I have an instance of class C but 'c.b' is null.
If I call injectFields then I have c.b is not null but c.b.a is null.

Does that make sense? I don't wanna pass the feather instance through
whole hierarchy or using it as singleton and the calling injectFields on
each node in the hierarchy.

Maybe I'm doing something wrong?
Any comments on this?

Exception information is lost when fields cannot be injected

Specifically, in line 87 of Feather.java:

catch (Exception e) {
  throw new FeatherException(String.format("Can't inject field %s in %s", field.getName(), target.getClass().getName()));
}

The caught exception is discarded. It would be preferable to set the caught exception as the cause by passing it in as the second argument to FeatherException.

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.