Module jcifs

Class SingletonContext

All Implemented Interfaces:
Runnable, CIFSContext

public class SingletonContext extends BaseContext implements CIFSContext
Global singleton context
Author:
mbechler
  • Method Details

    • init

      public static final void init(Properties props) throws CIFSException
      Initialize singleton context using custom properties This method can only be called once.
      Parameters:
      props - the properties to use for initialization
      Throws:
      CIFSException - if the singleton context is already initialized or there is an error during initialization
    • getInstance

      public static final SingletonContext getInstance()
      Get singleton context The singleton context will use system properties for configuration as well as values specified in a file specified through this org.codelibs.jcifs.smb.properties system property.
      Returns:
      a global context, initialized on first call
    • registerSmbURLHandler

      public static void registerSmbURLHandler()
      This static method registers the SMB URL protocol handler which is required to use SMB URLs with the java.net.URL class. If this method is not called before attempting to create an SMB URL with the URL class the following exception will occur:
       Exception MalformedURLException: unknown protocol: smb
           at java.net.URL.<init>(URL.java:480)
           at java.net.URL.<init>(URL.java:376)
           at java.net.URL.<init>(URL.java:330)
           at org.codelibs.jcifs.smb.impl.SmbFile.<init>(SmbFile.java:355)
           ...