ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dma...@apache.org
Subject ignite git commit: IGNITE-2332 - Support package-private implementations for services
Date Thu, 28 Jan 2016 08:50:24 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-1.5.6 7257625c3 -> a3acc095d


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/a3acc095
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a3acc095
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a3acc095

Branch: refs/heads/ignite-1.5.6
Commit: a3acc095d809f7576664154c6aaaddbc602a9fa2
Parents: 7257625
Author: Valentin Kulichenko <valentin.kulichenko@gmail.com>
Authored: Wed Jan 27 18:51:12 2016 -0800
Committer: Denis Magda <dmagda@gridgain.com>
Committed: Thu Jan 28 11:49:12 2016 +0300

----------------------------------------------------------------------
 .../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/a3acc095/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/a3acc095/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/a3acc095/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/a3acc095/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/a3acc095/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/a3acc095/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
+}


Mime
View raw message