Class DefaultServiceLocator

  • All Implemented Interfaces:
    ServiceLocator

    public class DefaultServiceLocator
    extends java.lang.Object
    implements ServiceLocator
    Service locator for XMvn.

    WARNING: This class is part of internal implementation of XMvn and it is marked as public only for technical reasons. This class is not part of XMvn API. Client code using XMvn should not reference it directly.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map<java.lang.Class<?>,​java.lang.Class<?>> knownServices  
      private java.util.Map<java.lang.Class<?>,​java.lang.Object> runningServices  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> void addService​(java.lang.Class<T> role, java.lang.Class<? extends T> serviceProvider)  
      <T> T getService​(java.lang.Class<T> role)
      Load an instance of XMvn service.
      private java.lang.Object loadService​(java.lang.Class<?> role)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • knownServices

        private final java.util.Map<java.lang.Class<?>,​java.lang.Class<?>> knownServices
      • runningServices

        private final java.util.Map<java.lang.Class<?>,​java.lang.Object> runningServices
    • Constructor Detail

      • DefaultServiceLocator

        public DefaultServiceLocator()
    • Method Detail

      • addService

        public <T> void addService​(java.lang.Class<T> role,
                                   java.lang.Class<? extends T> serviceProvider)
      • loadService

        private java.lang.Object loadService​(java.lang.Class<?> role)
      • getService

        public <T> T getService​(java.lang.Class<T> role)
        Description copied from interface: ServiceLocator
        Load an instance of XMvn service.
        Specified by:
        getService in interface ServiceLocator
        Parameters:
        role - interface class identifying requested service
        Returns:
        instance of XMvn service, never null.