Skip to content

Commit 2af3a4e

Browse files
committed
Enh 37170238 - [37059890->14.1.1.0.20] Port UniversalExtractor and UniversalUpdater to C++ and .NET (14.1.1.0 cl 111959 --> core/14.1.1.0)
[git-p4: depot-paths = "//dev/release.net/coherence-net-v14.1.1.0-core/": change = 111960]
1 parent 5a6c3a4 commit 2af3a4e

File tree

5 files changed

+430
-7
lines changed

5 files changed

+430
-7
lines changed

src/Coherence.Core/Config/coherence-pof-config.xml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0"?>
22
<!--
3-
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
3+
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
44
55
Licensed under the Universal Permissive License v 1.0 as shown at
6-
http://oss.oracle.com/licenses/upl.
6+
https://oss.oracle.com/licenses/upl.
77
-->
88
<pof-config xmlns="http://schemas.tangosol.com/pof">
99
<user-type-list>
@@ -528,6 +528,16 @@
528528
<class-name>Tangosol.Util.Extractor.ConditionalExtractor, Coherence.Core</class-name>
529529
</user-type>
530530

531+
<user-type>
532+
<type-id>192</type-id>
533+
<class-name>Tangosol.Util.Extractor.UniversalExtractor, Coherence.Core</class-name>
534+
</user-type>
535+
536+
<user-type>
537+
<type-id>193</type-id>
538+
<class-name>Tangosol.Util.Extractor.UniversalUpdater, Coherence.Core</class-name>
539+
</user-type>
540+
531541
<!-- Tangosol.Util.Aggregator namespace (continued) (250-259) -->
532542

