Skip to content

Concepts

NiteshKant edited this page Mar 5, 2013 · 1 revision

Karyon revolves around two basic entities, viz.,

Component

A component is a discoverable class visible to karyon which is annotated with @Component. A component typically is a standalone entity which is required for the application to work but is not a direct dependency of the application. An example inside karyon itself is Karyon admin container which is totally unrelated to the application but is required to be initialized before the start of the application.

Application

An application is a class inside your service that gets initialized at karyon's startup. Karyon initializes all components before it initializes the application. There can only be one application class inside a service. If you wish to make any class as an application, annotate it with @Application

How do these get initialized?

Karyon initializes the above classes using Governator and hence honors the lifecycle phases provided by governator.

How are they different than @AutoBindSingleton?

The above concepts is addressing a usecase where static initializations are required before the application proceeds with the actual work. The other way of doing this will be to define direct dependencies (via @Inject) in the application class. This makes the application hold references which it does not need directly. Inside netflix we need such initialization as part of initializing the netflix stack.