Questions tagged [jsr330]

JSR 330: Dependency Injection for Java

Specification: JSR 330

62 questions
64
votes
11 answers

Practical advice on using Jersey and Guice for RESTful service

From what I can find online, the state of the art for Guice + Jersey integration has stagnated since 2008 when it appears both teams reached an impasse. The crux of the issue is that JAX-RS annotations perform field and method injection and this…
toolbear
  • 6,478
  • 4
  • 31
  • 31
31
votes
1 answer

How to make Jersey work with Dagger dependency injection?

Jersey normally uses HK2 dependency injection, but I would like to use Jersey with Dagger 2. Both Dagger and HK2 implement JSR 330, which I have taken as evidence that this should be possible without too much effort. I found ways to make Jersey work…
Rinke
  • 5,249
  • 4
  • 32
  • 50
27
votes
3 answers

What are the best debugging tricks with Weld/CDI?

One of the beauties with Java EE 6 is the new dependency injection framework - CDI with the Weld reference implementation - which has prompted us to start migrating internally to JSR-330 in an implementation agnostic manner, with the explicit target…
Thorbjørn Ravn Andersen
  • 68,906
  • 28
  • 171
  • 323
17
votes
2 answers

@Named annotation in Spring MVC

Per Spring 3 document, The IoC container, the @Named annotation is a standard equivalent to the @Component annotation. Since @Repository, @Service, and @Controller are all @Component, I tried to used @Named for all of them in my Spring MVC…
Dino Tw
  • 2,791
  • 4
  • 27
  • 45
16
votes
5 answers

How to inject String constants easily with Weld?

We have a situation where we provide an external configuration in form of a Map to our running programs. I have found that JSR-330 Dependency Injection gives a much cleaner way to use that configuration map in the code instead of passing the map…
Thorbjørn Ravn Andersen
  • 68,906
  • 28
  • 171
  • 323
10
votes
1 answer

How do I configure JSR-330 @Provider and @Inject @Named("foo") String **programmatically** in Spring?

We have decided to use Dependency Injection with JSR-330 annotations for our future modularization efforts, and have been very pleased with the first deliverable based on Guice 2 SVN. Now we need to ensure and document through unit tests that the…
Thorbjørn Ravn Andersen
  • 68,906
  • 28
  • 171
  • 323
6
votes
1 answer

Guice and JSR-330

JSR-330 specifies certain naming conventions in terms of packages, for example: javax.inject.Inject javax.inject.Scope Guice is the Reference Implementation of JSR-330. However, when using it, you notice that it doesn't follow the spec. For…
6
votes
1 answer

Field injection with @Inject in Spring

I've got some strange behavior in working of @Inject in Spring. This example works well: @Controller @RequestMapping("/") public class HomeController { @Autowired private SomeBean someBean; @RequestMapping(method = GET) public…
Vitalii Vitrenko
  • 6,880
  • 2
  • 31
  • 52
5
votes
1 answer

Java: How to check if a method is overridden, using reflection

I need to do some processing to determine the dependencies of JSR-330 annotated classes, using reflection. I am fully aware of all JSR-330 compliant IoC containers, like Spring, Guice or PicoContainer. However, what I need is not to resolve and…
Eleaar
  • 218
  • 1
  • 3
  • 9
5
votes
1 answer

Is there a JSR-330 equivalent of Spring's @Value annotation?

I'm trying to use JSR-330 annotations with Spring 3. Is there a JSR-330 equivalent of Spring's @Value annotation for inserting property values? e.g. can I use @Provider in a way that will instruct Spring to inject a property value?
joelittlejohn
  • 10,921
  • 2
  • 36
  • 52
5
votes
1 answer

Is it possible to replace Spring @Scope("request") with JSR-330 @Scope variant?

Or, can I bound a custom implementation of org.springframework.beans.factory.config.Scope interface with a specific @Scope-annotated annotation? For example, I have customized a new scope type: @javax.inject.Scope @Retention(RUNTIME) @interface…
Xiè Jìléi
  • 12,317
  • 15
  • 72
  • 100
4
votes
1 answer

JSR Bean Validation and multiple groups, AND vs OR

Has anyone come across the need to have a constraint that is only applied when all group clauses are satisfied. In other words, for @NotNull(groups= {Group1.class, Group2.class}) private Integer value; The not null constraint is applied when…
Ashkan Aryan
  • 3,304
  • 3
  • 25
  • 43
4
votes
1 answer

A question about qualifier in Spring DI

Normally, a qualified component will be injected to annotated fields with the same qualifier: @Component class Apple1 implements IApple {} @Component @Black class Apple2 implements IApple {} class User { @Inject IApple apple; …
Xiè Jìléi
  • 12,317
  • 15
  • 72
  • 100
4
votes
1 answer

Does spring-context support JSR-330 Qualifier on bean instances?

Spring has its own Qualifier annotation, I think it's equivalent to the javax.inject.Named annotation, which in turn is a concrete qualifier in JSR-330. So, I'm wondering which version of Spring, if any, supports Qualifier? Here is my example…
Xiè Jìléi
  • 12,317
  • 15
  • 72
  • 100
4
votes
2 answers

JSR 330 and Guice interoperability

Does anybody have experience with JSR 330 vs Guice? From what I gather Guice is not an implementation of JSR 330 but if it is anything like Hibernate and JPA the implementation supports a bunch of additional functionality no in the API. Since I am…
benstpierre
  • 30,487
  • 46
  • 163
  • 272
1
2 3 4 5