Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

Service vs. POJO

Avatar

Level 6

I have to retrieve the value from a component dialog with some business rules. Since the logic is quite complicated, I write a java code. The question is should I make it as a service or just pure POJO? what's the rules and/or criteria to determine it.

 

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Level 9

If your code can be re-used somewhere else. Then, create service otherwise POJO would be fine.

---

Jitendra

View solution in original post

2 Replies

Avatar

Correct answer by
Level 9

If your code can be re-used somewhere else. Then, create service otherwise POJO would be fine.

---

Jitendra

Avatar

Level 10

I agree with Jitendra - if you do not want to have the benefits of a service (ie - dependency injection) - then you can write your Java code as a POJO, wrap it into a JAR and then deploy to AEM within an OSGi bundle without using @Service and @Component.