Writing blueprint xml is quite verbose and large blueprint xmls are difficult to keep in sync with code changes and especially refactorings. So you would like to do most declarations using annoations and ideally these annotations should be standardized.


The blueprint-maven-plugin allows to configure blueprint using annotations. It scans one or more paths for annotated classes and creates a blueprint.xml in target/generated-resources. So at runtime the bundle behaves like a normal blueprint bundle. The generated blueprint can also be used together with a manually created blueprint file. So for example property placeholder configurations or cxf services can be created in xml while most of the beans are automatically generated.




javax.inject (JSR 330)

  • @Inject Inject a bean by type and optionally further qualifiers
  • @Singleton Mark a class as being a bean
  • @Named("Myname") Names a @Singleton and qualifies an @Inject to limit it to matches with the same bean id

javax.annotation (JSR 250)

  • @PostConstruct Marks a method to be called after DI is finished (init-method)
  • @PreDestroy Marks a method to be called before the bean is destroyed (destroy-method)


  • @OsgiServiceProvider(classes={TaskService.class}) Publishes a bean as an OSGi service with the given interfaces
  • @OsgiService creates a reference to an OSGi service. On optional filter is also possible
  • @Properties Defines service properties for OSGiServiceProvider
  • @Property Defines a service property


  • @PersistenceContext(unitName="tasklist") inject a managed EntityManager for the given persistence unit into a field
  • @PersistenceUnit(unitName="tasklist") inject an unmanaged EntityManagerFactory for the given persistence unit into a field


  • @Transactional mark the class as transactional. Individual methods are not yet supported

Dependencies for annotations



For a complete example see tasklist-blueprint-cdi on github.