Interface ApplicationService

  • All Known Implementing Classes:
    AbstractCalendarService, UserCalendarService

    public interface ApplicationService
    A service providing the transverse operations related to a given Silverpeas application. A Silverpeas application is a component of the Silverpeas portal that provides the features to manage in a given way some types of user contributions and contents. Such an application can be either a personal tool or a shareable component.

    The service gathers the business functionalities the application offers to users or to other components in Silverpeas and it gives access to both the application settings and the application specific l10n translations. In the approach used in Silverpeas, this service should not be accessed directly by clients but through the business entities that are managed by the instances of the application (in the DDD (Domain Driven Development) way).

    Some transverse services in Silverpeas Core use this interface to discover and to access the business services of the applications in order to perform some of their centralized tasks. For example, the notification of user about new comments is based on this interface. So, in order to profit of these centralized and transverse functionalities, an application has to provide a specific business service that implements this interface. In order to facilitate the business service discovery, it is recommended to follow the convention in which the service is annotated by the javax.inject.Named annotation valued with the name of the application (starting in lower case) followed by the term "Service". For example, a service of a Foo application should be annotated by @Named("fooService").

    See Also:
    ApplicationServiceProvider
    • Method Detail

      • getInstance

        static ApplicationService getInstance​(String appId)
                                       throws org.silverpeas.kernel.exception.NotFoundException
        Gets the service of the application from which the specified instance is spawned.

        This method thrown an exception if no service is found for the specified component instance. To have a more control on how to handle such a situation, use instead the ApplicationServiceProvider.getApplicationServiceById(String) method that returns an Optional value.

        Parameters:
        appId - the unique identifier of an application instance.
        Returns:
        an ApplicationService object that can serv the calls for the specified application instance.
        Throws:
        org.silverpeas.kernel.exception.NotFoundException - if the application doesn't implement any transverse service.
      • getContributionById

        <T extends ContributionOptional<T> getContributionById​(ContributionIdentifier contributionId)
        Gets the contribution handled by an instance of the component with the specified unique identifier. The type of the contribution to get is provided by the given identifier.
        Type Parameters:
        T - The concrete type of the contribution to get. An application can manage more than one types of contributions.
        Parameters:
        contributionId - the unique identifier of the contribution to get.
        Returns:
        a contribution in Silverpeas.
      • getComponentSettings

        org.silverpeas.kernel.bundle.SettingBundle getComponentSettings()
        Gets the settings of this Silverpeas component.
        Returns:
        a SettingBundle instance giving access the settings.
      • getComponentMessages

        org.silverpeas.kernel.bundle.LocalizationBundle getComponentMessages​(String language)
        Gets the localized messages defined in this Silverpeas component.
        Parameters:
        language - the language in which the messages has to be localized. If empty or null, then the bundle with default messages is returned.
        Returns:
        a LocalizationBundle instance giving access the localized messages.
      • isRelatedTo

        boolean isRelatedTo​(String instanceId)
        Is this service related to the specified component instance. The service is related to the specified instance if it is a service defined by the application from which the instance was spawned.
        Parameters:
        instanceId - the unique instance identifier of the component.
        Returns:
        true if the instance is spawn from the application to which the service is related. False otherwise.