2.3.2.1. Java Class

Imagine that you are working for a publishing company called "La Verdad" that is going to use eXo platform. Your boss asks you be able to calculate the number of sentences of an article.

You remember in eXo product everything is a service so you decide to create a simple class. In the future, you want to be able to plug different implementations of your service, so that you should define an interface that defines your service.

package com.laverdad.services; 

public interface ArticleStatsService {
   public abstract int calcSentences(String article);
}

A very simple implementation:

public class ArticleStatsServiceImpl implements ArticleStatsService {

   public int calcSentences(String article) {
      throw new RuntimeException("Not implemented"); 
   }
}

That's it! You see there are no special prerequisites for a service.

You should already have prepared your working environment, where you have a base folder (let's call it our service base folder). If you wish to try out this example create this class in the com/laverdad/services/ArticleStatsService subfolder.

Copyright ©2012. All rights reserved. eXo Platform SAS