You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by nt...@apache.org on 2016/02/01 15:27:03 UTC
[08/48] ignite git commit: IGNITE-2332 - Support package-private
implementations for services
IGNITE-2332 - Support package-private implementations for services
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/644b198c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/644b198c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/644b198c
Branch: refs/heads/ignite-2454
Commit: 644b198c62b43ae084c5b6aedf02c98ee33c26de
Parents: bfae866
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Wed Jan 27 18:51:12 2016 -0800
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Wed Jan 27 18:51:12 2016 -0800
----------------------------------------------------------------------
.../processors/service/ServiceContextImpl.java | 4 +-
.../GridServicePackagePrivateSelfTest.java | 46 ++++++++++++++++++++
.../processors/service/inner/MyService.java | 30 +++++++++++++
.../service/inner/MyServiceFactory.java | 30 +++++++++++++
.../processors/service/inner/MyServiceImpl.java | 45 +++++++++++++++++++
.../testsuites/IgniteKernalSelfTestSuite.java | 4 +-
6 files changed, 157 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/644b198c/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceContextImpl.java
index b17beeb..6746e29 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceContextImpl.java
@@ -133,6 +133,8 @@ public class ServiceContextImpl implements ServiceContext {
if (mtd == null) {
try {
mtd = svc.getClass().getMethod(key.methodName(), key.argTypes());
+
+ mtd.setAccessible(true);
}
catch (NoSuchMethodException e) {
mtd = NULL_METHOD;
@@ -155,4 +157,4 @@ public class ServiceContextImpl implements ServiceContext {
@Override public String toString() {
return S.toString(ServiceContextImpl.class, this);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/644b198c/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServicePackagePrivateSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServicePackagePrivateSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServicePackagePrivateSelfTest.java
new file mode 100644
index 0000000..430d366
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServicePackagePrivateSelfTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.internal.processors.service;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.internal.processors.service.inner.MyService;
+import org.apache.ignite.internal.processors.service.inner.MyServiceFactory;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Test for package-private service implementation.
+ */
+public class GridServicePackagePrivateSelfTest extends GridCommonAbstractTest {
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPackagePrivateService() throws Exception {
+ Ignite server = startGrid("server");
+
+ server.services().deployClusterSingleton("my-service", MyServiceFactory.create());
+
+ Ignition.setClientMode(true);
+
+ Ignite client = startGrid("client");
+
+ MyService svc = client.services().serviceProxy("my-service", MyService.class, true);
+
+ assertEquals(42, svc.hello());
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/644b198c/modules/core/src/test/java/org/apache/ignite/internal/processors/service/inner/MyService.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/inner/MyService.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/inner/MyService.java
new file mode 100644
index 0000000..b558207
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/inner/MyService.java
@@ -0,0 +1,30 @@
+/*
+ * 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.internal.processors.service.inner;
+
+import org.apache.ignite.services.Service;
+
+/**
+ * Service.
+ */
+public interface MyService extends Service {
+ /**
+ * @return Some value.
+ */
+ int hello();
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/644b198c/modules/core/src/test/java/org/apache/ignite/internal/processors/service/inner/MyServiceFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/inner/MyServiceFactory.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/inner/MyServiceFactory.java
new file mode 100644
index 0000000..ace1c0b
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/inner/MyServiceFactory.java
@@ -0,0 +1,30 @@
+/*
+ * 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.internal.processors.service.inner;
+
+/**
+ * Service factory.
+ */
+public class MyServiceFactory {
+ /**
+ * @return Service.
+ */
+ public static MyService create() {
+ return new MyServiceImpl();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/644b198c/modules/core/src/test/java/org/apache/ignite/internal/processors/service/inner/MyServiceImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/inner/MyServiceImpl.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/inner/MyServiceImpl.java
new file mode 100644
index 0000000..cb2e0cf
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/inner/MyServiceImpl.java
@@ -0,0 +1,45 @@
+/*
+ * 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.internal.processors.service.inner;
+
+import org.apache.ignite.services.ServiceContext;
+
+/**
+ * Package-private service implementation.
+ */
+class MyServiceImpl implements MyService {
+ /** {@inheritDoc} */
+ @Override public int hello() {
+ return 42;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void cancel(ServiceContext ctx) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void init(ServiceContext ctx) throws Exception {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void execute(ServiceContext ctx) throws Exception {
+ // No-op.
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/644b198c/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
index 7197eb8..d9e9b0f 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
@@ -47,6 +47,7 @@ import org.apache.ignite.internal.managers.events.GridEventStorageManagerSelfTes
import org.apache.ignite.internal.managers.swapspace.GridSwapSpaceManagerSelfTest;
import org.apache.ignite.internal.processors.port.GridPortProcessorSelfTest;
import org.apache.ignite.internal.processors.service.GridServiceClientNodeTest;
+import org.apache.ignite.internal.processors.service.GridServicePackagePrivateSelfTest;
import org.apache.ignite.internal.processors.service.GridServiceProcessorMultiNodeConfigSelfTest;
import org.apache.ignite.internal.processors.service.GridServiceProcessorMultiNodeSelfTest;
import org.apache.ignite.internal.processors.service.GridServiceProcessorProxySelfTest;
@@ -121,7 +122,8 @@ public class IgniteKernalSelfTestSuite extends TestSuite {
suite.addTestSuite(GridServiceClientNodeTest.class);
suite.addTestSuite(GridServiceProcessorStopSelfTest.class);
suite.addTestSuite(ServicePredicateAccessCacheTest.class);
+ suite.addTestSuite(GridServicePackagePrivateSelfTest.class);
return suite;
}
-}
\ No newline at end of file
+}