/// <summary> /// Set callback for log max size exceeded. /// Applies only to USER policy. /// </summary> /// <param name="callback"> /// The callback object to invoke whenever the log size is exceeded. /// </param> public static void setLogSizeCb(MamaLogFileCallback callback) { // Dispose the old callback wrapper if (m_logSizeCbWrapper != null) { ((IDisposable)m_logSizeCbWrapper).Dispose(); m_logSizeCbWrapper = null; } // Null is allowed to clear the callback if (callback == null) { // Call the native function with null MamaWrapper.CheckResultCode(NativeMethods.mama_setLogSizeCb(null)); } else { // Create a new callback wrapper m_logSizeCbWrapper = new MamaCallbackWrapper <MamaLogFileCallback, LogSizeCallbackDelegate>( callback, null, new LogSizeCallbackDelegate(onNativeLogSizeExceeded)); // Call the native function MamaWrapper.CheckResultCode(NativeMethods.mama_setLogSizeCb((LogSizeCallbackDelegate)m_logSizeCbWrapper.NativeDelegate)); } }
/// <summary> /// </summary> public static MamaQueue getDefaultEventQueue(MamaBridge bridgeImpl) { IntPtr queuePtr = IntPtr.Zero; int code = NativeMethods.mama_getDefaultEventQueue(bridgeImpl.NativeHandle, ref queuePtr); MamaWrapper.CheckResultCode(code); return(new MamaQueue(queuePtr)); }
/// <summary> /// Enable logging. /// </summary> /// <param name="level"> /// The logging level allowed. /// </param> /// <exception cref="ArgumentOutOfRangeException"> /// The file name contains invalid characters. /// </exception> public static void enableLogging(MamaLogLevel level) { // Check for a valid enumeration value if (!Enum.IsDefined(typeof(MamaLogLevel), (int)level)) { throw new ArgumentOutOfRangeException("level"); } MamaWrapper.CheckResultCode(NativeMethods.mama_enableLogging(IntPtr.Zero, (int)level)); }
/// <summary> /// Start Mama in the background. This method invokes Mama.start() in a separate thread. /// </summary> /// <param name="bridgeImpl"> /// The bridge specific structure. /// </param> /// <param name="callback"> /// The callback for asynchronous status. /// </param> public static void startBackground(MamaBridge bridgeImpl, MamaStartBackgroundCallback callback) { // Allocate a fowarder object mStartBackgroundCallbackForwarder = new StartBackgroundCallbackForwarder(callback); mStartBackgroundShimCallback = new StartBackgroundCallbackForwarder.StartBackgroundCompleteDelegate(mStartBackgroundCallbackForwarder.onStartBackgroundCompleted); // Call the native function MamaWrapper.CheckResultCode(NativeMethods.mama_startBackground(bridgeImpl.NativeHandle, mStartBackgroundShimCallback)); }
/// <summary> /// Set the max number of log files. /// </summary> /// <param name="numFiles"></param> /// <exception cref="ArgumentOutOfRangeException"> /// Thrown if the number of files is 0 or less. /// </exception> public static void setNumLogFiles(int numFiles) { // Check the argument if (numFiles < 1) { throw new ArgumentOutOfRangeException("numFiles"); } MamaWrapper.CheckResultCode(NativeMethods.mama_setNumLogFiles(numFiles)); }
/// <summary> /// Set the log file max size. /// </summary> /// <param name="size"></param> /// <exception cref="ArgumentOutOfRangeException"> /// Thrown if the size is 0. /// </exception> public static void setLogSize(ulong size) { // Check the argument if (size == 0) { throw new ArgumentOutOfRangeException("size"); } MamaWrapper.CheckResultCode(NativeMethods.mama_setLogSize(size)); }
/// <summary> /// Set append to prevent overwriting existing logfiles. /// </summary> /// <param name="append"></param> public static void setAppendToLogFile(bool append) { int appendC = 0; if (append) { appendC = 1; } MamaWrapper.CheckResultCode(NativeMethods.mama_setAppendToLogFile(appendC)); }
public Enumerator(MamaSourceGroup that) { mMamaSourceGroup = that; mItems = new ArrayList(); mGroupIteratorDelegate = new MamaSourceGroupIterateDelegate(this.onIterate); int code = NativeMethods.mamaSourceGroup_iterateSources( mMamaSourceGroup.NativeHandle, mGroupIteratorDelegate, IntPtr.Zero); MamaWrapper.CheckResultCode(code); mIndex = 0; GC.KeepAlive(this); }
/// <summary> /// /// Close MAMA and free all associated resource. /// /// MAMA employs a reference count to track multiple calls to Mama.open() and /// Mama.close(). The count is incremented every time Mama.open() is called and /// decremented when Mama.close() is called. The /// resources are not actually released until the count reaches zero. /// /// This function is thread safe. /// </summary> public static void close() { try { MamaWrapper.CheckResultCode(NativeMethods.mama_close()); } finally { /* Decrement the ref count even if something went wrong or there will be crashes * when the various objects are finalized. * The objects will only destroy the native objects if MAMA is still open. */ Interlocked.Decrement(ref mMamaopen); } }
/// <summary> /// Enable logging, accepts a string representing the file location. /// </summary> /// <param name="fileName"> /// The full path to the log file. /// </param> /// <param name="level"> /// The logging level allowed. /// </param> /// <exception cref="ArgumentNullException"> /// The file name is null or blank. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// The file name contains invalid characters. /// </exception> public static void logToFile(string fileName, MamaLogLevel level) { // Check the arguments if ((fileName == null) || (fileName == string.Empty)) { throw new ArgumentNullException("fileName"); } // Check for invalid characters in the file name if (fileName.IndexOfAny(Path.GetInvalidPathChars()) != -1) { throw new ArgumentOutOfRangeException(fileName, "The file or path contains invalid characters"); } // Check for a valid enumeration value if (!Enum.IsDefined(typeof(MamaLogLevel), (int)level)) { throw new ArgumentOutOfRangeException("level"); } // Call the native function MamaWrapper.CheckResultCode(NativeMethods.mama_logToFile(fileName, (int)level)); }
/// <summary> /// Set logging policy. /// </summary> /// <param name="policy"></param> public static void setLogFilePolicy(MamaLogFilePolicy policy) { MamaWrapper.CheckResultCode(NativeMethods.mama_setLogFilePolicy((int)policy)); }
/// <summary> /// Disable logging. /// </summary> public static void disableLogging() { MamaWrapper.CheckResultCode(NativeMethods.mama_disableLogging()); }
/// <summary> /// Set a specific property for the API. /// If the property being set has already been given a value from a /// properties file that value will be replaced. /// See the example mama.properties provided with the distribution for /// examples of property formatting. The properties set via this function /// should be formatted in the same manner as those specified in /// mama.properties. /// The strings passed to the function are copied. /// </summary> public static void setProperty(string name, string value) { MamaWrapper.CheckResultCode(NativeMethods.mama_setProperty(name, value)); }
/// <summary> /// /// Initialize MAMA. /// /// Allows users of the API to override the default behavior of mama_open() /// where a file mama.properties is required to be located in the directory /// specified by %WOMBAT_PATH%. /// /// The properties file must have the same structure as a standard /// mama.properties file. /// /// If null is passed as the path the API will look for the properties file on /// the %WOMBAT_PATH%. /// /// If null is passed as the filename the API will look for the default /// filename of mama.properties /// </summary> /// <param name="path"> /// Fully qualified path to the directory containing the properties /// file /// </param> /// <param name="filename"> /// The name of the file containing MAMA properties. /// </param> public static void openWithProperties(string path, string filename) { initGetVersionWrapper(); MamaWrapper.CheckResultCode(NativeMethods.mama_openWithProperties(path, filename)); Interlocked.Increment(ref mMamaopen); }
/// <summary> /// /// Initialize MAMA. /// /// MAMA employs a reference count to track multiple calls to Mama.open() and /// Mama.close(). The count is incremented every time Mama.open() is called /// and decremented when Mama.close() is called. The resources are not actually /// released until the count reaches zero. /// /// If entitlements are enabled for the library, the available entitlement /// server names are read from the entitlement.servers property in the /// mama.properties file located in the %WOMBAT_PATH% directory. /// /// This function is thread safe. /// /// </summary> public static void open() { initGetVersionWrapper(); MamaWrapper.CheckResultCode(NativeMethods.mama_open()); Interlocked.Increment(ref mMamaopen); }
/// <summary> /// Stop dispatching on the default event queue for the specified bridge. /// /// MAMA employs a reference count to track multiple calls to Mama.start() and /// Mama.stop(). The count is incremented every time Mama.start() is called and /// decremented when Mama.stop() is called. The first Mama.start() call does not /// unblock until the count reaches zero. /// /// This function is thread safe. /// </summary> /// <param name="bridgeImpl"> /// The bridge specific structure. /// </param> public static void stop(MamaBridge bridgeImpl) { MamaWrapper.CheckResultCode(NativeMethods.mama_stop(bridgeImpl.NativeHandle)); }
/// <summary> /// /// Initialize MAMA. /// /// Allows users of the API to override the default behavior of mama_open() /// where a file mama.properties is required to be located in the directory /// specified by %WOMBAT_PATH%. /// /// The properties file must have the same structure as a standard /// mama.properties file. /// /// If null is passed as the path the API will look for the properties file on /// the %WOMBAT_PATH%. /// /// If null is passed as the filename the API will look for the default /// filename of mama.properties /// </summary> /// <param name="path"> /// Fully qualified path to the directory containing the properties /// file /// </param> /// <param name="filename"> /// The name of the file containing MAMA properties. /// </param> public static void openWithProperties(string path, string filename) { initGetVersionWrapper(); MamaWrapper.CheckResultCode(NativeMethods.mama_openWithProperties(path, filename)); }