From efab4a7ddfb79c1afcd9b2e98241e689cbc14ca1 Mon Sep 17 00:00:00 2001 From: lprimak Date: Thu, 3 Dec 2020 13:59:30 -0600 Subject: [PATCH 1/7] fixed bugs in clustered singleton, added arquillian tests --- .../ClusteredSingletonLookupImplBase.java | 44 +++--- .../common/spi/ClusteredSingletonLookup.java | 4 + .../AbstractSingletonContainer.java | 7 +- .../cluster/ClusterScopeContext.java | 8 +- .../cluster/ClusterScopedInterceptor.java | 23 ++- .../cluster/ClusteredSingletonLookupImpl.java | 17 ++- .../licenseheader.txt | 43 ++++++ .../clustered-singleton-test/pom.xml | 55 +++++++ .../singleton/ClusteredAnnotatedAPI1.java | 65 ++++++++ .../singleton/ClusteredAnnotatedAPI2.java | 62 ++++++++ .../singleton/ClusteredEventBusStartup.java | 75 ++++++++++ .../singleton/ClusteredSingletonCDI1.java | 79 ++++++++++ .../singleton/ClusteredSingletonCDI2.java | 78 ++++++++++ .../singleton/ClusteredSingletonEjbXml.java | 61 ++++++++ .../singleton/ClusteredSingletonEjbXml2.java | 54 +++++++ .../ClusteredSingletonInterceptedEJB.java | 141 ++++++++++++++++++ .../clust/singleton/SingletonCommon.java | 73 +++++++++ .../com/flowlogix/clust/singleton/Stock.java | 57 +++++++ .../singleton/api/AnnotatedSingletonAPI.java | 52 +++++++ .../api/InterceptedSingletonAPI.java | 53 +++++++ .../clust/singleton/api/Secondary.java | 61 ++++++++ .../clust/singleton/api/SingletonAPI.java | 52 +++++++ .../interceptor/ClusteredInterceptor.java | 91 +++++++++++ .../interceptor/InterceptorCommon.java | 69 +++++++++ .../singleton/interceptor/TimerRanFlag.java | 53 +++++++ .../clust/singleton/startup/AppStartup.java | 91 +++++++++++ .../src/main/webapp/WEB-INF/ejb-jar.xml | 22 +++ .../main/webapp/WEB-INF/glassfish-ejb-jar.xml | 16 ++ .../src/main/webapp/WEB-INF/glassfish-web.xml | 25 ++++ .../src/main/webapp/WEB-INF/web.xml | 4 + .../src/main/webapp/index.html | 10 ++ .../singleton/ClusteredSingletonTest.java | 121 +++++++++++++++ .../NonSerializableDeploymentFailTest.java | 76 ++++++++++ .../ForFailures/META-INF/ejb-jar.xml | 15 ++ .../META-INF/glassfish-ejb-jar.xml | 10 ++ .../samples/clustered-singleton/pom.xml | 1 + 36 files changed, 1722 insertions(+), 46 deletions(-) create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/licenseheader.txt create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/pom.xml create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredAnnotatedAPI1.java create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredAnnotatedAPI2.java create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredEventBusStartup.java create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonCDI1.java create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonCDI2.java create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonEjbXml.java create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonEjbXml2.java create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonInterceptedEJB.java create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/SingletonCommon.java create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/Stock.java create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/AnnotatedSingletonAPI.java create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/InterceptedSingletonAPI.java create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/Secondary.java create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/SingletonAPI.java create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/ClusteredInterceptor.java create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/InterceptorCommon.java create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/TimerRanFlag.java create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/startup/AppStartup.java create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/ejb-jar.xml create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/glassfish-ejb-jar.xml create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/glassfish-web.xml create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/web.xml create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/index.html create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/com/flowlogix/clust/singleton/ClusteredSingletonTest.java create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/com/flowlogix/clust/singleton/expectedfail/NonSerializableDeploymentFailTest.java create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/resources/ForFailures/META-INF/ejb-jar.xml create mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/resources/ForFailures/META-INF/glassfish-ejb-jar.xml diff --git a/appserver/common/container-common/src/main/java/com/sun/enterprise/container/common/impl/util/ClusteredSingletonLookupImplBase.java b/appserver/common/container-common/src/main/java/com/sun/enterprise/container/common/impl/util/ClusteredSingletonLookupImplBase.java index b992b28b64e..c8ca7e1996b 100644 --- a/appserver/common/container-common/src/main/java/com/sun/enterprise/container/common/impl/util/ClusteredSingletonLookupImplBase.java +++ b/appserver/common/container-common/src/main/java/com/sun/enterprise/container/common/impl/util/ClusteredSingletonLookupImplBase.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 @@ -57,14 +57,15 @@ * @author lprimak */ public abstract class ClusteredSingletonLookupImplBase implements ClusteredSingletonLookup { - private final HazelcastCore hzCore = Globals.getDefaultHabitat().getService(HazelcastCore.class); private final String componentId; private final SingletonType singletonType; private final String keyPrefix; private final String mapKey; private final AtomicReference sessionHzKey = new AtomicReference<>(); - private final AtomicReference lockKey = new AtomicReference<>(); + private final AtomicReference lock = new AtomicReference<>(); + private final AtomicReference count = new AtomicReference<>(); + public ClusteredSingletonLookupImplBase(String componentId, SingletonType singletonType) { this.componentId = componentId; @@ -81,26 +82,13 @@ protected final String getMapKey() { return mapKey; } - protected final String getLockKey() { - return lockKey.updateAndGet(v -> v != null ? v : makeLockKey()); - } - public final String getSessionHzKey() { return sessionHzKey.updateAndGet(v -> v != null ? v : makeSessionHzKey()); } - /** - * {@link #getSessionHzKey()} and {@link #getLockKey()} are dependent on {@link #getClusteredSessionKey()} so should - * its value change cache keys need to be invalidated using this method. - */ - protected final void invalidateKeys() { - sessionHzKey.set(null); - lockKey.set(null); - } - @Override public ILock getDistributedLock() { - return getHazelcastInstance().getLock(getLockKey()); + return lock.updateAndGet(v -> v != null ? v : getHazelcastInstance().getLock(makeLockKey())); } @Override @@ -109,8 +97,8 @@ public IMap getClusteredSingletonMap() { } @Override - public IAtomicLong getClusteredUsageCount() { - return getHazelcastInstance().getAtomicLong(getSessionHzKey()+ "/count"); + public IAtomicLong getClusteredUsageCount() { + return count.updateAndGet(v -> v != null ? v : getHazelcastInstance().getAtomicLong(makeCountKey())); } private HazelcastInstance getHazelcastInstance() { @@ -130,6 +118,20 @@ public boolean isDistributedLockEnabled() { return isClusteredEnabled(); } + @Override + public void destroy() { + getClusteredSingletonMap().delete(getClusteredSessionKey()); + ILock oldLockValue = lock.getAndSet(null); + if (oldLockValue != null) { + oldLockValue.destroy(); + } + + IAtomicLong oldCountValue = count.getAndSet(null); + if (oldCountValue != null) { + oldCountValue.destroy(); + } + } + @Override public HazelcastCore getHazelcastCore() { return hzCore; @@ -147,6 +149,10 @@ private String makeLockKey() { return getSessionHzKey() + "/lock"; } + private String makeCountKey() { + return getSessionHzKey() + "/count"; + } + private String makeSessionHzKey() { return getKeyPrefix() + componentId + "/" + getClusteredSessionKey(); } diff --git a/appserver/common/container-common/src/main/java/com/sun/enterprise/container/common/spi/ClusteredSingletonLookup.java b/appserver/common/container-common/src/main/java/com/sun/enterprise/container/common/spi/ClusteredSingletonLookup.java index b74653d9d92..00085939c5f 100644 --- a/appserver/common/container-common/src/main/java/com/sun/enterprise/container/common/spi/ClusteredSingletonLookup.java +++ b/appserver/common/container-common/src/main/java/com/sun/enterprise/container/common/spi/ClusteredSingletonLookup.java @@ -57,6 +57,10 @@ public interface ClusteredSingletonLookup { String getClusteredSessionKey(); boolean isClusteredEnabled(); IAtomicLong getClusteredUsageCount(); + /** + * destroys usage count and distributed lock objects + */ + void destroy(); HazelcastCore getHazelcastCore(); enum SingletonType { diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/AbstractSingletonContainer.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/AbstractSingletonContainer.java index 1daa6b011b5..12dfe41829e 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/AbstractSingletonContainer.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/AbstractSingletonContainer.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -// Portions Copyright [2016-2019] [Payara Foundation and/or its affiliates] +// Portions Copyright [2016-2020] [Payara Foundation and/or its affiliates] package com.sun.ejb.containers; @@ -121,7 +121,7 @@ public abstract class AbstractSingletonContainer extends BaseContainer { private final InvocationInfo postConstructInvInfo; private final InvocationInfo preDestroyInvInfo; - protected final ClusteredSingletonLookup clusteredLookup = // + protected final ClusteredSingletonLookup clusteredLookup = new ClusteredSingletonLookupImpl(ejbDescriptor, componentId); @@ -712,8 +712,7 @@ public void destroy(Object obj) { EjbSessionDescriptor sessDesc = (EjbSessionDescriptor) ejbDescriptor; IAtomicLong count = clusteredLookup.getClusteredUsageCount(); if (count.decrementAndGet() <= 0) { - clusteredLookup.getClusteredSingletonMap().delete(clusteredLookup.getClusteredSessionKey()); - count.destroy(); + clusteredLookup.destroy(); } else if (sessDesc.dontCallPreDestroyOnDetach()) { doPreDestroy = false; } diff --git a/appserver/payara-appserver-modules/payara-micro-cdi/src/main/java/fish/payara/micro/cdi/extension/cluster/ClusterScopeContext.java b/appserver/payara-appserver-modules/payara-micro-cdi/src/main/java/fish/payara/micro/cdi/extension/cluster/ClusterScopeContext.java index 873e5b672b3..e4c7322e09c 100644 --- a/appserver/payara-appserver-modules/payara-micro-cdi/src/main/java/fish/payara/micro/cdi/extension/cluster/ClusterScopeContext.java +++ b/appserver/payara-appserver-modules/payara-micro-cdi/src/main/java/fish/payara/micro/cdi/extension/cluster/ClusterScopeContext.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 @@ -121,12 +121,12 @@ private TT getFromApplicationScoped(Contextual contextual, Optional Clustered getAnnotation(BeanManager beanManager, Class clazz) { return CdiUtils.getAnnotation(beanManager, clazz, Clustered.class).get(); } - private static String firstNonNull(String... items) { + static String firstNonNull(String... items) { for (String i : items) { if (i != null && !i.trim().isEmpty()) { return i; diff --git a/appserver/payara-appserver-modules/payara-micro-cdi/src/main/java/fish/payara/micro/cdi/extension/cluster/ClusterScopedInterceptor.java b/appserver/payara-appserver-modules/payara-micro-cdi/src/main/java/fish/payara/micro/cdi/extension/cluster/ClusterScopedInterceptor.java index f52ed943514..0676e8c94d7 100644 --- a/appserver/payara-appserver-modules/payara-micro-cdi/src/main/java/fish/payara/micro/cdi/extension/cluster/ClusterScopedInterceptor.java +++ b/appserver/payara-appserver-modules/payara-micro-cdi/src/main/java/fish/payara/micro/cdi/extension/cluster/ClusterScopedInterceptor.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 @@ -44,7 +44,6 @@ import fish.payara.cluster.DistributedLockType; import static fish.payara.micro.cdi.extension.cluster.ClusterScopeContext.getAnnotation; import static fish.payara.micro.cdi.extension.cluster.ClusterScopeContext.getBeanName; -import fish.payara.micro.cdi.extension.cluster.annotations.ClusterScoped; import fish.payara.micro.cdi.extension.cluster.annotations.ClusterScopedIntercepted; import java.io.IOException; import java.io.ObjectInputStream; @@ -53,7 +52,6 @@ import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.annotation.Priority; -import javax.enterprise.context.spi.Context; import javax.enterprise.inject.spi.Bean; import javax.enterprise.inject.spi.BeanManager; import javax.enterprise.inject.spi.CDI; @@ -88,7 +86,7 @@ public Object lockAndRefresh(InvocationContext invocationContext) throws Excepti return invocationContext.proceed(); } finally { - refresh(beanClass); + refresh(beanClass, invocationContext.getTarget()); unlock(beanClass, clusteredAnnotation); } } @@ -96,7 +94,8 @@ public Object lockAndRefresh(InvocationContext invocationContext) throws Excepti @PostConstruct Object postConstruct(InvocationContext invocationContext) throws Exception { Class beanClass = invocationContext.getTarget().getClass().getSuperclass(); - clusteredLookup.setClusteredSessionKey(beanClass); + Clustered clusteredAnnotation = getAnnotation(beanManager, beanClass); + clusteredLookup.setClusteredSessionKeyIfNotSet(beanClass, clusteredAnnotation); clusteredLookup.getClusteredUsageCount().incrementAndGet(); return invocationContext.proceed(); } @@ -105,11 +104,10 @@ Object postConstruct(InvocationContext invocationContext) throws Exception { Object preDestroy(InvocationContext invocationContext) throws Exception { Class beanClass = invocationContext.getTarget().getClass().getSuperclass(); Clustered clusteredAnnotation = getAnnotation(beanManager, beanClass); - clusteredLookup.setClusteredSessionKey(beanClass); + clusteredLookup.setClusteredSessionKeyIfNotSet(beanClass, clusteredAnnotation); IAtomicLong count = clusteredLookup.getClusteredUsageCount(); if (count.decrementAndGet() <= 0) { - clusteredLookup.getClusteredSingletonMap().delete(clusteredLookup.getClusteredSessionKey()); - count.destroy(); + clusteredLookup.destroy(); } else if (!clusteredAnnotation.callPreDestoyOnDetach()) { return null; } @@ -119,27 +117,26 @@ Object preDestroy(InvocationContext invocationContext) throws Exception { private void lock(Class beanClass, Clustered clusteredAnnotation) { if (clusteredAnnotation.lock() == DistributedLockType.LOCK) { - clusteredLookup.setClusteredSessionKey(beanClass); + clusteredLookup.setClusteredSessionKeyIfNotSet(beanClass, clusteredAnnotation); clusteredLookup.getDistributedLock().lock(); } } private void unlock(Class beanClass, Clustered clusteredAnnotation) { if (clusteredAnnotation.lock() == DistributedLockType.LOCK) { - clusteredLookup.setClusteredSessionKey(beanClass); + clusteredLookup.setClusteredSessionKeyIfNotSet(beanClass, clusteredAnnotation); clusteredLookup.getDistributedLock().unlock(); } } - private void refresh(Class beanClass) { + private void refresh(Class beanClass, Object instance) { Set> managedBeans = beanManager.getBeans(beanClass); if (managedBeans.size() > 1) { throw new IllegalArgumentException("Multiple beans found for " + beanClass); } Bean bean = managedBeans.iterator().next(); String beanName = getBeanName(bean, getAnnotation(beanManager, bean)); - Context ctx = beanManager.getContext(ClusterScoped.class); - clusteredLookup.getClusteredSingletonMap().put(beanName, ctx.get(bean)); + clusteredLookup.getClusteredSingletonMap().set(beanName, instance); } private void init() { diff --git a/appserver/payara-appserver-modules/payara-micro-cdi/src/main/java/fish/payara/micro/cdi/extension/cluster/ClusteredSingletonLookupImpl.java b/appserver/payara-appserver-modules/payara-micro-cdi/src/main/java/fish/payara/micro/cdi/extension/cluster/ClusteredSingletonLookupImpl.java index 6a34071061b..8e2d261e8b6 100644 --- a/appserver/payara-appserver-modules/payara-micro-cdi/src/main/java/fish/payara/micro/cdi/extension/cluster/ClusteredSingletonLookupImpl.java +++ b/appserver/payara-appserver-modules/payara-micro-cdi/src/main/java/fish/payara/micro/cdi/extension/cluster/ClusteredSingletonLookupImpl.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2018] 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 @@ -41,9 +41,11 @@ import com.sun.enterprise.container.common.impl.util.ClusteredSingletonLookupImplBase; import static com.sun.enterprise.container.common.spi.ClusteredSingletonLookup.SingletonType.CDI; +import fish.payara.cluster.Clustered; import static fish.payara.micro.cdi.extension.cluster.ClusterScopeContext.getAnnotation; import static fish.payara.micro.cdi.extension.cluster.ClusterScopeContext.getBeanName; import java.util.Set; +import java.util.concurrent.atomic.AtomicReference; import javax.enterprise.inject.spi.Bean; import javax.enterprise.inject.spi.BeanManager; @@ -53,9 +55,8 @@ * @author lprimak */ public class ClusteredSingletonLookupImpl extends ClusteredSingletonLookupImplBase { - private final BeanManager beanManager; - private final ThreadLocal sessionKey = new ThreadLocal<>(); + private final AtomicReference sessionKey = new AtomicReference<>(); public ClusteredSingletonLookupImpl(BeanManager beanManager, String componentId) { super(componentId, CDI); @@ -67,15 +68,19 @@ public String getClusteredSessionKey() { return sessionKey.get(); } - void setClusteredSessionKey(Class beanClass) { + void setClusteredSessionKeyIfNotSet(Class beanClass, Clustered clusteredAnnotation) { + sessionKey.updateAndGet(v -> v != null ? v : makeSessionKey(beanClass, clusteredAnnotation)); + } + + private String makeSessionKey(Class beanClass, Clustered clusteredAnnotation) { Set> managedBeans = beanManager.getBeans(beanClass); if (managedBeans.size() > 1) { throw new IllegalArgumentException("Multiple beans found for " + beanClass); } if (managedBeans.size() == 1) { Bean bean = managedBeans.iterator().next(); - sessionKey.set(getBeanName(bean, getAnnotation(beanManager, bean))); - invalidateKeys(); + return getBeanName(bean, getAnnotation(beanManager, bean)); } + return ClusterScopeContext.firstNonNull(clusteredAnnotation.keyName(), beanClass.getName()); } } diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/licenseheader.txt b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/licenseheader.txt new file mode 100644 index 00000000000..40a440215e5 --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/licenseheader.txt @@ -0,0 +1,43 @@ +<#if licenseFirst??> +${licenseFirst} + +${licensePrefix}DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +${licensePrefix} +${licensePrefix}Copyright (c) [2016-${date?date?string("yyyy")}] Payara Foundation and/or its affiliates. All rights reserved. +${licensePrefix} +${licensePrefix}The contents of this file are subject to the terms of either the GNU +${licensePrefix}General Public License Version 2 only ("GPL") or the Common Development +${licensePrefix}and Distribution License("CDDL") (collectively, the "License"). You +${licensePrefix}may not use this file except in compliance with the License. You can +${licensePrefix}obtain a copy of the License at +${licensePrefix}https://github.com/payara/Payara/blob/master/LICENSE.txt +${licensePrefix}See the License for the specific +${licensePrefix}language governing permissions and limitations under the License. +${licensePrefix} +${licensePrefix}When distributing the software, include this License Header Notice in each +${licensePrefix}file and include the License file at glassfish/legal/LICENSE.txt. +${licensePrefix} +${licensePrefix}GPL Classpath Exception: +${licensePrefix}The Payara Foundation designates this particular file as subject to the "Classpath" +${licensePrefix}exception as provided by the Payara Foundation in the GPL Version 2 section of the License +${licensePrefix}file that accompanied this code. +${licensePrefix} +${licensePrefix}Modifications: +${licensePrefix}If applicable, add the following below the License Header, with the fields +${licensePrefix}enclosed by brackets [] replaced by your own identifying information: +${licensePrefix}"Portions Copyright [year] [name of copyright owner]" +${licensePrefix} +${licensePrefix}Contributor(s): +${licensePrefix}If you wish your version of this file to be governed by only the CDDL or +${licensePrefix}only the GPL Version 2, indicate your decision by adding "[Contributor] +${licensePrefix}elects to include this software in this distribution under the [CDDL or GPL +${licensePrefix}Version 2] license." If you don't indicate a single choice of license, a +${licensePrefix}recipient has the option to distribute your version of this file under +${licensePrefix}either the CDDL, the GPL Version 2 or to extend the choice of license to +${licensePrefix}its licensees as provided above. However, if you add GPL Version 2 code +${licensePrefix}and therefore, elected the GPL Version 2 license, then the option applies +${licensePrefix}only if the new code is made subject to such option by the copyright +${licensePrefix}holder. +<#if licenseLast??> +${licenseLast} + \ No newline at end of file diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/pom.xml b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/pom.xml new file mode 100644 index 00000000000..e31c5ae72da --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + clustered-singleton + war + + Payara Tests - Clustered Singleton Sample and Test + + + fish.payara.samples + clustered-singleton-parent + 5.2020.7-SNAPSHOT + + + + UTF-8 + false + + + + + org.projectlombok + lombok + 1.18.10 + provided + + + jakarta.platform + jakarta.jakartaee-web-api + provided + + + fish.payara.api + payara-api + provided + + + + junit + junit + test + + + org.hamcrest + hamcrest-library + 1.3 + test + + + org.jboss.arquillian.junit + arquillian-junit-container + test + + + diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredAnnotatedAPI1.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredAnnotatedAPI1.java new file mode 100644 index 00000000000..f79faaf696d --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredAnnotatedAPI1.java @@ -0,0 +1,65 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-2017] 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 com.flowlogix.clust.singleton; + +import com.flowlogix.clust.singleton.api.AnnotatedSingletonAPI; +import fish.payara.cluster.Clustered; +import javax.ejb.Singleton; +import javax.enterprise.inject.Vetoed; +import lombok.experimental.Delegate; +import lombok.extern.java.Log; + +/** + * + * @author lprimak + */ +@Clustered(keyName = "ClusteredAnnotated1") +@Singleton(name = "ClusteredSingletonAnnotatedEJB1") +@Vetoed @Log +public class ClusteredAnnotatedAPI1 implements AnnotatedSingletonAPI { + @Override + public String getHello() { + return String.format("Clustered Annotated API EJB Hello (1): %s", sc); + } + + protected final @Delegate SingletonCommon sc = new SingletonCommon(this); + + private static final long serialVersionUID = 1L; +} diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredAnnotatedAPI2.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredAnnotatedAPI2.java new file mode 100644 index 00000000000..09b9559a0af --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredAnnotatedAPI2.java @@ -0,0 +1,62 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-2017] 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 com.flowlogix.clust.singleton; + +import com.flowlogix.clust.singleton.api.AnnotatedSingletonAPI; +import fish.payara.cluster.Clustered; +import javax.ejb.Singleton; +import javax.enterprise.inject.Vetoed; +import lombok.extern.java.Log; + +/** + * + * @author lprimak + */ +@Clustered(keyName = "ClusteredAnnotated1") +@Singleton(name = "ClusteredSingletonAnnotatedEJB2") +@Vetoed @Log +public class ClusteredAnnotatedAPI2 extends ClusteredAnnotatedAPI1 implements AnnotatedSingletonAPI { + @Override + public String getHello() { + return String.format("Clustered Annotated API EJB Hello (2): %s", sc); + } + + private static final long serialVersionUID = 1L; +} diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredEventBusStartup.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredEventBusStartup.java new file mode 100644 index 00000000000..ed48cd81230 --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredEventBusStartup.java @@ -0,0 +1,75 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-2017] 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 com.flowlogix.clust.singleton; + +import fish.payara.cluster.Clustered; +import fish.payara.micro.cdi.Outbound; +import java.io.Serializable; +import java.util.logging.Level; +import javax.ejb.Schedule; +import javax.ejb.Singleton; +import javax.ejb.Startup; +import javax.enterprise.event.Event; +import javax.inject.Inject; +import lombok.extern.java.Log; + +/** + * + * @author lprimak + */ + +@Clustered +@Singleton @Startup @Log +public class ClusteredEventBusStartup implements Serializable { + @Schedule(hour = "*", minute="*", second = "*/1", persistent = false) + private void generatePrice() { + ++numInvocations; + stock = new Stock("PYA", "Some very long description of Payara", Math.random() * 100.0); + log.log(Level.INFO, "Sock: {0}, numInvocations: {1}", new Object[] { stock, numInvocations }); + stockEvents.fire(stock); + } + + private Stock stock; + private int numInvocations; + @Inject + @Outbound(loopBack = true) + private Event stockEvents; + private static final long serialVersionUID = 1L; +} diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonCDI1.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonCDI1.java new file mode 100644 index 00000000000..cf84333d8cc --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonCDI1.java @@ -0,0 +1,79 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-2017] 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 com.flowlogix.clust.singleton; + +import com.flowlogix.clust.singleton.api.SingletonAPI; +import fish.payara.cluster.Clustered; +import fish.payara.cluster.DistributedLockType; +import java.io.Serializable; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Default; +import lombok.experimental.Delegate; +import lombok.extern.java.Log; + +/** + * + * @author lprimak + */ +@ApplicationScoped +@Clustered(keyName = "ClusteredSingletonCDI1", lock = DistributedLockType.LOCK) +@Log +@Default +public class ClusteredSingletonCDI1 implements SingletonAPI, Serializable { + @Override + public String getHello() { + return String.format("CDI Bean Hello (1): %s", sc); + } + + @PostConstruct + void postConstruct() { + log.info("CDI1 PostConstruct"); + + } + @PreDestroy + void preDestroy() { + log.info("CDI1 PreDestroy"); + } + + protected final @Delegate SingletonCommon sc = new SingletonCommon(this); + private static final long serialVersionUID = 1L; +} diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonCDI2.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonCDI2.java new file mode 100644 index 00000000000..25cde4a2a84 --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonCDI2.java @@ -0,0 +1,78 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-2017] 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 com.flowlogix.clust.singleton; + +import com.flowlogix.clust.singleton.api.Secondary; +import fish.payara.cluster.Clustered; +import fish.payara.cluster.DistributedLockType; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.enterprise.context.ApplicationScoped; +import lombok.extern.java.Log; + +/** + * + * @author lprimak + */ +@ApplicationScoped +@Clustered(keyName = "ClusteredSingletonCDI1", lock = DistributedLockType.LOCK) +@Log +@Secondary +public class ClusteredSingletonCDI2 extends ClusteredSingletonCDI1 { + @Override + public String getHello() { + return String.format("CDI Bean Hello (2): %s", sc); + } + + @PostConstruct + @Override + void postConstruct() { + log.info("CDI2 PostConstruct"); + + } + + @PreDestroy + @Override + void preDestroy() { + log.info("CDI2 PreDestroy"); + } + + private static final long serialVersionUID = 1L; +} diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonEjbXml.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonEjbXml.java new file mode 100644 index 00000000000..4f249726a27 --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonEjbXml.java @@ -0,0 +1,61 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-2017] 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 com.flowlogix.clust.singleton; + +import com.flowlogix.clust.singleton.api.SingletonAPI; +import java.io.Serializable; +import javax.enterprise.inject.Vetoed; +import lombok.experimental.Delegate; + +/** + * + * @author lprimak + */ +@Vetoed +public class ClusteredSingletonEjbXml implements SingletonAPI, Serializable { + @Override + public String getHello() { + return String.format("Descriptor EJB Hello: %s", sc); + } + + private final @Delegate SingletonCommon sc = new SingletonCommon(this); + + private static final long serialVersionUID = 1L; +} diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonEjbXml2.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonEjbXml2.java new file mode 100644 index 00000000000..8d428ccfe82 --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonEjbXml2.java @@ -0,0 +1,54 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-2017] 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 com.flowlogix.clust.singleton; + +import com.flowlogix.clust.singleton.api.SingletonAPI; +import java.io.Serializable; +import javax.enterprise.inject.Vetoed; + +/** + * + * @author lprimak + */ +@Vetoed +public class ClusteredSingletonEjbXml2 extends ClusteredSingletonEjbXml implements SingletonAPI, Serializable { + + private static final long serialVersionUID = 1L; +} diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonInterceptedEJB.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonInterceptedEJB.java new file mode 100644 index 00000000000..06c6e503368 --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonInterceptedEJB.java @@ -0,0 +1,141 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-2017] 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 com.flowlogix.clust.singleton; + +import com.flowlogix.clust.singleton.api.InterceptedSingletonAPI; +import com.flowlogix.clust.singleton.interceptor.ClusteredInterceptor; +import com.flowlogix.clust.singleton.interceptor.TimerRanFlag; +import fish.payara.cluster.Clustered; +import java.io.Serializable; +import java.util.logging.Level; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.annotation.Resource; +import javax.ejb.Asynchronous; +import javax.ejb.ConcurrencyManagement; +import javax.ejb.ConcurrencyManagementType; +import javax.ejb.EJB; +import javax.ejb.SessionContext; +import javax.ejb.Singleton; +import javax.ejb.Timeout; +import javax.ejb.TimerConfig; +import javax.ejb.TimerService; +import javax.enterprise.inject.Vetoed; +import javax.interceptor.Interceptors; +import lombok.SneakyThrows; +import lombok.experimental.Delegate; +import lombok.extern.java.Log; + +/** + * + * @author lprimak + */ +@Clustered +@Singleton(name = "ClusteredSingletonInterceptedEJB") +@Vetoed +@Log +@ConcurrencyManagement(ConcurrencyManagementType.BEAN) +@Interceptors(ClusteredInterceptor.class) +public class ClusteredSingletonInterceptedEJB implements InterceptedSingletonAPI, Serializable { + public ClusteredSingletonInterceptedEJB() { + log.log(Level.INFO, "{0} - Constructor", getClass().getSimpleName()); + } + + @PostConstruct + void init() { + log.log(Level.INFO, "{0} - PostConstruct", getClass().getSimpleName()); + ts.createSingleActionTimer(0, new TimerConfig(null, false)); + } + + @PreDestroy + void destroy() { + log.log(Level.INFO, "{0} - PreDestroy", getClass().getSimpleName()); + } + + @Override + public String getHello() { + invocationIntercepted = (ctx.getContextData().get(ClusteredInterceptor.AroundInvokeKey) != null) ? + ctx.getContextData().get(ClusteredInterceptor.AroundInvokeKey).equals(ClusteredInterceptor.AroundInvokeValue) + : "".equals(ClusteredInterceptor.AroundInvokeValue); + return String.format("Intercepted Annotated EJB Hello: %s, consistent: %s", sc, isConsistent()? "yes" : "NO!!!"); + } + + @Override + @SneakyThrows(InterruptedException.class) + public void waitForTimer() { + for(int ii = 0; ii < 1000 && !timerRan.isTimerRan(); ++ii) { + Thread.sleep(5); + } + } + + @Override + public boolean isConsistent() { + return constructorIntercepted && timerIntercepted && invocationIntercepted; + } + + public void setConstructorInterceptorCalled() { + constructorIntercepted = true; + } + + @Override + @Asynchronous + public void async() { + log.info(String.format("Async called: %s", getState())); + } + + @Timeout + private void timeout() { + log.info("Timer Action"); + timerRan.setTimerRan(true); + timerIntercepted = (ctx.getContextData().get(ClusteredInterceptor.AroundTimeoutKey) != null) ? + ctx.getContextData().get(ClusteredInterceptor.AroundTimeoutKey).equals(ClusteredInterceptor.AroundTimeoutValue) + : "".equals(ClusteredInterceptor.AroundTimeoutValue); + } + + private final @Delegate SingletonCommon sc = new SingletonCommon(this); + private transient @Resource TimerService ts; + private transient @Resource SessionContext ctx; + private boolean constructorIntercepted; + private boolean timerIntercepted; + private boolean invocationIntercepted; + private transient @EJB TimerRanFlag timerRan; + + private static final long serialVersionUID = 1L; +} diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/SingletonCommon.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/SingletonCommon.java new file mode 100644 index 00000000000..16ad3556f13 --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/SingletonCommon.java @@ -0,0 +1,73 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-2017] 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 com.flowlogix.clust.singleton; + +import java.io.Serializable; +import java.net.InetAddress; +import java.util.Objects; +import java.util.UUID; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; +import lombok.extern.java.Log; + +/** + * + * @author lprimak + */ +@RequiredArgsConstructor +@Log +public class SingletonCommon implements Serializable { + @SneakyThrows + @Override + public String toString() { + return String.format("instance = 0x%x, host = %s, State(UUID) = %s", + Objects.hashCode(parent), InetAddress.getLocalHost().getHostName(), getState()); + } + + public void randomizeState() { + state = UUID.randomUUID(); + } + + private final Object parent; + private @Getter UUID state = UUID.randomUUID(); + + private static final long serialVersionUID = 1L; +} diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/Stock.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/Stock.java new file mode 100644 index 00000000000..fadaa6fa3dd --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/Stock.java @@ -0,0 +1,57 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-2017] 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 com.flowlogix.clust.singleton; + +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Data; + +/** + * + * @author lprimak + */ +@Data @AllArgsConstructor +public class Stock implements Serializable { + private String cusip; + private String description; + private Double price; + + private static final long serialVersionUID = 1L; +} diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/AnnotatedSingletonAPI.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/AnnotatedSingletonAPI.java new file mode 100644 index 00000000000..9f9f4720999 --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/AnnotatedSingletonAPI.java @@ -0,0 +1,52 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-2017] 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 com.flowlogix.clust.singleton.api; + +import java.io.Serializable; +import javax.ejb.Local; + +/** + * + * @author lprimak + */ +@Local +public interface AnnotatedSingletonAPI extends SingletonAPI, Serializable { + // intentionally left blank +} diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/InterceptedSingletonAPI.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/InterceptedSingletonAPI.java new file mode 100644 index 00000000000..4c5b1dbcdc8 --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/InterceptedSingletonAPI.java @@ -0,0 +1,53 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-2017] 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 com.flowlogix.clust.singleton.api; + +import javax.ejb.Local; + +/** + * + * @author lprimak + */ +@Local +public interface InterceptedSingletonAPI extends SingletonAPI { + void waitForTimer(); + boolean isConsistent(); + void async(); +} diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/Secondary.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/Secondary.java new file mode 100644 index 00000000000..bd60a094662 --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/Secondary.java @@ -0,0 +1,61 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-2017] 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 com.flowlogix.clust.singleton.api; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.inject.Qualifier; + +/** + * + * @author lprimak + */ +@Qualifier +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD, ElementType.TYPE, ElementType.PARAMETER, ElementType.METHOD}) +@Inherited +@Documented +public @interface Secondary { + +} diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/SingletonAPI.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/SingletonAPI.java new file mode 100644 index 00000000000..f5397d04064 --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/SingletonAPI.java @@ -0,0 +1,52 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-2017] 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 com.flowlogix.clust.singleton.api; + +import java.util.UUID; + +/** + * + * @author lprimak + */ +public interface SingletonAPI { + String getHello(); + UUID getState(); + void randomizeState(); +} diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/ClusteredInterceptor.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/ClusteredInterceptor.java new file mode 100644 index 00000000000..49cb4cf8abb --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/ClusteredInterceptor.java @@ -0,0 +1,91 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-2017] 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 com.flowlogix.clust.singleton.interceptor; + +import com.flowlogix.clust.singleton.ClusteredSingletonInterceptedEJB; +import java.io.Serializable; +import javax.interceptor.AroundConstruct; +import javax.interceptor.AroundInvoke; +import javax.interceptor.AroundTimeout; +import javax.interceptor.InvocationContext; +import lombok.Cleanup; +import lombok.SneakyThrows; +import lombok.extern.java.Log; + +/** + * + * @author lprimak + */ +@Log +public class ClusteredInterceptor implements Serializable { + @AroundConstruct + @SneakyThrows + public void aroundConstruct(InvocationContext ctx) { + log.info("AroundConstruct"); + ctx.proceed(); + ClusteredSingletonInterceptedEJB target = (ClusteredSingletonInterceptedEJB)ctx.getTarget(); + target.setConstructorInterceptorCalled(); + } + + @AroundTimeout + @SneakyThrows + public Object aroundTimeout(InvocationContext ctx) { + log.info("AroundTimeout"); + @Cleanup InterceptorCommon.InterceptorData cd = ic.setData(ctx, AroundTimeoutKey, AroundTimeoutValue); + return ctx.proceed(); + } + + @AroundInvoke + @SneakyThrows + public Object aroundInvoke(InvocationContext ctx) { + log.info("AroundInvoke"); + @Cleanup InterceptorCommon.InterceptorData cd = ic.setData(ctx, AroundInvokeKey, AroundInvokeValue); + return ctx.proceed(); + } + + + public static final String AroundTimeoutKey = "AroundTimeout"; + public static final String AroundTimeoutValue = "timeout"; + public static final String AroundInvokeKey = "AroundInvoke"; + public static final String AroundInvokeValue = "invoke"; + + + private final InterceptorCommon ic = new InterceptorCommon(); +} diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/InterceptorCommon.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/InterceptorCommon.java new file mode 100644 index 00000000000..dc62643bd70 --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/InterceptorCommon.java @@ -0,0 +1,69 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-2017] 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 com.flowlogix.clust.singleton.interceptor; + +import java.io.Serializable; +import javax.interceptor.InvocationContext; +import lombok.RequiredArgsConstructor; + +/** + * + * @author lprimak + */ +public class InterceptorCommon implements Serializable { + public InterceptorData setData(InvocationContext ctx, String key, Object value) { + return new InterceptorData(ctx, key).setData(value); + } + + @RequiredArgsConstructor + public static class InterceptorData { + public InterceptorData setData(Object value) { + ctx.getContextData().put(key, value); + return this; + } + + public void close() { + ctx.getContextData().remove(key); + } + + private final InvocationContext ctx; + private final String key; + } +} diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/TimerRanFlag.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/TimerRanFlag.java new file mode 100644 index 00000000000..2a41273fc8f --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/TimerRanFlag.java @@ -0,0 +1,53 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-2018] 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 com.flowlogix.clust.singleton.interceptor; + +import javax.ejb.Singleton; +import lombok.Getter; +import lombok.Setter; + +/** + * + * @author lprimak + */ +@Singleton +public class TimerRanFlag { + private @Getter @Setter boolean timerRan; +} diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/startup/AppStartup.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/startup/AppStartup.java new file mode 100644 index 00000000000..acac7dcbeab --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/startup/AppStartup.java @@ -0,0 +1,91 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-2017] 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 com.flowlogix.clust.singleton.startup; + +import com.flowlogix.clust.singleton.api.InterceptedSingletonAPI; +import com.flowlogix.clust.singleton.api.SingletonAPI; +import javax.annotation.PostConstruct; +import javax.annotation.Resource; +import javax.ejb.EJB; +import javax.ejb.Singleton; +import javax.ejb.Startup; +import javax.ejb.Timeout; +import javax.ejb.TimerConfig; +import javax.ejb.TimerService; +import javax.inject.Inject; +import lombok.extern.java.Log; + +/** + * + * @author lprimak + */ +@Singleton +@Startup +@Log +public class AppStartup { + @PostConstruct + void postConstruct() { + ts.createSingleActionTimer(0, new TimerConfig(null, false)); + } + + @Timeout + void init() { + annotatedAPI.waitForTimer(); + log.info("First Time ..."); + doInit(); + log.info("Second Time ..."); + doInit(); + } + + + void doInit() { + log.info(descAPI.getHello()); + log.info(annotatedAPI.getHello()); + log.info(cdiAPI.getHello()); + cdiAPI.getHello(); + annotatedAPI.async(); + } + + + private @EJB(lookup = "java:module/ClusteredSingletonEjbXml1") SingletonAPI descAPI; + private @EJB InterceptedSingletonAPI annotatedAPI; + private @Inject SingletonAPI cdiAPI; + private @Resource TimerService ts; +} diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/ejb-jar.xml b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/ejb-jar.xml new file mode 100644 index 00000000000..6a129a5f86e --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/ejb-jar.xml @@ -0,0 +1,22 @@ + + + + + ClusteredSingletonEjbXml1 + com.flowlogix.clust.singleton.api.SingletonAPI + com.flowlogix.clust.singleton.ClusteredSingletonEjbXml + Singleton + Container + + + ClusteredSingletonEjbXml2 + com.flowlogix.clust.singleton.api.SingletonAPI + com.flowlogix.clust.singleton.ClusteredSingletonEjbXml2 + Singleton + Container + + + diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/glassfish-ejb-jar.xml b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/glassfish-ejb-jar.xml new file mode 100644 index 00000000000..7fd7efe07ce --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/glassfish-ejb-jar.xml @@ -0,0 +1,16 @@ + + + + + ClusteredSingletonEjbXml1 + true + ClusteredSingletonEjbXml + + + ClusteredSingletonEjbXml2 + true + ClusteredSingletonEjbXml + + + true + diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/glassfish-web.xml b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/glassfish-web.xml new file mode 100644 index 00000000000..673cc06fc51 --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/glassfish-web.xml @@ -0,0 +1,25 @@ + + + + + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/web.xml b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000000..d8feb7e697e --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,4 @@ + + + + diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/index.html b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/index.html new file mode 100644 index 00000000000..3368e9c377e --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/index.html @@ -0,0 +1,10 @@ + + + + Start Page + + + +

Hello World!

+ + diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/com/flowlogix/clust/singleton/ClusteredSingletonTest.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/com/flowlogix/clust/singleton/ClusteredSingletonTest.java new file mode 100644 index 00000000000..32efbf177ef --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/com/flowlogix/clust/singleton/ClusteredSingletonTest.java @@ -0,0 +1,121 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-2017] 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 com.flowlogix.clust.singleton; + +import com.flowlogix.clust.singleton.api.AnnotatedSingletonAPI; +import com.flowlogix.clust.singleton.api.InterceptedSingletonAPI; +import com.flowlogix.clust.singleton.api.Secondary; +import com.flowlogix.clust.singleton.api.SingletonAPI; +import java.io.File; +import javax.ejb.EJB; +import javax.ejb.EJBException; +import javax.inject.Inject; +import lombok.extern.java.Log; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.startsWith; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * + * @author lprimak + */ +@RunWith(Arquillian.class) +@Log +public class ClusteredSingletonTest { + @Deployment + public static WebArchive createDeployment() { + return ShrinkWrap.create(WebArchive.class, "cst.war") + .addPackages(false, "com.flowlogix.clust.singleton", + "com.flowlogix.clust.singleton.api", "com.flowlogix.clust.singleton.interceptor") + .addAsWebInfResource(new File(WEBAPP_SRC, "WEB-INF/ejb-jar.xml")) + .addAsWebInfResource(new File(WEBAPP_SRC, "WEB-INF/glassfish-ejb-jar.xml")); + } + + @Test + public void descriptorApi() { + assertThat(descAPI1.getHello(), startsWith("Descriptor EJB Hello")); + assertThat(descAPI1.getState(), equalTo(descAPI2.getState())); + } + + @Test + public void annotatedApi() { + assertThat(annotatedApi1.getHello(), startsWith("Clustered Annotated API EJB Hello")); + assertThat(annotatedApi1.getState(), equalTo(annotatedApi2.getState())); + } + + @Test + public void cdiApi() { + assertThat(cdiApi1.getHello(), startsWith("CDI Bean Hello")); + assertThat(cdiApi1.getState(), equalTo(cdiApi2.getState())); + } + + @Test(expected = EJBException.class) + public void twoMethodsNotEqual() { + assertThat(annotatedApi1.getHello(), not(equalTo(annotatedApi2.getHello()))); + } + + @Test + public void interceptor() { + assertThat(interceptedAPI.getHello(), startsWith("Intercepted Annotated EJB Hello")); + interceptedAPI.waitForTimer(); + assertThat(interceptedAPI.isConsistent(), is(true)); + } + + + private @EJB(lookup = "java:module/ClusteredSingletonEjbXml1") SingletonAPI descAPI1; + private @EJB(lookup = "java:module/ClusteredSingletonEjbXml2") SingletonAPI descAPI2; + + private @EJB(lookup = "java:module/ClusteredSingletonAnnotatedEJB1") AnnotatedSingletonAPI annotatedApi1; + private @EJB(lookup = "java:module/ClusteredSingletonAnnotatedEJB2") AnnotatedSingletonAPI annotatedApi2; + + private @EJB InterceptedSingletonAPI interceptedAPI; + private @Inject SingletonAPI cdiApi1; + private @Inject @Secondary SingletonAPI cdiApi2; + + public static final String WEBAPP_SRC = "src/main/webapp"; +} diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/com/flowlogix/clust/singleton/expectedfail/NonSerializableDeploymentFailTest.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/com/flowlogix/clust/singleton/expectedfail/NonSerializableDeploymentFailTest.java new file mode 100644 index 00000000000..f02de136bfd --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/com/flowlogix/clust/singleton/expectedfail/NonSerializableDeploymentFailTest.java @@ -0,0 +1,76 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-2017] 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 com.flowlogix.clust.singleton.expectedfail; + +import fish.payara.cluster.Clustered; +import javax.ejb.Singleton; +import lombok.extern.java.Log; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.ShouldThrowException; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * + * @author lprimak + */ +@RunWith(Arquillian.class) +@Log +public class NonSerializableDeploymentFailTest { + @Deployment @ShouldThrowException(RuntimeException.class) + public static WebArchive createDeployment() { + log.info("Please Ignore the following SEVERE: exit_code, it's expected"); + return ShrinkWrap.create(WebArchive.class) + .addPackage(NonSerializableDeploymentFailTest.class.getPackage()); + } + + @Clustered + @Singleton + static public class NonSerializableClusteredSingleton { + + } + + @Test + public void dummy() { + } +} diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/resources/ForFailures/META-INF/ejb-jar.xml b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/resources/ForFailures/META-INF/ejb-jar.xml new file mode 100644 index 00000000000..57551821021 --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/resources/ForFailures/META-INF/ejb-jar.xml @@ -0,0 +1,15 @@ + + + + + NonSerializableSingleton + com.flowlogix.clust.singleton.api.SingletonAPI + com.flowlogix.clust.singleton.expectedfail.NonSerializableSingleton + Singleton + Container + + + diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/resources/ForFailures/META-INF/glassfish-ejb-jar.xml b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/resources/ForFailures/META-INF/glassfish-ejb-jar.xml new file mode 100644 index 00000000000..435f9edbb38 --- /dev/null +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/resources/ForFailures/META-INF/glassfish-ejb-jar.xml @@ -0,0 +1,10 @@ + + + + + ClusteredSingletonEjbXml + true + true + + + diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/pom.xml b/appserver/tests/payara-samples/samples/clustered-singleton/pom.xml index 247cfbf93c2..17fb5c7c947 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/pom.xml +++ b/appserver/tests/payara-samples/samples/clustered-singleton/pom.xml @@ -62,6 +62,7 @@ clustered-singleton-ejb + clustered-singleton-test From d55f76583f6e4088d5bef177ea388603745f0b56 Mon Sep 17 00:00:00 2001 From: lprimak Date: Thu, 3 Dec 2020 15:55:11 -0600 Subject: [PATCH 2/7] clustered singleton-related CP objects can't be destroyed --- .../impl/util/ClusteredSingletonLookupImplBase.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/appserver/common/container-common/src/main/java/com/sun/enterprise/container/common/impl/util/ClusteredSingletonLookupImplBase.java b/appserver/common/container-common/src/main/java/com/sun/enterprise/container/common/impl/util/ClusteredSingletonLookupImplBase.java index c8ca7e1996b..e4828842ff6 100644 --- a/appserver/common/container-common/src/main/java/com/sun/enterprise/container/common/impl/util/ClusteredSingletonLookupImplBase.java +++ b/appserver/common/container-common/src/main/java/com/sun/enterprise/container/common/impl/util/ClusteredSingletonLookupImplBase.java @@ -121,14 +121,13 @@ public boolean isDistributedLockEnabled() { @Override public void destroy() { getClusteredSingletonMap().delete(getClusteredSessionKey()); - ILock oldLockValue = lock.getAndSet(null); - if (oldLockValue != null) { - oldLockValue.destroy(); - } + // CP locks and AtomicLong's can't be destroyed, as per https://github.com/hazelcast/hazelcast/issues/17498 + // so we just release the references to them and reset to zero where we can + lock.set(null); IAtomicLong oldCountValue = count.getAndSet(null); if (oldCountValue != null) { - oldCountValue.destroy(); + oldCountValue.set(0); } } From 5c7a88138cd57804160795b969c5bac6bff5f494 Mon Sep 17 00:00:00 2001 From: lprimak Date: Fri, 4 Dec 2020 14:50:55 -0600 Subject: [PATCH 3/7] renamed packages --- .../licenseheader.txt | 43 ------------------- .../clustered-singleton-test/pom.xml | 1 - .../singleton/ClusteredAnnotatedAPI1.java | 4 +- .../singleton/ClusteredAnnotatedAPI2.java | 4 +- .../singleton/ClusteredEventBusStartup.java | 2 +- .../singleton/ClusteredSingletonCDI1.java | 4 +- .../singleton/ClusteredSingletonCDI2.java | 4 +- .../singleton/ClusteredSingletonEjbXml.java | 4 +- .../singleton/ClusteredSingletonEjbXml2.java | 4 +- .../ClusteredSingletonInterceptedEJB.java | 8 ++-- .../clustered}/singleton/SingletonCommon.java | 2 +- .../samples/clustered}/singleton/Stock.java | 2 +- .../singleton/api/AnnotatedSingletonAPI.java | 2 +- .../api/InterceptedSingletonAPI.java | 2 +- .../clustered}/singleton/api/Secondary.java | 2 +- .../singleton/api/SingletonAPI.java | 2 +- .../interceptor/ClusteredInterceptor.java | 4 +- .../interceptor/InterceptorCommon.java | 2 +- .../singleton/interceptor/TimerRanFlag.java | 2 +- .../singleton/startup/AppStartup.java | 6 +-- .../src/main/webapp/WEB-INF/ejb-jar.xml | 8 ++-- .../singleton/ClusteredSingletonTest.java | 15 ++++--- .../NonSerializableDeploymentFailTest.java | 2 +- .../ForFailures/META-INF/ejb-jar.xml | 4 +- 24 files changed, 45 insertions(+), 88 deletions(-) delete mode 100644 appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/licenseheader.txt rename appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/{com/flowlogix/clust => fish/payara/samples/clustered}/singleton/ClusteredAnnotatedAPI1.java (95%) rename appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/{com/flowlogix/clust => fish/payara/samples/clustered}/singleton/ClusteredAnnotatedAPI2.java (95%) rename appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/{com/flowlogix/clust => fish/payara/samples/clustered}/singleton/ClusteredEventBusStartup.java (98%) rename appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/{com/flowlogix/clust => fish/payara/samples/clustered}/singleton/ClusteredSingletonCDI1.java (96%) rename appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/{com/flowlogix/clust => fish/payara/samples/clustered}/singleton/ClusteredSingletonCDI2.java (96%) rename appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/{com/flowlogix/clust => fish/payara/samples/clustered}/singleton/ClusteredSingletonEjbXml.java (95%) rename appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/{com/flowlogix/clust => fish/payara/samples/clustered}/singleton/ClusteredSingletonEjbXml2.java (95%) rename appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/{com/flowlogix/clust => fish/payara/samples/clustered}/singleton/ClusteredSingletonInterceptedEJB.java (94%) rename appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/{com/flowlogix/clust => fish/payara/samples/clustered}/singleton/SingletonCommon.java (98%) rename appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/{com/flowlogix/clust => fish/payara/samples/clustered}/singleton/Stock.java (97%) rename appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/{com/flowlogix/clust => fish/payara/samples/clustered}/singleton/api/AnnotatedSingletonAPI.java (97%) rename appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/{com/flowlogix/clust => fish/payara/samples/clustered}/singleton/api/InterceptedSingletonAPI.java (97%) rename appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/{com/flowlogix/clust => fish/payara/samples/clustered}/singleton/api/Secondary.java (97%) rename appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/{com/flowlogix/clust => fish/payara/samples/clustered}/singleton/api/SingletonAPI.java (97%) rename appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/{com/flowlogix/clust => fish/payara/samples/clustered}/singleton/interceptor/ClusteredInterceptor.java (96%) rename appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/{com/flowlogix/clust => fish/payara/samples/clustered}/singleton/interceptor/InterceptorCommon.java (97%) rename appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/{com/flowlogix/clust => fish/payara/samples/clustered}/singleton/interceptor/TimerRanFlag.java (97%) rename appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/{com/flowlogix/clust => fish/payara/samples/clustered}/singleton/startup/AppStartup.java (94%) rename appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/{com/flowlogix/clust => fish/payara/samples/clustered}/singleton/ClusteredSingletonTest.java (89%) rename appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/{com/flowlogix/clust => fish/payara/samples/clustered}/singleton/expectedfail/NonSerializableDeploymentFailTest.java (97%) diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/licenseheader.txt b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/licenseheader.txt deleted file mode 100644 index 40a440215e5..00000000000 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/licenseheader.txt +++ /dev/null @@ -1,43 +0,0 @@ -<#if licenseFirst??> -${licenseFirst} - -${licensePrefix}DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. -${licensePrefix} -${licensePrefix}Copyright (c) [2016-${date?date?string("yyyy")}] Payara Foundation and/or its affiliates. All rights reserved. -${licensePrefix} -${licensePrefix}The contents of this file are subject to the terms of either the GNU -${licensePrefix}General Public License Version 2 only ("GPL") or the Common Development -${licensePrefix}and Distribution License("CDDL") (collectively, the "License"). You -${licensePrefix}may not use this file except in compliance with the License. You can -${licensePrefix}obtain a copy of the License at -${licensePrefix}https://github.com/payara/Payara/blob/master/LICENSE.txt -${licensePrefix}See the License for the specific -${licensePrefix}language governing permissions and limitations under the License. -${licensePrefix} -${licensePrefix}When distributing the software, include this License Header Notice in each -${licensePrefix}file and include the License file at glassfish/legal/LICENSE.txt. -${licensePrefix} -${licensePrefix}GPL Classpath Exception: -${licensePrefix}The Payara Foundation designates this particular file as subject to the "Classpath" -${licensePrefix}exception as provided by the Payara Foundation in the GPL Version 2 section of the License -${licensePrefix}file that accompanied this code. -${licensePrefix} -${licensePrefix}Modifications: -${licensePrefix}If applicable, add the following below the License Header, with the fields -${licensePrefix}enclosed by brackets [] replaced by your own identifying information: -${licensePrefix}"Portions Copyright [year] [name of copyright owner]" -${licensePrefix} -${licensePrefix}Contributor(s): -${licensePrefix}If you wish your version of this file to be governed by only the CDDL or -${licensePrefix}only the GPL Version 2, indicate your decision by adding "[Contributor] -${licensePrefix}elects to include this software in this distribution under the [CDDL or GPL -${licensePrefix}Version 2] license." If you don't indicate a single choice of license, a -${licensePrefix}recipient has the option to distribute your version of this file under -${licensePrefix}either the CDDL, the GPL Version 2 or to extend the choice of license to -${licensePrefix}its licensees as provided above. However, if you add GPL Version 2 code -${licensePrefix}and therefore, elected the GPL Version 2 license, then the option applies -${licensePrefix}only if the new code is made subject to such option by the copyright -${licensePrefix}holder. -<#if licenseLast??> -${licenseLast} - \ No newline at end of file diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/pom.xml b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/pom.xml index e31c5ae72da..f32182b9618 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/pom.xml +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/pom.xml @@ -43,7 +43,6 @@ org.hamcrest hamcrest-library - 1.3 test diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredAnnotatedAPI1.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI1.java similarity index 95% rename from appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredAnnotatedAPI1.java rename to appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI1.java index f79faaf696d..e652f5c5591 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredAnnotatedAPI1.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI1.java @@ -37,9 +37,9 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package com.flowlogix.clust.singleton; +package fish.payara.samples.clustered.singleton; -import com.flowlogix.clust.singleton.api.AnnotatedSingletonAPI; +import fish.payara.samples.clustered.singleton.api.AnnotatedSingletonAPI; import fish.payara.cluster.Clustered; import javax.ejb.Singleton; import javax.enterprise.inject.Vetoed; diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredAnnotatedAPI2.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI2.java similarity index 95% rename from appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredAnnotatedAPI2.java rename to appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI2.java index 09b9559a0af..22a44a8758c 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredAnnotatedAPI2.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI2.java @@ -37,9 +37,9 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package com.flowlogix.clust.singleton; +package fish.payara.samples.clustered.singleton; -import com.flowlogix.clust.singleton.api.AnnotatedSingletonAPI; +import fish.payara.samples.clustered.singleton.api.AnnotatedSingletonAPI; import fish.payara.cluster.Clustered; import javax.ejb.Singleton; import javax.enterprise.inject.Vetoed; diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredEventBusStartup.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredEventBusStartup.java similarity index 98% rename from appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredEventBusStartup.java rename to appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredEventBusStartup.java index ed48cd81230..e1d150ee2bb 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredEventBusStartup.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredEventBusStartup.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package com.flowlogix.clust.singleton; +package fish.payara.samples.clustered.singleton; import fish.payara.cluster.Clustered; import fish.payara.micro.cdi.Outbound; diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonCDI1.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI1.java similarity index 96% rename from appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonCDI1.java rename to appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI1.java index cf84333d8cc..028d23ea8fb 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonCDI1.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI1.java @@ -37,9 +37,9 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package com.flowlogix.clust.singleton; +package fish.payara.samples.clustered.singleton; -import com.flowlogix.clust.singleton.api.SingletonAPI; +import fish.payara.samples.clustered.singleton.api.SingletonAPI; import fish.payara.cluster.Clustered; import fish.payara.cluster.DistributedLockType; import java.io.Serializable; diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonCDI2.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI2.java similarity index 96% rename from appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonCDI2.java rename to appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI2.java index 25cde4a2a84..c7327c457fe 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonCDI2.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI2.java @@ -37,9 +37,9 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package com.flowlogix.clust.singleton; +package fish.payara.samples.clustered.singleton; -import com.flowlogix.clust.singleton.api.Secondary; +import fish.payara.samples.clustered.singleton.api.Secondary; import fish.payara.cluster.Clustered; import fish.payara.cluster.DistributedLockType; import javax.annotation.PostConstruct; diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonEjbXml.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonEjbXml.java similarity index 95% rename from appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonEjbXml.java rename to appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonEjbXml.java index 4f249726a27..b60d079448a 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonEjbXml.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonEjbXml.java @@ -37,9 +37,9 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package com.flowlogix.clust.singleton; +package fish.payara.samples.clustered.singleton; -import com.flowlogix.clust.singleton.api.SingletonAPI; +import fish.payara.samples.clustered.singleton.api.SingletonAPI; import java.io.Serializable; import javax.enterprise.inject.Vetoed; import lombok.experimental.Delegate; diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonEjbXml2.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonEjbXml2.java similarity index 95% rename from appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonEjbXml2.java rename to appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonEjbXml2.java index 8d428ccfe82..cecd13274e4 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonEjbXml2.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonEjbXml2.java @@ -37,9 +37,9 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package com.flowlogix.clust.singleton; +package fish.payara.samples.clustered.singleton; -import com.flowlogix.clust.singleton.api.SingletonAPI; +import fish.payara.samples.clustered.singleton.api.SingletonAPI; import java.io.Serializable; import javax.enterprise.inject.Vetoed; diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonInterceptedEJB.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonInterceptedEJB.java similarity index 94% rename from appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonInterceptedEJB.java rename to appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonInterceptedEJB.java index 06c6e503368..cfb85db9b3b 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/ClusteredSingletonInterceptedEJB.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonInterceptedEJB.java @@ -37,11 +37,11 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package com.flowlogix.clust.singleton; +package fish.payara.samples.clustered.singleton; -import com.flowlogix.clust.singleton.api.InterceptedSingletonAPI; -import com.flowlogix.clust.singleton.interceptor.ClusteredInterceptor; -import com.flowlogix.clust.singleton.interceptor.TimerRanFlag; +import fish.payara.samples.clustered.singleton.api.InterceptedSingletonAPI; +import fish.payara.samples.clustered.singleton.interceptor.ClusteredInterceptor; +import fish.payara.samples.clustered.singleton.interceptor.TimerRanFlag; import fish.payara.cluster.Clustered; import java.io.Serializable; import java.util.logging.Level; diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/SingletonCommon.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/SingletonCommon.java similarity index 98% rename from appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/SingletonCommon.java rename to appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/SingletonCommon.java index 16ad3556f13..dd6fc97c03c 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/SingletonCommon.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/SingletonCommon.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package com.flowlogix.clust.singleton; +package fish.payara.samples.clustered.singleton; import java.io.Serializable; import java.net.InetAddress; diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/Stock.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/Stock.java similarity index 97% rename from appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/Stock.java rename to appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/Stock.java index fadaa6fa3dd..4d825b1a6b7 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/Stock.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/Stock.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package com.flowlogix.clust.singleton; +package fish.payara.samples.clustered.singleton; import java.io.Serializable; import lombok.AllArgsConstructor; diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/AnnotatedSingletonAPI.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/AnnotatedSingletonAPI.java similarity index 97% rename from appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/AnnotatedSingletonAPI.java rename to appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/AnnotatedSingletonAPI.java index 9f9f4720999..2ec38586f1d 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/AnnotatedSingletonAPI.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/AnnotatedSingletonAPI.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package com.flowlogix.clust.singleton.api; +package fish.payara.samples.clustered.singleton.api; import java.io.Serializable; import javax.ejb.Local; diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/InterceptedSingletonAPI.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/InterceptedSingletonAPI.java similarity index 97% rename from appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/InterceptedSingletonAPI.java rename to appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/InterceptedSingletonAPI.java index 4c5b1dbcdc8..98d9b47fda8 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/InterceptedSingletonAPI.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/InterceptedSingletonAPI.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package com.flowlogix.clust.singleton.api; +package fish.payara.samples.clustered.singleton.api; import javax.ejb.Local; diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/Secondary.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/Secondary.java similarity index 97% rename from appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/Secondary.java rename to appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/Secondary.java index bd60a094662..a53194d269e 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/Secondary.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/Secondary.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package com.flowlogix.clust.singleton.api; +package fish.payara.samples.clustered.singleton.api; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/SingletonAPI.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/SingletonAPI.java similarity index 97% rename from appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/SingletonAPI.java rename to appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/SingletonAPI.java index f5397d04064..bd4e5e5ce3a 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/api/SingletonAPI.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/SingletonAPI.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package com.flowlogix.clust.singleton.api; +package fish.payara.samples.clustered.singleton.api; import java.util.UUID; diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/ClusteredInterceptor.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/ClusteredInterceptor.java similarity index 96% rename from appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/ClusteredInterceptor.java rename to appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/ClusteredInterceptor.java index 49cb4cf8abb..fc8cd24a70a 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/ClusteredInterceptor.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/ClusteredInterceptor.java @@ -37,9 +37,9 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package com.flowlogix.clust.singleton.interceptor; +package fish.payara.samples.clustered.singleton.interceptor; -import com.flowlogix.clust.singleton.ClusteredSingletonInterceptedEJB; +import fish.payara.samples.clustered.singleton.ClusteredSingletonInterceptedEJB; import java.io.Serializable; import javax.interceptor.AroundConstruct; import javax.interceptor.AroundInvoke; diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/InterceptorCommon.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/InterceptorCommon.java similarity index 97% rename from appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/InterceptorCommon.java rename to appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/InterceptorCommon.java index dc62643bd70..ace571ed6f8 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/InterceptorCommon.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/InterceptorCommon.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package com.flowlogix.clust.singleton.interceptor; +package fish.payara.samples.clustered.singleton.interceptor; import java.io.Serializable; import javax.interceptor.InvocationContext; diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/TimerRanFlag.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/TimerRanFlag.java similarity index 97% rename from appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/TimerRanFlag.java rename to appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/TimerRanFlag.java index 2a41273fc8f..f44839c5392 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/interceptor/TimerRanFlag.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/TimerRanFlag.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package com.flowlogix.clust.singleton.interceptor; +package fish.payara.samples.clustered.singleton.interceptor; import javax.ejb.Singleton; import lombok.Getter; diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/startup/AppStartup.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/startup/AppStartup.java similarity index 94% rename from appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/startup/AppStartup.java rename to appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/startup/AppStartup.java index acac7dcbeab..2bfbed23728 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/com/flowlogix/clust/singleton/startup/AppStartup.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/startup/AppStartup.java @@ -37,10 +37,10 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package com.flowlogix.clust.singleton.startup; +package fish.payara.samples.clustered.singleton.startup; -import com.flowlogix.clust.singleton.api.InterceptedSingletonAPI; -import com.flowlogix.clust.singleton.api.SingletonAPI; +import fish.payara.samples.clustered.singleton.api.InterceptedSingletonAPI; +import fish.payara.samples.clustered.singleton.api.SingletonAPI; import javax.annotation.PostConstruct; import javax.annotation.Resource; import javax.ejb.EJB; diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/ejb-jar.xml b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/ejb-jar.xml index 6a129a5f86e..645ad661a64 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/ejb-jar.xml +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/ejb-jar.xml @@ -6,15 +6,15 @@ ClusteredSingletonEjbXml1 - com.flowlogix.clust.singleton.api.SingletonAPI - com.flowlogix.clust.singleton.ClusteredSingletonEjbXml + fish.payara.samples.clustered.singleton.api.SingletonAPI + fish.payara.samples.clustered.singleton.ClusteredSingletonEjbXml Singleton Container ClusteredSingletonEjbXml2 - com.flowlogix.clust.singleton.api.SingletonAPI - com.flowlogix.clust.singleton.ClusteredSingletonEjbXml2 + fish.payara.samples.clustered.singleton.api.SingletonAPI + fish.payara.samples.clustered.singleton.ClusteredSingletonEjbXml2 Singleton Container diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/com/flowlogix/clust/singleton/ClusteredSingletonTest.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/ClusteredSingletonTest.java similarity index 89% rename from appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/com/flowlogix/clust/singleton/ClusteredSingletonTest.java rename to appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/ClusteredSingletonTest.java index 32efbf177ef..5f82eccd7c6 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/com/flowlogix/clust/singleton/ClusteredSingletonTest.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/ClusteredSingletonTest.java @@ -37,12 +37,12 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package com.flowlogix.clust.singleton; +package fish.payara.samples.clustered.singleton; -import com.flowlogix.clust.singleton.api.AnnotatedSingletonAPI; -import com.flowlogix.clust.singleton.api.InterceptedSingletonAPI; -import com.flowlogix.clust.singleton.api.Secondary; -import com.flowlogix.clust.singleton.api.SingletonAPI; +import fish.payara.samples.clustered.singleton.api.AnnotatedSingletonAPI; +import fish.payara.samples.clustered.singleton.api.InterceptedSingletonAPI; +import fish.payara.samples.clustered.singleton.api.Secondary; +import fish.payara.samples.clustered.singleton.api.SingletonAPI; import java.io.File; import javax.ejb.EJB; import javax.ejb.EJBException; @@ -70,8 +70,9 @@ public class ClusteredSingletonTest { @Deployment public static WebArchive createDeployment() { return ShrinkWrap.create(WebArchive.class, "cst.war") - .addPackages(false, "com.flowlogix.clust.singleton", - "com.flowlogix.clust.singleton.api", "com.flowlogix.clust.singleton.interceptor") + .addPackages(false, "fish.payara.samples.clustered.singleton", + "fish.payara.samples.clustered.singleton.api", + "fish.payara.samples.clustered.singleton.interceptor") .addAsWebInfResource(new File(WEBAPP_SRC, "WEB-INF/ejb-jar.xml")) .addAsWebInfResource(new File(WEBAPP_SRC, "WEB-INF/glassfish-ejb-jar.xml")); } diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/com/flowlogix/clust/singleton/expectedfail/NonSerializableDeploymentFailTest.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/expectedfail/NonSerializableDeploymentFailTest.java similarity index 97% rename from appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/com/flowlogix/clust/singleton/expectedfail/NonSerializableDeploymentFailTest.java rename to appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/expectedfail/NonSerializableDeploymentFailTest.java index f02de136bfd..fbf3dc761a0 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/com/flowlogix/clust/singleton/expectedfail/NonSerializableDeploymentFailTest.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/expectedfail/NonSerializableDeploymentFailTest.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package com.flowlogix.clust.singleton.expectedfail; +package fish.payara.samples.clustered.singleton.expectedfail; import fish.payara.cluster.Clustered; import javax.ejb.Singleton; diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/resources/ForFailures/META-INF/ejb-jar.xml b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/resources/ForFailures/META-INF/ejb-jar.xml index 57551821021..e7f78d5f19c 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/resources/ForFailures/META-INF/ejb-jar.xml +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/resources/ForFailures/META-INF/ejb-jar.xml @@ -6,8 +6,8 @@ NonSerializableSingleton - com.flowlogix.clust.singleton.api.SingletonAPI - com.flowlogix.clust.singleton.expectedfail.NonSerializableSingleton + fish.payara.samples.clustered.singleton.api.SingletonAPI + fish.payara.samples.clustered.singleton.expectedfail.NonSerializableSingleton Singleton Container From 2b2270002ce3e248317002a3c8ea8c0ec1b62a7d Mon Sep 17 00:00:00 2001 From: lprimak Date: Fri, 4 Dec 2020 15:40:47 -0600 Subject: [PATCH 4/7] delombok --- .../clustered-singleton-test/pom.xml | 6 -- .../singleton/ClusteredAnnotatedAPI1.java | 21 +++-- .../singleton/ClusteredAnnotatedAPI2.java | 10 +-- .../singleton/ClusteredEventBusStartup.java | 35 ++++---- .../singleton/ClusteredSingletonCDI1.java | 23 +++-- .../singleton/ClusteredSingletonCDI2.java | 22 +++-- .../singleton/ClusteredSingletonEjbXml.java | 16 +++- .../ClusteredSingletonInterceptedEJB.java | 50 +++++++---- .../clustered/singleton/SingletonCommon.java | 44 ++++++---- .../samples/clustered/singleton/Stock.java | 87 ++++++++++++++++--- .../interceptor/ClusteredInterceptor.java | 52 +++++------ .../interceptor/InterceptorCommon.java | 31 ++++--- .../singleton/interceptor/TimerRanFlag.java | 25 +++--- .../singleton/startup/AppStartup.java | 15 ++-- .../singleton/ClusteredSingletonTest.java | 6 +- .../NonSerializableDeploymentFailTest.java | 8 +- 16 files changed, 282 insertions(+), 169 deletions(-) diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/pom.xml b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/pom.xml index f32182b9618..f419a0c5642 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/pom.xml +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/pom.xml @@ -18,12 +18,6 @@ - - org.projectlombok - lombok - 1.18.10 - provided - jakarta.platform jakarta.jakartaee-web-api diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI1.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI1.java index e652f5c5591..13a868173d4 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI1.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI1.java @@ -41,25 +41,34 @@ import fish.payara.samples.clustered.singleton.api.AnnotatedSingletonAPI; import fish.payara.cluster.Clustered; +import java.util.logging.Logger; import javax.ejb.Singleton; import javax.enterprise.inject.Vetoed; -import lombok.experimental.Delegate; -import lombok.extern.java.Log; /** - * * @author lprimak */ @Clustered(keyName = "ClusteredAnnotated1") @Singleton(name = "ClusteredSingletonAnnotatedEJB1") -@Vetoed @Log +@Vetoed public class ClusteredAnnotatedAPI1 implements AnnotatedSingletonAPI { + private static final Logger log = Logger.getLogger(ClusteredAnnotatedAPI1.class.getName()); + private static final long serialVersionUID = 1L; + protected final SingletonCommon sc = new SingletonCommon(this); + @Override public String getHello() { return String.format("Clustered Annotated API EJB Hello (1): %s", sc); } - protected final @Delegate SingletonCommon sc = new SingletonCommon(this); - private static final long serialVersionUID = 1L; + @Override + public void randomizeState() { + this.sc.randomizeState(); + } + + @Override + public java.util.UUID getState() { + return this.sc.getState(); + } } diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI2.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI2.java index 22a44a8758c..f86e901a1a3 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI2.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI2.java @@ -41,22 +41,22 @@ import fish.payara.samples.clustered.singleton.api.AnnotatedSingletonAPI; import fish.payara.cluster.Clustered; +import java.util.logging.Logger; import javax.ejb.Singleton; import javax.enterprise.inject.Vetoed; -import lombok.extern.java.Log; /** - * * @author lprimak */ @Clustered(keyName = "ClusteredAnnotated1") @Singleton(name = "ClusteredSingletonAnnotatedEJB2") -@Vetoed @Log +@Vetoed public class ClusteredAnnotatedAPI2 extends ClusteredAnnotatedAPI1 implements AnnotatedSingletonAPI { + private static final Logger log = Logger.getLogger(ClusteredAnnotatedAPI2.class.getName()); + private static final long serialVersionUID = 1L; + @Override public String getHello() { return String.format("Clustered Annotated API EJB Hello (2): %s", sc); } - - private static final long serialVersionUID = 1L; } diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredEventBusStartup.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredEventBusStartup.java index e1d150ee2bb..6ac8e5276e1 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredEventBusStartup.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredEventBusStartup.java @@ -1,8 +1,8 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * + * * Copyright (c) [2016-2017] 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 @@ -11,20 +11,20 @@ * 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] @@ -43,33 +43,32 @@ import fish.payara.micro.cdi.Outbound; import java.io.Serializable; import java.util.logging.Level; +import java.util.logging.Logger; import javax.ejb.Schedule; import javax.ejb.Singleton; import javax.ejb.Startup; import javax.enterprise.event.Event; import javax.inject.Inject; -import lombok.extern.java.Log; /** - * * @author lprimak */ - @Clustered -@Singleton @Startup @Log +@Singleton @Startup public class ClusteredEventBusStartup implements Serializable { - @Schedule(hour = "*", minute="*", second = "*/1", persistent = false) + private static final Logger log = Logger.getLogger(ClusteredEventBusStartup.class.getName()); + private static final long serialVersionUID = 1L; + private Stock stock; + private int numInvocations; + @Inject + @Outbound(loopBack = true) + private Event stockEvents; + + @Schedule(hour = "*", minute = "*", second = "*/1", persistent = false) private void generatePrice() { ++numInvocations; stock = new Stock("PYA", "Some very long description of Payara", Math.random() * 100.0); log.log(Level.INFO, "Sock: {0}, numInvocations: {1}", new Object[] { stock, numInvocations }); stockEvents.fire(stock); } - - private Stock stock; - private int numInvocations; - @Inject - @Outbound(loopBack = true) - private Event stockEvents; - private static final long serialVersionUID = 1L; } diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI1.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI1.java index 028d23ea8fb..6cf9b50e4d8 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI1.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI1.java @@ -43,22 +43,24 @@ import fish.payara.cluster.Clustered; import fish.payara.cluster.DistributedLockType; import java.io.Serializable; +import java.util.UUID; +import java.util.logging.Logger; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.enterprise.context.ApplicationScoped; import javax.enterprise.inject.Default; -import lombok.experimental.Delegate; -import lombok.extern.java.Log; /** - * * @author lprimak */ @ApplicationScoped @Clustered(keyName = "ClusteredSingletonCDI1", lock = DistributedLockType.LOCK) -@Log @Default public class ClusteredSingletonCDI1 implements SingletonAPI, Serializable { + private static final Logger log = Logger.getLogger(ClusteredSingletonCDI1.class.getName()); + private static final long serialVersionUID = 1L; + protected final SingletonCommon sc = new SingletonCommon(this); + @Override public String getHello() { return String.format("CDI Bean Hello (1): %s", sc); @@ -67,13 +69,20 @@ public String getHello() { @PostConstruct void postConstruct() { log.info("CDI1 PostConstruct"); - } + @PreDestroy void preDestroy() { log.info("CDI1 PreDestroy"); } - protected final @Delegate SingletonCommon sc = new SingletonCommon(this); - private static final long serialVersionUID = 1L; + @Override + public void randomizeState() { + this.sc.randomizeState(); + } + + @Override + public UUID getState() { + return this.sc.getState(); + } } diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI2.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI2.java index c7327c457fe..a8aea08ec4e 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI2.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI2.java @@ -1,8 +1,8 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * + * * Copyright (c) [2016-2017] 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 @@ -11,20 +11,20 @@ * 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] @@ -42,20 +42,21 @@ import fish.payara.samples.clustered.singleton.api.Secondary; import fish.payara.cluster.Clustered; import fish.payara.cluster.DistributedLockType; +import java.util.logging.Logger; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.enterprise.context.ApplicationScoped; -import lombok.extern.java.Log; /** - * * @author lprimak */ @ApplicationScoped @Clustered(keyName = "ClusteredSingletonCDI1", lock = DistributedLockType.LOCK) -@Log @Secondary public class ClusteredSingletonCDI2 extends ClusteredSingletonCDI1 { + private static final Logger log = Logger.getLogger(ClusteredSingletonCDI2.class.getName()); + private static final long serialVersionUID = 1L; + @Override public String getHello() { return String.format("CDI Bean Hello (2): %s", sc); @@ -65,7 +66,6 @@ public String getHello() { @Override void postConstruct() { log.info("CDI2 PostConstruct"); - } @PreDestroy @@ -73,6 +73,4 @@ void postConstruct() { void preDestroy() { log.info("CDI2 PreDestroy"); } - - private static final long serialVersionUID = 1L; } diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonEjbXml.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonEjbXml.java index b60d079448a..a7d887feb0e 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonEjbXml.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonEjbXml.java @@ -41,21 +41,29 @@ import fish.payara.samples.clustered.singleton.api.SingletonAPI; import java.io.Serializable; +import java.util.UUID; import javax.enterprise.inject.Vetoed; -import lombok.experimental.Delegate; /** - * * @author lprimak */ @Vetoed public class ClusteredSingletonEjbXml implements SingletonAPI, Serializable { + private static final long serialVersionUID = 1L; + private final SingletonCommon sc = new SingletonCommon(this); + @Override public String getHello() { return String.format("Descriptor EJB Hello: %s", sc); } - private final @Delegate SingletonCommon sc = new SingletonCommon(this); + @Override + public void randomizeState() { + this.sc.randomizeState(); + } - private static final long serialVersionUID = 1L; + @Override + public UUID getState() { + return this.sc.getState(); + } } diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonInterceptedEJB.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonInterceptedEJB.java index cfb85db9b3b..95cd3932a90 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonInterceptedEJB.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonInterceptedEJB.java @@ -44,7 +44,9 @@ import fish.payara.samples.clustered.singleton.interceptor.TimerRanFlag; import fish.payara.cluster.Clustered; import java.io.Serializable; +import java.util.UUID; import java.util.logging.Level; +import java.util.logging.Logger; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.annotation.Resource; @@ -59,21 +61,29 @@ import javax.ejb.TimerService; import javax.enterprise.inject.Vetoed; import javax.interceptor.Interceptors; -import lombok.SneakyThrows; -import lombok.experimental.Delegate; -import lombok.extern.java.Log; /** - * * @author lprimak */ @Clustered @Singleton(name = "ClusteredSingletonInterceptedEJB") @Vetoed -@Log @ConcurrencyManagement(ConcurrencyManagementType.BEAN) @Interceptors(ClusteredInterceptor.class) public class ClusteredSingletonInterceptedEJB implements InterceptedSingletonAPI, Serializable { + private static final Logger log = Logger.getLogger(ClusteredSingletonInterceptedEJB.class.getName()); + private static final long serialVersionUID = 1L; + private final SingletonCommon sc = new SingletonCommon(this); + @Resource + private transient TimerService ts; + @Resource + private transient SessionContext ctx; + private boolean constructorIntercepted; + private boolean timerIntercepted; + private boolean invocationIntercepted; + @EJB + private transient TimerRanFlag timerRan; + public ClusteredSingletonInterceptedEJB() { log.log(Level.INFO, "{0} - Constructor", getClass().getSimpleName()); } @@ -98,10 +108,13 @@ public String getHello() { } @Override - @SneakyThrows(InterruptedException.class) public void waitForTimer() { - for(int ii = 0; ii < 1000 && !timerRan.isTimerRan(); ++ii) { - Thread.sleep(5); + try { + for (int ii = 0; ii < 1000 && !timerRan.isTimerRan(); ++ii) { + Thread.sleep(5); + } + } catch (final InterruptedException ex) { + throw new RuntimeException(ex); } } @@ -114,6 +127,17 @@ public void setConstructorInterceptorCalled() { constructorIntercepted = true; } + + @Override + public void randomizeState() { + this.sc.randomizeState(); + } + + @Override + public UUID getState() { + return this.sc.getState(); + } + @Override @Asynchronous public void async() { @@ -128,14 +152,4 @@ private void timeout() { ctx.getContextData().get(ClusteredInterceptor.AroundTimeoutKey).equals(ClusteredInterceptor.AroundTimeoutValue) : "".equals(ClusteredInterceptor.AroundTimeoutValue); } - - private final @Delegate SingletonCommon sc = new SingletonCommon(this); - private transient @Resource TimerService ts; - private transient @Resource SessionContext ctx; - private boolean constructorIntercepted; - private boolean timerIntercepted; - private boolean invocationIntercepted; - private transient @EJB TimerRanFlag timerRan; - - private static final long serialVersionUID = 1L; } diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/SingletonCommon.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/SingletonCommon.java index dd6fc97c03c..ca469908de0 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/SingletonCommon.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/SingletonCommon.java @@ -1,8 +1,8 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * + * * Copyright (c) [2016-2017] 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 @@ -11,20 +11,20 @@ * 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] @@ -41,33 +41,39 @@ import java.io.Serializable; import java.net.InetAddress; +import java.net.UnknownHostException; import java.util.Objects; import java.util.UUID; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import lombok.SneakyThrows; -import lombok.extern.java.Log; +import java.util.logging.Logger; /** - * * @author lprimak */ -@RequiredArgsConstructor -@Log public class SingletonCommon implements Serializable { - @SneakyThrows + private static final Logger log = Logger.getLogger(SingletonCommon.class.getName()); + private static final long serialVersionUID = 1L; + private final Object parent; + private UUID state = UUID.randomUUID(); + @Override public String toString() { - return String.format("instance = 0x%x, host = %s, State(UUID) = %s", - Objects.hashCode(parent), InetAddress.getLocalHost().getHostName(), getState()); + try { + return String.format("instance = 0x%x, host = %s, State(UUID) = %s", + Objects.hashCode(parent), InetAddress.getLocalHost().getHostName(), getState()); + } catch (final UnknownHostException ex) { + throw new RuntimeException(ex); + } } public void randomizeState() { state = UUID.randomUUID(); } - private final Object parent; - private @Getter UUID state = UUID.randomUUID(); + public SingletonCommon(final Object parent) { + this.parent = parent; + } - private static final long serialVersionUID = 1L; + public UUID getState() { + return this.state; + } } diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/Stock.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/Stock.java index 4d825b1a6b7..740b8f647f2 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/Stock.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/Stock.java @@ -1,8 +1,8 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * + * * Copyright (c) [2016-2017] 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 @@ -11,20 +11,20 @@ * 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] @@ -40,18 +40,83 @@ package fish.payara.samples.clustered.singleton; import java.io.Serializable; -import lombok.AllArgsConstructor; -import lombok.Data; /** - * * @author lprimak */ -@Data @AllArgsConstructor public class Stock implements Serializable { + private static final long serialVersionUID = 1L; private String cusip; private String description; private Double price; - private static final long serialVersionUID = 1L; + public Stock(final String cusip, final String description, final Double price) { + this.cusip = cusip; + this.description = description; + this.price = price; + } + + public String getCusip() { + return this.cusip; + } + + public String getDescription() { + return this.description; + } + + public Double getPrice() { + return this.price; + } + + public void setCusip(final String cusip) { + this.cusip = cusip; + } + + public void setDescription(final String description) { + this.description = description; + } + + public void setPrice(final Double price) { + this.price = price; + } + + @Override + public boolean equals(final java.lang.Object o) { + if (o == this) return true; + if (!(o instanceof Stock)) return false; + final Stock other = (Stock) o; + if (!other.canEqual((java.lang.Object) this)) return false; + final java.lang.Object this$price = this.getPrice(); + final java.lang.Object other$price = other.getPrice(); + if (this$price == null ? other$price != null : !this$price.equals(other$price)) return false; + final java.lang.Object this$cusip = this.getCusip(); + final java.lang.Object other$cusip = other.getCusip(); + if (this$cusip == null ? other$cusip != null : !this$cusip.equals(other$cusip)) return false; + final java.lang.Object this$description = this.getDescription(); + final java.lang.Object other$description = other.getDescription(); + if (this$description == null ? other$description != null : !this$description.equals(other$description)) return false; + return true; + } + + protected boolean canEqual(final java.lang.Object other) { + return other instanceof Stock; + } + + @Override + public int hashCode() { + final int PRIME = 59; + int result = 1; + final java.lang.Object $price = this.getPrice(); + result = result * PRIME + ($price == null ? 43 : $price.hashCode()); + final java.lang.Object $cusip = this.getCusip(); + result = result * PRIME + ($cusip == null ? 43 : $cusip.hashCode()); + final java.lang.Object $description = this.getDescription(); + result = result * PRIME + ($description == null ? 43 : $description.hashCode()); + return result; + } + + @Override + public String toString() { + return "Stock(cusip=" + this.getCusip() + ", description=" + this.getDescription() + ", price=" + this.getPrice() + ")"; + } } diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/ClusteredInterceptor.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/ClusteredInterceptor.java index fc8cd24a70a..67008efb173 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/ClusteredInterceptor.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/ClusteredInterceptor.java @@ -41,51 +41,53 @@ import fish.payara.samples.clustered.singleton.ClusteredSingletonInterceptedEJB; import java.io.Serializable; +import java.util.logging.Logger; import javax.interceptor.AroundConstruct; import javax.interceptor.AroundInvoke; import javax.interceptor.AroundTimeout; import javax.interceptor.InvocationContext; -import lombok.Cleanup; -import lombok.SneakyThrows; -import lombok.extern.java.Log; /** - * * @author lprimak */ -@Log public class ClusteredInterceptor implements Serializable { + private static final Logger log = Logger.getLogger(ClusteredInterceptor.class.getName()); + private static final long serialVersionUID = 1L; + public static final String AroundTimeoutKey = "AroundTimeout"; + public static final String AroundTimeoutValue = "timeout"; + public static final String AroundInvokeKey = "AroundInvoke"; + public static final String AroundInvokeValue = "invoke"; + private final InterceptorCommon ic = new InterceptorCommon(); + @AroundConstruct - @SneakyThrows public void aroundConstruct(InvocationContext ctx) { - log.info("AroundConstruct"); - ctx.proceed(); - ClusteredSingletonInterceptedEJB target = (ClusteredSingletonInterceptedEJB)ctx.getTarget(); - target.setConstructorInterceptorCalled(); + try { + log.info("AroundConstruct"); + ctx.proceed(); + ClusteredSingletonInterceptedEJB target = (ClusteredSingletonInterceptedEJB) ctx.getTarget(); + target.setConstructorInterceptorCalled(); + } catch (final Exception ex) { + throw new RuntimeException(ex); + } } @AroundTimeout - @SneakyThrows public Object aroundTimeout(InvocationContext ctx) { log.info("AroundTimeout"); - @Cleanup InterceptorCommon.InterceptorData cd = ic.setData(ctx, AroundTimeoutKey, AroundTimeoutValue); - return ctx.proceed(); + try (InterceptorCommon.InterceptorData cd = ic.setData(ctx, AroundTimeoutKey, AroundTimeoutValue)) { + return ctx.proceed(); + } catch (Exception ex) { + throw new RuntimeException(ex); + } } @AroundInvoke - @SneakyThrows public Object aroundInvoke(InvocationContext ctx) { log.info("AroundInvoke"); - @Cleanup InterceptorCommon.InterceptorData cd = ic.setData(ctx, AroundInvokeKey, AroundInvokeValue); - return ctx.proceed(); + try (InterceptorCommon.InterceptorData cd = ic.setData(ctx, AroundInvokeKey, AroundInvokeValue)) { + return ctx.proceed(); + } catch (Exception ex) { + throw new RuntimeException(ex); + } } - - - public static final String AroundTimeoutKey = "AroundTimeout"; - public static final String AroundTimeoutValue = "timeout"; - public static final String AroundInvokeKey = "AroundInvoke"; - public static final String AroundInvokeValue = "invoke"; - - - private final InterceptorCommon ic = new InterceptorCommon(); } diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/InterceptorCommon.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/InterceptorCommon.java index ace571ed6f8..3c7085e073a 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/InterceptorCommon.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/InterceptorCommon.java @@ -1,8 +1,8 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * + * * Copyright (c) [2016-2017] 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 @@ -11,20 +11,20 @@ * 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] @@ -41,29 +41,34 @@ import java.io.Serializable; import javax.interceptor.InvocationContext; -import lombok.RequiredArgsConstructor; /** - * * @author lprimak */ public class InterceptorCommon implements Serializable { + private static final long serialVersionUID = 1L; + public InterceptorData setData(InvocationContext ctx, String key, Object value) { return new InterceptorData(ctx, key).setData(value); } - @RequiredArgsConstructor - public static class InterceptorData { + public static class InterceptorData implements AutoCloseable { + private final InvocationContext ctx; + private final String key; + + public InterceptorData(final InvocationContext ctx, final String key) { + this.ctx = ctx; + this.key = key; + } + public InterceptorData setData(Object value) { ctx.getContextData().put(key, value); return this; } + @Override public void close() { ctx.getContextData().remove(key); } - - private final InvocationContext ctx; - private final String key; } } diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/TimerRanFlag.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/TimerRanFlag.java index f44839c5392..57bc6656e0e 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/TimerRanFlag.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/TimerRanFlag.java @@ -1,8 +1,8 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * + * * Copyright (c) [2016-2018] 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 @@ -11,20 +11,20 @@ * 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] @@ -40,14 +40,19 @@ package fish.payara.samples.clustered.singleton.interceptor; import javax.ejb.Singleton; -import lombok.Getter; -import lombok.Setter; /** - * * @author lprimak */ @Singleton public class TimerRanFlag { - private @Getter @Setter boolean timerRan; + private boolean timerRan; + + public boolean isTimerRan() { + return this.timerRan; + } + + public void setTimerRan(final boolean timerRan) { + this.timerRan = timerRan; + } } diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/startup/AppStartup.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/startup/AppStartup.java index 2bfbed23728..23d0388fd97 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/startup/AppStartup.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/startup/AppStartup.java @@ -41,6 +41,7 @@ import fish.payara.samples.clustered.singleton.api.InterceptedSingletonAPI; import fish.payara.samples.clustered.singleton.api.SingletonAPI; +import java.util.logging.Logger; import javax.annotation.PostConstruct; import javax.annotation.Resource; import javax.ejb.EJB; @@ -50,7 +51,6 @@ import javax.ejb.TimerConfig; import javax.ejb.TimerService; import javax.inject.Inject; -import lombok.extern.java.Log; /** * @@ -58,8 +58,13 @@ */ @Singleton @Startup -@Log public class AppStartup { + private static final Logger log = Logger.getLogger(AppStartup.class.getName()); + private @EJB(lookup = "java:module/ClusteredSingletonEjbXml1") SingletonAPI descAPI; + private @EJB InterceptedSingletonAPI annotatedAPI; + private @Inject SingletonAPI cdiAPI; + private @Resource TimerService ts; + @PostConstruct void postConstruct() { ts.createSingleActionTimer(0, new TimerConfig(null, false)); @@ -82,10 +87,4 @@ void doInit() { cdiAPI.getHello(); annotatedAPI.async(); } - - - private @EJB(lookup = "java:module/ClusteredSingletonEjbXml1") SingletonAPI descAPI; - private @EJB InterceptedSingletonAPI annotatedAPI; - private @Inject SingletonAPI cdiAPI; - private @Resource TimerService ts; } diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/ClusteredSingletonTest.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/ClusteredSingletonTest.java index 5f82eccd7c6..fc2b06afdec 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/ClusteredSingletonTest.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/ClusteredSingletonTest.java @@ -44,10 +44,10 @@ import fish.payara.samples.clustered.singleton.api.Secondary; import fish.payara.samples.clustered.singleton.api.SingletonAPI; import java.io.File; +import java.util.logging.Logger; import javax.ejb.EJB; import javax.ejb.EJBException; import javax.inject.Inject; -import lombok.extern.java.Log; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; @@ -61,12 +61,12 @@ import org.junit.runner.RunWith; /** - * * @author lprimak */ @RunWith(Arquillian.class) -@Log public class ClusteredSingletonTest { + private static final Logger log = Logger.getLogger(ClusteredSingletonTest.class.getName()); + @Deployment public static WebArchive createDeployment() { return ShrinkWrap.create(WebArchive.class, "cst.war") diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/expectedfail/NonSerializableDeploymentFailTest.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/expectedfail/NonSerializableDeploymentFailTest.java index fbf3dc761a0..8b0361ee79c 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/expectedfail/NonSerializableDeploymentFailTest.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/expectedfail/NonSerializableDeploymentFailTest.java @@ -40,8 +40,8 @@ package fish.payara.samples.clustered.singleton.expectedfail; import fish.payara.cluster.Clustered; +import java.util.logging.Logger; import javax.ejb.Singleton; -import lombok.extern.java.Log; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.ShouldThrowException; import org.jboss.arquillian.junit.Arquillian; @@ -51,15 +51,15 @@ import org.junit.runner.RunWith; /** - * * @author lprimak */ @RunWith(Arquillian.class) -@Log public class NonSerializableDeploymentFailTest { + private static final Logger log = Logger.getLogger(NonSerializableDeploymentFailTest.class.getName()); + @Deployment @ShouldThrowException(RuntimeException.class) public static WebArchive createDeployment() { - log.info("Please Ignore the following SEVERE: exit_code, it's expected"); + log.info("Please Ignore the following SEVERE: exit_code, it\'s expected"); return ShrinkWrap.create(WebArchive.class) .addPackage(NonSerializableDeploymentFailTest.class.getPackage()); } From 4bea4a71d8952ef4fe2a96567ac83c1338178a24 Mon Sep 17 00:00:00 2001 From: lprimak Date: Fri, 4 Dec 2020 15:43:57 -0600 Subject: [PATCH 5/7] bump version number --- .../clustered-singleton/clustered-singleton-test/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/pom.xml b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/pom.xml index f419a0c5642..f1ba6fc13d7 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/pom.xml +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/pom.xml @@ -9,7 +9,7 @@ fish.payara.samples clustered-singleton-parent - 5.2020.7-SNAPSHOT + 5.2020.8-SNAPSHOT From 14be950fdf2c3de5d2efd602913bd3e3cd6aa8d1 Mon Sep 17 00:00:00 2001 From: lprimak Date: Fri, 4 Dec 2020 15:47:56 -0600 Subject: [PATCH 6/7] minor cleanup of UUID --- .../samples/clustered/singleton/ClusteredAnnotatedAPI1.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI1.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI1.java index 13a868173d4..f4c5d1e6952 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI1.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI1.java @@ -41,6 +41,7 @@ import fish.payara.samples.clustered.singleton.api.AnnotatedSingletonAPI; import fish.payara.cluster.Clustered; +import java.util.UUID; import java.util.logging.Logger; import javax.ejb.Singleton; import javax.enterprise.inject.Vetoed; @@ -68,7 +69,7 @@ public void randomizeState() { } @Override - public java.util.UUID getState() { + public UUID getState() { return this.sc.getState(); } } From 49a35d343be295d52c5ee47a93c90a4f50bd3822 Mon Sep 17 00:00:00 2001 From: lprimak Date: Mon, 7 Dec 2020 10:52:37 -0600 Subject: [PATCH 7/7] copyright updates --- .../common/spi/ClusteredSingletonLookup.java | 2 +- .../clustered-singleton-test/pom.xml | 39 +++++++++++++++++++ .../singleton/ClusteredAnnotatedAPI1.java | 2 +- .../singleton/ClusteredAnnotatedAPI2.java | 2 +- .../singleton/ClusteredEventBusStartup.java | 2 +- .../singleton/ClusteredSingletonCDI1.java | 2 +- .../singleton/ClusteredSingletonCDI2.java | 2 +- .../singleton/ClusteredSingletonEjbXml.java | 2 +- .../singleton/ClusteredSingletonEjbXml2.java | 14 +++---- .../ClusteredSingletonInterceptedEJB.java | 2 +- .../clustered/singleton/SingletonCommon.java | 2 +- .../samples/clustered/singleton/Stock.java | 2 +- .../singleton/api/AnnotatedSingletonAPI.java | 2 +- .../api/InterceptedSingletonAPI.java | 2 +- .../clustered/singleton/api/Secondary.java | 14 +++---- .../clustered/singleton/api/SingletonAPI.java | 2 +- .../interceptor/ClusteredInterceptor.java | 2 +- .../interceptor/InterceptorCommon.java | 2 +- .../singleton/interceptor/TimerRanFlag.java | 2 +- .../singleton/startup/AppStartup.java | 2 +- .../src/main/webapp/WEB-INF/glassfish-web.xml | 15 ------- .../singleton/ClusteredSingletonTest.java | 2 +- .../NonSerializableDeploymentFailTest.java | 2 +- .../samples/clustered-singleton/pom.xml | 2 +- 24 files changed, 73 insertions(+), 49 deletions(-) diff --git a/appserver/common/container-common/src/main/java/com/sun/enterprise/container/common/spi/ClusteredSingletonLookup.java b/appserver/common/container-common/src/main/java/com/sun/enterprise/container/common/spi/ClusteredSingletonLookup.java index 00085939c5f..caa8fc667d0 100644 --- a/appserver/common/container-common/src/main/java/com/sun/enterprise/container/common/spi/ClusteredSingletonLookup.java +++ b/appserver/common/container-common/src/main/java/com/sun/enterprise/container/common/spi/ClusteredSingletonLookup.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2018] 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 diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/pom.xml b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/pom.xml index f1ba6fc13d7..39fd3340004 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/pom.xml +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/pom.xml @@ -1,4 +1,43 @@ + 4.0.0 clustered-singleton diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI1.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI1.java index f4c5d1e6952..66d42104df3 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI1.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI1.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2017] 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 diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI2.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI2.java index f86e901a1a3..cf1f7c3ba0a 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI2.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredAnnotatedAPI2.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2017] 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 diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredEventBusStartup.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredEventBusStartup.java index 6ac8e5276e1..b0f5be3a807 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredEventBusStartup.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredEventBusStartup.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2017] 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 diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI1.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI1.java index 6cf9b50e4d8..0e879d521cc 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI1.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI1.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2017] 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 diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI2.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI2.java index a8aea08ec4e..d79555ca048 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI2.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonCDI2.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2017] 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 diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonEjbXml.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonEjbXml.java index a7d887feb0e..b79d8eae7cc 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonEjbXml.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonEjbXml.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2017] 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 diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonEjbXml2.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonEjbXml2.java index cecd13274e4..1e92734dfac 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonEjbXml2.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonEjbXml2.java @@ -1,8 +1,8 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) [2016-2017] 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 * and Distribution License("CDDL") (collectively, the "License"). You @@ -11,20 +11,20 @@ * 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] diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonInterceptedEJB.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonInterceptedEJB.java index 95cd3932a90..8d8bf3e2828 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonInterceptedEJB.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/ClusteredSingletonInterceptedEJB.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2017] 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 diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/SingletonCommon.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/SingletonCommon.java index ca469908de0..3cef57d460c 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/SingletonCommon.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/SingletonCommon.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2017] 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 diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/Stock.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/Stock.java index 740b8f647f2..771249eefad 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/Stock.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/Stock.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2017] 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 diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/AnnotatedSingletonAPI.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/AnnotatedSingletonAPI.java index 2ec38586f1d..0ba1c4f2ad7 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/AnnotatedSingletonAPI.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/AnnotatedSingletonAPI.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2017] 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 diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/InterceptedSingletonAPI.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/InterceptedSingletonAPI.java index 98d9b47fda8..2c308813294 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/InterceptedSingletonAPI.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/InterceptedSingletonAPI.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2017] 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 diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/Secondary.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/Secondary.java index a53194d269e..f1245463f84 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/Secondary.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/Secondary.java @@ -1,8 +1,8 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) [2016-2017] 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 * and Distribution License("CDDL") (collectively, the "License"). You @@ -11,20 +11,20 @@ * 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] diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/SingletonAPI.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/SingletonAPI.java index bd4e5e5ce3a..71bd644785f 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/SingletonAPI.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/api/SingletonAPI.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2017] 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 diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/ClusteredInterceptor.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/ClusteredInterceptor.java index 67008efb173..6a935907fc1 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/ClusteredInterceptor.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/ClusteredInterceptor.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2017] 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 diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/InterceptorCommon.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/InterceptorCommon.java index 3c7085e073a..84994530a92 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/InterceptorCommon.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/InterceptorCommon.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2017] 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 diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/TimerRanFlag.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/TimerRanFlag.java index 57bc6656e0e..a4743ec00f7 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/TimerRanFlag.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/interceptor/TimerRanFlag.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2018] 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 diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/startup/AppStartup.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/startup/AppStartup.java index 23d0388fd97..10961034088 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/startup/AppStartup.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/java/fish/payara/samples/clustered/singleton/startup/AppStartup.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2017] 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 diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/glassfish-web.xml b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/glassfish-web.xml index 673cc06fc51..13e0059fffb 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/glassfish-web.xml +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/main/webapp/WEB-INF/glassfish-web.xml @@ -1,19 +1,4 @@ - diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/ClusteredSingletonTest.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/ClusteredSingletonTest.java index fc2b06afdec..6ec12f2b505 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/ClusteredSingletonTest.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/ClusteredSingletonTest.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2017] 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 diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/expectedfail/NonSerializableDeploymentFailTest.java b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/expectedfail/NonSerializableDeploymentFailTest.java index 8b0361ee79c..7feeba1cd92 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/expectedfail/NonSerializableDeploymentFailTest.java +++ b/appserver/tests/payara-samples/samples/clustered-singleton/clustered-singleton-test/src/test/java/fish/payara/samples/clustered/singleton/expectedfail/NonSerializableDeploymentFailTest.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) [2016-2017] 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 diff --git a/appserver/tests/payara-samples/samples/clustered-singleton/pom.xml b/appserver/tests/payara-samples/samples/clustered-singleton/pom.xml index 17fb5c7c947..1598b6e3aea 100644 --- a/appserver/tests/payara-samples/samples/clustered-singleton/pom.xml +++ b/appserver/tests/payara-samples/samples/clustered-singleton/pom.xml @@ -3,7 +3,7 @@ ~ /* ~ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. ~ * - ~ * Copyright (c) [2019] Payara Foundation and/or its affiliates. All rights reserved. + ~ * Copyright (c) [2019-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