Class DefaultClientProfile


  • public class DefaultClientProfile
    extends java.lang.Object
    Factory which supplies the default ClientProfile for use by SAMP clients. By using this class to obtain ClientProfile instances, applications can be used with non-standard profiles supplied at runtime without requiring any code changes.

    The profile returned by this class depends on the SAMP_HUB environment variable (HUBLOC_ENV). If it consists of the prefix "jsamp-class:" (HUBLOC_CLASS_PREFIX) followed by the classname of a class which implements ClientProfile and has a no-arg constructor, then an instance of the named class is used. Otherwise, an instance of StandardClientProfile or WebClientProfile is returned.

    Since:
    4 Aug 2009
    Author:
    Mark Taylor
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String HUBLOC_CLASS_PREFIX
      Prefix for SAMP_HUB env var indicating a supplied ClientProfile implementation ("jsamp-class:").
      static java.lang.String HUBLOC_ENV
      Environment variable used for hub location ("SAMP_HUB").
      private static java.util.logging.Logger logger_  
      private static ClientProfile profile_  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private DefaultClientProfile()
      No-arg constructor prevents instantiation.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static ClientProfile getProfile()
      Returns a ClientProfile instance suitable for general purpose use.
      static void setProfile​(ClientProfile profile)
      Sets the profile object which will be returned by getProfile().
      • Methods inherited from class java.lang.Object

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

      • logger_

        private static final java.util.logging.Logger logger_
      • HUBLOC_ENV

        public static final java.lang.String HUBLOC_ENV
        Environment variable used for hub location ("SAMP_HUB").
        See Also:
        Constant Field Values
      • HUBLOC_CLASS_PREFIX

        public static final java.lang.String HUBLOC_CLASS_PREFIX
        Prefix for SAMP_HUB env var indicating a supplied ClientProfile implementation ("jsamp-class:").
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultClientProfile

        private DefaultClientProfile()
        No-arg constructor prevents instantiation.
    • Method Detail

      • getProfile

        public static ClientProfile getProfile()
        Returns a ClientProfile instance suitable for general purpose use. By default this is currently the Standard Profile (StandardClientProfile.getInstance()), but the instance may be modified programatically or by use of the SAMP_HUB environment variable.

        If no instance has been set, the SAMP_HUB environment variable is examined. If it consists of the prefix "jsamp-class:" (HUBLOC_CLASS_PREFIX) followed by the classname of a class which implements ClientProfile and has a no-arg constructor, then an instance of the named class is used. Otherwise, an instance of StandardClientProfile is returned.

        The instance is obtained lazily.

        Returns:
        client profile instance
      • setProfile

        public static void setProfile​(ClientProfile profile)
        Sets the profile object which will be returned by getProfile().
        Parameters:
        profile - default profile instance