diff --git a/Jenkinsfile b/Jenkinsfile
index 4f82d78cfa0..aabeb0f4cbc 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -5,6 +5,9 @@ def DOMAIN_NAME
def payaraBuildNumber
pipeline {
agent any
+ options {
+ disableConcurrentBuilds()
+ }
environment {
MP_METRICS_TAGS='tier=integration'
MP_CONFIG_CACHE_DURATION=0
diff --git a/appserver/tests/payara-samples/micro-programmatic/pom.xml b/appserver/tests/payara-samples/micro-programmatic/pom.xml
index e57898ee92c..94c84d32d3d 100644
--- a/appserver/tests/payara-samples/micro-programmatic/pom.xml
+++ b/appserver/tests/payara-samples/micro-programmatic/pom.xml
@@ -27,14 +27,6 @@
junit
junit
-
- org.jboss.shrinkwrap
- shrinkwrap-api
-
-
- org.jboss.shrinkwrap
- shrinkwrap-impl-base
-
diff --git a/appserver/tests/payara-samples/micro-programmatic/src/test/java/fish/payara/samples/programatic/DeployApplicationTest.java b/appserver/tests/payara-samples/micro-programmatic/src/test/java/fish/payara/samples/programatic/DeployApplicationTest.java
deleted file mode 100644
index ba637e3ba64..00000000000
--- a/appserver/tests/payara-samples/micro-programmatic/src/test/java/fish/payara/samples/programatic/DeployApplicationTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2021 Payara Foundation and/or its affiliates. All rights reserved.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common Development
- * and Distribution License("CDDL") (collectively, the "License"). You
- * may not use this file except in compliance with the License. You can
- * obtain a copy of the License at
- * https://github.com/payara/Payara/blob/master/LICENSE.txt
- * See the License for the specific
- * language governing permissions and limitations under the License.
- *
- * When distributing the software, include this License Header Notice in each
- * file and include the License file at glassfish/legal/LICENSE.txt.
- *
- * GPL Classpath Exception:
- * The Payara Foundation designates this particular file as subject to the "Classpath"
- * exception as provided by the Payara Foundation in the GPL Version 2 section of the License
- * file that accompanied this code.
- *
- * Modifications:
- * If applicable, add the following below the License Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyright [year] [name of copyright owner]"
- *
- * Contributor(s):
- * If you wish your version of this file to be governed by only the CDDL or
- * only the GPL Version 2, indicate your decision by adding "[Contributor]
- * elects to include this software in this distribution under the [CDDL or GPL
- * Version 2] license." If you don't indicate a single choice of license, a
- * recipient has the option to distribute your version of this file under
- * either the CDDL, the GPL Version 2 or to extend the choice of license to
- * its licensees as provided above. However, if you add GPL Version 2 code
- * and therefore, elected the GPL Version 2 license, then the option applies
- * only if the new code is made subject to such option by the copyright
- * holder.
- */
-package fish.payara.samples.programatic;
-
-import java.io.File;
-import java.io.InputStream;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.Scanner;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.exporter.ZipExporter;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.After;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import org.junit.Before;
-import org.junit.Test;
-
-public class DeployApplicationTest {
-
- private static final File WAR_FILE = createWar();
- private static final String WEBAPP_CONTEXT = "/" + WAR_FILE.getName().substring(0, WAR_FILE.getName().length() - 4);
- private static final String HOST_NAME = System.getProperty("payara.adminHost", "localhost");
-
- private PayaraMicroServer server;
-
- @Before
- public void startMicroInstance() {
- server = PayaraMicroServer.newInstance();
- }
-
- @Test
- public void deployApplicationInVanillaMode() throws Exception {
- assertNotNull(server);
- server.start("--autobindhttp", "--nocluster", "--deploy", WAR_FILE.getAbsolutePath());
- assertEquals(TestServlet.RESPONSE_TEXT, download(HOST_NAME, server.getHttpPort()));
- }
-
- @After
- public void stopMicroInstance() {
- if (server != null) {
- server.stop();
- }
- }
-
- private String download(String hostName, int hostPort) throws Exception {
- final URL url = new URL("http", hostName, hostPort, WEBAPP_CONTEXT);
- final Object object = url.getContent();
- if (object instanceof InputStream) {
- final InputStream input = (InputStream) object;
- try (Scanner scanner = new Scanner(input, StandardCharsets.UTF_8.name())) {
- return scanner.nextLine();
- } finally {
- input.close();
- }
- }
- throw new AssertionError("Expected input stream, but received this: " + object.toString());
- }
-
- private static File createWar() {
- try {
- final WebArchive war = ShrinkWrap.create(WebArchive.class).addClass(TestServlet.class);
- System.out.println(war);
- final File warFile = File.createTempFile(TestServlet.class.getSimpleName(), "WebApp.war");
- warFile.deleteOnExit();
- war.as(ZipExporter.class).exportTo(warFile, true);
- return warFile;
- } catch (Exception e) {
- throw new AssertionError("Failed to create war file", e);
- }
- }
-
-}
diff --git a/appserver/tests/payara-samples/micro-programmatic/src/test/java/fish/payara/samples/programatic/TestServlet.java b/appserver/tests/payara-samples/micro-programmatic/src/test/java/fish/payara/samples/programatic/TestServlet.java
deleted file mode 100644
index 0426977f4cb..00000000000
--- a/appserver/tests/payara-samples/micro-programmatic/src/test/java/fish/payara/samples/programatic/TestServlet.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2021 Payara Foundation and/or its affiliates. All rights reserved.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common Development
- * and Distribution License("CDDL") (collectively, the "License"). You
- * may not use this file except in compliance with the License. You can
- * obtain a copy of the License at
- * https://github.com/payara/Payara/blob/master/LICENSE.txt
- * See the License for the specific
- * language governing permissions and limitations under the License.
- *
- * When distributing the software, include this License Header Notice in each
- * file and include the License file at glassfish/legal/LICENSE.txt.
- *
- * GPL Classpath Exception:
- * The Payara Foundation designates this particular file as subject to the "Classpath"
- * exception as provided by the Payara Foundation in the GPL Version 2 section of the License
- * file that accompanied this code.
- *
- * Modifications:
- * If applicable, add the following below the License Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyright [year] [name of copyright owner]"
- *
- * Contributor(s):
- * If you wish your version of this file to be governed by only the CDDL or
- * only the GPL Version 2, indicate your decision by adding "[Contributor]
- * elects to include this software in this distribution under the [CDDL or GPL
- * Version 2] license." If you don't indicate a single choice of license, a
- * recipient has the option to distribute your version of this file under
- * either the CDDL, the GPL Version 2 or to extend the choice of license to
- * its licensees as provided above. However, if you add GPL Version 2 code
- * and therefore, elected the GPL Version 2 license, then the option applies
- * only if the new code is made subject to such option by the copyright
- * holder.
- */
-
-package fish.payara.samples.programatic;
-
-import java.io.IOException;
-
-import javax.servlet.annotation.WebServlet;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * @author David Matejcek
- */
-@WebServlet(urlPatterns = "/")
-public class TestServlet extends HttpServlet {
-
-
- public static final String RESPONSE_TEXT = "This is a response from " + TestServlet.class;
-
- @Override
- public void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException {
- resp.setStatus(200);
- resp.setContentType("text/plain");
- resp.getOutputStream().println(RESPONSE_TEXT);
- }
-}
diff --git a/appserver/web/gf-web-connector/src/main/java/fish/payara/appserver/context/JavaEEContextUtilImpl.java b/appserver/web/gf-web-connector/src/main/java/fish/payara/appserver/context/JavaEEContextUtilImpl.java
index 226d273a0e3..94b6adadbee 100644
--- a/appserver/web/gf-web-connector/src/main/java/fish/payara/appserver/context/JavaEEContextUtilImpl.java
+++ b/appserver/web/gf-web-connector/src/main/java/fish/payara/appserver/context/JavaEEContextUtilImpl.java
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) [2016-2020] Payara Foundation and/or its affiliates. All rights reserved.
+ * Copyright (c) [2016-2021] Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
@@ -146,11 +146,14 @@ private boolean isLoaded(String componentId, ComponentInvocation invocation) {
: compEnvMgr.getJndiNameEnvironment(componentId);
if (env != null) {
ApplicationInfo appInfo = appRegistry.get(DOLUtils.getApplicationFromEnv(env).getRegistrationName());
- Collection modules = appInfo.getModuleInfos();
- String moduleName = DOLUtils.getModuleName(env);
- if (modules.stream().filter(mod -> mod.getName().equals(moduleName))
- .anyMatch(moduleInfo -> !moduleInfo.isLoaded())) {
- return false;
+ if (appInfo != null) {
+ // Check if deployed vs. Payara internal application
+ Collection modules = appInfo.getModuleInfos();
+ String moduleName = DOLUtils.getModuleName(env);
+ if (modules.stream().filter(mod -> mod.getName().equals(moduleName))
+ .anyMatch(moduleInfo -> !moduleInfo.isLoaded())) {
+ return false;
+ }
}
}
return env != null;
diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/HazelcastCore.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/HazelcastCore.java
index db58c3fb43f..28ddb02f9c0 100644
--- a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/HazelcastCore.java
+++ b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/HazelcastCore.java
@@ -62,7 +62,6 @@
import static com.hazelcast.spi.properties.ClusterProperty.WAIT_SECONDS_BEFORE_JOIN;
import com.sun.enterprise.util.Utility;
import fish.payara.nucleus.events.HazelcastEvents;
-import fish.payara.nucleus.hazelcast.contextproxy.CachingProviderProxy;
import org.glassfish.api.StartupRunLevel;
import org.glassfish.api.admin.ServerEnvironment;
import org.glassfish.api.admin.ServerEnvironment.Status;
@@ -534,7 +533,7 @@ private synchronized void bootstrapHazelcast() {
}
setAttribute(theInstance.getCluster().getLocalMember().getUuid(), INSTANCE_ATTRIBUTE, memberName);
setAttribute(theInstance.getCluster().getLocalMember().getUuid(), INSTANCE_GROUP_ATTRIBUTE, memberGroup);
- hazelcastCachingProvider = new CachingProviderProxy(new HazelcastServerCachingProvider(theInstance), context);
+ hazelcastCachingProvider = new HazelcastServerCachingProvider(theInstance);
bindToJNDI();
if(env.getStatus() == Status.started) {
// only issue this event if the server is already running,
diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/PayaraHazelcastTenant.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/PayaraHazelcastTenant.java
new file mode 100644
index 00000000000..540c0ab53f9
--- /dev/null
+++ b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/PayaraHazelcastTenant.java
@@ -0,0 +1,218 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) [2016-2020] Payara Foundation and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://github.com/payara/Payara/blob/master/LICENSE.txt
+ * See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at glassfish/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * The Payara Foundation designates this particular file as subject to the "Classpath"
+ * exception as provided by the Payara Foundation in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package fish.payara.nucleus.hazelcast;
+
+import com.hazelcast.nio.ObjectDataInput;
+import com.hazelcast.nio.ObjectDataOutput;
+import com.hazelcast.nio.serialization.DataSerializable;
+import com.hazelcast.spi.tenantcontrol.DestroyEventContext;
+import com.hazelcast.spi.tenantcontrol.TenantControl;
+import com.hazelcast.spi.tenantcontrol.Tenantable;
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.glassfish.api.event.EventListener;
+import org.glassfish.api.event.Events;
+import org.glassfish.api.invocation.InvocationManager;
+import org.glassfish.deployment.versioning.VersioningUtils;
+import org.glassfish.internal.api.Globals;
+import org.glassfish.internal.api.JavaEEContextUtil;
+import org.glassfish.internal.data.ApplicationInfo;
+import org.glassfish.internal.data.ModuleInfo;
+import org.glassfish.internal.deployment.Deployment;
+
+/**
+ * Java EE Context and class loading support for Hazelcast objects and thread-callbacks
+ *
+ * @author lprimak
+ */
+public class PayaraHazelcastTenant implements TenantControl, DataSerializable {
+ private final JavaEEContextUtil ctxUtil = Globals.getDefaultHabitat().getService(JavaEEContextUtil.class);
+ private final Events events = Globals.getDefaultHabitat().getService(Events.class);
+ private final InvocationManager invMgr = Globals.getDefaultHabitat().getService(InvocationManager.class);
+ private final Lock lock = new ReentrantLock();
+ private final Condition condition = lock.newCondition();
+ private static final Logger log = Logger.getLogger(PayaraHazelcastTenant.class.getName());
+ private static final Map blockedCounts = new ConcurrentHashMap<>();
+
+ // transient fields
+ private EventListenerImpl destroyEventListener;
+
+ // serialized fields
+ private JavaEEContextUtil.Instance contextInstance;
+ private String moduleName;
+
+
+ PayaraHazelcastTenant() {
+ if (invMgr.getCurrentInvocation() != null) {
+ contextInstance = ctxUtil.currentInvocation();
+ moduleName = VersioningUtils.getUntaggedName(invMgr.getCurrentInvocation().getModuleName());
+ } else {
+ contextInstance = ctxUtil.empty();
+ }
+ }
+
+ @Override
+ public void registerObject(DestroyEventContext destroyContext) {
+ destroyEventListener = new EventListenerImpl(destroyContext);
+ events.register(destroyEventListener);
+ }
+
+ @Override
+ public void unregisterObject() {
+ // Hazelcast object has been destroyed
+ events.unregister(destroyEventListener);
+ destroyEventListener = null;
+ }
+
+ @Override
+ public Closeable setTenant() {
+ try {
+ return contextInstance.pushRequestContext()::close;
+ } catch (IllegalStateException exc) {
+ throw exc;
+ }
+ }
+
+ @Override
+ public void writeData(ObjectDataOutput out) throws IOException {
+ out.writeObject(contextInstance);
+ out.writeUTF(moduleName);
+ }
+
+ @Override
+ public void readData(ObjectDataInput in) throws IOException {
+ contextInstance = in.readObject();
+ moduleName = in.readUTF();
+ }
+
+ @Override
+ public boolean isAvailable(Tenantable tenantable) {
+ if (contextInstance.isLoaded()) {
+ return true;
+ }
+ if (!tenantable.requiresTenantContext() || tenantNotRequired(tenantable)) {
+ return true;
+ }
+ lock.lock();
+ try {
+ String componentId = contextInstance.getInstanceComponentId();
+ int unavailableCount = blockedCounts.compute(componentId, (k, v) -> v == null ? 0 : ++v);
+ log.log(unavailableCount > 100 ? Level.INFO : Level.FINEST,
+ String.format("BLOCKED: tenant not available: %s, module %s, Operation: %s",
+ componentId, moduleName, tenantable.getClass().getName()));
+ if (unavailableCount > 100) {
+ blockedCounts.remove(componentId);
+ }
+ condition.await(100, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException ex) {
+ } finally {
+ lock.unlock();
+ }
+ return false;
+ }
+
+ @Override
+ public void clearThreadContext() {
+ if (!invMgr.isInvocationStackEmpty()) {
+ log.warning(String.format("clearThreadContext - non-empty invocations: %s", invMgr.getAllInvocations().toString()));
+ invMgr.putAllInvocations(null);
+ }
+ }
+
+ /**
+ * workaround for operations that are not supposed to require tenant control but are
+ *
+ * @param tenantable
+ * @return true if tenant is not required
+ */
+ private boolean tenantNotRequired(Tenantable tenantable) {
+ switch (tenantable.getClass().getSimpleName()) {
+ case "DeleteOperation":
+ {
+ return true;
+ }
+ default:
+ return false;
+ }
+ }
+
+ private void tenantUnavailable() {
+ contextInstance.clearInstanceInvocation();
+ }
+
+
+ private class EventListenerImpl implements EventListener {
+ private final DestroyEventContext destroyEvent;
+
+
+ private EventListenerImpl(DestroyEventContext event) {
+ this.destroyEvent = event;
+ }
+
+ @Override
+ public void event(EventListener.Event> payaraEvent) {
+ if (payaraEvent.is(Deployment.MODULE_STARTED)) {
+ ModuleInfo hook = (ModuleInfo) payaraEvent.hook();
+ if (!(hook instanceof ApplicationInfo) && VersioningUtils.getUntaggedName(hook.getName()).equals(moduleName)) {
+ lock.lock();
+ try {
+ condition.signalAll();
+ } finally {
+ lock.unlock();
+ }
+ }
+ } else if (payaraEvent.is(Deployment.MODULE_STOPPED)) {
+ ModuleInfo hook = (ModuleInfo) payaraEvent.hook();
+ if (!(hook instanceof ApplicationInfo) && VersioningUtils.getUntaggedName(hook.getName()).equals(moduleName)) {
+ // decouple the tenant classes from the event
+ tenantUnavailable();
+ destroyEvent.tenantUnavailable();
+ }
+ }
+ }
+ }
+}
diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/contextproxy/EntryProcessorProxy.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/PayaraHazelcastTenantFactory.java
similarity index 59%
rename from nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/contextproxy/EntryProcessorProxy.java
rename to nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/PayaraHazelcastTenantFactory.java
index 7912570fe78..7086c4fb393 100644
--- a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/contextproxy/EntryProcessorProxy.java
+++ b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/PayaraHazelcastTenantFactory.java
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) [2016-2019] Payara Foundation and/or its affiliates. All rights reserved.
+ * Copyright (c) [2016-2020] Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
@@ -37,37 +37,42 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
-package fish.payara.nucleus.hazelcast.contextproxy;
+package fish.payara.nucleus.hazelcast;
-import java.io.Serializable;
+import com.hazelcast.spi.tenantcontrol.TenantControl;
+import com.hazelcast.spi.tenantcontrol.TenantControlFactory;
+import org.glassfish.api.invocation.ComponentInvocation;
+import org.glassfish.api.invocation.InvocationManager;
+import org.glassfish.internal.api.Globals;
import org.glassfish.internal.api.JavaEEContextUtil;
-import org.glassfish.internal.api.JavaEEContextUtil.Context;
-import javax.cache.processor.EntryProcessor;
-import javax.cache.processor.EntryProcessorException;
-import javax.cache.processor.MutableEntry;
/**
- * push Java EE environment before invoking delegate
+ * Java EE Context and class loading support for Hazelcast objects and thread-based callbacks
*
* @author lprimak
- * @param
- * @param
- * @param
*/
-public class EntryProcessorProxy implements EntryProcessor, Serializable {
+public class PayaraHazelcastTenantFactory implements TenantControlFactory {
+ private final JavaEEContextUtil ctxUtil = Globals.getDefaultHabitat().getService(JavaEEContextUtil.class);
+ private final InvocationManager invocationMgr = Globals.getDefaultHabitat().getService(InvocationManager.class);
+
@Override
- public T process(MutableEntry me, Object... os) throws EntryProcessorException {
- try (Context ctx = ctxUtilInst.pushContext()) {
- return delegate.process(me, os);
+ public TenantControl saveCurrentTenant() {
+ ComponentInvocation invocation = invocationMgr.getCurrentInvocation();
+ TenantControl tenantControl = TenantControl.NOOP_TENANT_CONTROL;
+ if (invocation != null) {
+ tenantControl = invocation.getRegistryFor(TenantControl.class);
+ if (tenantControl == null && ctxUtil.isInvocationLoaded()) {
+ tenantControl = new PayaraHazelcastTenant();
+ invocation.setRegistryFor(TenantControl.class, tenantControl);
+ } else if (tenantControl == null) {
+ tenantControl = TenantControl.NOOP_TENANT_CONTROL;
+ }
}
+ return tenantControl;
}
- public EntryProcessorProxy(EntryProcessor delegate, JavaEEContextUtil.Instance ctxUtilInst) {
- this.delegate = delegate;
- this.ctxUtilInst = ctxUtilInst;
+ @Override
+ public boolean isClassesAlwaysAvailable() {
+ return false;
}
-
- private final EntryProcessor delegate;
- private final JavaEEContextUtil.Instance ctxUtilInst;
- private static final long serialVersionUID = 1L;
}
diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/ListCacheKeys.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/ListCacheKeys.java
index c7ecfcedd4b..fed03601052 100644
--- a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/ListCacheKeys.java
+++ b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/ListCacheKeys.java
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) [2016-2020] Payara Foundation and/or its affiliates. All rights reserved.
+ * Copyright (c) [2016-2021] Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
@@ -40,7 +40,6 @@
package fish.payara.nucleus.hazelcast.admin;
import com.hazelcast.cache.impl.CacheEntry;
-import com.hazelcast.cache.impl.CachePartitionsIterator;
import com.hazelcast.cache.impl.CacheProxy;
import com.hazelcast.core.DistributedObject;
import com.hazelcast.core.HazelcastInstance;
@@ -118,7 +117,7 @@ public void execute(AdminCommandContext context) {
CacheProxy jcache = (CacheProxy) dobject;
if (cacheName == null || cacheName.isEmpty() || cacheName.equals(jcache.getName())) {
builder.append("JCache ").append(jcache.getName()).append("\n{");
- keyIterator = new CachePartitionsIterator<>(jcache, 10, true);
+ keyIterator = jcache.iterator();
}
}
while (keyIterator != null && keyIterator.hasNext()) {
diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/contextproxy/CacheManagerProxy.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/contextproxy/CacheManagerProxy.java
deleted file mode 100644
index 772c591c5a7..00000000000
--- a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/contextproxy/CacheManagerProxy.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) [2016-2019] Payara Foundation and/or its affiliates. All rights reserved.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common Development
- * and Distribution License("CDDL") (collectively, the "License"). You
- * may not use this file except in compliance with the License. You can
- * obtain a copy of the License at
- * https://github.com/payara/Payara/blob/master/LICENSE.txt
- * See the License for the specific
- * language governing permissions and limitations under the License.
- *
- * When distributing the software, include this License Header Notice in each
- * file and include the License file at glassfish/legal/LICENSE.txt.
- *
- * GPL Classpath Exception:
- * The Payara Foundation designates this particular file as subject to the "Classpath"
- * exception as provided by the Payara Foundation in the GPL Version 2 section of the License
- * file that accompanied this code.
- *
- * Modifications:
- * If applicable, add the following below the License Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyright [year] [name of copyright owner]"
- *
- * Contributor(s):
- * If you wish your version of this file to be governed by only the CDDL or
- * only the GPL Version 2, indicate your decision by adding "[Contributor]
- * elects to include this software in this distribution under the [CDDL or GPL
- * Version 2] license." If you don't indicate a single choice of license, a
- * recipient has the option to distribute your version of this file under
- * either the CDDL, the GPL Version 2 or to extend the choice of license to
- * its licensees as provided above. However, if you add GPL Version 2 code
- * and therefore, elected the GPL Version 2 license, then the option applies
- * only if the new code is made subject to such option by the copyright
- * holder.
- */
-package fish.payara.nucleus.hazelcast.contextproxy;
-
-import org.glassfish.internal.api.JavaEEContextUtil;
-
-import java.net.URI;
-import java.util.Properties;
-
-import javax.cache.Cache;
-import javax.cache.CacheManager;
-import javax.cache.configuration.CompleteConfiguration;
-import javax.cache.configuration.Configuration;
-import javax.cache.spi.CachingProvider;
-
-import org.glassfish.internal.api.ServerContext;
-
-/**
- * Proxy all applicable factory calls
- * so Java EE context is propagated from within Hazelcast threads
- *
- * @author lprimak
- */
-public class CacheManagerProxy implements CacheManager {
- @Override
- public > Cache createCache(String string, C config) throws IllegalArgumentException {
- Cache cache;
- JavaEEContextUtil ctxUtil = serverContext.getDefaultServices().getService(JavaEEContextUtil.class);
- if(ctxUtil != null && config instanceof CompleteConfiguration) {
- CompleteConfiguration cfg = new CompleteConfigurationProxy<>((CompleteConfiguration)config, ctxUtil.currentInvocation());
- cache = delegate.createCache(string, cfg);
- } else {
- cache = delegate.createCache(string, config);
- }
-
- return ctxUtil != null? new CacheProxy<>(cache, ctxUtil.currentInvocation()) : cache;
- }
-
- @Override
- public Cache getCache(String cacheName) {
- JavaEEContextUtil ctxUtil = serverContext.getDefaultServices().getService(JavaEEContextUtil.class);
- Cache cache = delegate.getCache(cacheName);
- return cache != null? new CacheProxy<>(cache, ctxUtil.currentInvocation()) : null;
- }
-
- @Override
- public Cache getCache(String cacheName, Class keyType, Class valueType) {
- JavaEEContextUtil ctxUtil = serverContext.getDefaultServices().getService(JavaEEContextUtil.class);
- Cache cache = delegate.getCache(cacheName, keyType, valueType);
- return cache != null? new CacheProxy<>(cache, ctxUtil.currentInvocation()) : null;
- }
-
-
- private final CacheManager delegate;
- private final ServerContext serverContext;
-
- @Override
- public CachingProvider getCachingProvider() {
- return delegate.getCachingProvider();
- }
-
- public CacheManagerProxy(CacheManager delegate, ServerContext serverContext) {
- this.delegate = delegate;
- this.serverContext = serverContext;
- }
-
- @Override
- public URI getURI() {
- return delegate.getURI();
- }
-
- @Override
- public ClassLoader getClassLoader() {
- return delegate.getClassLoader();
- }
-
- @Override
- public Properties getProperties() {
- return delegate.getProperties();
- }
-
- @Override
- public Iterable getCacheNames() {
- return delegate.getCacheNames();
- }
-
- @Override
- public void destroyCache(String cacheName) {
- delegate.destroyCache(cacheName);
- }
-
- @Override
- public void enableManagement(String cacheName, boolean enabled) {
- delegate.enableManagement(cacheName, enabled);
- }
-
- @Override
- public void enableStatistics(String cacheName, boolean enabled) {
- delegate.enableStatistics(cacheName, enabled);
- }
-
- @Override
- public void close() {
- delegate.close();
- }
-
- @Override
- public boolean isClosed() {
- return delegate.isClosed();
- }
-
- @Override
- public T unwrap(Class clazz) {
- return delegate.unwrap(clazz);
- }
-}
diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/contextproxy/CacheProxy.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/contextproxy/CacheProxy.java
deleted file mode 100644
index ff063c982ee..00000000000
--- a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/contextproxy/CacheProxy.java
+++ /dev/null
@@ -1,395 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) [2016-2019] Payara Foundation and/or its affiliates. All rights reserved.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common Development
- * and Distribution License("CDDL") (collectively, the "License"). You
- * may not use this file except in compliance with the License. You can
- * obtain a copy of the License at
- * https://github.com/payara/Payara/blob/master/LICENSE.txt
- * See the License for the specific
- * language governing permissions and limitations under the License.
- *
- * When distributing the software, include this License Header Notice in each
- * file and include the License file at glassfish/legal/LICENSE.txt.
- *
- * GPL Classpath Exception:
- * The Payara Foundation designates this particular file as subject to the "Classpath"
- * exception as provided by the Payara Foundation in the GPL Version 2 section of the License
- * file that accompanied this code.
- *
- * Modifications:
- * If applicable, add the following below the License Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyright [year] [name of copyright owner]"
- *
- * Contributor(s):
- * If you wish your version of this file to be governed by only the CDDL or
- * only the GPL Version 2, indicate your decision by adding "[Contributor]
- * elects to include this software in this distribution under the [CDDL or GPL
- * Version 2] license." If you don't indicate a single choice of license, a
- * recipient has the option to distribute your version of this file under
- * either the CDDL, the GPL Version 2 or to extend the choice of license to
- * its licensees as provided above. However, if you add GPL Version 2 code
- * and therefore, elected the GPL Version 2 license, then the option applies
- * only if the new code is made subject to such option by the copyright
- * holder.
- */
-package fish.payara.nucleus.hazelcast.contextproxy;
-
-import org.glassfish.internal.api.JavaEEContextUtil;
-import org.glassfish.internal.api.JavaEEContextUtil.Context;
-
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import javax.cache.Cache;
-import javax.cache.CacheManager;
-import javax.cache.configuration.CacheEntryListenerConfiguration;
-import javax.cache.configuration.Configuration;
-import javax.cache.configuration.Factory;
-import javax.cache.event.CacheEntryCreatedListener;
-import javax.cache.event.CacheEntryEvent;
-import javax.cache.event.CacheEntryEventFilter;
-import javax.cache.event.CacheEntryExpiredListener;
-import javax.cache.event.CacheEntryListener;
-import javax.cache.event.CacheEntryListenerException;
-import javax.cache.event.CacheEntryRemovedListener;
-import javax.cache.event.CacheEntryUpdatedListener;
-import javax.cache.integration.CompletionListener;
-import javax.cache.processor.EntryProcessor;
-import javax.cache.processor.EntryProcessorException;
-import javax.cache.processor.EntryProcessorResult;
-
-/**
- * proxy the cache so we can set up invocation context for
- * the Hazelcast thread
- *
- * @author lprimak
- * @param key
- * @param value
- */
-public class CacheProxy implements Cache {
-
- private static class CPLProxy implements CompletionListener {
- @Override
- public void onCompletion() {
- try (Context ctx = ctxUtilInst.pushContext()) {
- delegate.onCompletion();
- }
- }
-
- @Override
- public void onException(Exception excptn) {
- try (Context ctx = ctxUtilInst.pushContext()) {
- delegate.onException(excptn);
- }
- }
-
- public CPLProxy(CompletionListener delegate, JavaEEContextUtil.Instance ctxUtilInst) {
- this.delegate = delegate;
- this.ctxUtilInst = ctxUtilInst;
- }
-
- private final CompletionListener delegate;
- private final JavaEEContextUtil.Instance ctxUtilInst;
- }
-
- @Override
- public void loadAll(Set extends K> set, boolean bln, CompletionListener cl) {
- if(!(cl instanceof CPLProxy)) {
- cl = new CPLProxy(cl, ctxUtilInst);
- }
- delegate.loadAll(set, bln, cl);
- }
-
- @Override
- public T invoke(K k, EntryProcessor ep, Object... os) throws EntryProcessorException {
- if(!(ep instanceof EntryProcessorProxy)) {
- ep = new EntryProcessorProxy<>(ep, ctxUtilInst);
- }
- return delegate.invoke(k, ep, os);
- }
-
- @Override
- public Map> invokeAll(Set extends K> set, EntryProcessor ep, Object... os) {
- if(!(ep instanceof EntryProcessorProxy)) {
- ep = new EntryProcessorProxy<>(ep, ctxUtilInst);
- }
- return delegate.invokeAll(set, ep, os);
- }
-
- private static class CELProxy implements CacheEntryCreatedListener, CacheEntryExpiredListener,
- CacheEntryRemovedListener, CacheEntryUpdatedListener {
- @Override
- public void onCreated(Iterable> itrbl) throws CacheEntryListenerException {
- CacheEntryCreatedListener listener = (CacheEntryCreatedListener)delegate;
- try (Context ctx = ctxUtilInst.pushRequestContext()) {
- listener.onCreated(itrbl);
- }
- }
-
- @Override
- public void onExpired(Iterable> itrbl) throws CacheEntryListenerException {
- CacheEntryExpiredListener listener = (CacheEntryExpiredListener)delegate;
- try (Context ctx = ctxUtilInst.pushRequestContext()) {
- listener.onExpired(itrbl);
- }
- }
-
- @Override
- public void onRemoved(Iterable> itrbl) throws CacheEntryListenerException {
- CacheEntryRemovedListener listener = (CacheEntryRemovedListener)delegate;
- try (Context ctx = ctxUtilInst.pushRequestContext()) {
- listener.onRemoved(itrbl);
- }
- }
-
- @Override
- public void onUpdated(Iterable> itrbl) throws CacheEntryListenerException {
- CacheEntryUpdatedListener listener = (CacheEntryUpdatedListener)delegate;
- try (Context ctx = ctxUtilInst.pushRequestContext()) {
- listener.onUpdated(itrbl);
- }
- }
-
- public CELProxy(CacheEntryListener delegate, JavaEEContextUtil.Instance ctxUtilInst) {
- this.delegate = delegate;
- this.ctxUtilInst = ctxUtilInst;
- }
-
- private final CacheEntryListener delegate;
- private final JavaEEContextUtil.Instance ctxUtilInst;
- }
-
- private static class CELFProxy implements Factory> {
- @Override
- public CacheEntryListener super K, ? super V> create() {
- try (Context ctx = ctxUtilInst.pushContext()) {
- return new CELProxy<>(delegate.create(), ctxUtilInst);
- }
- }
-
- public CELFProxy(Factory> delegate, JavaEEContextUtil.Instance ctxUtilInst) {
- this.delegate = delegate;
- this.ctxUtilInst = ctxUtilInst;
- }
-
- private final Factory> delegate;
- private final JavaEEContextUtil.Instance ctxUtilInst;
- private static final long serialVersionUID = 1L;
- }
-
- private static class CEEVProxy implements CacheEntryEventFilter {
- @Override
- public boolean evaluate(CacheEntryEvent extends K, ? extends V> cee) throws CacheEntryListenerException {
- try (Context ctx = ctxUtilInst.pushRequestContext()) {
- return delegate.evaluate(cee);
- }
- }
-
- public CEEVProxy(CacheEntryEventFilter delegate, JavaEEContextUtil.Instance ctxUtilInst) {
- this.delegate = delegate;
- this.ctxUtilInst = ctxUtilInst;
- }
-
- private final CacheEntryEventFilter delegate;
- private final JavaEEContextUtil.Instance ctxUtilInst;
- }
-
- private static class CEEVFProxy implements Factory> {
- @Override
- public CacheEntryEventFilter super K, ? super V> create() {
- try (Context ctx = ctxUtilInst.pushContext()) {
- return new CEEVProxy<>(delegate.create(), ctxUtilInst);
- }
- }
-
- public CEEVFProxy(Factory> delegate, JavaEEContextUtil.Instance ctxUtilInst) {
- this.delegate = delegate;
- this.ctxUtilInst = ctxUtilInst;
- }
-
- private final Factory> delegate;
- private final JavaEEContextUtil.Instance ctxUtilInst;
- private static final long serialVersionUID = 1L;
- }
-
- private static class CELCProxy implements CacheEntryListenerConfiguration {
- @Override
- public Factory> getCacheEntryListenerFactory() {
- try (Context ctx = ctxUtilInst.pushContext()) {
- return new CELFProxy<>(delegate.getCacheEntryListenerFactory(), ctxUtilInst);
- }
- }
-
- @Override
- public boolean isOldValueRequired() {
- try (Context ctx = ctxUtilInst.pushContext()) {
- return delegate.isOldValueRequired();
- }
- }
-
- @Override
- public Factory> getCacheEntryEventFilterFactory() {
- try (Context ctx = ctxUtilInst.pushContext()) {
- return new CEEVFProxy<>(delegate.getCacheEntryEventFilterFactory(), ctxUtilInst);
- }
- }
-
- @Override
- public boolean isSynchronous() {
- try (Context ctx = ctxUtilInst.pushContext()) {
- return delegate.isSynchronous();
- }
- }
-
- public CELCProxy(CacheEntryListenerConfiguration delegate, JavaEEContextUtil.Instance ctxUtilInst) {
- this.delegate = delegate;
- this.ctxUtilInst = ctxUtilInst;
- }
-
- private final CacheEntryListenerConfiguration delegate;
- private final JavaEEContextUtil.Instance ctxUtilInst;
-
- private static final long serialVersionUID = 1L;
- }
-
- @Override
- public void registerCacheEntryListener(CacheEntryListenerConfiguration celc) {
- if(!(celc instanceof CELCProxy)) {
- celc = new CELCProxy<>(celc, ctxUtilInst);
- }
- delegate.registerCacheEntryListener(celc);
- }
-
- private final Cache delegate;
- private final JavaEEContextUtil.Instance ctxUtilInst;
-
- @Override
- public V get(K key) {
- return delegate.get(key);
- }
-
- @Override
- public Map getAll(Set extends K> keys) {
- return delegate.getAll(keys);
- }
-
- public CacheProxy(Cache delegate, JavaEEContextUtil.Instance ctxUtilInst) {
- this.delegate = delegate;
- this.ctxUtilInst = ctxUtilInst;
- }
-
- @Override
- public boolean containsKey(K key) {
- return delegate.containsKey(key);
- }
-
- @Override
- public void put(K key, V value) {
- delegate.put(key, value);
- }
-
- @Override
- public V getAndPut(K key, V value) {
- return delegate.getAndPut(key, value);
- }
-
- @Override
- public void putAll(Map extends K, ? extends V> map) {
- delegate.putAll(map);
- }
-
- @Override
- public boolean putIfAbsent(K key, V value) {
- return delegate.putIfAbsent(key, value);
- }
-
- @Override
- public boolean remove(K key) {
- return delegate.remove(key);
- }
-
- @Override
- public boolean remove(K key, V oldValue) {
- return delegate.remove(key, oldValue);
- }
-
- @Override
- public V getAndRemove(K key) {
- return delegate.getAndRemove(key);
- }
-
- @Override
- public boolean replace(K key, V oldValue, V newValue) {
- return delegate.replace(key, oldValue, newValue);
- }
-
- @Override
- public boolean replace(K key, V value) {
- return delegate.replace(key, value);
- }
-
- @Override
- public V getAndReplace(K key, V value) {
- return delegate.getAndReplace(key, value);
- }
-
- @Override
- public void removeAll(Set extends K> keys) {
- delegate.removeAll(keys);
- }
-
- @Override
- public void removeAll() {
- delegate.removeAll();
- }
-
- @Override
- public void clear() {
- delegate.clear();
- }
-
- @Override
- public > C getConfiguration(Class clazz) {
- return delegate.getConfiguration(clazz);
- }
-
- @Override
- public String getName() {
- return delegate.getName();
- }
-
- @Override
- public CacheManager getCacheManager() {
- return delegate.getCacheManager();
- }
-
- @Override
- public void close() {
- delegate.close();
- }
-
- @Override
- public boolean isClosed() {
- return delegate.isClosed();
- }
-
- @Override
- public T unwrap(Class clazz) {
- return delegate.unwrap(clazz);
- }
-
- @Override
- public void deregisterCacheEntryListener(CacheEntryListenerConfiguration cacheEntryListenerConfiguration) {
- delegate.deregisterCacheEntryListener(cacheEntryListenerConfiguration);
- }
-
- @Override
- public Iterator> iterator() {
- return delegate.iterator();
- }
-}
diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/contextproxy/CachingProviderProxy.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/contextproxy/CachingProviderProxy.java
deleted file mode 100644
index 83281f5c64d..00000000000
--- a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/contextproxy/CachingProviderProxy.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) [2016-2019] Payara Foundation and/or its affiliates. All rights reserved.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common Development
- * and Distribution License("CDDL") (collectively, the "License"). You
- * may not use this file except in compliance with the License. You can
- * obtain a copy of the License at
- * https://github.com/payara/Payara/blob/master/LICENSE.txt
- * See the License for the specific
- * language governing permissions and limitations under the License.
- *
- * When distributing the software, include this License Header Notice in each
- * file and include the License file at glassfish/legal/LICENSE.txt.
- *
- * GPL Classpath Exception:
- * The Payara Foundation designates this particular file as subject to the "Classpath"
- * exception as provided by the Payara Foundation in the GPL Version 2 section of the License
- * file that accompanied this code.
- *
- * Modifications:
- * If applicable, add the following below the License Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyright [year] [name of copyright owner]"
- *
- * Contributor(s):
- * If you wish your version of this file to be governed by only the CDDL or
- * only the GPL Version 2, indicate your decision by adding "[Contributor]
- * elects to include this software in this distribution under the [CDDL or GPL
- * Version 2] license." If you don't indicate a single choice of license, a
- * recipient has the option to distribute your version of this file under
- * either the CDDL, the GPL Version 2 or to extend the choice of license to
- * its licensees as provided above. However, if you add GPL Version 2 code
- * and therefore, elected the GPL Version 2 license, then the option applies
- * only if the new code is made subject to such option by the copyright
- * holder.
- */
-package fish.payara.nucleus.hazelcast.contextproxy;
-
-import java.net.URI;
-import java.util.Properties;
-import javax.cache.CacheManager;
-import javax.cache.configuration.OptionalFeature;
-import javax.cache.spi.CachingProvider;
-import org.glassfish.internal.api.ServerContext;
-
-/**
- *
- * @author lprimak
- */
-public class CachingProviderProxy implements CachingProvider {
- @Override
- public CacheManager getCacheManager(URI uri, ClassLoader cl, Properties prprts) {
- return new CacheManagerProxy(delegate.getCacheManager(uri, cl, prprts), serverContext);
- }
-
- @Override
- public CacheManager getCacheManager(URI uri, ClassLoader cl) {
- return new CacheManagerProxy(delegate.getCacheManager(uri, cl), serverContext);
- }
-
- @Override
- public CacheManager getCacheManager() {
- return new CacheManagerProxy(delegate.getCacheManager(), serverContext);
- }
-
- public CachingProviderProxy(CachingProvider delegate, ServerContext serverContext) {
- this.delegate = delegate;
- this.serverContext = serverContext;
- }
- private final CachingProvider delegate;
- private final ServerContext serverContext;
-
- @Override
- public ClassLoader getDefaultClassLoader() {
- return delegate.getDefaultClassLoader();
- }
-
- @Override
- public URI getDefaultURI() {
- return delegate.getDefaultURI();
- }
-
- @Override
- public Properties getDefaultProperties() {
- return delegate.getDefaultProperties();
- }
-
- @Override
- public void close() {
- delegate.close();
- }
-
- @Override
- public void close(ClassLoader classLoader) {
- delegate.close(classLoader);
- }
-
- @Override
- public void close(URI uri, ClassLoader classLoader) {
- delegate.close(uri, classLoader);
- }
-
- @Override
- public boolean isSupported(OptionalFeature optionalFeature) {
- return delegate.isSupported(optionalFeature);
- }
-}
diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/contextproxy/CompleteConfigurationProxy.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/contextproxy/CompleteConfigurationProxy.java
deleted file mode 100644
index 7a9b4413eb6..00000000000
--- a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/contextproxy/CompleteConfigurationProxy.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) [2016-2019] Payara Foundation and/or its affiliates. All rights reserved.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common Development
- * and Distribution License("CDDL") (collectively, the "License"). You
- * may not use this file except in compliance with the License. You can
- * obtain a copy of the License at
- * https://github.com/payara/Payara/blob/master/LICENSE.txt
- * See the License for the specific
- * language governing permissions and limitations under the License.
- *
- * When distributing the software, include this License Header Notice in each
- * file and include the License file at glassfish/legal/LICENSE.txt.
- *
- * GPL Classpath Exception:
- * The Payara Foundation designates this particular file as subject to the "Classpath"
- * exception as provided by the Payara Foundation in the GPL Version 2 section of the License
- * file that accompanied this code.
- *
- * Modifications:
- * If applicable, add the following below the License Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyright [year] [name of copyright owner]"
- *
- * Contributor(s):
- * If you wish your version of this file to be governed by only the CDDL or
- * only the GPL Version 2, indicate your decision by adding "[Contributor]
- * elects to include this software in this distribution under the [CDDL or GPL
- * Version 2] license." If you don't indicate a single choice of license, a
- * recipient has the option to distribute your version of this file under
- * either the CDDL, the GPL Version 2 or to extend the choice of license to
- * its licensees as provided above. However, if you add GPL Version 2 code
- * and therefore, elected the GPL Version 2 license, then the option applies
- * only if the new code is made subject to such option by the copyright
- * holder.
- */
-package fish.payara.nucleus.hazelcast.contextproxy;
-
-import org.glassfish.internal.api.JavaEEContextUtil;
-import org.glassfish.internal.api.JavaEEContextUtil.Context;
-import java.util.Collection;
-import java.util.Map;
-import javax.cache.Cache;
-import javax.cache.configuration.CompleteConfiguration;
-import javax.cache.configuration.Factory;
-import javax.cache.configuration.MutableConfiguration;
-import javax.cache.integration.CacheLoader;
-import javax.cache.integration.CacheLoaderException;
-import javax.cache.integration.CacheWriter;
-import javax.cache.integration.CacheWriterException;
-
-/**
- * Proxy all applicable factory calls
- * so Java EE context is propagated from within Hazelcast threads
- *
- * @author lprimak
- */
-class CompleteConfigurationProxy extends MutableConfiguration {
- public CompleteConfigurationProxy(CompleteConfiguration config, JavaEEContextUtil.Instance ctxUtilInst) {
- super(config);
- this.ctxUtilInst = ctxUtilInst;
- init();
- }
-
- private void init() {
- if(cacheLoaderFactory != null) {
- cacheLoaderFactory = proxyLoader(cacheLoaderFactory);
- }
- if(cacheWriterFactory != null) {
- cacheWriterFactory = proxyWriter(cacheWriterFactory);
- }
- }
-
- private Factory> proxyLoader(final Factory> fact) {
- return new Factory>() {
- @Override
- public CacheLoader create() {
- try (Context ctx = ctxUtilInst.pushContext()) {
- final CacheLoader loader = fact.create();
- return new CacheLoaderImpl(loader);
- }
- }
-
- class CacheLoaderImpl implements CacheLoader {
- public CacheLoaderImpl(CacheLoader loader) {
- this.loader = loader;
- }
-
- @Override
- public V load(K k) throws CacheLoaderException {
- try (Context context = ctxUtilInst.pushRequestContext()) {
- return loader.load(k);
- }
- }
-
- @Override
- public Map loadAll(Iterable extends K> itrbl) throws CacheLoaderException {
- try (Context context = ctxUtilInst.pushRequestContext()) {
- return loader.loadAll(itrbl);
- }
- }
-
- private final CacheLoader loader;
- }
-
- private static final long serialVersionUID = 1L;
- };
- }
-
- private Factory> proxyWriter(final Factory> fact) {
- return new Factory>() {
- @Override
- public CacheWriter create() {
- try (Context ctx = ctxUtilInst.pushContext()) {
- @SuppressWarnings("unchecked")
- final CacheWriter delegate = (CacheWriter) fact.create();
- return new CacheWriterImpl(delegate);
- }
- }
-
- class CacheWriterImpl implements CacheWriter {
- @Override
- public void write(Cache.Entry extends K, ? extends V> entry) throws CacheWriterException {
- try (Context context = ctxUtilInst.pushRequestContext()) {
- delegate.write(entry);
- }
- }
-
- @Override
- public void writeAll(Collection> clctn) throws CacheWriterException {
- try (Context context = ctxUtilInst.pushRequestContext()) {
- delegate.writeAll(clctn);
- }
- }
-
- @Override
- public void delete(Object o) throws CacheWriterException {
- try (Context context = ctxUtilInst.pushRequestContext()) {
- delegate.delete(o);
- }
- }
-
- @Override
- public void deleteAll(Collection> clctn) throws CacheWriterException {
- try (Context context = ctxUtilInst.pushRequestContext()) {
- delegate.deleteAll(clctn);
- }
- }
-
- public CacheWriterImpl(CacheWriter delegate) {
- this.delegate = delegate;
- }
-
- private final CacheWriter delegate;
- }
-
- private static final long serialVersionUID = 1L;
- };
- }
-
- private final JavaEEContextUtil.Instance ctxUtilInst;
- private static final long serialVersionUID = 1L;
-}
diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/resources/META-INF/services/com.hazelcast.spi.tenantcontrol.TenantControlFactory b/nucleus/payara-modules/hazelcast-bootstrap/src/main/resources/META-INF/services/com.hazelcast.spi.tenantcontrol.TenantControlFactory
new file mode 100644
index 00000000000..1396ebe0e3b
--- /dev/null
+++ b/nucleus/payara-modules/hazelcast-bootstrap/src/main/resources/META-INF/services/com.hazelcast.spi.tenantcontrol.TenantControlFactory
@@ -0,0 +1 @@
+fish.payara.nucleus.hazelcast.PayaraHazelcastTenantFactory
diff --git a/pom.xml b/pom.xml
index 00c98d4a792..dc4db153b01 100644
--- a/pom.xml
+++ b/pom.xml
@@ -154,7 +154,7 @@
1.0-2
2.10.2
1.25
- 4.1
+ 4.2
2.2
2.3.2
2.3.2
@@ -224,7 +224,7 @@
1.7
1.7
${project.build.outputDirectory}
- 0.2.3
+ 0.2.2