|
| 1 | +/* |
| 2 | + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. |
| 3 | + * |
| 4 | + * Licensed under the Universal Permissive License v 1.0 as shown at |
| 5 | + * https://oss.oracle.com/licenses/upl. |
| 6 | + */ |
| 7 | +using System; |
| 8 | +using System.Diagnostics; |
| 9 | +using System.IO; |
| 10 | + |
| 11 | +using Tangosol.IO.Pof; |
| 12 | + |
| 13 | +namespace Tangosol.Util.Extractor |
| 14 | +{ |
| 15 | + /// <summary> |
| 16 | + /// Universal <see cref="IValueUpdater"/> implementation. |
| 17 | + /// </summary> |
| 18 | + /// <remarks> |
| 19 | + /// UniversalUpdater can only run within the Coherence cluster. |
| 20 | + /// Refer to the Coherence for Java documentation for more information. |
| 21 | + /// </remarks> |
| 22 | + /// <author>Gene Gleyzer 2005.10.27</author> |
| 23 | + /// <author>Joe Fialli 2017.11.28</author> |
| 24 | + /// <author>Patrick Fry 2024.09.23</author> |
| 25 | + /// <since>14.1.2.0.0</since> |
| 26 | + public class UniversalUpdater : IValueUpdater, IPortableObject |
| 27 | + { |
| 28 | + #region Properties |
| 29 | + |
| 30 | + /// <summary> |
| 31 | + /// Get the method or property name. |
| 32 | + /// </summary> |
| 33 | + /// <value> |
| 34 | + /// the method or property name. |
| 35 | + /// </value> |
| 36 | + public virtual string Name |
| 37 | + { |
| 38 | + get { return m_name; } |
| 39 | + } |
| 40 | + |
| 41 | + #endregion |
| 42 | + |
| 43 | + #region Constructors |
| 44 | + |
| 45 | + /// <summary> |
| 46 | + /// Default constructor (necessary for the IPortableObject interface). |
| 47 | + /// </summary> |
| 48 | + public UniversalUpdater() |
| 49 | + { |
| 50 | + } |
| 51 | + |
| 52 | + /// <summary> |
| 53 | + /// Construct a UniversalUpdater for the provided name. |
| 54 | + /// </summary> |
| 55 | + /// <param name="name"> |
| 56 | + /// A method or property name. |
| 57 | + /// </param> |
| 58 | + public UniversalUpdater(string name) |
| 59 | + { |
| 60 | + Debug.Assert(name != null); |
| 61 | + |
| 62 | + m_name = name; |
| 63 | + } |
| 64 | + |
| 65 | + #endregion |
| 66 | + |
| 67 | + #region IValueUpdater implementation |
| 68 | + |
| 69 | + /// <summary> |
| 70 | + /// Update the passed target object using the specified value. |
| 71 | + /// </summary> |
| 72 | + /// <remarks> |
| 73 | + /// This method will always throw a <see cref="NotSupportedException"/> |
| 74 | + /// if called directly by the .NET client application, as its execution |
| 75 | + /// is only meaningful within the cluster. |
| 76 | + /// </remarks> |
| 77 | + /// <param name="target"> |
| 78 | + /// The object to update. |
| 79 | + /// </param> |
| 80 | + /// <param name="value"> |
| 81 | + /// The new value to update the target's property with. |
| 82 | + /// </param> |
| 83 | + /// <exception cref="NotSupportedException"> |
| 84 | + /// Always, as it is expected that this extractor will only be |
| 85 | + /// executed within the cluster. |
| 86 | + /// </exception> |
| 87 | + public void Update(object target, object value) |
| 88 | + { |
| 89 | + throw new NotSupportedException(); |
| 90 | + } |
| 91 | + |
| 92 | + #endregion |
| 93 | + |
| 94 | + #region IPortableObject implementation |
| 95 | + |
| 96 | + /// <summary> |
| 97 | + /// Restore the contents of a user type instance by reading its state |
| 98 | + /// using the specified <see cref="IPofReader"/> object. |
| 99 | + /// </summary> |
| 100 | + /// <param name="reader"> |
| 101 | + /// The <b>IPofReader</b> from which to read the object's state. |
| 102 | + /// </param> |
| 103 | + /// <exception cref="IOException"> |
| 104 | + /// If an I/O error occurs. |
| 105 | + /// </exception> |
| 106 | + public void ReadExternal(IPofReader reader) |
| 107 | + { |
| 108 | + m_name = reader.ReadString(0); |
| 109 | + } |
| 110 | + |
| 111 | + /// <summary> |
| 112 | + /// Save the contents of a POF user type instance by writing its |
| 113 | + /// state using the specified <see cref="IPofWriter"/> object. |
| 114 | + /// </summary> |
| 115 | + /// <param name="writer"> |
| 116 | + /// The <b>IPofWriter</b> to which to write the object's state. |
| 117 | + /// </param> |
| 118 | + /// <exception cref="IOException"> |
| 119 | + /// If an I/O error occurs. |
| 120 | + /// </exception> |
| 121 | + public void WriteExternal(IPofWriter writer) |
| 122 | + { |
| 123 | + writer.WriteString(0, Name); |
| 124 | + } |
| 125 | + |
| 126 | + #endregion |
| 127 | + |
| 128 | + #region Data members |
| 129 | + |
| 130 | + /// <summary> |
| 131 | + /// A method name, or a property name. |
| 132 | + /// </summary> |
| 133 | + protected string m_name; |
| 134 | + |
| 135 | + #endregion |
| 136 | + } |
| 137 | +} |
0 commit comments