I work with the OSGi-Apache karaf + Apache Felix technology stack. The project consists of spaghetti code. I am trying to refactor, correct, improve. But with OSGi faced for the first time.

What I want to do:

  1. Use singletons, as in @Autowired. Is there something similar in OSGi?

  2. use Repository or DAO pattern, as in the spring. Is there such a thing in OSGi?

I must say that I tried to associate with the spring but nothing happened. I tried following the example of Habra, but I started the example, but I could not embed it into the working project

If there is no singleton implementation, maybe just use a regular pattern and write your own?

I have a native sql, bare queries, and no ORMok.

  • here the practice is accepted: one specific question - one (and more) answer. Please ask the second question by using the “Ask a Question” button in the upper right corner of the page, and it is better to remove it from this question. as well as unnecessary information to understand the issue. - aleksandr barakin
  • If Java8, then Instead of \ @Autowired, we use the now standard \ @Inject. - Sergey Mitrofanov

0