Repository: ignite
Updated Branches:
  refs/heads/ignite-1786 72362d41f -> b7450ef4a


http://git-wip-us.apache.org/repos/asf/ignite/blob/4d99d9ee/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git 
a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj 
b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index 24ccad2..19d370a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -115,6 +115,7 @@
     <Compile Include="Cache\IMutableCacheEntry.cs" />
     <Compile Include="Cache\Package-Info.cs" />
     <Compile Include="Cache\Query\Continuous\ContinuousQuery.cs" />
+    <Compile Include="Cache\Query\Continuous\ContinuousQueryExtensions.cs" />
     <Compile Include="Cache\Query\Continuous\IContinuousQueryHandle.cs" />
     <Compile Include="Cache\Query\Continuous\Package-Info.cs" />
     <Compile Include="Cache\Query\IQueryCursor.cs" />
@@ -145,6 +146,8 @@
     <Compile Include="Common\IgniteGuid.cs" />
     <Compile Include="Common\Package-Info.cs" />
     <Compile Include="Impl\Common\Platform.cs" />
+    <Compile Include="Impl\Cache\Event\JavaCacheEntryEventFilter.cs" />
+    <Compile Include="Impl\Common\PlatformJavaObjectFactoryProxy.cs" />
     <Compile Include="Compute\ComputeExecutionRejectedException.cs" />
     <Compile Include="Compute\ComputeJobAdapter.cs" />
     <Compile Include="Compute\ComputeJobFailoverException.cs" />
@@ -394,6 +397,7 @@
     <Compile Include="Impl\Unmanaged\UnmanagedNonReleaseableTarget.cs" />
     <Compile Include="Impl\Unmanaged\UnmanagedTarget.cs" />
     <Compile Include="Impl\Unmanaged\UnmanagedUtils.cs" />
+    <Compile Include="Interop\JavaObject.cs" />
     <Compile Include="Lifecycle\Package-Info.cs" />
     <Compile Include="Messaging\Package-Info.cs" />
     <Compile Include="Package-Info.cs" />
@@ -488,6 +492,9 @@
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
   </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Impl\Common\JavaObjects\" />
+  </ItemGroup>
   <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <PropertyGroup Condition="'$(Platform)' == 'AnyCPU'">
@@ -495,11 +502,11 @@
        set 
COMPLUS_ApplicationMigrationRuntimeActivationConfigPath=$(ProjectDir)
        PowerShell.exe -executionpolicy remotesigned -File build-common.ps1 
-Configuration $(ConfigurationName) -msbuildexe 
"$(MSBuildBinPath)\msbuild.exe"</PreBuildEvent>
   </PropertyGroup>
-  <!-- To modify your build process, add your task inside one of the targets 
below and uncomment it. 
+  <!-- To modify your build process, add your task inside one of the targets 
below and uncomment it.
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">
   </Target>
   <Target Name="AfterBuild">
   </Target>
   -->
-</Project>
\ No newline at end of file
+</Project>

http://git-wip-us.apache.org/repos/asf/ignite/blob/4d99d9ee/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/ContinuousQueryExtensions.cs
----------------------------------------------------------------------
diff --git 
a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/ContinuousQueryExtensions.cs
 
