Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-13734 .NET: Register service return type on method invocation #8602

Merged
merged 7 commits into from
Dec 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,11 @@ public PlatformBinaryProcessor(PlatformContext platformCtx) {

case OP_GET_TYPE: {
int typeId = reader.readInt();
byte platformId = reader.readByte();

try {
String typeName = platformContext().kernalContext().marshallerContext()
.getClassName(MarshallerPlatformIds.DOTNET_ID, typeId);
.getClassName(platformId, typeId);

writer.writeString(typeName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
import org.apache.ignite.compute.ComputeTaskAdapter;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.platform.model.ACL;
import org.apache.ignite.platform.model.Account;
import org.apache.ignite.platform.model.Address;
import org.apache.ignite.platform.model.Department;
import org.apache.ignite.platform.model.Employee;
import org.apache.ignite.platform.model.Key;
import org.apache.ignite.platform.model.Role;
import org.apache.ignite.platform.model.User;
import org.apache.ignite.platform.model.Value;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.services.Service;
import org.apache.ignite.services.ServiceContext;
Expand Down Expand Up @@ -503,6 +512,22 @@ public Map testMap(Map map) {
return m;
}

/** */
public Account[] testAccounts() {
return new Account[] {
new Account("123", 42),
new Account("321", 0)
};
}

/** */
public User[] testUsers() {
return new User[] {
new User(1, ACL.ALLOW, new Role("admin")),
new User(2, ACL.DENY, new Role("user"))
};
}

/** */
public void testDateArray(Timestamp[] dates) {
assertNotNull(dates);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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.
*/

package org.apache.ignite.platform.model;

/** Test enum. */
public enum ACL {
ALLOW, DENY
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* 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.
*/

package org.apache.ignite.platform.model;

import java.util.Objects;

/** */
public class Account {
/** */
private String id;

/** */
private int amount;

/** */
public Account() {
}

public Account(String id, int amount) {
this.id = id;
this.amount = amount;
}

/** */
public String getId() {
return id;
}

/** */
public void setId(String id) {
this.id = id;
}

/** */
public int getAmount() {
return amount;
}

/** */
public void setAmount(int amount) {
this.amount = amount;
}

@Override public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Account account = (Account)o;
return Objects.equals(id, account.id);
}

@Override public int hashCode() {
return Objects.hash(id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.ignite.platform;
package org.apache.ignite.platform.model;

/** Test value object. */
public class Address {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.ignite.platform;
package org.apache.ignite.platform.model;

/** Test value object. */
public class Department {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.ignite.platform;
package org.apache.ignite.platform.model;

/** Test value object. */
public class Employee {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.ignite.platform;
package org.apache.ignite.platform.model;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.
*/

package org.apache.ignite.platform.model;

/** Test value object. */
public class Role {
/** */
String name;

/** */
public Role(String name) {
this.name = name;
}

/** */
public String getName() {
return name;
}

/** */
public void setName(String name) {
this.name = name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* 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.
*/

package org.apache.ignite.platform.model;

/** Test value object. */
public class User {
/** */
private int id;

/** */
private ACL acl;

/** */
private Role role;

/** */
public User(int id, ACL acl, Role role) {
this.id = id;
this.acl = acl;
this.role = role;
}

/** */
public int getId() {
return id;
}

/** */
public void setId(int id) {
this.id = id;
}

/** */
public ACL getAcl() {
return acl;
}

/** */
public void setAcl(ACL acl) {
this.acl = acl;
}

/** */
public Role getRole() {
return role;
}

/** */
public void setRole(Role role) {
this.role = role;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.ignite.platform;
package org.apache.ignite.platform.model;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Apache.Ignite.Core.Tests.Services
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Apache.Ignite.Core.Binary;
using org.apache.ignite.platform;
using org.apache.ignite.platform.model;

/// <summary>
/// Java service proxy interface.
Expand Down Expand Up @@ -170,6 +170,12 @@ public interface IJavaService

/** */
Employee[] testEmployees(Employee[] emps);

/** */
Account[] testAccounts();

/** */
User[] testUsers();

/** */
ICollection testDepartments(ICollection deps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Apache.Ignite.Core.Tests.Services
using System.Collections;
using System.Collections.Generic;
using Apache.Ignite.Core.Binary;
using org.apache.ignite.platform;
using org.apache.ignite.platform.model;

/// <summary>
/// Explicit service proxy over dynamic variable.
Expand Down Expand Up @@ -319,6 +319,16 @@ public Employee[] testEmployees(Employee[] emps)
return _svc.testEmployees(emps);
}

public Account[] testAccounts()
{
return _svc.testAccounts();
}

public User[] testUsers()
{
return _svc.testUsers();
}

/** <inheritDoc /> */
public ICollection testDepartments(ICollection deps)
{
Expand Down
Loading