zsoltherpai / feather Goto Github PK
View Code? Open in Web Editor NEWLightweight dependency injection for Java and Android (JSR-330)
License: Other
Lightweight dependency injection for Java and Android (JSR-330)
License: Other
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! ๐
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
Hi, I have noticed, that You have done performance test against Dagger v1, but there is already v2 that claims, that is faster than v1. There are also other popular frameworks:
https://github.com/hnakagawa/proton
https://github.com/google/tiger
https://github.com/MichaelRocks/lightsaber
https://github.com/johncarl81/transfuse
I want to instantiate a Logger by passing a class to it and injecting the logger into another instance crated through other means but the documentation isn't clear on that.
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);
}
}
}
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.
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.
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>
It would be useful to have the exception printed in the logs or passed to the FeatherException:
here
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?
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.
Hi! Is possibile to have a Lazy injection???
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.