533543
<user-type>
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
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+
using System.Text;
11+
12+
using Tangosol.IO.Pof;
13+
14+
namespace Tangosol.Util.Extractor
15+
{
16+
/// <summary>
17+
/// Universal <see cref="IValueExtractor"/> implementation.
18+
/// </summary>
19+
/// <remarks>
20+
/// UniversalExtractor can only run within the Coherence cluster.
21+
/// Refer to the Coherence for Java documentation for more information.
22+
/// </remarks>
23+
/// <author>Cameron Purdy 2002.11.01</author>
24+
/// <author>Gene Gleyzer 2002.11.01</author>
25+
/// <author>Everett Williams 2007.02.01</author>
26+
/// <author>Joe Fialli 2017.11.20</author>
27+
/// <author>Patrick Fry 2024.09.13</author>
28+
/// <since>14.1.2.0.0</since>
29+
public class UniversalExtractor : AbstractExtractor, IValueExtractor, IPortableObject
30+
{
31+
#region Properties
32+
33+
/// <summary>
34+
/// Get the method or property name.
35+
/// </summary>
36+
/// <value>
37+
/// the method or property name.
38+
/// </value>
39+
public virtual string Name
40+
{
41+
get { return m_name; }
42+
}
43+
44+
/// <summary>
45+
/// Gets the array of arguments used to invoke the method.
46+
/// </summary>
47+
/// <value>
48+
/// The array of arguments used to invoke the method.
49+
/// </value>
50+
public virtual Object[] Parameters
51+
{
52+
get { return m_parameters; }
53+
}
54+
55+
#endregion
56+
57+
#region Constructors
58+
59+
/// <summary>
60+
/// Default constructor (necessary for the IPortableObject interface).
61+
/// </summary>
62+
public UniversalExtractor()
63+
{}
64+
65+
/// <summary>
66+
/// Construct a <b>UniversalExtractor</b> based on a member name.
67+
/// </summary>
68+
/// <param name="name">
69+
/// A method or property name.
70+
/// </param>
71+
public UniversalExtractor(string name)
72+
: this(name, null, VALUE)
73+
{
74+
}
75+
76+
/// <summary>
77+
/// Construct a <b>UniversalExtractor</b>.
78+
/// </summary>
79+
/// <param name="name">
80+
/// A method or property name.
81+
/// </param>
82+
/// <param name="parameters">
83+
/// The array of arguments to be used in the method invocation;
84+
/// may be <c>null</c>.
85+
/// </param>
86+
public UniversalExtractor(string name, object[] parameters)
87+
: this(name, parameters, VALUE)
88+
{
89+
}
90+
91+
/// <summary>
92+
/// Construct a <b>UniversalExtractor</b> based on a method name,
93+
/// optional parameters and the entry extraction target.
94+
/// </summary>
95+
/// <param name="name">
96+
/// A method or property name.
97+
/// </param>
98+
/// <param name="parameters">
99+
/// The array of arguments to be used in the method invocation;
100+
/// may be <c>null</c>.
101+
/// </param>
102+
/// <param name="target">
103+
/// One of the <see cref="AbstractExtractor.VALUE"/> or
104+
/// <see cref="AbstractExtractor.KEY"/> values
105+
/// </param>
106+
public UniversalExtractor(string name, object[] parameters, int target)
107+
{
108+
Debug.Assert(name != null);
109+
110+
if (parameters != null && parameters.Length > 0 && !name.EndsWith(METHOD_SUFFIX))
111+
{
112+
throw new ArgumentException("UniversalExtractor constructor: parameter name[value:" + name + "] must end with method suffix \"" + METHOD_SUFFIX + "\" when optional parameters provided");
113+
}
114+
m_name = name;
115+
m_parameters = parameters;
116+
m_target = target;
117+
}
118+
119+
#endregion
120+
121+
#region Object override methods
122+
123+
/// <summary>
124+
/// Provide a human-readable description of this
125+
/// <see cref="IValueExtractor"/> object.
126+
/// </summary>
127+
/// <returns>
128+
/// A human-readable description of this <b>IValueExtractor</b>
129+
/// object.
130+
/// </returns>
131+
public override string ToString()
132+
{
133+
Object[] parameters = m_parameters;
134+
int cParams = parameters == null ? 0 : parameters.Length;
135+
136+
StringBuilder sb = new StringBuilder();
137+
if (m_target == KEY)
138+
{
139+
sb.Append(".Key");
140+
}
141+
sb.Append('.').Append(m_name).Append('(');
142+
for (int i = 0; i < cParams; i++)
143+
{
144+
if (i != 0)
145+
{
146+
sb.Append(", ");
147+
}
148+
sb.Append(parameters[i]);
149+
}
150+
sb.Append(')');
151+
152+
return sb.ToString();
153+
}
154+
155+
#endregion
156+
157+
#region IPortableObject implementation
158+
159+
/// <summary>
160+
/// Restore the contents of a user type instance by reading its state
161+
/// using the specified <see cref="IPofReader"/> object.
162+
/// </summary>
163+
/// <param name="reader">
164+
/// The <b>IPofReader</b> from which to read the object's state.
165+
/// </param>
166+
/// <exception cref="IOException">
167+
/// If an I/O error occurs.
168+
/// </exception>
169+
public virtual void ReadExternal(IPofReader reader)
170+
{
171+
m_name = reader.ReadString(0);
172+
m_parameters = (object[]) reader.ReadArray(1);
173+
m_target = reader.ReadInt32(2);
174+
}
175+
176+
/// <summary>
177+
/// Save the contents of a POF user type instance by writing its
178+
/// state using the specified <see cref="IPofWriter"/> object.
179+
/// </summary>
180+
/// <param name="writer">
181+
/// The <b>IPofWriter</b> to which to write the object's state.
182+
/// </param>
183+
/// <exception cref="IOException">
184+
/// If an I/O error occurs.
185+
/// </exception>
186+
public virtual void WriteExternal(IPofWriter writer)
187+
{
188+
string name = m_name;
189+
if (name == null)
190+
{
191+
throw new InvalidOperationException("UniversalExtractor was constructed without a method name");
192+
}
193+
writer.WriteString(0, name);
194+
writer.WriteArray(1, m_parameters);
195+
writer.WriteInt32(2, m_target);
196+
}
197+
198+
#endregion
199+
200+
#region Data members
201+
202+
/// <summary>
203+
/// The name of the member to invoke.
204+
/// </summary>
205+
protected string m_name;
206+
207+
/// <summary>
208+
/// The parameter array.
209+
/// </summary>
210+
protected Object[] m_parameters;
211+
212+
/// <summary>
213+
/// If m_name ends with this suffix, it represents a method name.
214+
/// </summary>
215+
public static readonly string METHOD_SUFFIX = "()";
216+
217+
#endregion
218+
}
219+
}
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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

Comments
 (0)