krish
krish

Reputation: 479

How to decide when to write OSGI services or servlet or components

am confused on the terminology and usage of the OSGI components, services, servlets, and how to decide which one to write while implementing the functionality requirements. Can anyone explain this one with an good example use case in AEM. Thanks in advance.

Upvotes: 3

Views: 2405

Answers (1)

Neil Bartlett
Neil Bartlett

Reputation: 23948

You should always write components. A component is the key unit of code in OSGi. Every class you write is either a component, or created/used by a component.

Some of those components will be services. A component that provides functionality that can be invoked from another module provides that functionality as a service. Not all components need to be services.

Servlets are a concept that exists outside of OSGi. HttpServlet is a class you extend if you want to implement server-side HTTP functionality. In OSGi you can provide HTTP functionality by writing a component that extends HttpServlet and provides a Servlet service.

Upvotes: 2

Related Questions