b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/ContinuousQueryExtensions.cs
new file mode 100644
index 0000000..8aa5e42
--- /dev/null
+++ 
b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/ContinuousQueryExtensions.cs
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Cache.Query.Continuous
+{
+    using Apache.Ignite.Core.Cache.Event;
+    using Apache.Ignite.Core.Impl.Cache.Event;
+    using Apache.Ignite.Core.Impl.Common;
+    using Apache.Ignite.Core.Interop;
+
+    /// <summary>
+    /// Extensions for continuous queries.
+    /// </summary>
+    public static class ContinuousQueryExtensions
+    {
+        /// <summary>
+        /// Creates the cache event filter that delegates to the corresponding 
Java object.
+        /// </summary>
+        /// <typeparam name="TK">Key type.</typeparam>
+        /// <typeparam name="TV">Value type.</typeparam>
+        public static ICacheEntryEventFilter<TK, TV> 
ToCacheEntryEventFilter<TK, TV>(this JavaObject javaObject)
+        {
+            IgniteArgumentCheck.NotNull(javaObject, "javaObject");
+
+            return new JavaCacheEntryEventFilter<TK, TV>(javaObject.ClassName, 
javaObject.Properties);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/4d99d9ee/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
----------------------------------------------------------------------
diff --git 
a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs 
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
index 4142d60..0bdbdf9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
@@ -187,6 +187,9 @@ namespace Apache.Ignite.Core.Impl.Binary
         /** Type: stream receiver holder. */
         public const byte TypeStreamReceiverHolder = 94;
 
+        /** Type: platform object proxy. */
+        public const byte TypePlatformJavaObjectFactoryProxy = 99;
+
         /** Collection: custom. */
         public const byte CollectionCustom = 0;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/4d99d9ee/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
----------------------------------------------------------------------
diff --git 
a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs 
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
index 1a01f2c..aa881bb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
@@ -27,6 +27,7 @@ namespace Apache.Ignite.Core.Impl.Binary
     using Apache.Ignite.Core.Impl.Binary.Metadata;
     using Apache.Ignite.Core.Impl.Cache;
     using Apache.Ignite.Core.Impl.Cache.Query.Continuous;
+    using Apache.Ignite.Core.Impl.Common;
     using Apache.Ignite.Core.Impl.Compute;
     using Apache.Ignite.Core.Impl.Compute.Closure;
     using Apache.Ignite.Core.Impl.Datastream;
@@ -574,6 +575,7 @@ namespace Apache.Ignite.Core.Impl.Binary
             AddSystemType(BinaryUtils.TypeMessageListenerHolder, w => new 
MessageListenerHolder(w));
             AddSystemType(BinaryUtils.TypeStreamReceiverHolder, w => new 
StreamReceiverHolder(w));
             AddSystemType(0, w => new AffinityKey(w), "affKey");
+            AddSystemType(BinaryUtils.TypePlatformJavaObjectFactoryProxy, w => 
new PlatformJavaObjectFactoryProxy());
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/4d99d9ee/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Event/JavaCacheEntryEventFilter.cs
----------------------------------------------------------------------
diff --git 
a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Event/JavaCacheEntryEventFilter.cs
 
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Event/JavaCacheEntryEventFilter.cs
new file mode 100644
index 0000000..b5c2ece
--- /dev/null
+++ 
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Event/JavaCacheEntryEventFilter.cs
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.Cache.Event
+{
+    using System;
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Cache.Event;
+    using Apache.Ignite.Core.Impl.Common;
+
+    /// <summary>
+    /// Cache entry event filter that delegates to Java.
+    /// </summary>
+    /// <typeparam name="TK">Key type.</typeparam>
+    /// <typeparam name="TV">Value type.</typeparam>
+    internal class JavaCacheEntryEventFilter<TK, TV> : 
PlatformJavaObjectFactoryProxy, ICacheEntryEventFilter<TK, TV>
+    {
+        /** <inheritdoc /> */
+        public bool Evaluate(ICacheEntryEvent<TK, TV> evt)
+        {
+            throw new InvalidOperationException(GetType() + " cannot be 
invoked directly.");
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see 
cref="JavaCacheEntryEventFilter{TK, TV}"/> class.
+        /// </summary>
+        /// <param name="factoryClassName">Name of the factory class.</param>
+        /// <param name="properties">The properties.</param>
+        public JavaCacheEntryEventFilter(string factoryClassName, 
IDictionary<string, object> properties) 
+            : base(FactoryType.User, factoryClassName, null, properties)
+        {
+            // No-op.
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/4d99d9ee/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
----------------------------------------------------------------------
diff --git 
a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
 
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
index bbc2dbe..6cfbe92 100644
--- 
a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
+++ 
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
@@ -26,6 +26,7 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
     using Apache.Ignite.Core.Cache.Query.Continuous;
     using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Binary.IO;
+    using Apache.Ignite.Core.Impl.Common;
     using Apache.Ignite.Core.Impl.Resource;
     using Apache.Ignite.Core.Impl.Unmanaged;
     using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
@@ -111,10 +112,20 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
             writer.WriteBoolean(qry.Local);
             writer.WriteBoolean(_filter != null);
 
-            var filterHolder = _filter == null || qry.Local ? null :
-                new ContinuousQueryFilterHolder(_filter, _keepBinary);
+            var javaFilter = _filter as PlatformJavaObjectFactoryProxy;
 
-            writer.WriteObject(filterHolder);
+            if (javaFilter != null)
+            {
+                writer.WriteObject(javaFilter.GetRawProxy());
+            }
+            else
+            {
+                var filterHolder = _filter == null || qry.Local
+                    ? null
+                    : new ContinuousQueryFilterHolder(_filter, _keepBinary);
+
+                writer.WriteObject(filterHolder);
+            }
 
             writer.WriteInt(qry.BufferSize);
             writer.WriteLong((long)qry.TimeInterval.TotalMilliseconds);

http://git-wip-us.apache.org/repos/asf/ignite/blob/4d99d9ee/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/PlatformJavaObjectFactoryProxy.cs
----------------------------------------------------------------------
diff --git 
a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/PlatformJavaObjectFactoryProxy.cs
 
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/PlatformJavaObjectFactoryProxy.cs
new file mode 100644
index 0000000..89b2891
--- /dev/null
+++ 
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/PlatformJavaObjectFactoryProxy.cs
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.Common
+{
+    using System;
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Impl.Binary;
+
+    /// <summary>
+    /// Maps to PlatformJavaObjectFactoryProxy in Java.
+    /// </summary>
+    internal class PlatformJavaObjectFactoryProxy : IBinaryWriteAware
+    {
+        /// <summary>
+        /// Represents the factory type.
+        /// </summary>
+        internal enum FactoryType
+        {
+            User = 0,
+            Default = 1
+        }
+
+        /** Type code. */
+        private readonly FactoryType _factoryType;
+
+        /** Java class name */
+        private readonly string _factoryClassName;
+
+        /** Optional payload. */
+        private readonly object _payload;
+
+        /** Properties to set */
+        private readonly IDictionary<string, object> _properties;
+
+        /// <summary>
+        /// Initializes a new instance of the <see 
cref="PlatformJavaObjectFactoryProxy" /> class.
+        /// </summary>
+        /// <param name="type">The type.</param>
+        /// <param name="factoryClassName">Name of the factory class.</param>
+        /// <param name="payload">The payload.</param>
+        /// <param name="properties">The properties.</param>
+        protected PlatformJavaObjectFactoryProxy(FactoryType type, string 
factoryClassName, object payload, 
+            IDictionary<string, object> properties)
+        {
+            _factoryType = type;
+            _factoryClassName = factoryClassName;
+            _payload = payload;
+            _properties = properties;
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see 
cref="PlatformJavaObjectFactoryProxy"/> class.
+        /// </summary>
+        public PlatformJavaObjectFactoryProxy()
+        {
+            throw new InvalidOperationException(GetType() + " should never be 
deserialized on .NET side.");
+        }
+
+        /** <inheritdoc /> */
+        public void WriteBinary(IBinaryWriter writer)
+        {
+            var w = writer.GetRawWriter();
+
+            w.WriteInt((int) _factoryType);
+            w.WriteString(_factoryClassName);
+            w.WriteObject(_payload);
+
+            if (_properties != null)
+            {
+                w.WriteInt(_properties.Count);
+
+                foreach (var pair in _properties)
+                {
+                    w.WriteString(pair.Key);
+                    w.WriteObject(pair.Value);
+                }
+            }
+            else
+                w.WriteInt(0);
+        }
+
+        /// <summary>
+        /// Gets the raw proxy (not the derived type) for serialization.
+        /// </summary>
+        public PlatformJavaObjectFactoryProxy GetRawProxy()
+        {
+            return new PlatformJavaObjectFactoryProxy(_factoryType, 
_factoryClassName, _payload, _properties);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/4d99d9ee/modules/platforms/dotnet/Apache.Ignite.Core/Interop/JavaObject.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Interop/JavaObject.cs 
b/modules/platforms/dotnet/Apache.Ignite.Core/Interop/JavaObject.cs
new file mode 100644
index 0000000..98ef619
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Interop/JavaObject.cs
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Interop
+{
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Impl.Common;
+
+    /// <summary>
+    /// Represents a Java object wrapper.
+    /// <para />
+    /// <see cref="JavaObject"/> can be converted to Ignite filters and 
predicates 
+    /// which can be used on non-.NET Ignite nodes.
+    /// <para />
+    /// Workflow is as follows:
+    /// Instantiate specified Java class;
+    /// Set property values;
+    /// If the resulting object implements PlatformJavaObjectFactory, call 
create() method and use the result,
+    /// otherwise use the original object.
+    /// </summary>
+    public class JavaObject
+    {
+        /** Java class name. */
+        private readonly string _className;
+
+        /** Properties. */
+        private readonly IDictionary<string, object> _properties = new 
Dictionary<string, object>();
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="JavaObject"/> class.
+        /// </summary>
+        /// <param name="className">Name of the Java class.</param>
+        public JavaObject(string className)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(className, "className");
+
+            _className = className;
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="JavaObject"/> class.
+        /// </summary>
+        /// <param name="className">Name of the Java class.</param>
+        /// <param name="properties">The properties to set on the Java 
object.</param>
+        public JavaObject(string className, IDictionary<string, object> 
properties) : this(className)
+        {
+            _properties = properties ?? _properties;
+        }
+
+        /// <summary>
+        /// Gets the Java class name.
+        /// </summary>
+        public string ClassName
+        {
+            get { return _className; }
+        }
+
+        /// <summary>
+        /// Gets the properties to be set on the Java object.
+        /// </summary>
+        public IDictionary<string, object> Properties
+        {
+            get { return _properties; }
+        }
+    }
+}

Reply via email to