You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2018/12/06 22:23:05 UTC
[01/27] tomee git commit: Uses constructor instead of addAll method
for performance proposes
Repository: tomee
Updated Branches:
refs/heads/master c1f9d1976 -> 4c835ca03
Uses constructor instead of addAll method for performance proposes
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/b06bd4eb
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/b06bd4eb
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/b06bd4eb
Branch: refs/heads/master
Commit: b06bd4eb194bb1b09c601a814f25f084536c7c00
Parents: 7ff618f
Author: Otavio Santana <ot...@gmail.com>
Authored: Tue Dec 4 11:20:21 2018 -0200
Committer: Otavio Santana <ot...@gmail.com>
Committed: Tue Dec 4 11:20:21 2018 -0200
----------------------------------------------------------------------
.../src/main/java/org/apache/openejb/BeanContext.java | 3 +--
.../src/main/java/org/apache/openejb/ClassLoaderUtil.java | 3 +--
.../src/main/java/org/apache/openejb/OpenEjbContainer.java | 3 +--
.../apache/openejb/assembler/classic/MethodInfoUtil.java | 3 +--
.../main/java/org/apache/openejb/cdi/WebappBeanManager.java | 3 +--
.../java/org/apache/openejb/config/DeploymentLoader.java | 9 +++------
.../java/org/apache/openejb/core/BaseSessionContext.java | 3 +--
.../java/org/apache/openejb/core/timer/EJBCronTrigger.java | 4 +---
.../org/apache/openejb/core/timer/MemoryTimerStore.java | 3 +--
.../apache/openejb/core/stateful/StatefulContainerTest.java | 6 ++----
.../openejb/core/stateless/StatelessContainerTest.java | 3 +--
.../core/stateless/StatelessInvocationStatsTest.java | 3 +--
.../openejb/core/stateless/StatelessMetaAnnotationTest.java | 3 +--
.../openejb/core/stateless/StatelessPoolStatsTest.java | 3 +--
14 files changed, 17 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/b06bd4eb/container/openejb-core/src/main/java/org/apache/openejb/BeanContext.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/BeanContext.java b/container/openejb-core/src/main/java/org/apache/openejb/BeanContext.java
index 0b98269..778c3f3 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/BeanContext.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/BeanContext.java
@@ -211,8 +211,7 @@ public class BeanContext extends DeploymentContext {
if (timeout != null) {
final AnnotatedType annotatedType = cdiEjbBean.getAnnotatedType();
final AnnotationManager annotationManager = getWebBeansContext().getAnnotationManager();
- final Collection<Annotation> annotations = new HashSet<>();
- annotations.addAll(annotationManager.getInterceptorAnnotations(annotatedType.getAnnotations()));
+ final Collection<Annotation> annotations = new HashSet<>(annotationManager.getInterceptorAnnotations(annotatedType.getAnnotations()));
final Set<AnnotatedMethod<?>> methods = annotatedType.getMethods();
for (final AnnotatedMethod<?> m : methods) {
if (timeout.equals(m.getJavaMember())) {
http://git-wip-us.apache.org/repos/asf/tomee/blob/b06bd4eb/container/openejb-core/src/main/java/org/apache/openejb/ClassLoaderUtil.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/ClassLoaderUtil.java b/container/openejb-core/src/main/java/org/apache/openejb/ClassLoaderUtil.java
index d36eb60..642ceab 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/ClassLoaderUtil.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/ClassLoaderUtil.java
@@ -334,8 +334,7 @@ public class ClassLoaderUtil {
urls = rawUrls;
} else {
final CompositeClassLoaderConfigurer configurer = new CompositeClassLoaderConfigurer(configurer1, configurer2, configurer3);
- final Collection<URL> list = new ArrayList<>();
- list.addAll(Arrays.asList(rawUrls));
+ final Collection<URL> list = new ArrayList<>(Arrays.asList(rawUrls));
ClassLoaderConfigurer.Helper.configure(list, configurer);
urls = list.toArray(new URL[list.size()]);
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/b06bd4eb/container/openejb-core/src/main/java/org/apache/openejb/OpenEjbContainer.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/OpenEjbContainer.java b/container/openejb-core/src/main/java/org/apache/openejb/OpenEjbContainer.java
index fb3cae2..6713824 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/OpenEjbContainer.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/OpenEjbContainer.java
@@ -278,8 +278,7 @@ public final class OpenEjbContainer extends EJBContainer {
final Set<String> callers;
if (map.containsKey(OPENEJB_ADDITIONNAL_CALLERS_KEY)) {
- callers = new LinkedHashSet<>();
- callers.addAll(Arrays.asList(((String) map.get(OPENEJB_ADDITIONNAL_CALLERS_KEY)).split(",")));
+ callers = new LinkedHashSet<>(Arrays.asList(((String) map.get(OPENEJB_ADDITIONNAL_CALLERS_KEY)).split(",")));
} else {
callers = NewLoaderLogic.callers();
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/b06bd4eb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodInfoUtil.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodInfoUtil.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodInfoUtil.java
index f3dc4c9..95d592e 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodInfoUtil.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/MethodInfoUtil.java
@@ -432,10 +432,9 @@ public class MethodInfoUtil {
}
private static List<Method> getWildCardView(final BeanContext info) {
- final List<Method> methods = new ArrayList<>();
final List<Method> beanMethods = asList(info.getBeanClass().getMethods());
- methods.addAll(beanMethods);
+ final List<Method> methods = new ArrayList<>(beanMethods);
if (info.getRemoteInterface() != null) {
methods.addAll(exclude(beanMethods, info.getRemoteInterface().getMethods()));
http://git-wip-us.apache.org/repos/asf/tomee/blob/b06bd4eb/container/openejb-core/src/main/java/org/apache/openejb/cdi/WebappBeanManager.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cdi/WebappBeanManager.java b/container/openejb-core/src/main/java/org/apache/openejb/cdi/WebappBeanManager.java
index 73ab2b0..055afbc 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/WebappBeanManager.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/WebappBeanManager.java
@@ -90,8 +90,7 @@ public class WebappBeanManager extends BeanManagerImpl {
@Override
public <T> Set<ObserverMethod<? super T>> resolveObserverMethods(final T event, final EventMetadataImpl metadata) {
- final Set<ObserverMethod<? super T>> set = new HashSet<>();
- set.addAll(super.resolveObserverMethods(event, metadata));
+ final Set<ObserverMethod<? super T>> set = new HashSet<>(super.resolveObserverMethods(event, metadata));
if (isEvent(event)) {
final BeanManagerImpl parentBm = getParentBm();
http://git-wip-us.apache.org/repos/asf/tomee/blob/b06bd4eb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
index 22d92e4..c818503 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
@@ -268,10 +268,9 @@ public class DeploymentLoader implements DeploymentFilterable {
}
public static void addWebModuleDescriptors(final URL baseUrl, final WebModule webModule, final AppModule appModule) throws OpenEJBException {
- final Map<String, Object> otherDD = new HashMap<>();
final List<URL> urls = webModule.getScannableUrls();
final ResourceFinder finder = new ResourceFinder("", urls.toArray(new URL[urls.size()]));
- otherDD.putAll(getDescriptors(finder, false));
+ final Map<String, Object> otherDD = new HashMap<>(getDescriptors(finder, false));
// "persistence.xml" is done separately since we manage a list of url and not s single url
try {
@@ -965,9 +964,8 @@ public class DeploymentLoader implements DeploymentFilterable {
// determine war class path
- final List<URL> webUrls = new ArrayList<>();
ensureContainerUrls();
- webUrls.addAll(containerUrls);
+ final List<URL> webUrls = new ArrayList<>(containerUrls);
final SystemInstance systemInstance = SystemInstance.get();
@@ -1543,8 +1541,7 @@ public class DeploymentLoader implements DeploymentFilterable {
}
// create the class loader
- final List<URL> classPath = new ArrayList<>();
- classPath.addAll(rarLibs.values());
+ final List<URL> classPath = new ArrayList<>(rarLibs.values());
final ClassLoaderConfigurer configurer = QuickJarsTxtParser.parse(new File(rarFile, "META-INF/" + QuickJarsTxtParser.FILE_NAME));
if (configurer != null) {
http://git-wip-us.apache.org/repos/asf/tomee/blob/b06bd4eb/container/openejb-core/src/main/java/org/apache/openejb/core/BaseSessionContext.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/BaseSessionContext.java b/container/openejb-core/src/main/java/org/apache/openejb/core/BaseSessionContext.java
index 8a3edb7..f88a230 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/core/BaseSessionContext.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/core/BaseSessionContext.java
@@ -148,8 +148,7 @@ public abstract class BaseSessionContext extends BaseContext implements SessionC
if (InterfaceType.LOCALBEAN.equals(interfaceType)) {
return LocalBeanProxyFactory.constructProxy(di.get(BeanContext.ProxyClass.class).getProxy(), handler);
} else {
- final List<Class> interfaces = new ArrayList<>();
- interfaces.addAll(di.getInterfaces(interfaceType));
+ final List<Class> interfaces = new ArrayList<>(di.getInterfaces(interfaceType));
interfaces.add(Serializable.class);
interfaces.add(IntraVmProxy.class);
if (BeanType.STATEFUL.equals(type) || BeanType.MANAGED.equals(type)) {
http://git-wip-us.apache.org/repos/asf/tomee/blob/b06bd4eb/container/openejb-core/src/main/java/org/apache/openejb/core/timer/EJBCronTrigger.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/timer/EJBCronTrigger.java b/container/openejb-core/src/main/java/org/apache/openejb/core/timer/EJBCronTrigger.java
index 83cc0e0..585a3e9 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/core/timer/EJBCronTrigger.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/core/timer/EJBCronTrigger.java
@@ -971,9 +971,7 @@ public class EJBCronTrigger extends CronTriggerImpl {
private TreeSet<Integer> getNewValuesFromDynamicExpressions(final Calendar calendar) {
- final TreeSet<Integer> newValues = new TreeSet<>();
-
- newValues.addAll(values);
+ final TreeSet<Integer> newValues = new TreeSet<>(values);
for (final RangeExpression weekDayRangeExpression : weekDayRangeExpressions) {
http://git-wip-us.apache.org/repos/asf/tomee/blob/b06bd4eb/container/openejb-core/src/main/java/org/apache/openejb/core/timer/MemoryTimerStore.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/timer/MemoryTimerStore.java b/container/openejb-core/src/main/java/org/apache/openejb/core/timer/MemoryTimerStore.java
index ab110d5..178ee90 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/core/timer/MemoryTimerStore.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/core/timer/MemoryTimerStore.java
@@ -225,8 +225,7 @@ public class MemoryTimerStore implements TimerStore {
@Override
public Map<Long, TimerData> getTasks() {
checkThread();
- final TreeMap<Long, TimerData> allTasks = new TreeMap<>();
- allTasks.putAll(taskStore);
+ final TreeMap<Long, TimerData> allTasks = new TreeMap<>(taskStore);
for (final Long key : remove) {
allTasks.remove(key);
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/b06bd4eb/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulContainerTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulContainerTest.java b/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulContainerTest.java
index 45b42b3..56fb812 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulContainerTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulContainerTest.java
@@ -60,8 +60,7 @@ public class StatefulContainerTest extends TestCase {
}
public void testBusinessLocalBeanInterface() throws Exception {
- final List localbeanExpectedLifecycle = new ArrayList();
- localbeanExpectedLifecycle.addAll(expectedLifecycle);
+ final List localbeanExpectedLifecycle = new ArrayList(expectedLifecycle);
// WAS can't avoid the extra constructor call
// NOW it was rewritten to avoid it
@@ -162,8 +161,7 @@ public class StatefulContainerTest extends TestCase {
}
public void testBusinessLocalBeanInterfaceInTx() throws Exception {
- final List localbeanExpectedLifecycle = new ArrayList();
- localbeanExpectedLifecycle.addAll(inTxExpectedLifecycle);
+ final List localbeanExpectedLifecycle = new ArrayList(inTxExpectedLifecycle);
// WAS can't avoid the extra constructor call
// NOW it was rewritten to avoid it
http://git-wip-us.apache.org/repos/asf/tomee/blob/b06bd4eb/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessContainerTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessContainerTest.java b/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessContainerTest.java
index 2eda85f..d7a5554 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessContainerTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessContainerTest.java
@@ -74,8 +74,7 @@ public class StatelessContainerTest extends TestCase {
assertSame("lifecycle", lifecycle, WidgetBean.lifecycle);
// Check the lifecycle of the bean
- final List localBeanExpected = new ArrayList();
- localBeanExpected.addAll(expected);
+ final List localBeanExpected = new ArrayList(expected);
assertEquals(join("\n", localBeanExpected), join("\n", lifecycle));
}
{
http://git-wip-us.apache.org/repos/asf/tomee/blob/b06bd4eb/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessInvocationStatsTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessInvocationStatsTest.java b/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessInvocationStatsTest.java
index 2abd084..dc26b02 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessInvocationStatsTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessInvocationStatsTest.java
@@ -285,8 +285,7 @@ public class StatelessInvocationStatsTest {
expectedOperations.add(new MBeanOperationInfo(s + ".values", "", new MBeanParameterInfo[0], "[D", MBeanOperationInfo.UNKNOWN));
}
- final List<MBeanOperationInfo> actualOperations1 = new ArrayList<>();
- actualOperations1.addAll(Arrays.asList(beanInfo.getOperations()));
+ final List<MBeanOperationInfo> actualOperations1 = new ArrayList<>(Arrays.asList(beanInfo.getOperations()));
//Verify invocation operation information and remove bean.
Assert.assertEquals(expectedOperations, actualOperations1);
http://git-wip-us.apache.org/repos/asf/tomee/blob/b06bd4eb/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessMetaAnnotationTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessMetaAnnotationTest.java b/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessMetaAnnotationTest.java
index 36e2de9..84eff8f 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessMetaAnnotationTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessMetaAnnotationTest.java
@@ -85,8 +85,7 @@ public class StatelessMetaAnnotationTest extends TestCase {
assertSame("lifecycle", lifecycle, WidgetBean.lifecycle);
// Check the lifecycle of the bean
- final List localBeanExpected = new ArrayList();
- localBeanExpected.addAll(expected);
+ final List localBeanExpected = new ArrayList(expected);
assertEquals(join("\n", localBeanExpected), join("\n", lifecycle));
}
{
http://git-wip-us.apache.org/repos/asf/tomee/blob/b06bd4eb/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessPoolStatsTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessPoolStatsTest.java b/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessPoolStatsTest.java
index 6a878bc..b991671 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessPoolStatsTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessPoolStatsTest.java
@@ -199,8 +199,7 @@ public class StatelessPoolStatsTest extends TestCase {
operations, "void", MBeanOperationInfo.UNKNOWN));
expectedOperations.add(new MBeanOperationInfo("flush", "", new MBeanParameterInfo[0], "void", MBeanOperationInfo.UNKNOWN));
- final List<MBeanOperationInfo> actualOperations = new ArrayList<>();
- actualOperations.addAll(Arrays.asList(poolMBeanInfo.getOperations()));
+ final List<MBeanOperationInfo> actualOperations = new ArrayList<>(Arrays.asList(poolMBeanInfo.getOperations()));
assertEquals(expectedOperations, actualOperations);
}
[17/27] tomee git commit: change artifactId to project.artifactId
Posted by jg...@apache.org.
change artifactId to project.artifactId
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/92309e97
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/92309e97
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/92309e97
Branch: refs/heads/master
Commit: 92309e97795daaaedb4dd99fb4018ae0e16ede0b
Parents: 388460f
Author: Sendil Kumar <se...@live.com>
Authored: Wed Dec 5 19:50:24 2018 +0100
Committer: Sendil Kumar <se...@live.com>
Committed: Wed Dec 5 19:50:24 2018 +0100
----------------------------------------------------------------------
examples/mp-metrics-counted/pom.xml | 2 +-
examples/mp-metrics-timed/pom.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/92309e97/examples/mp-metrics-counted/pom.xml
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-counted/pom.xml b/examples/mp-metrics-counted/pom.xml
index 0b96850..9e12854 100644
--- a/examples/mp-metrics-counted/pom.xml
+++ b/examples/mp-metrics-counted/pom.xml
@@ -80,7 +80,7 @@
<version>${project.version}</version>
<configuration>
<tomeeClassifier>microprofile</tomeeClassifier>
- <context>${artifactId}</context>
+ <context>${project.artifactId}</context>
</configuration>
</plugin>
</plugins>
http://git-wip-us.apache.org/repos/asf/tomee/blob/92309e97/examples/mp-metrics-timed/pom.xml
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-timed/pom.xml b/examples/mp-metrics-timed/pom.xml
index 01c7186..88fcd30 100644
--- a/examples/mp-metrics-timed/pom.xml
+++ b/examples/mp-metrics-timed/pom.xml
@@ -80,7 +80,7 @@
<version>8.0.0-SNAPSHOT</version>
<configuration>
<tomeeClassifier>microprofile</tomeeClassifier>
- <context>${artifactId}</context>
+ <context>${project.artifactId}</context>
</configuration>
</plugin>
</plugins>
[08/27] tomee git commit: TOMEE-2301 - add test fo the thread factory
service
Posted by jg...@apache.org.
TOMEE-2301 - add test fo the thread factory service
Signed-off-by: brunobat <br...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/2aaca111
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/2aaca111
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/2aaca111
Branch: refs/heads/master
Commit: 2aaca11108805c73cd1b86fb7f0a2cc4af5d92b2
Parents: e96315b
Author: brunobat <br...@gmail.com>
Authored: Wed Dec 5 15:26:36 2018 +0000
Committer: brunobat <br...@gmail.com>
Committed: Wed Dec 5 15:27:04 2018 +0000
----------------------------------------------------------------------
.../executor/ThreadFactoryServiceTest.java | 53 ++++++++++++++++++++
1 file changed, 53 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/2aaca111/examples/concurrency-utils/src/test/java/org/superbiz/executor/ThreadFactoryServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/concurrency-utils/src/test/java/org/superbiz/executor/ThreadFactoryServiceTest.java b/examples/concurrency-utils/src/test/java/org/superbiz/executor/ThreadFactoryServiceTest.java
new file mode 100644
index 0000000..8518c28
--- /dev/null
+++ b/examples/concurrency-utils/src/test/java/org/superbiz/executor/ThreadFactoryServiceTest.java
@@ -0,0 +1,53 @@
+package org.superbiz.executor;
+
+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.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+import java.util.concurrent.TimeUnit;
+import java.util.logging.Logger;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+@RunWith(Arquillian.class)
+public class ThreadFactoryServiceTest {
+
+ private static final Logger LOGGER = Logger.getLogger(ThreadFactoryServiceTest.class.getSimpleName());
+
+ @Inject
+ private ThreadFactoryService factoryService;
+
+ @Deployment()
+ public static final WebArchive app() {
+ return ShrinkWrap.create(WebArchive.class, "example.war")
+ .addClasses(ThreadFactoryService.class)
+ .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
+ }
+
+ @Test
+ public void asyncTask() throws InterruptedException {
+
+ factoryService.asyncTask(1);
+ LOGGER.info("Do something else");
+ TimeUnit.MILLISECONDS.sleep(200);
+ }
+}
\ No newline at end of file
[03/27] tomee git commit: uses Collection.singletonList when just
there is one element
Posted by jg...@apache.org.
uses Collection.singletonList when just there is one element
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/a381b9f6
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/a381b9f6
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/a381b9f6
Branch: refs/heads/master
Commit: a381b9f61763228cb3bdab609e8f487bcd9a83e2
Parents: e556346
Author: Otavio Santana <ot...@gmail.com>
Authored: Tue Dec 4 11:48:36 2018 -0200
Committer: Otavio Santana <ot...@gmail.com>
Committed: Tue Dec 4 11:48:36 2018 -0200
----------------------------------------------------------------------
.../openejb/assembler/classic/EnterpriseBeanBuilder.java | 3 ++-
.../java/org/apache/openejb/config/AnnotationDeployer.java | 2 +-
.../apache/openejb/config/ConfigurableClasspathArchive.java | 3 ++-
.../java/org/apache/openejb/config/DeploymentLoader.java | 3 ++-
.../java/org/apache/openejb/config/sys/SaxAppCtxConfig.java | 9 +++++----
.../main/java/org/apache/openejb/util/AnnotationFinder.java | 2 +-
.../java/org/apache/openejb/util/helper/CommandHelper.java | 5 +++--
.../openejb/core/security/SecurityServiceImplTest.java | 3 ++-
.../main/java/org/apache/openejb/junit/OpenEjbRunner.java | 3 ++-
9 files changed, 20 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/a381b9f6/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java
index 5fd3b16..6886c56 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java
@@ -40,6 +40,7 @@ import javax.persistence.SynchronizationType;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -387,7 +388,7 @@ class EnterpriseBeanBuilder {
candidateInfo.className = info.className;
candidateInfo.id = info.id;
candidateInfo.methodName = info.methodName;
- candidateInfo.methodParams = Arrays.asList(Timer.class.getName());
+ candidateInfo.methodParams = Collections.singletonList(Timer.class.getName());
timeout = MethodInfoUtil.toMethod(ejbClass, candidateInfo);
}
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/a381b9f6/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java b/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
index 169cdde..63fcef3 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
@@ -3127,7 +3127,7 @@ public class AnnotationDeployer implements DynamicDeployer {
all.local.addAll(xml.local);
all.remote.addAll(xml.remote);
- final List<Class<?>> classes = strict ? new ArrayList(Arrays.asList(beanClass)) : Classes.ancestors(beanClass);
+ final List<Class<?>> classes = strict ? new ArrayList(Collections.singletonList(beanClass)) : Classes.ancestors(beanClass);
for (final Class<?> clazz : classes) {
http://git-wip-us.apache.org/repos/asf/tomee/blob/a381b9f6/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurableClasspathArchive.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurableClasspathArchive.java b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurableClasspathArchive.java
index 76e7376..519790f 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurableClasspathArchive.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurableClasspathArchive.java
@@ -34,6 +34,7 @@ import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -56,7 +57,7 @@ public class ConfigurableClasspathArchive extends CompositeArchive implements Sc
}
public ConfigurableClasspathArchive(final ClassLoader loader, final URL url) {
- this(new FakeModule(loader), Arrays.asList(url));
+ this(new FakeModule(loader), Collections.singletonList(url));
}
public ConfigurableClasspathArchive(final Module module, final boolean forceDescriptor, final Iterable<URL> urls) {
http://git-wip-us.apache.org/repos/asf/tomee/blob/a381b9f6/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
index c818503..c9aafc4 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
@@ -837,7 +837,8 @@ public class DeploymentLoader implements DeploymentFilterable {
{
final Object pXml = appModule.getAltDDs().get("persistence.xml");
- List<URL> persistenceXmls = pXml == null ? null : (List.class.isInstance(pXml) ? (List<URL>) pXml : new ArrayList<>(asList(URL.class.cast(pXml))));
+ List<URL> persistenceXmls = pXml == null ? null : (List.class.isInstance(pXml) ? (List<URL>) pXml :
+ new ArrayList<>(Collections.singletonList(URL.class.cast(pXml))));
if (persistenceXmls == null) {
persistenceXmls = new ArrayList<>();
appModule.getAltDDs().put("persistence.xml", persistenceXmls);
http://git-wip-us.apache.org/repos/asf/tomee/blob/a381b9f6/container/openejb-core/src/main/java/org/apache/openejb/config/sys/SaxAppCtxConfig.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/sys/SaxAppCtxConfig.java b/container/openejb-core/src/main/java/org/apache/openejb/config/sys/SaxAppCtxConfig.java
index 0164794..07bb121 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/sys/SaxAppCtxConfig.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/sys/SaxAppCtxConfig.java
@@ -41,6 +41,7 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -60,15 +61,15 @@ public class SaxAppCtxConfig {
private static final Collection<String> IMPORT_ALIASES = Arrays.asList("import", "include");
private static final Collection<String> APPLICATION_ALIASES = Arrays.asList("appcontext", "app-context", "application");
private static final Collection<String> POJOS_ALIASES = Arrays.asList("pojocontexts", "pojo-contexts", "pojos");
- private static final Collection<String> POJO_ALIASES = Arrays.asList("pojo");
+ private static final Collection<String> POJO_ALIASES = Collections.singletonList("pojo");
private static final Collection<String> BEAN_CONTEXTS_ALIASES = Arrays.asList("beancontexts", "bean-contexts", "ejbs");
private static final Collection<String> WEBAPP_ALIASES = Arrays.asList("webapps", "webcontexts", "web-contexts", "wars");
private static final Collection<String> MODULE_ALIASES = Arrays.asList("modulecontext", "module");
private static final Collection<String> BEAN_CONTEXT_ALIASES = Arrays.asList("ejb", "beancontext", "bean-context");
private static final Collection<String> CONFIGURATION_ALIASES = Arrays.asList("configuration", "properties", "settings");
- private static final Collection<String> RESOURCES_ALIASES = Arrays.asList("resources");
- private static final Collection<String> SERVICE_ALIASES = Arrays.asList("service");
- private static final Collection<String> RESOURCE_ALIASES = Arrays.asList("resource");
+ private static final Collection<String> RESOURCES_ALIASES = Collections.singletonList("resources");
+ private static final Collection<String> SERVICE_ALIASES = Collections.singletonList("service");
+ private static final Collection<String> RESOURCE_ALIASES = Collections.singletonList("resource");
private static final Collection<String> ENV_ENTRIES_ALIASES = Arrays.asList("enventries", "env-entries");
private static final Collection<String> ENV_ENTRY_ALIASES = Arrays.asList("enventry", "env-entry");
http://git-wip-us.apache.org/repos/asf/tomee/blob/a381b9f6/container/openejb-core/src/main/java/org/apache/openejb/util/AnnotationFinder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/AnnotationFinder.java b/container/openejb-core/src/main/java/org/apache/openejb/util/AnnotationFinder.java
index 8d9570a..e1c4266 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/util/AnnotationFinder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/util/AnnotationFinder.java
@@ -109,7 +109,7 @@ public class AnnotationFinder {
}
public AnnotationFinder(final ClassLoader classLoader, final URL url) {
- this(classLoader, Arrays.asList(url));
+ this(classLoader, Collections.singletonList(url));
}
public AnnotationFinder(final ClassLoader classLoader, final Collection<URL> urls) {
http://git-wip-us.apache.org/repos/asf/tomee/blob/a381b9f6/container/openejb-core/src/main/java/org/apache/openejb/util/helper/CommandHelper.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/helper/CommandHelper.java b/container/openejb-core/src/main/java/org/apache/openejb/util/helper/CommandHelper.java
index c7a3c84..30c3b8c 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/util/helper/CommandHelper.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/util/helper/CommandHelper.java
@@ -26,6 +26,7 @@ import org.apache.openejb.table.Lines;
import org.apache.openejb.util.JavaSecurityManagers;
import java.util.Arrays;
+import java.util.Collections;
public final class CommandHelper {
private CommandHelper() {
@@ -69,14 +70,14 @@ public final class CommandHelper {
if (!empty) {
sb.append(", ");
}
- sb.append("Local").append(Arrays.asList(bc.getBusinessLocalInterfaces()));
+ sb.append("Local").append(Collections.singletonList(bc.getBusinessLocalInterfaces()));
empty = false;
}
if (bc.getBusinessRemoteInterface() != null) {
if (!empty) {
sb.append(", ");
}
- sb.append("Remote").append(Arrays.asList(bc.getBusinessRemoteInterfaces()));
+ sb.append("Remote").append(Collections.singletonList(bc.getBusinessRemoteInterfaces()));
}
return sb.toString();
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/a381b9f6/container/openejb-core/src/test/java/org/apache/openejb/core/security/SecurityServiceImplTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/security/SecurityServiceImplTest.java b/container/openejb-core/src/test/java/org/apache/openejb/core/security/SecurityServiceImplTest.java
index a6787ea..197747f 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/core/security/SecurityServiceImplTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/security/SecurityServiceImplTest.java
@@ -23,6 +23,7 @@ import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
+import java.util.Collections;
import java.util.Enumeration;
import java.util.concurrent.atomic.AtomicReference;
@@ -36,7 +37,7 @@ public class SecurityServiceImplTest {
final ClassLoader jaasLoader = new URLClassLoader(new URL[0]) {
@Override
public Enumeration<URL> getResources(final String name) throws IOException {
- return new ArrayEnumeration(asList(new URL("file:/tmp/jaas/folder+with+plus/login.config")));
+ return new ArrayEnumeration(Collections.singletonList(new URL("file:/tmp/jaas/folder+with+plus/login.config")));
}
};
Thread.currentThread().setContextClassLoader(jaasLoader);
http://git-wip-us.apache.org/repos/asf/tomee/blob/a381b9f6/container/openejb-junit/src/main/java/org/apache/openejb/junit/OpenEjbRunner.java
----------------------------------------------------------------------
diff --git a/container/openejb-junit/src/main/java/org/apache/openejb/junit/OpenEjbRunner.java b/container/openejb-junit/src/main/java/org/apache/openejb/junit/OpenEjbRunner.java
index 276c621..bbcdaf4 100644
--- a/container/openejb-junit/src/main/java/org/apache/openejb/junit/OpenEjbRunner.java
+++ b/container/openejb-junit/src/main/java/org/apache/openejb/junit/OpenEjbRunner.java
@@ -29,6 +29,7 @@ import org.junit.runners.model.InitializationError;
import java.lang.reflect.Method;
import java.util.Arrays;
+import java.util.Collections;
public class OpenEjbRunner extends Runner {
private final Runner delegate;
@@ -54,7 +55,7 @@ public class OpenEjbRunner extends Runner {
try {
delegate = getDelegateRunner(testClazz);
} catch (final Throwable e) {
- throw new InitializationError(Arrays.asList(e));
+ throw new InitializationError(Collections.singletonList(e));
}
}
[05/27] tomee git commit: uses entreset instead of key
Posted by jg...@apache.org.
uses entreset instead of key
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/5c9bad84
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/5c9bad84
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/5c9bad84
Branch: refs/heads/master
Commit: 5c9bad84f7d58b8d3c418befe62d3fa5e526bb8d
Parents: d1135d3
Author: Otavio Santana <ot...@gmail.com>
Authored: Tue Dec 4 12:48:21 2018 -0200
Committer: Otavio Santana <ot...@gmail.com>
Committed: Tue Dec 4 12:48:21 2018 -0200
----------------------------------------------------------------------
.../openejb/assembler/classic/Assembler.java | 7 +++--
.../org/apache/openejb/config/AutoConfig.java | 18 ++++++-------
.../apache/openejb/config/DeploymentLoader.java | 28 ++++++++++----------
.../openejb/core/managed/SimplePassivater.java | 4 +--
.../core/security/jaas/SQLLoginModule.java | 8 +++---
.../openejb/core/stateful/SimplePassivater.java | 4 +--
.../openejb/resource/AutoConnectionTracker.java | 6 ++---
.../openejb/ivm/naming/IvmContextTest.java | 4 +--
8 files changed, 39 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/5c9bad84/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
index f10ce76..a0cf0fb 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
@@ -611,10 +611,9 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
containerInfos.add(serviceInfo);
}
- final Set<String> apps = appContainers.keySet();
- for (final String app : apps) {
- final List<ContainerInfo> containerInfos = appContainers.get(app);
- final ClassLoader classLoader = appClassLoaders.get(app);
+ for (final Entry<String, List<ContainerInfo>> stringListEntry : appContainers.entrySet()) {
+ final List<ContainerInfo> containerInfos = stringListEntry.getValue();
+ final ClassLoader classLoader = appClassLoaders.get(stringListEntry.getKey());
final ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
http://git-wip-us.apache.org/repos/asf/tomee/blob/5c9bad84/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java b/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
index 4c8e877..54f0f59 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
@@ -2287,19 +2287,19 @@ public class AutoConfig implements DynamicDeployer, JndiConstants {
for (final String s : resourceAdapterIds) {
logger.debug(appId + " module contains resource adapter id: " + s);
}
- for (final String s : resourceIdsByType.keySet()) {
- for (final String value : resourceIdsByType.get(s)) {
- logger.debug(appId + " module contains resource type: " + s + " --> " + value);
+ for (final Map.Entry<String, List<String>> stringListEntry : resourceIdsByType.entrySet()) {
+ for (final String value : stringListEntry.getValue()) {
+ logger.debug(appId + " module contains resource type: " + stringListEntry.getKey() + " --> " + value);
}
}
- for (final String s : resourceEnvIdsByType.keySet()) {
- for (final String value : resourceEnvIdsByType.get(s)) {
- logger.debug(appId + " module contains resource env type: " + s + " --> " + value);
+ for (final Map.Entry<String, List<String>> stringListEntry : resourceEnvIdsByType.entrySet()) {
+ for (final String value : stringListEntry.getValue()) {
+ logger.debug(appId + " module contains resource env type: " + stringListEntry.getKey() + " --> " + value);
}
}
- for (final String s : containerIdsByType.keySet()) {
- for (final String value : containerIdsByType.get(s)) {
- logger.debug(appId + " module contains container type: " + s + " --> " + value);
+ for (final Map.Entry<String, List<String>> stringListEntry : containerIdsByType.entrySet()) {
+ for (final String value : stringListEntry.getValue()) {
+ logger.debug(appId + " module contains container type: " + stringListEntry.getKey() + " --> " + value);
}
}
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5c9bad84/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
index a66be39..1611740 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
@@ -561,9 +561,9 @@ public class DeploymentLoader implements DeploymentFilterable {
}
// EJB modules
- for (final String moduleName : ejbModules.keySet()) {
+ for (final Map.Entry<String, URL> stringURLEntry : ejbModules.entrySet()) {
try {
- URL ejbUrl = ejbModules.get(moduleName);
+ URL ejbUrl = stringURLEntry.getValue();
// we should try to use a reference to the temp classloader
if (ClassLoaderUtil.isUrlCached(appModule.getJarLocation(), ejbUrl)) {
try {
@@ -579,14 +579,14 @@ public class DeploymentLoader implements DeploymentFilterable {
final EjbModule ejbModule = createEjbModule(ejbUrl, absolutePath, appClassLoader);
appModule.getEjbModules().add(ejbModule);
} catch (final OpenEJBException e) {
- logger.error("Unable to load EJBs from EAR: " + appId + ", module: " + moduleName + ". Exception: " + e.getMessage(), e);
+ logger.error("Unable to load EJBs from EAR: " + appId + ", module: " + stringURLEntry.getKey() + ". Exception: " + e.getMessage(), e);
}
}
// Application Client Modules
- for (final String moduleName : clientModules.keySet()) {
+ for (final Map.Entry<String, URL> stringURLEntry : clientModules.entrySet()) {
try {
- URL clientUrl = clientModules.get(moduleName);
+ URL clientUrl = stringURLEntry.getValue();
// we should try to use a reference to the temp classloader
if (ClassLoaderUtil.isUrlCached(appModule.getJarLocation(), clientUrl)) {
try {
@@ -603,14 +603,14 @@ public class DeploymentLoader implements DeploymentFilterable {
appModule.getClientModules().add(clientModule);
} catch (final Exception e) {
- logger.error("Unable to load App Client from EAR: " + appId + ", module: " + moduleName + ". Exception: " + e.getMessage(), e);
+ logger.error("Unable to load App Client from EAR: " + appId + ", module: " + stringURLEntry.getKey() + ". Exception: " + e.getMessage(), e);
}
}
// Resource modules
- for (final String moduleName : resouceModules.keySet()) {
+ for (final Map.Entry<String, URL> stringURLEntry : resouceModules.entrySet()) {
try {
- URL rarUrl = resouceModules.get(moduleName);
+ URL rarUrl = stringURLEntry.getValue();
// we should try to use a reference to the temp classloader
if (ClassLoaderUtil.isUrlCached(appModule.getJarLocation(), rarUrl)) {
try {
@@ -620,22 +620,22 @@ public class DeploymentLoader implements DeploymentFilterable {
// no-op
}
}
- final ConnectorModule connectorModule = createConnectorModule(appId, URLs.toFilePath(rarUrl), appClassLoader, moduleName);
+ final ConnectorModule connectorModule = createConnectorModule(appId, URLs.toFilePath(rarUrl), appClassLoader, stringURLEntry.getKey());
if (connectorModule != null) {
appModule.getConnectorModules().add(connectorModule);
}
} catch (final OpenEJBException e) {
- logger.error("Unable to load RAR: " + appId + ", module: " + moduleName + ". Exception: " + e.getMessage(), e);
+ logger.error("Unable to load RAR: " + appId + ", module: " + stringURLEntry.getKey() + ". Exception: " + e.getMessage(), e);
}
}
// Web modules
- for (final String moduleName : webModules.keySet()) {
+ for (final Map.Entry<String, URL> stringURLEntry : webModules.entrySet()) {
try {
- final URL warUrl = webModules.get(moduleName);
- addWebModule(appModule, warUrl, appClassLoader, webContextRoots.get(moduleName), null);
+ final URL warUrl = stringURLEntry.getValue();
+ addWebModule(appModule, warUrl, appClassLoader, webContextRoots.get(stringURLEntry.getKey()), null);
} catch (final OpenEJBException e) {
- logger.error("Unable to load WAR: " + appId + ", module: " + moduleName + ". Exception: " + e.getMessage(), e);
+ logger.error("Unable to load WAR: " + appId + ", module: " + stringURLEntry.getKey() + ". Exception: " + e.getMessage(), e);
}
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5c9bad84/container/openejb-core/src/main/java/org/apache/openejb/core/managed/SimplePassivater.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/managed/SimplePassivater.java b/container/openejb-core/src/main/java/org/apache/openejb/core/managed/SimplePassivater.java
index aa84b03..c6424f9 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/core/managed/SimplePassivater.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/core/managed/SimplePassivater.java
@@ -97,8 +97,8 @@ public class SimplePassivater implements PassivationStrategy {
@Override
public void passivate(final Map hash) throws SystemException {
- for (final Object id : hash.keySet()) {
- passivate(id, hash.get(id));
+ for (final Object o : hash.entrySet()) {
+ passivate(((Map.Entry) o).getKey(), ((Map.Entry) o).getValue());
}
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5c9bad84/container/openejb-core/src/main/java/org/apache/openejb/core/security/jaas/SQLLoginModule.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/security/jaas/SQLLoginModule.java b/container/openejb-core/src/main/java/org/apache/openejb/core/security/jaas/SQLLoginModule.java
index af61231..0551ad3 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/core/security/jaas/SQLLoginModule.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/core/security/jaas/SQLLoginModule.java
@@ -102,13 +102,13 @@ public class SQLLoginModule implements LoginModule {
this.subject = subject;
this.handler = callbackHandler;
- for (final Object key : options.keySet()) {
- final Option option = Option.findByName((String) key);
+ for (final Object o : options.entrySet()) {
+ final Option option = Option.findByName((String) ((Map.Entry) o).getKey());
if (option != null) {
- final String value = (String) options.get(key);
+ final String value = (String) ((Map.Entry) o).getValue();
optionsMap.put(option, value.trim());
} else {
- log.warning("Ignoring option: {0}. Not supported.", key);
+ log.warning("Ignoring option: {0}. Not supported.", ((Map.Entry) o).getKey());
}
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5c9bad84/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/SimplePassivater.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/SimplePassivater.java b/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/SimplePassivater.java
index e49766f..21a45a3 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/SimplePassivater.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/SimplePassivater.java
@@ -101,8 +101,8 @@ public class SimplePassivater implements PassivationStrategy {
@Override
public void passivate(final Map hash) throws SystemException {
- for (final Object id : hash.keySet()) {
- passivate(id, hash.get(id));
+ for (final Object o : hash.entrySet()) {
+ passivate(((Map.Entry) o).getKey(), ((Map.Entry) o).getValue());
}
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5c9bad84/container/openejb-core/src/main/java/org/apache/openejb/resource/AutoConnectionTracker.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/resource/AutoConnectionTracker.java b/container/openejb-core/src/main/java/org/apache/openejb/resource/AutoConnectionTracker.java
index abbfe8a..4f735c1 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/resource/AutoConnectionTracker.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/resource/AutoConnectionTracker.java
@@ -133,14 +133,14 @@ public class AutoConnectionTracker implements ConnectionTracker {
final Map<ManagedConnectionInfo, Map<ConnectionInfo, Object>> txConnections = (Map<ManagedConnectionInfo, Map<ConnectionInfo, Object>>) registry.getResource(KEY);
if (txConnections != null && txConnections.size() > 0) {
- for (final ManagedConnectionInfo managedConnectionInfo : txConnections.keySet()) {
+ for (final Map.Entry<ManagedConnectionInfo, Map<ConnectionInfo, Object>> managedConnectionInfoMapEntry : txConnections.entrySet()) {
final StringBuilder sb = new StringBuilder();
- final Collection<ConnectionInfo> connectionInfos = txConnections.get(managedConnectionInfo).keySet();
+ final Collection<ConnectionInfo> connectionInfos = managedConnectionInfoMapEntry.getValue().keySet();
for (final ConnectionInfo connectionInfo : connectionInfos) {
sb.append("\n ").append("Connection handle opened at ").append(stackTraceToString(connectionInfo.getTrace().getStackTrace()));
}
- logger.warning("Transaction complete, but connection still has handles associated: " + managedConnectionInfo + "\nAbandoned connection information: " + sb);
+ logger.warning("Transaction complete, but connection still has handles associated: " + managedConnectionInfoMapEntry.getKey() + "\nAbandoned connection information: " + sb);
}
}
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/5c9bad84/container/openejb-core/src/test/java/org/apache/openejb/ivm/naming/IvmContextTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/ivm/naming/IvmContextTest.java b/container/openejb-core/src/test/java/org/apache/openejb/ivm/naming/IvmContextTest.java
index 243020a..805326a 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/ivm/naming/IvmContextTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/ivm/naming/IvmContextTest.java
@@ -329,8 +329,8 @@ public class IvmContextTest {
}
writer.println();
- for (Context subContext : subContexts.keySet()) {
- hasErrors |= listContext(subContext, subContexts.get(subContext), writer);
+ for (Map.Entry<Context, String> contextStringEntry : subContexts.entrySet()) {
+ hasErrors |= listContext(contextStringEntry.getKey(), contextStringEntry.getValue(), writer);
}
return hasErrors;
[20/27] tomee git commit: Merge branch 'executor-example' of
https://github.com/brunobat/tomee
Posted by jg...@apache.org.
Merge branch 'executor-example' of https://github.com/brunobat/tomee
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/5659ee9a
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/5659ee9a
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/5659ee9a
Branch: refs/heads/master
Commit: 5659ee9a86f0f86118a6403bf94376b4fdf5beb4
Parents: c1f9d19 2aaca11
Author: Jonathan Gallimore <jg...@tomitribe.com>
Authored: Thu Dec 6 20:20:11 2018 +0000
Committer: Jonathan Gallimore <jg...@tomitribe.com>
Committed: Thu Dec 6 20:20:11 2018 +0000
----------------------------------------------------------------------
examples/concurrency-utils/pom.xml | 68 ++++++++++
.../executor/ManagedScheduledService.java | 129 ++++++++++++++++++
.../org/superbiz/executor/ManagedService.java | 95 ++++++++++++++
.../superbiz/executor/ThreadFactoryService.java | 71 ++++++++++
.../executor/ManagedScheduledServiceTest.java | 130 +++++++++++++++++++
.../superbiz/executor/ManagedServiceTest.java | 105 +++++++++++++++
.../executor/ThreadFactoryServiceTest.java | 53 ++++++++
examples/pom.xml | 1 +
8 files changed, 652 insertions(+)
----------------------------------------------------------------------
[02/27] tomee git commit: uses collections addAll instead of forEach
interaction
Posted by jg...@apache.org.
uses collections addAll instead of forEach interaction
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/e5563468
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/e5563468
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/e5563468
Branch: refs/heads/master
Commit: e5563468dbc7dd583fb9ddd3969f609d1e6c64a3
Parents: b06bd4e
Author: Otavio Santana <ot...@gmail.com>
Authored: Tue Dec 4 11:34:19 2018 -0200
Committer: Otavio Santana <ot...@gmail.com>
Committed: Tue Dec 4 11:34:19 2018 -0200
----------------------------------------------------------------------
.../java/org/apache/openejb/BeanContext.java | 8 ++-----
.../openejb/assembler/classic/Assembler.java | 24 +++++---------------
.../assembler/classic/ValidatorBuilder.java | 4 +---
.../openejb/config/ConfigurationFactory.java | 8 ++-----
.../org/apache/openejb/util/ReferencesTest.java | 4 +---
5 files changed, 12 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/e5563468/container/openejb-core/src/main/java/org/apache/openejb/BeanContext.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/BeanContext.java b/container/openejb-core/src/main/java/org/apache/openejb/BeanContext.java
index 778c3f3..89f42a6 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/BeanContext.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/BeanContext.java
@@ -691,13 +691,9 @@ public class BeanContext extends DeploymentContext {
final ArrayList<Class> classes = new ArrayList<>();
- for (final Class local : businessRemotes) {
- classes.add(local);
- }
+ classes.addAll(businessRemotes);
- for (final Class local : businessLocals) {
- classes.add(local);
- }
+ classes.addAll(businessLocals);
classes.add(this.beanClass);
http://git-wip-us.apache.org/repos/asf/tomee/blob/e5563468/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
index 12cae0b..f10ce76 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
@@ -1416,18 +1416,10 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
final List<CommonInfoObject> vfs = new ArrayList<>(
appInfo.clients.size() + appInfo.connectors.size() +
appInfo.ejbJars.size() + appInfo.webApps.size());
- for (final ClientInfo clientInfo : appInfo.clients) {
- vfs.add(clientInfo);
- }
- for (final ConnectorInfo connectorInfo : appInfo.connectors) {
- vfs.add(connectorInfo);
- }
- for (final EjbJarInfo ejbJarInfo : appInfo.ejbJars) {
- vfs.add(ejbJarInfo);
- }
- for (final WebAppInfo webAppInfo : appInfo.webApps) {
- vfs.add(webAppInfo);
- }
+ vfs.addAll(appInfo.clients);
+ vfs.addAll(appInfo.connectors);
+ vfs.addAll(appInfo.ejbJars);
+ vfs.addAll(appInfo.webApps);
return vfs;
}
@@ -2422,12 +2414,8 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
final List<String> clientIds = new ArrayList<>();
for (final ClientInfo clientInfo : appInfo.clients) {
clientIds.add(clientInfo.moduleId);
- for (final String className : clientInfo.localClients) {
- clientIds.add(className);
- }
- for (final String className : clientInfo.remoteClients) {
- clientIds.add(className);
- }
+ clientIds.addAll(clientInfo.localClients);
+ clientIds.addAll(clientInfo.remoteClients);
}
for (final WebContext webContext : appContext.getWebContexts()) {
http://git-wip-us.apache.org/repos/asf/tomee/blob/e5563468/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java
index 0513f00..f55d165 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java
@@ -96,9 +96,7 @@ public final class ValidatorBuilder {
for (final PropertyType p : config.getProperty()) {
info.propertyTypes.put(p.getName(), p.getValue());
}
- for (final String element : config.getConstraintMapping()) {
- info.constraintMappings.add(element);
- }
+ info.constraintMappings.addAll(config.getConstraintMapping());
}
return info;
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/e5563468/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
index cdc19c5..b6a6f1f 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
@@ -1711,15 +1711,11 @@ public class ConfigurationFactory implements OpenEjbConfigurationFactory {
final OpenEjbConfiguration runningConfig = getRunningConfig();
if (runningConfig != null) {
- for (final ContainerInfo containerInfo : runningConfig.containerSystem.containers) {
- containers.add(containerInfo);
- }
+ containers.addAll(runningConfig.containerSystem.containers);
}
if (sys != null) {
- for (final ContainerInfo containerInfo : sys.containerSystem.containers) {
- containers.add(containerInfo);
- }
+ containers.addAll(sys.containerSystem.containers);
}
return containers;
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/e5563468/container/openejb-core/src/test/java/org/apache/openejb/util/ReferencesTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/util/ReferencesTest.java b/container/openejb-core/src/test/java/org/apache/openejb/util/ReferencesTest.java
index 24f23be..b8284eb 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/util/ReferencesTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/util/ReferencesTest.java
@@ -240,9 +240,7 @@ public class ReferencesTest extends TestCase {
public Bean(final String name, final String... refs) {
this.name = name;
this.refs = new LinkedHashSet<>(refs.length);
- for (final String s : refs) {
- this.refs.add(s);
- }
+ this.refs.addAll(Arrays.asList(refs));
}
public String toString() {
[10/27] tomee git commit: TOMEE-2301 - Creation on 3 test: normal
path, timeout, ended with exception
Posted by jg...@apache.org.
TOMEE-2301 - Creation on 3 test: normal path, timeout, ended with exception
Signed-off-by: brunobat <br...@gmail.com>
rename project
Signed-off-by: brunobat <br...@gmail.com>
perform first example
Signed-off-by: brunobat <br...@gmail.com>
Add example with exception handling and refactor
Signed-off-by: brunobat <br...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/d0c72909
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/d0c72909
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/d0c72909
Branch: refs/heads/master
Commit: d0c7290916d85ec1e7c85d0647ebb0bb2f7467b8
Parents: b3d8edc
Author: brunobat <br...@gmail.com>
Authored: Thu Nov 29 12:21:19 2018 +0000
Committer: brunobat <br...@gmail.com>
Committed: Wed Dec 5 15:27:04 2018 +0000
----------------------------------------------------------------------
examples/concurrency-utils/pom.xml | 68 +++++++++++++
.../org/superbiz/executor/ManagedService.java | 89 ++++++++++++++++
.../superbiz/executor/ManagedServiceTest.java | 102 +++++++++++++++++++
examples/executor/pom.xml | 68 -------------
.../org/superbiz/executor/AsyncBookService.java | 77 --------------
.../superbiz/executor/AsyncBookServiceTest.java | 73 -------------
examples/pom.xml | 1 +
7 files changed, 260 insertions(+), 218 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/d0c72909/examples/concurrency-utils/pom.xml
----------------------------------------------------------------------
diff --git a/examples/concurrency-utils/pom.xml b/examples/concurrency-utils/pom.xml
new file mode 100644
index 0000000..0e0fba6
--- /dev/null
+++ b/examples/concurrency-utils/pom.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>concurrency-utils</artifactId>
+ <version>8.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>OpenEJB :: Examples :: Concurrency utilities example</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <javaee-api.version>8.0</javaee-api.version>
+ <junit.version>4.12</junit.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>${javaee-api.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <!--Tests-->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>arquillian-tomee-remote</artifactId>
+ <version>${pom.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ <version>1.4.0.Final</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-container-test-api</artifactId>
+ <version>1.4.0.Final</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.7.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/d0c72909/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedService.java
----------------------------------------------------------------------
diff --git a/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedService.java b/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedService.java
new file mode 100644
index 0000000..89c89fe
--- /dev/null
+++ b/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedService.java
@@ -0,0 +1,89 @@
+package org.superbiz.executor;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import javax.annotation.Resource;
+import javax.enterprise.concurrent.ManagedExecutorService;
+import javax.enterprise.context.RequestScoped;
+import java.util.concurrent.CompletableFuture;
+import java.util.function.Supplier;
+
+import static java.util.Objects.nonNull;
+
+
+@RequestScoped
+public class ManagedService {
+
+ @Resource
+ private ManagedExecutorService executor;
+
+ /**
+ * Executes an opperation asynchronously, in a different thread provided by the {@link ManagedExecutorService}.
+ * The computation will carry on after the return of the method.
+ *
+ * @param value The demo data.
+ * @return A {@link CompletableFuture} that will return immediately.
+ */
+ public CompletableFuture<Integer> asyncTask(final int value) {
+ return CompletableFuture
+ .supplyAsync(delayedTask(value, 100, null), executor) // Execute asynchronously.
+ .thenApply(i -> i + 1); // After the return of the task, do something else with the result.
+ }
+
+ /**
+ * Executes an opperation asynchronously, in a different thread provided by the {@link ManagedExecutorService}.
+ * The computation will carry on after the return of the method.
+ *
+ * @param value The demo data.
+ * @return A {@link CompletableFuture} that will return immediately.
+ */
+ public CompletableFuture<Integer> asyncTaskWithException(final int value) {
+ return CompletableFuture
+ .supplyAsync(delayedTask(value, 100, "Planned exception"), executor) // Execute asynchronously.
+ .thenApply(i -> i + 1); // After the return of the task, do something else with the result.
+ }
+
+ /**
+ * Method to simulate an asynchronous task. Will add 1 to the value for each invocation.
+ *
+ * @param value The demo data.
+ * @param delayMs How long the task will take to complete. In ms.
+ * @param errorMessage Message for the exception simulating an execution problem
+ * @return
+ */
+ private Supplier<Integer> delayedTask(final int value,
+ final int delayMs,
+ final String errorMessage) {
+ return () -> {
+ if (nonNull(errorMessage)) {
+ System.out.println("Exception will be thrown");
+ throw new RuntimeException(errorMessage);
+ }
+
+ try {
+ // simulate long processing task
+ Thread.sleep(delayMs);
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Problem while waiting");
+ }
+ System.out.println("delayedTask complete");
+ return value + 1;
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/d0c72909/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedServiceTest.java b/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedServiceTest.java
new file mode 100644
index 0000000..1dd6ff9
--- /dev/null
+++ b/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedServiceTest.java
@@ -0,0 +1,102 @@
+package org.superbiz.executor;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+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.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+
+@RunWith(Arquillian.class)
+public class ManagedServiceTest {
+
+ @Inject
+ private ManagedService managedService;
+
+ @Deployment()
+ public static final WebArchive app() {
+ return ShrinkWrap.create(WebArchive.class, "example.war")
+ .addClasses(ManagedService.class)
+ .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
+ }
+
+ /**
+ * Happy path. Normal invocation.
+ */
+ @Test
+ public void managedInvocationTest() {
+ final CompletableFuture<Integer> future = managedService.asyncTask(1);
+ System.out.println("You can do something else in the meantime and later get the future value");
+ try {
+ // To prevent hanged tasks, you should obtain the value of a future with a timeout.
+ assertEquals(3, future.get(200, TimeUnit.MILLISECONDS).intValue());
+ } catch (Exception e) {
+ fail("Unexpected exception" + e);
+ }
+ }
+
+ /**
+ * Request timeout. The result will take at least 100ms and we want it after 10ms.
+ *
+ * @throws InterruptedException
+ * @throws ExecutionException
+ * @throws TimeoutException
+ */
+ @Test(expected = TimeoutException.class)
+ public void managedInvocationTestWithTimeout() throws InterruptedException, ExecutionException, TimeoutException {
+ final CompletableFuture<Integer> future = managedService.asyncTask(1);
+ future.get(10, TimeUnit.MILLISECONDS);
+ }
+
+ /**
+ * The execution ended with an exception.
+ * Handle the exception apropriately.
+ *
+ * @throws InterruptedException
+ * @throws ExecutionException
+ * @throws TimeoutException
+ */
+ @Test
+ public void managedInvocationTestWithException() {
+ final CompletableFuture<Integer> future = managedService.asyncTaskWithException(1);
+
+ try {
+ future.get(200, TimeUnit.MILLISECONDS);
+ } catch (ExecutionException e) {
+ // the thrown RuntimeException will be wrapped around an ExecutionException
+ assertEquals("Planned exception", e.getCause().getMessage());
+ } catch (Exception e) {
+ fail("Unexpected exception" + e);
+ }
+
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/d0c72909/examples/executor/pom.xml
----------------------------------------------------------------------
diff --git a/examples/executor/pom.xml b/examples/executor/pom.xml
deleted file mode 100644
index 08a6dd3..0000000
--- a/examples/executor/pom.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.superbiz</groupId>
- <artifactId>executor</artifactId>
- <version>8.0.0-SNAPSHOT</version>
- <packaging>jar</packaging>
- <name>OpenEJB :: Examples :: Executor for concurrency utilities</name>
-
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <javaee-api.version>8.0</javaee-api.version>
- <junit.version>4.12</junit.version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tomee</groupId>
- <artifactId>javaee-api</artifactId>
- <version>${javaee-api.version}</version>
- <scope>provided</scope>
- </dependency>
- <!--Tests-->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tomee</groupId>
- <artifactId>arquillian-tomee-remote</artifactId>
- <version>${pom.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.junit</groupId>
- <artifactId>arquillian-junit-container</artifactId>
- <version>1.4.0.Final</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.container</groupId>
- <artifactId>arquillian-container-test-api</artifactId>
- <version>1.4.0.Final</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.7.1</version>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/d0c72909/examples/executor/src/main/java/org/superbiz/executor/AsyncBookService.java
----------------------------------------------------------------------
diff --git a/examples/executor/src/main/java/org/superbiz/executor/AsyncBookService.java b/examples/executor/src/main/java/org/superbiz/executor/AsyncBookService.java
deleted file mode 100644
index 1f17189..0000000
--- a/examples/executor/src/main/java/org/superbiz/executor/AsyncBookService.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package org.superbiz.executor;
-
-import javax.annotation.Resource;
-import javax.ejb.Asynchronous;
-import javax.enterprise.concurrent.ManagedExecutorService;
-import javax.enterprise.context.RequestScoped;
-import java.io.IOException;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.Future;
-import java.util.function.Supplier;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-@RequestScoped
-public class AsyncBookService {
-
- @Resource
- private ManagedExecutorService executor;
-
- @Asynchronous
- public Future<String> serviceA() {
- CompletableFuture<String> future = new CompletableFuture<>();
- future.completeExceptionally(new IOException("Simulated error"));
- return future;
- }
-
- @Asynchronous
- public CompletableFuture<Integer> serviceB() {
- return CompletableFuture.supplyAsync(delayedSupplier(1, 100), executor)
- .thenApply(i -> i + 1);
- }
-
- @Asynchronous
- public CompletableFuture<Integer> serviceB() {
- return CompletableFuture.supplyAsync(delayedWithExceptionSupplier(100, new RuntimeException("test")), executor);
- }
-
- private Supplier<Integer> delayedSupplier(final int value,
- final int delayMs) {
- return () -> {
- try {
- Thread.sleep(delayMs);
- } catch (InterruptedException e) {
- throw new RuntimeException("Problem while waiting");
- }
- return value;
- };
- }
-
- private CompletableFuture<Integer> delayedWithExceptionSupplier(final int delayMs,
- final Throwable t) {
- final CompletableFuture<Integer> future = new CompletableFuture<>();
- try {
- Thread.sleep(delayMs);
- future.completeExceptionally(t);
- } catch (InterruptedException e) {
- throw new RuntimeException("Problem while waiting");
- }
- return future;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/tomee/blob/d0c72909/examples/executor/src/test/java/org/superbiz/executor/AsyncBookServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/executor/src/test/java/org/superbiz/executor/AsyncBookServiceTest.java b/examples/executor/src/test/java/org/superbiz/executor/AsyncBookServiceTest.java
deleted file mode 100644
index e567da4..0000000
--- a/examples/executor/src/test/java/org/superbiz/executor/AsyncBookServiceTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.superbiz.executor;
-
-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.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import javax.inject.Inject;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-@RunWith(Arquillian.class)
-public class AsyncBookServiceTest {
-
- @Inject
- private AsyncBookService service;
-
- @Deployment()
- public static final WebArchive app() {
- return ShrinkWrap.create(WebArchive.class, "example.war")
- .addClasses(AsyncBookService.class)
- .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
- }
-
- @Test
- public void testServiceA() {
- final Future<String> future = service.serviceA();
- try {
- future.get(200, TimeUnit.MILLISECONDS);
- } catch (InterruptedException | TimeoutException e) {
- fail("Unexpected exception" + e);
- } catch (ExecutionException ioe) {
- assertEquals("Simulated error", ioe.getCause().getMessage());
- }
- }
-
- @Test
- public void testServiceB() {
- final CompletableFuture<Integer> future = service.serviceB();
- try {
- assertEquals(2, future.get(200, TimeUnit.MILLISECONDS).intValue());
- } catch (Exception e) {
- fail("Unexpected exception" + e);
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/d0c72909/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index 9a19500..2531aa7 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -174,6 +174,7 @@ BROKEN, see TOMEE-2140
<module>mp-metrics-counted</module>
<module>mp-metrics-timed</module>
<module>websocket-tls-basic-auth</module>
+ <module>concurrency-utils</module>
</modules>
<dependencies>
[06/27] tomee git commit: TOMEE-2313 - Fixed surefire and openjpa
versions on webapp archetype resource pom
Posted by jg...@apache.org.
TOMEE-2313 - Fixed surefire and openjpa versions on webapp archetype resource pom
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/6e5d0b45
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/6e5d0b45
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/6e5d0b45
Branch: refs/heads/master
Commit: 6e5d0b45b267dad1905a1b0e7da1a5235a1d1359
Parents: 95c8263
Author: Daniel Cunha (soro) <da...@apache.org>
Authored: Tue Dec 4 15:11:44 2018 -0300
Committer: Daniel Cunha (soro) <da...@apache.org>
Committed: Tue Dec 4 15:11:44 2018 -0300
----------------------------------------------------------------------
maven/tomee-webapp-archetype/pom.xml | 4 +++-
.../src/main/resources/archetype-resources/pom.xml | 6 +++---
2 files changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/6e5d0b45/maven/tomee-webapp-archetype/pom.xml
----------------------------------------------------------------------
diff --git a/maven/tomee-webapp-archetype/pom.xml b/maven/tomee-webapp-archetype/pom.xml
index 3301f92..9620ef4 100644
--- a/maven/tomee-webapp-archetype/pom.xml
+++ b/maven/tomee-webapp-archetype/pom.xml
@@ -43,7 +43,9 @@ Licensed to the Apache Software Foundation (ASF) under one or more
<configuration>
<target>
<replace file="${project.build.directory}/classes/archetype-resources/pom.xml" token="[TOMEE]" value="${project.version}"/>
- <replace file="${project.build.directory}/classes/archetype-resources/pom.xml" token="[OPENEJB]" value="{project.version}"/>
+ <replace file="${project.build.directory}/classes/archetype-resources/pom.xml" token="[OPENEJB]" value="${project.version}"/>
+ <replace file="${project.build.directory}/classes/archetype-resources/pom.xml" token="[OPENJPA]" value="${openjpa.version}"/>
+ <replace file="${project.build.directory}/classes/archetype-resources/pom.xml" token="[JAVAEE]" value="${version.javaee-api}"/>
</target>
</configuration>
</execution>
http://git-wip-us.apache.org/repos/asf/tomee/blob/6e5d0b45/maven/tomee-webapp-archetype/src/main/resources/archetype-resources/pom.xml
----------------------------------------------------------------------
diff --git a/maven/tomee-webapp-archetype/src/main/resources/archetype-resources/pom.xml b/maven/tomee-webapp-archetype/src/main/resources/archetype-resources/pom.xml
index e8332f8..bc9a944 100644
--- a/maven/tomee-webapp-archetype/src/main/resources/archetype-resources/pom.xml
+++ b/maven/tomee-webapp-archetype/src/main/resources/archetype-resources/pom.xml
@@ -34,7 +34,7 @@
<dependency>
<groupId>org.apache.tomee</groupId>
<artifactId>javaee-api</artifactId>
- <version>8.0</version>
+ <version>[JAVAEE]</version>
<scope>provided</scope>
</dependency>
@@ -112,7 +112,7 @@
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
- <version>3.0.0</version>
+ <version>[OPENJPA]</version>
<configuration>
<includes>**/entities/*.class</includes>
<excludes>**/entities/XML*.class</excludes>
@@ -133,7 +133,7 @@
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<!-- set the version to be the same as the level in your runtime -->
- <version>3.0.0</version>
+ <version>[OPENJPA]</version>
</dependency>
</dependencies>
</plugin>
[12/27] tomee git commit: TOMEE-2301 - improving javadoc and adding
output messages to track the execution. Use TimeUnit Sleep.
Posted by jg...@apache.org.
TOMEE-2301 - improving javadoc and adding output messages to track the execution. Use TimeUnit Sleep.
Signed-off-by: brunobat <br...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/de075f8d
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/de075f8d
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/de075f8d
Branch: refs/heads/master
Commit: de075f8d9d7c96f26f9684119b150e7f52eaa225
Parents: d0c7290
Author: brunobat <br...@gmail.com>
Authored: Mon Dec 3 16:16:12 2018 +0000
Committer: brunobat <br...@gmail.com>
Committed: Wed Dec 5 15:27:04 2018 +0000
----------------------------------------------------------------------
.../org/superbiz/executor/ManagedService.java | 27 +++++++++++---------
.../superbiz/executor/ManagedServiceTest.java | 14 +++++-----
2 files changed, 22 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/de075f8d/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedService.java
----------------------------------------------------------------------
diff --git a/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedService.java b/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedService.java
index 89c89fe..eecbb46 100644
--- a/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedService.java
+++ b/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedService.java
@@ -21,6 +21,7 @@ import javax.annotation.Resource;
import javax.enterprise.concurrent.ManagedExecutorService;
import javax.enterprise.context.RequestScoped;
import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import static java.util.Objects.nonNull;
@@ -40,8 +41,9 @@ public class ManagedService {
* @return A {@link CompletableFuture} that will return immediately.
*/
public CompletableFuture<Integer> asyncTask(final int value) {
+ System.out.println("Create asyncTask");
return CompletableFuture
- .supplyAsync(delayedTask(value, 100, null), executor) // Execute asynchronously.
+ .supplyAsync(longTask(value, 100, null), executor) // Execute asynchronously.
.thenApply(i -> i + 1); // After the return of the task, do something else with the result.
}
@@ -53,22 +55,23 @@ public class ManagedService {
* @return A {@link CompletableFuture} that will return immediately.
*/
public CompletableFuture<Integer> asyncTaskWithException(final int value) {
+ System.out.println("Create asyncTaskWithException");
return CompletableFuture
- .supplyAsync(delayedTask(value, 100, "Planned exception"), executor) // Execute asynchronously.
+ .supplyAsync(longTask(value, 100, "Planned exception"), executor) // Execute asynchronously.
.thenApply(i -> i + 1); // After the return of the task, do something else with the result.
}
/**
* Method to simulate an asynchronous task. Will add 1 to the value for each invocation.
*
- * @param value The demo data.
- * @param delayMs How long the task will take to complete. In ms.
- * @param errorMessage Message for the exception simulating an execution problem
- * @return
+ * @param value The demo data.
+ * @param taskDurationMs How long the task will take to complete. In ms.
+ * @param errorMessage Message for the exception simulating an execution problem
+ * @return a {@link Supplier} function processing the new value
*/
- private Supplier<Integer> delayedTask(final int value,
- final int delayMs,
- final String errorMessage) {
+ private Supplier<Integer> longTask(final int value,
+ final int taskDurationMs,
+ final String errorMessage) {
return () -> {
if (nonNull(errorMessage)) {
System.out.println("Exception will be thrown");
@@ -76,12 +79,12 @@ public class ManagedService {
}
try {
- // simulate long processing task
- Thread.sleep(delayMs);
+ // Simulate a long processing task using TimeUnit to sleep.
+ TimeUnit.MILLISECONDS.sleep(taskDurationMs);
} catch (InterruptedException e) {
throw new RuntimeException("Problem while waiting");
}
- System.out.println("delayedTask complete");
+ System.out.println("longTask complete");
return value + 1;
};
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/de075f8d/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedServiceTest.java b/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedServiceTest.java
index 1dd6ff9..30b6f6f 100644
--- a/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedServiceTest.java
+++ b/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedServiceTest.java
@@ -66,9 +66,9 @@ public class ManagedServiceTest {
/**
* Request timeout. The result will take at least 100ms and we want it after 10ms.
*
- * @throws InterruptedException
- * @throws ExecutionException
- * @throws TimeoutException
+ * @throws InterruptedException we don't expect it
+ * @throws ExecutionException we don't expect it
+ * @throws TimeoutException Expected exception
*/
@Test(expected = TimeoutException.class)
public void managedInvocationTestWithTimeout() throws InterruptedException, ExecutionException, TimeoutException {
@@ -78,11 +78,11 @@ public class ManagedServiceTest {
/**
* The execution ended with an exception.
- * Handle the exception apropriately.
+ * Handle the exception appropriately.
*
- * @throws InterruptedException
- * @throws ExecutionException
- * @throws TimeoutException
+ * @throws InterruptedException we don't expect it
+ * @throws ExecutionException Expected exception
+ * @throws TimeoutException we don't expect it
*/
@Test
public void managedInvocationTestWithException() {
[21/27] tomee git commit: Merge branch 'improve_collections' of
https://github.com/otaviojava/tomee
Posted by jg...@apache.org.
Merge branch 'improve_collections' of https://github.com/otaviojava/tomee
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/2967640a
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/2967640a
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/2967640a
Branch: refs/heads/master
Commit: 2967640af9fa84a0619b42b72c162b3a79640b05
Parents: 5659ee9 5c9bad8
Author: Jonathan Gallimore <jg...@tomitribe.com>
Authored: Thu Dec 6 20:21:08 2018 +0000
Committer: Jonathan Gallimore <jg...@tomitribe.com>
Committed: Thu Dec 6 20:21:08 2018 +0000
----------------------------------------------------------------------
.../java/org/apache/openejb/BeanContext.java | 11 ++---
.../org/apache/openejb/ClassLoaderUtil.java | 3 +-
.../org/apache/openejb/OpenEjbContainer.java | 3 +-
.../openejb/assembler/classic/Assembler.java | 31 ++++----------
.../classic/EnterpriseBeanBuilder.java | 3 +-
.../classic/InterceptorBindingBuilder.java | 4 +-
.../assembler/classic/MethodInfoUtil.java | 3 +-
.../assembler/classic/ValidatorBuilder.java | 7 ++-
.../apache/openejb/cdi/WebappBeanManager.java | 3 +-
.../openejb/config/AnnotationDeployer.java | 2 +-
.../org/apache/openejb/config/AutoConfig.java | 18 ++++----
.../config/ConfigurableClasspathArchive.java | 3 +-
.../openejb/config/ConfigurationFactory.java | 8 +---
.../apache/openejb/config/DeploymentLoader.java | 45 +++++++++-----------
.../openejb/config/sys/SaxAppCtxConfig.java | 9 ++--
.../apache/openejb/core/BaseSessionContext.java | 3 +-
.../openejb/core/managed/SimplePassivater.java | 4 +-
.../core/security/jaas/SQLLoginModule.java | 8 ++--
.../openejb/core/stateful/SimplePassivater.java | 4 +-
.../openejb/core/timer/EJBCronTrigger.java | 4 +-
.../openejb/core/timer/MemoryTimerStore.java | 3 +-
.../openejb/resource/AutoConnectionTracker.java | 6 +--
.../apache/openejb/util/AnnotationFinder.java | 2 +-
.../openejb/util/helper/CommandHelper.java | 5 ++-
.../core/security/SecurityServiceImplTest.java | 3 +-
.../core/stateful/StatefulContainerTest.java | 6 +--
.../core/stateless/StatelessContainerTest.java | 3 +-
.../stateless/StatelessInvocationStatsTest.java | 3 +-
.../stateless/StatelessMetaAnnotationTest.java | 3 +-
.../core/stateless/StatelessPoolStatsTest.java | 3 +-
.../openejb/ivm/naming/IvmContextTest.java | 4 +-
.../org/apache/openejb/util/ReferencesTest.java | 4 +-
.../org/apache/openejb/junit/OpenEjbRunner.java | 3 +-
33 files changed, 94 insertions(+), 130 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/2967640a/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/2967640a/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
----------------------------------------------------------------------
[18/27] tomee git commit: TOMEE-2326 - Define description and rules
to create new examples
Posted by jg...@apache.org.
TOMEE-2326 - Define description and rules to create new examples
Signed-off-by: brunobat <br...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/fed45505
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/fed45505
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/fed45505
Branch: refs/heads/master
Commit: fed45505b0cad0185708c3555fb6c2c552a7213f
Parents: 7d54b67
Author: brunobat <br...@gmail.com>
Authored: Thu Dec 6 13:40:11 2018 +0000
Committer: brunobat <br...@gmail.com>
Committed: Thu Dec 6 15:01:24 2018 +0000
----------------------------------------------------------------------
examples/README.adoc | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/fed45505/examples/README.adoc
----------------------------------------------------------------------
diff --git a/examples/README.adoc b/examples/README.adoc
new file mode 100644
index 0000000..294453e
--- /dev/null
+++ b/examples/README.adoc
@@ -0,0 +1,21 @@
+= TomEE Examples
+
+These examples demonstrate particular features of the JEE ecosystem to help
+developers in the creation of their own applications.
+
+The idea is that each example focuses in a very specific framework feature and
+demonstrates it's usage and behaviour in a simple way.
+
+== Rules to create a new example.
+
+* Demo just one feaure with simple business logic.
+* Don't use more than 4 names in the example's name.
+Like in the _cdi-basic_ example where @Inject is demontrated in the _Course_ class.
+* If your example has already 1000 lines, consider either simplifying it or split it.
+* Don't define a Parent in maven's _pom.xml_. This will make the project completely self contained and independent,
+making the required dependencies clear.
+* Make sure you only include dependencies that are realy needed.
+* Always include an integration test with Arquillian or ApplicationComposer.
+* Document the bahaviour of each method with javadoc.
+* Include a README file explining the purpose and what's doing on.
+* Make sure you add the new project to the parent project _pom.xml_ modules section.
[13/27] tomee git commit: TOMEE-2301 - Scheduler executor and
exception handling examples.
Posted by jg...@apache.org.
TOMEE-2301 - Scheduler executor and exception handling examples.
Signed-off-by: brunobat <br...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/934814e3
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/934814e3
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/934814e3
Branch: refs/heads/master
Commit: 934814e368b0f566c30b67168724ab611e0b97b2
Parents: fe7bc8f
Author: brunobat <br...@gmail.com>
Authored: Tue Dec 4 11:04:32 2018 +0000
Committer: brunobat <br...@gmail.com>
Committed: Wed Dec 5 15:27:04 2018 +0000
----------------------------------------------------------------------
.../executor/ManagedScheduledService.java | 9 ++--
.../executor/ManagedScheduledServiceTest.java | 52 ++++++++++++++++++--
2 files changed, 54 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/934814e3/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedScheduledService.java
----------------------------------------------------------------------
diff --git a/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedScheduledService.java b/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedScheduledService.java
index 1032f51..07760a3 100644
--- a/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedScheduledService.java
+++ b/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedScheduledService.java
@@ -34,13 +34,14 @@ public class ManagedScheduledService {
@Resource
private ManagedScheduledExecutorService executor;
- public Future<Integer> singleFixedDelayTask(final int value) {
+ public Future<Integer> singleFixedDelayTask(final int value, final String errorMessage) {
System.out.println("longCallableTask scheduled");
- return executor.schedule(longCallableTask(value, 10, null), 100, TimeUnit.MILLISECONDS);
+ return executor.schedule(longCallableTask(value, 10, errorMessage), 100, TimeUnit.MILLISECONDS);
}
- public ScheduledFuture<?> periodicFixedDelayTask(final int value) {
- return executor.scheduleAtFixedRate(longRunnableTask(value, 10, null), 0, 100, TimeUnit.MILLISECONDS);
+ public ScheduledFuture<?> periodicFixedDelayTask(final int value, final String errorMessage) {
+ System.out.println("longRunnableTask scheduled");
+ return executor.scheduleAtFixedRate(longRunnableTask(value, 10, errorMessage), 0, 100, TimeUnit.MILLISECONDS);
}
private Runnable longRunnableTask(final int value,
http://git-wip-us.apache.org/repos/asf/tomee/blob/934814e3/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedScheduledServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedScheduledServiceTest.java b/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedScheduledServiceTest.java
index b4e3807..4baf428 100644
--- a/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedScheduledServiceTest.java
+++ b/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedScheduledServiceTest.java
@@ -27,10 +27,12 @@ import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
@RunWith(Arquillian.class)
public class ManagedScheduledServiceTest {
@@ -48,12 +50,56 @@ public class ManagedScheduledServiceTest {
@Test
public void singleFixedDelayTask() throws InterruptedException, ExecutionException, TimeoutException {
- final Future<Integer> future = scheduledService.singleFixedDelayTask(1);
- assertEquals(2, future.get(200, TimeUnit.MILLISECONDS).intValue());
+ final Future<Integer> futureA = scheduledService.singleFixedDelayTask(1, null);
+ final Future<Integer> futureB = scheduledService.singleFixedDelayTask(50, null);
+ System.out.println("Do some other work while we wait for the tasks");
+ assertEquals(2, futureA.get(200, TimeUnit.MILLISECONDS).intValue());
+ assertEquals(51, futureB.get(200, TimeUnit.MILLISECONDS).intValue());
}
@Test
- public void periodicFixedDelayTask() {
+ public void periodicFixedDelayTask() throws InterruptedException, TimeoutException, ExecutionException {
+ final ScheduledFuture<?> scheduledFuture = scheduledService.periodicFixedDelayTask(1, null);
+ TimeUnit.MILLISECONDS.sleep(500);
+ if (!scheduledFuture.isCancelled()) {
+ scheduledFuture.cancel(true);
+ System.out.println("task stopped");
+ }
}
+
+
+ @Test
+ public void singleFixedDelayTaskWithException() throws InterruptedException, ExecutionException, TimeoutException {
+ final Future<Integer> future = scheduledService.singleFixedDelayTask(1, "Planned exception");
+ try {
+ future.get(200, TimeUnit.MILLISECONDS);
+ } catch (ExecutionException e) {
+ // the thrown RuntimeException will be wrapped around an ExecutionException
+ assertEquals("Planned exception", e.getCause().getMessage());
+ } catch (Exception e) {
+ fail("Unexpected exception" + e);
+ }
+ }
+
+ @Test
+ public void periodicFixedDelayTaskWithException() throws InterruptedException {
+ final ScheduledFuture<?> scheduledFuture = scheduledService.periodicFixedDelayTask(1, "Planned exception");
+ TimeUnit.MILLISECONDS.sleep(500);
+
+ try {
+ scheduledFuture.get(200, TimeUnit.MILLISECONDS);
+ } catch (ExecutionException e) {
+ // the thrown RuntimeException will be wrapped around an ExecutionException
+ assertEquals("Planned exception", e.getCause().getMessage());
+ } catch (Exception e) {
+ fail("Unexpected exception" + e);
+ }
+
+ if (!scheduledFuture.isCancelled()) {
+ scheduledFuture.cancel(true);
+ System.out.println("task stopped");
+ }
+ }
+
}
\ No newline at end of file
[26/27] tomee git commit: Merge branch 'examples-readme' of
https://github.com/brunobat/tomee
Posted by jg...@apache.org.
Merge branch 'examples-readme' of https://github.com/brunobat/tomee
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/fb932f44
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/fb932f44
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/fb932f44
Branch: refs/heads/master
Commit: fb932f448e6af1d9fc15a424e0b1fddc1d1f0c8a
Parents: bbe21c7 70eb624
Author: Jonathan Gallimore <jg...@tomitribe.com>
Authored: Thu Dec 6 20:25:08 2018 +0000
Committer: Jonathan Gallimore <jg...@tomitribe.com>
Committed: Thu Dec 6 20:25:08 2018 +0000
----------------------------------------------------------------------
examples/README.adoc | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
----------------------------------------------------------------------
[14/27] tomee git commit: TOMEE-2301 - Start with scheduled executor
part
Posted by jg...@apache.org.
TOMEE-2301 - Start with scheduled executor part
Signed-off-by: brunobat <br...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/fe7bc8ff
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/fe7bc8ff
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/fe7bc8ff
Branch: refs/heads/master
Commit: fe7bc8ff6e0cfd8110ef687ca46afedbbcaeb8cf
Parents: de075f8
Author: brunobat <br...@gmail.com>
Authored: Mon Dec 3 18:25:25 2018 +0000
Committer: brunobat <br...@gmail.com>
Committed: Wed Dec 5 15:27:04 2018 +0000
----------------------------------------------------------------------
.../executor/ManagedScheduledService.java | 83 ++++++++++++++++++++
.../executor/ManagedScheduledServiceTest.java | 59 ++++++++++++++
2 files changed, 142 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/fe7bc8ff/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedScheduledService.java
----------------------------------------------------------------------
diff --git a/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedScheduledService.java b/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedScheduledService.java
new file mode 100644
index 0000000..1032f51
--- /dev/null
+++ b/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedScheduledService.java
@@ -0,0 +1,83 @@
+package org.superbiz.executor;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import javax.annotation.Resource;
+import javax.enterprise.concurrent.ManagedScheduledExecutorService;
+import javax.enterprise.context.RequestScoped;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
+import static java.util.Objects.nonNull;
+
+
+@RequestScoped
+public class ManagedScheduledService {
+
+ @Resource
+ private ManagedScheduledExecutorService executor;
+
+ public Future<Integer> singleFixedDelayTask(final int value) {
+ System.out.println("longCallableTask scheduled");
+ return executor.schedule(longCallableTask(value, 10, null), 100, TimeUnit.MILLISECONDS);
+ }
+
+ public ScheduledFuture<?> periodicFixedDelayTask(final int value) {
+ return executor.scheduleAtFixedRate(longRunnableTask(value, 10, null), 0, 100, TimeUnit.MILLISECONDS);
+ }
+
+ private Runnable longRunnableTask(final int value,
+ final int taskDurationMs,
+ final String errorMessage) {
+ return () -> {
+ if (nonNull(errorMessage)) {
+ System.out.println("Exception will be thrown");
+ throw new RuntimeException(errorMessage);
+ }
+
+ Integer result = value + 1;
+ System.out.println("longRunnableTask complete. Value is " + result);
+ // Cannot return result with a Runnable.
+ };
+ }
+
+ private Callable<Integer> longCallableTask(final int value,
+ final int taskDurationMs,
+ final String errorMessage) {
+ return () -> {
+ System.out.println("longCallableTask start");
+ if (nonNull(errorMessage)) {
+ System.out.println("Exception will be thrown");
+ throw new RuntimeException(errorMessage);
+ }
+
+ try {
+ // Simulate a long processing task using TimeUnit to sleep.
+ TimeUnit.MILLISECONDS.sleep(taskDurationMs);
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Problem while waiting");
+ }
+ System.out.println("longCallableTask complete");
+ // We can return a result with a Callable.
+ return value + 1;
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/fe7bc8ff/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedScheduledServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedScheduledServiceTest.java b/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedScheduledServiceTest.java
new file mode 100644
index 0000000..b4e3807
--- /dev/null
+++ b/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedScheduledServiceTest.java
@@ -0,0 +1,59 @@
+package org.superbiz.executor;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+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.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(Arquillian.class)
+public class ManagedScheduledServiceTest {
+
+ @Inject
+ private ManagedScheduledService scheduledService;
+
+ @Deployment()
+ public static final WebArchive app() {
+ return ShrinkWrap.create(WebArchive.class, "example.war")
+ .addClasses(ManagedScheduledService.class)
+ .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
+ }
+
+
+ @Test
+ public void singleFixedDelayTask() throws InterruptedException, ExecutionException, TimeoutException {
+ final Future<Integer> future = scheduledService.singleFixedDelayTask(1);
+ assertEquals(2, future.get(200, TimeUnit.MILLISECONDS).intValue());
+
+ }
+
+ @Test
+ public void periodicFixedDelayTask() {
+ }
+}
\ No newline at end of file
[16/27] tomee git commit: fix constant namings
Posted by jg...@apache.org.
fix constant namings
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/7516fe70
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/7516fe70
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/7516fe70
Branch: refs/heads/master
Commit: 7516fe701a775aa2ac2982966bcdca4cabce5cb5
Parents: 4b760d3
Author: Hayri Cicek <ha...@kodnito.com>
Authored: Wed Dec 5 17:55:07 2018 +0100
Committer: Hayri Cicek <ha...@kodnito.com>
Committed: Wed Dec 5 17:55:07 2018 +0100
----------------------------------------------------------------------
.../discovery/MulticastDiscoveryAgent.java | 10 ++---
.../discovery/MultipointDiscoveryAgent.java | 10 ++---
.../server/discovery/MultipointServer.java | 42 ++++++++++----------
.../openejb/server/webservices/WsServlet.java | 8 ++--
.../server/webservices/saaj/SaajUniverse.java | 18 ++++-----
.../org/apache/tomee/installer/Installer.java | 18 ++++-----
6 files changed, 53 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/7516fe70/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MulticastDiscoveryAgent.java
----------------------------------------------------------------------
diff --git a/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MulticastDiscoveryAgent.java b/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MulticastDiscoveryAgent.java
index 5db7c58..b74d074 100644
--- a/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MulticastDiscoveryAgent.java
+++ b/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MulticastDiscoveryAgent.java
@@ -46,7 +46,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
*/
public class MulticastDiscoveryAgent implements DiscoveryAgent, ServerService, SelfManaging {
- private static final Logger LOG = Logger.getInstance(LogCategory.OPENEJB_SERVER.createChild("discovery").createChild("multicast"), MulticastDiscoveryAgent.class);
+ private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB_SERVER.createChild("discovery").createChild("multicast"), MulticastDiscoveryAgent.class);
private final AtomicBoolean running = new AtomicBoolean(false);
@@ -65,7 +65,7 @@ public class MulticastDiscoveryAgent implements DiscoveryAgent, ServerService, S
public void init(final Properties props) {
final Options options = new Options(props);
- options.setLogger(new OptionsLog(LOG));
+ options.setLogger(new OptionsLog(LOGGER));
host = props.getProperty("bind", host);
loopbackMode = options.get("loopback_mode", loopbackMode);
@@ -215,7 +215,7 @@ public class MulticastDiscoveryAgent implements DiscoveryAgent, ServerService, S
// ignore
} catch (IOException e) {
if (running.get()) {
- LOG.error("failed to process packet: " + e);
+ LOGGER.error("failed to process packet: " + e);
}
}
}
@@ -248,10 +248,10 @@ public class MulticastDiscoveryAgent implements DiscoveryAgent, ServerService, S
if (failed == null) {
failed = e;
- LOG.error("Failed to advertise our service: " + uri, e);
+ LOGGER.error("Failed to advertise our service: " + uri, e);
final String message = e.getMessage();
if (null != message && message.toLowerCase().contains("operation not permitted")) {
- LOG.error("The 'Operation not permitted' error has been know to be caused by improper firewall/network setup. "
+ LOGGER.error("The 'Operation not permitted' error has been know to be caused by improper firewall/network setup. "
+ "Please make sure that the OS is properly configured to allow multicast traffic over: " + multicast.getLocalAddress());
}
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/7516fe70/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointDiscoveryAgent.java
----------------------------------------------------------------------
diff --git a/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointDiscoveryAgent.java b/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointDiscoveryAgent.java
index f2f3e3f..c7d6980 100644
--- a/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointDiscoveryAgent.java
+++ b/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointDiscoveryAgent.java
@@ -46,7 +46,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
*/
public class MultipointDiscoveryAgent implements DiscoveryAgent, ServerService, SelfManaging {
- private static final Logger LOG = Logger.getInstance(LogCategory.OPENEJB_SERVER.createChild("discovery").createChild("multipoint"), MultipointDiscoveryAgent.class);
+ private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB_SERVER.createChild("discovery").createChild("multipoint"), MultipointDiscoveryAgent.class);
private final AtomicBoolean running = new AtomicBoolean(false);
@@ -86,7 +86,7 @@ public class MultipointDiscoveryAgent implements DiscoveryAgent, ServerService,
public void init(final Properties props) {
final Options options = new Options(props);
- options.setLogger(new OptionsLog(LOG));
+ options.setLogger(new OptionsLog(LOGGER));
host = props.getProperty("bind", host);
port = options.get("port", port);
@@ -178,9 +178,9 @@ public class MultipointDiscoveryAgent implements DiscoveryAgent, ServerService,
public void start() throws ServiceException {
try {
if (running.compareAndSet(false, true)) {
- LOG.info("MultipointDiscoveryAgent Starting");
+ LOGGER.info("MultipointDiscoveryAgent Starting");
multipointServer = new MultipointServer(host, discoveryHost, port, tracker, name, debug, roots, reconnectDelay).start();
- LOG.info("MultipointDiscoveryAgent Started");
+ LOGGER.info("MultipointDiscoveryAgent Started");
this.port = multipointServer.getPort();
@@ -206,7 +206,7 @@ public class MultipointDiscoveryAgent implements DiscoveryAgent, ServerService,
@Managed
public void stop() throws ServiceException {
if (running.compareAndSet(true, false)) {
- LOG.info("MultipointDiscoveryAgent Stopping");
+ LOGGER.info("MultipointDiscoveryAgent Stopping");
multipointServer.stop();
}
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/7516fe70/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointServer.java
----------------------------------------------------------------------
diff --git a/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointServer.java b/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointServer.java
index 16da60c..e8c293c 100644
--- a/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointServer.java
+++ b/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointServer.java
@@ -71,7 +71,7 @@ import java.util.concurrent.locks.ReentrantLock;
@Managed
public class MultipointServer {
- private static final Logger log = Logger.getInstance(LogCategory.OPENEJB_SERVER.createChild("discovery").createChild("multipoint"), MultipointServer.class);
+ private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB_SERVER.createChild("discovery").createChild("multipoint"), MultipointServer.class);
private static final URI END_LIST = URI.create("end:list");
@@ -145,7 +145,7 @@ public class MultipointServer {
this.roots.size(),
reconnectDelay.toString());
- log.debug(format);
+ LOGGER.debug(format);
selector = Selector.open();
@@ -243,7 +243,7 @@ public class MultipointServer {
final Host host = new Host(uri);
synchronized (connect) {
if (!connections.containsKey(uri) && !connect.contains(host)) {
- log.info("Reconnect{uri=" + uri + "}");
+ LOGGER.info("Reconnect{uri=" + uri + "}");
connect.addLast(host);
host.resolveDns();
this.joined = System.nanoTime();
@@ -256,7 +256,7 @@ public class MultipointServer {
if (running.compareAndSet(false, true)) {
final String multipointServer = Join.join(".", "MultipointServer", name, port);
- log.info("MultipointServer Starting : Thread '" + multipointServer + "'");
+ LOGGER.info("MultipointServer Starting : Thread '" + multipointServer + "'");
final Thread thread = new Thread(new Runnable() {
@Override
@@ -339,7 +339,7 @@ public class MultipointServer {
this.uri = uri != null ? uri : createURI(address.getHostName(), address.getPort());
this.key = channel.register(selector, 0, this);
sessionsCreated.record();
- log.info("Constructing " + this);
+ LOGGER.info("Constructing " + this);
}
public Session ops(final int ops) {
@@ -354,8 +354,8 @@ public class MultipointServer {
public void state(final int ops, final State state) {
// trace("transition "+state +" "+ops);
if (this.state != state) {
- if (log.isDebugEnabled()) {
- log.debug(message(state.name()));
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug(message(state.name()));
}
}
this.state = state;
@@ -370,8 +370,8 @@ public class MultipointServer {
private void trace(final String str) {
// println(message(str));
- if (log.isDebugEnabled()) {
- log.debug(message(str));
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug(message(str));
// new Exception().fillInStackTrace().printStackTrace();
}
}
@@ -379,8 +379,8 @@ public class MultipointServer {
private void info(final String str) {
// println(message(str));
- if (log.isInfoEnabled()) {
- log.info(message(str));
+ if (LOGGER.isInfoEnabled()) {
+ LOGGER.info(message(str));
}
}
@@ -537,10 +537,10 @@ public class MultipointServer {
failed = 0;
} catch (IOException ex) {
if (failed++ > 100) {
- log.fatal("Too many Multipoint Failures. Terminating service.", ex);
+ LOGGER.fatal("Too many Multipoint Failures. Terminating service.", ex);
return;
}
- log.error("Multipoint Failure.", ex);
+ LOGGER.error("Multipoint Failure.", ex);
try {
Thread.sleep(100);
} catch (InterruptedException e) {
@@ -607,7 +607,7 @@ public class MultipointServer {
// This keeps the heartbeat and rejoin regular
selectorTimeout = adjustedSelectorTimeout(start);
}
- log.info("MultipointServer has terminated.");
+ LOGGER.info("MultipointServer has terminated.");
}
private long adjustedSelectorTimeout(final long start) {
@@ -627,14 +627,14 @@ public class MultipointServer {
final Host host = connect.removeFirst();
- log.debug("Initiate(uri=" + host.getUri() + ")");
+ LOGGER.debug("Initiate(uri=" + host.getUri() + ")");
if (connections.containsKey(host.getUri()))
continue;
if (!host.isDone()) {
unresolved.add(host);
- log.debug("Unresolved(uri=" + host.getUri() + ")");
+ LOGGER.debug("Unresolved(uri=" + host.getUri() + ")");
continue;
}
@@ -644,11 +644,11 @@ public class MultipointServer {
} catch (ExecutionException e) {
final Throwable t = (e.getCause() != null) ? e.getCause() : e;
final String message = String.format("Failed Connect{uri=%s} %s{message=\"%s\"}", host.getUri(), t.getClass().getSimpleName(), t.getMessage());
- log.warning(message);
+ LOGGER.warning(message);
continue;
} catch (TimeoutException e) {
unresolved.add(host);
- log.debug("Unresolved(uri=" + host.getUri() + ")");
+ LOGGER.debug("Unresolved(uri=" + host.getUri() + ")");
continue;
}
@@ -935,10 +935,10 @@ public class MultipointServer {
// map as this particular session is not in that
// map -- only the good session that will not be
// closed is in there.
- log.info("Hungup " + session);
+ LOGGER.info("Hungup " + session);
session.trace("hungup");
} else {
- log.info("Closed " + session);
+ LOGGER.info("Closed " + session);
session.trace("closed");
synchronized (connect) {
connections.remove(session.uri);
@@ -975,7 +975,7 @@ public class MultipointServer {
synchronized (connect) {
if (!connections.containsKey(uri) && !connect.contains(host)) {
- log.info("Queuing{uri=" + uri + "}");
+ LOGGER.info("Queuing{uri=" + uri + "}");
connect.addLast(host);
host.resolveDns();
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/7516fe70/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/WsServlet.java
----------------------------------------------------------------------
diff --git a/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/WsServlet.java b/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/WsServlet.java
index ff7d65c..9a7487f 100644
--- a/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/WsServlet.java
+++ b/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/WsServlet.java
@@ -43,7 +43,7 @@ public class WsServlet implements Servlet {
public static final String WEBSERVICE_CONTAINER = WsServlet.class.getName() + "@WebServiceContainer";
private static final DefaultContext DEFAULT_CONTEXT = new DefaultContext();
- private static final ThreadLocal<ServletEndpointContext> ENDPOINTCONTENT = new ThreadLocal<>();
+ private static final ThreadLocal<ServletEndpointContext> ENDPOINT_CONTENT = new ThreadLocal<>();
private ServletConfig config;
private Object pojo;
@@ -87,7 +87,7 @@ public class WsServlet implements Servlet {
if (service == null) throw new ServletException("WebServiceContainer has not been set");
ServletEndpointContext context = getContext();
- ENDPOINTCONTENT.set(new InvocationContext((HttpServletRequest) req));
+ ENDPOINT_CONTENT.set(new InvocationContext((HttpServletRequest) req));
try {
res.setContentType("text/xml");
HttpRequest httpRequest = new ServletRequestAdapter((HttpServletRequest) req, (HttpServletResponse) res, config.getServletContext());
@@ -105,7 +105,7 @@ public class WsServlet implements Servlet {
throw new ServletException("Error processing webservice request", e);
}
} finally {
- ENDPOINTCONTENT.set(context);
+ ENDPOINT_CONTENT.set(context);
}
}
@@ -145,7 +145,7 @@ public class WsServlet implements Servlet {
}
private static ServletEndpointContext getContext() {
- ServletEndpointContext context = ENDPOINTCONTENT.get();
+ ServletEndpointContext context = ENDPOINT_CONTENT.get();
return context != null ? context : DEFAULT_CONTEXT;
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/7516fe70/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/saaj/SaajUniverse.java
----------------------------------------------------------------------
diff --git a/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/saaj/SaajUniverse.java b/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/saaj/SaajUniverse.java
index 0394f92..d1196bb 100644
--- a/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/saaj/SaajUniverse.java
+++ b/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/saaj/SaajUniverse.java
@@ -23,7 +23,7 @@ import org.apache.openejb.util.Logger;
import java.util.LinkedList;
public class SaajUniverse {
- private static final Logger logger = Logger.getInstance(LogCategory.OPENEJB_WS, SaajUniverse.class);
+ private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB_WS, SaajUniverse.class);
static {
if (SystemInstance.get().getOptions().get("openejb.soap.override-factory", false)) { // default are far faster than our chain
@@ -47,7 +47,7 @@ public class SaajUniverse {
public static final Type AXIS1 = Type.AXIS1;
public static final Type AXIS2 = Type.AXIS2;
- private static final ThreadLocal<LinkedList<Type>> CURRENTUNIVERSE =
+ private static final ThreadLocal<LinkedList<Type>> CURRENT_UNIVERSE =
new ThreadLocal<LinkedList<Type>>() {
@Override
protected LinkedList<Type> initialValue() {
@@ -56,25 +56,25 @@ public class SaajUniverse {
};
public void set(Type newUniverse) {
- final LinkedList<Type> universeList = CURRENTUNIVERSE.get();
+ final LinkedList<Type> universeList = CURRENT_UNIVERSE.get();
universeList.add(newUniverse);
- if (logger.isDebugEnabled()) {
- logger.debug("Set universe: " + Thread.currentThread() + " " + newUniverse);
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Set universe: " + Thread.currentThread() + " " + newUniverse);
}
}
public void unset() {
- final LinkedList<Type> universeList = CURRENTUNIVERSE.get();
+ final LinkedList<Type> universeList = CURRENT_UNIVERSE.get();
if (universeList != null && !universeList.isEmpty()) {
universeList.removeLast();
- if (logger.isDebugEnabled()) {
- logger.debug("Restored universe: " + Thread.currentThread());
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Restored universe: " + Thread.currentThread());
}
}
}
static Type getCurrentUniverse() {
- final LinkedList<Type> universeList = CURRENTUNIVERSE.get();
+ final LinkedList<Type> universeList = CURRENT_UNIVERSE.get();
if (universeList != null && !universeList.isEmpty()) {
return universeList.getLast();
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/7516fe70/tomee/tomee-common/src/main/java/org/apache/tomee/installer/Installer.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-common/src/main/java/org/apache/tomee/installer/Installer.java b/tomee/tomee-common/src/main/java/org/apache/tomee/installer/Installer.java
index 36ec230..cfa4742 100644
--- a/tomee/tomee-common/src/main/java/org/apache/tomee/installer/Installer.java
+++ b/tomee/tomee-common/src/main/java/org/apache/tomee/installer/Installer.java
@@ -32,31 +32,31 @@ public class Installer implements InstallerInterface {
private Status status = Status.NONE;
private boolean force;
- private static final boolean LISTENERINSTALLED;
- private static final boolean AGENTINSTALLED;
+ private static final boolean LISTENER_INSTALLED;
+ private static final boolean AGENT_INSTALLED;
static {
final Options opts = SystemInstance.get().getOptions();
// is the OpenEJB listener installed
- LISTENERINSTALLED = "OpenEJBListener".equals(opts.get("openejb.embedder.source", ""))
+ LISTENER_INSTALLED = "OpenEJBListener".equals(opts.get("openejb.embedder.source", ""))
|| "ServerListener".equals(opts.get("openejb.embedder.source", ""));
// is the OpenEJB javaagent installed
- AGENTINSTALLED = InstallerTools.invokeStaticNoArgMethod(
+ AGENT_INSTALLED = InstallerTools.invokeStaticNoArgMethod(
"org.apache.openejb.javaagent.Agent", "getInstrumentation") != null;
}
public static boolean isListenerInstalled() {
- return LISTENERINSTALLED;
+ return LISTENER_INSTALLED;
}
public static boolean isAgentInstalled() {
- return AGENTINSTALLED;
+ return AGENT_INSTALLED;
}
public Installer(final Paths paths) {
this.paths = paths;
- if (LISTENERINSTALLED && AGENTINSTALLED) {
+ if (LISTENER_INSTALLED && AGENT_INSTALLED) {
status = Status.INSTALLED;
}
}
@@ -377,7 +377,7 @@ public class Installer implements InstallerInterface {
}
public void installListener(final String listener) {
- if (LISTENERINSTALLED && !force) {
+ if (LISTENER_INSTALLED && !force) {
// OpenEJB Listener already installed
return;
}
@@ -460,7 +460,7 @@ public class Installer implements InstallerInterface {
// the geronimo locator to find the implementation
// because it needs some OSGi API we don't want to add
public void installJavaagent() {
- if (AGENTINSTALLED && !force) {
+ if (AGENT_INSTALLED && !force) {
// OpenEJB Agent already installed"
return;
}
[15/27] tomee git commit: Fix checking for INTERACTIVE option in
embedded Main
Posted by jg...@apache.org.
Fix checking for INTERACTIVE option in embedded Main
https://github.com/apache/tomee/commit/469e7cb94c52d06102622bd0f54e0bf1a6a470ff#diff-03949e036a3ccddcf99c00ded5317c66R261
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/3f6959d9
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/3f6959d9
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/3f6959d9
Branch: refs/heads/master
Commit: 3f6959d96c4acbb4870cd376e780672bcea4c6cb
Parents: 4b760d3
Author: Mischa Spiegelmock <re...@cpan.org>
Authored: Wed Dec 5 18:29:20 2018 +0200
Committer: GitHub <no...@github.com>
Committed: Wed Dec 5 18:29:20 2018 +0200
----------------------------------------------------------------------
.../src/main/java/org/apache/tomee/embedded/Main.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/3f6959d9/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Main.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Main.java b/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Main.java
index dcb670e..3e4d1cf 100644
--- a/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Main.java
+++ b/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Main.java
@@ -184,7 +184,7 @@ public class Main {
}
}
});
- if (options.hasOption(INTERACTIVE)) {
+ if (line.hasOption(INTERACTIVE)) {
String l;
final Scanner scanner = new Scanner(System.in);
while ((l = scanner.nextLine()) != null) {
[07/27] tomee git commit: TOMEE-2301 - Add Thread factory example and
fix some typos
Posted by jg...@apache.org.
TOMEE-2301 - Add Thread factory example and fix some typos
Signed-off-by: brunobat <br...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/e96315bb
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/e96315bb
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/e96315bb
Branch: refs/heads/master
Commit: e96315bbf5b2ccb40866e0155132129b229306ca
Parents: ce01d8d
Author: brunobat <br...@gmail.com>
Authored: Wed Dec 5 15:25:54 2018 +0000
Committer: brunobat <br...@gmail.com>
Committed: Wed Dec 5 15:27:04 2018 +0000
----------------------------------------------------------------------
.../executor/ManagedScheduledService.java | 2 +-
.../org/superbiz/executor/ManagedService.java | 4 +-
.../superbiz/executor/ThreadFactoryService.java | 71 ++++++++++++++++++++
3 files changed, 74 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/e96315bb/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedScheduledService.java
----------------------------------------------------------------------
diff --git a/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedScheduledService.java b/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedScheduledService.java
index e5c1e75..c0f2bdb 100644
--- a/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedScheduledService.java
+++ b/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedScheduledService.java
@@ -71,7 +71,7 @@ public class ManagedScheduledService {
* Will simulate a long running operation
*
* @param value The value to compute
- * @param taskDurationMs the time lenght of the operation
+ * @param taskDurationMs the time length of the operation
* @param errorMessage If not null an exception with be thrown with this message
* @return a {@link Runnable}
*/
http://git-wip-us.apache.org/repos/asf/tomee/blob/e96315bb/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedService.java
----------------------------------------------------------------------
diff --git a/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedService.java b/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedService.java
index a8aa2cb..dabcf68 100644
--- a/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedService.java
+++ b/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedService.java
@@ -37,7 +37,7 @@ public class ManagedService {
private ManagedExecutorService executor;
/**
- * Executes an opperation asynchronously, in a different thread provided by the {@link ManagedExecutorService}.
+ * Executes an operation asynchronously, in a different thread provided by the {@link ManagedExecutorService}.
* The computation will carry on after the return of the method.
*
* @param value The demo data.
@@ -51,7 +51,7 @@ public class ManagedService {
}
/**
- * Executes an opperation asynchronously, in a different thread provided by the {@link ManagedExecutorService}.
+ * Executes an operation asynchronously, in a different thread provided by the {@link ManagedExecutorService}.
* The computation will carry on after the return of the method.
*
* @param value The demo data.
http://git-wip-us.apache.org/repos/asf/tomee/blob/e96315bb/examples/concurrency-utils/src/main/java/org/superbiz/executor/ThreadFactoryService.java
----------------------------------------------------------------------
diff --git a/examples/concurrency-utils/src/main/java/org/superbiz/executor/ThreadFactoryService.java b/examples/concurrency-utils/src/main/java/org/superbiz/executor/ThreadFactoryService.java
new file mode 100644
index 0000000..17086e5
--- /dev/null
+++ b/examples/concurrency-utils/src/main/java/org/superbiz/executor/ThreadFactoryService.java
@@ -0,0 +1,71 @@
+package org.superbiz.executor;
+
+import javax.annotation.Resource;
+import javax.enterprise.concurrent.ManagedThreadFactory;
+import javax.enterprise.context.RequestScoped;
+import java.util.concurrent.TimeUnit;
+import java.util.logging.Logger;
+
+import static java.util.Objects.nonNull;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+@RequestScoped
+public class ThreadFactoryService {
+
+ private static final Logger LOGGER = Logger.getLogger(ThreadFactoryService.class.getSimpleName());
+
+ @Resource
+ private ManagedThreadFactory factory;
+
+ public void asyncTask(final int value) {
+ LOGGER.info("Create asyncTask");
+ final Thread thread = factory.newThread(longRunnableTask(value, 100, null));
+ thread.setName("pretty asyncTask");
+ thread.start();
+ }
+
+ /**
+ * Will simulate a long running operation
+ *
+ * @param value The value to compute
+ * @param taskDurationMs the time length of the operation
+ * @param errorMessage If not null an exception with be thrown with this message
+ * @return a {@link Runnable}
+ */
+ private Runnable longRunnableTask(final int value,
+ final int taskDurationMs,
+ final String errorMessage) {
+ return () -> {
+ if (nonNull(errorMessage)) {
+ LOGGER.severe("Exception will be thrown");
+ throw new RuntimeException(errorMessage);
+ }
+ try {
+ // Simulate a long processing task using TimeUnit to sleep.
+ TimeUnit.MILLISECONDS.sleep(taskDurationMs);
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Problem while waiting");
+ }
+
+ Integer result = value + 1;
+ LOGGER.info("longRunnableTask complete. Value is " + result);
+ // Cannot return result with a Runnable.
+ };
+ }
+
+}
[24/27] tomee git commit: Merge branch 'fix_constants_naming' of
https://github.com/cicekhayri/tomee
Posted by jg...@apache.org.
Merge branch 'fix_constants_naming' of https://github.com/cicekhayri/tomee
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/68e3fa6c
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/68e3fa6c
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/68e3fa6c
Branch: refs/heads/master
Commit: 68e3fa6c343eeca8c55509064570745d23519912
Parents: 2785ba5 7516fe7
Author: Jonathan Gallimore <jg...@tomitribe.com>
Authored: Thu Dec 6 20:23:51 2018 +0000
Committer: Jonathan Gallimore <jg...@tomitribe.com>
Committed: Thu Dec 6 20:23:51 2018 +0000
----------------------------------------------------------------------
.../discovery/MulticastDiscoveryAgent.java | 10 ++---
.../discovery/MultipointDiscoveryAgent.java | 10 ++---
.../server/discovery/MultipointServer.java | 42 ++++++++++----------
.../openejb/server/webservices/WsServlet.java | 8 ++--
.../server/webservices/saaj/SaajUniverse.java | 18 ++++-----
.../org/apache/tomee/installer/Installer.java | 18 ++++-----
6 files changed, 53 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
[19/27] tomee git commit: TOMEE-2326 - Address review requests
Posted by jg...@apache.org.
TOMEE-2326 - Address review requests
Signed-off-by: brunobat <br...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/70eb624a
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/70eb624a
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/70eb624a
Branch: refs/heads/master
Commit: 70eb624a0bc9fcc2a14cb00303676f5027c67857
Parents: fed4550
Author: brunobat <br...@gmail.com>
Authored: Thu Dec 6 15:04:19 2018 +0000
Committer: brunobat <br...@gmail.com>
Committed: Thu Dec 6 15:04:19 2018 +0000
----------------------------------------------------------------------
examples/README.adoc | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/70eb624a/examples/README.adoc
----------------------------------------------------------------------
diff --git a/examples/README.adoc b/examples/README.adoc
index 294453e..62b0ee7 100644
--- a/examples/README.adoc
+++ b/examples/README.adoc
@@ -1,14 +1,14 @@
= TomEE Examples
-These examples demonstrate particular features of the JEE ecosystem to help
+These examples demonstrate particular features of the Java EE ecosystem to help
developers in the creation of their own applications.
The idea is that each example focuses in a very specific framework feature and
-demonstrates it's usage and behaviour in a simple way.
+demonstrates its usage and behaviour in a simple way.
== Rules to create a new example.
-* Demo just one feaure with simple business logic.
+* Demo just one feature with simple business logic.
* Don't use more than 4 names in the example's name.
Like in the _cdi-basic_ example where @Inject is demontrated in the _Course_ class.
* If your example has already 1000 lines, consider either simplifying it or split it.
[22/27] tomee git commit: Merge branch 'TOMEE-2313' of
https://github.com/danielsoro/tomee
Posted by jg...@apache.org.
Merge branch 'TOMEE-2313' of https://github.com/danielsoro/tomee
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/ab07eaa3
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/ab07eaa3
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/ab07eaa3
Branch: refs/heads/master
Commit: ab07eaa3e3db6908d8e2e2c7510096b22960b589
Parents: 2967640 6e5d0b4
Author: Jonathan Gallimore <jg...@tomitribe.com>
Authored: Thu Dec 6 20:21:48 2018 +0000
Committer: Jonathan Gallimore <jg...@tomitribe.com>
Committed: Thu Dec 6 20:21:48 2018 +0000
----------------------------------------------------------------------
maven/tomee-webapp-archetype/pom.xml | 4 +++-
.../src/main/resources/archetype-resources/pom.xml | 6 +++---
2 files changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
[27/27] tomee git commit: Remove unused imports
Posted by jg...@apache.org.
Remove unused imports
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/4c835ca0
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/4c835ca0
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/4c835ca0
Branch: refs/heads/master
Commit: 4c835ca03878b6ae19c730485f249932ed7e240b
Parents: fb932f4
Author: Jonathan Gallimore <jg...@tomitribe.com>
Authored: Thu Dec 6 21:23:06 2018 +0000
Committer: Jonathan Gallimore <jg...@tomitribe.com>
Committed: Thu Dec 6 21:23:06 2018 +0000
----------------------------------------------------------------------
.../java/org/apache/openejb/assembler/classic/ValidatorBuilder.java | 1 -
.../src/main/java/org/apache/openejb/util/AnnotationFinder.java | 1 -
.../src/main/java/org/apache/openejb/util/helper/CommandHelper.java | 1 -
3 files changed, 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/4c835ca0/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java
index 92a6fae..56a9dab 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java
@@ -52,7 +52,6 @@ import java.io.Serializable;
import java.util.Collection;
import java.util.EnumSet;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Map;
http://git-wip-us.apache.org/repos/asf/tomee/blob/4c835ca0/container/openejb-core/src/main/java/org/apache/openejb/util/AnnotationFinder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/AnnotationFinder.java b/container/openejb-core/src/main/java/org/apache/openejb/util/AnnotationFinder.java
index e1c4266..65ac86e 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/util/AnnotationFinder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/util/AnnotationFinder.java
@@ -36,7 +36,6 @@ import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
http://git-wip-us.apache.org/repos/asf/tomee/blob/4c835ca0/container/openejb-core/src/main/java/org/apache/openejb/util/helper/CommandHelper.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/helper/CommandHelper.java b/container/openejb-core/src/main/java/org/apache/openejb/util/helper/CommandHelper.java
index 30c3b8c..188e879 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/util/helper/CommandHelper.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/util/helper/CommandHelper.java
@@ -25,7 +25,6 @@ import org.apache.openejb.table.Line;
import org.apache.openejb.table.Lines;
import org.apache.openejb.util.JavaSecurityManagers;
-import java.util.Arrays;
import java.util.Collections;
public final class CommandHelper {
[11/27] tomee git commit: TOMEE-2301 - project creation
Posted by jg...@apache.org.
TOMEE-2301 - project creation
Signed-off-by: brunobat <br...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/b3d8edcc
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/b3d8edcc
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/b3d8edcc
Branch: refs/heads/master
Commit: b3d8edcc845b4f025d7ba32c14770c28ff60c389
Parents: 4b760d3
Author: brunobat <br...@gmail.com>
Authored: Thu Nov 29 12:21:07 2018 +0000
Committer: brunobat <br...@gmail.com>
Committed: Wed Dec 5 15:27:04 2018 +0000
----------------------------------------------------------------------
examples/executor/pom.xml | 68 +++++++++++++++++
.../org/superbiz/executor/AsyncBookService.java | 77 ++++++++++++++++++++
.../superbiz/executor/AsyncBookServiceTest.java | 73 +++++++++++++++++++
3 files changed, 218 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/b3d8edcc/examples/executor/pom.xml
----------------------------------------------------------------------
diff --git a/examples/executor/pom.xml b/examples/executor/pom.xml
new file mode 100644
index 0000000..08a6dd3
--- /dev/null
+++ b/examples/executor/pom.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>executor</artifactId>
+ <version>8.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>OpenEJB :: Examples :: Executor for concurrency utilities</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <javaee-api.version>8.0</javaee-api.version>
+ <junit.version>4.12</junit.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>${javaee-api.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <!--Tests-->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>arquillian-tomee-remote</artifactId>
+ <version>${pom.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ <version>1.4.0.Final</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-container-test-api</artifactId>
+ <version>1.4.0.Final</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.7.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/b3d8edcc/examples/executor/src/main/java/org/superbiz/executor/AsyncBookService.java
----------------------------------------------------------------------
diff --git a/examples/executor/src/main/java/org/superbiz/executor/AsyncBookService.java b/examples/executor/src/main/java/org/superbiz/executor/AsyncBookService.java
new file mode 100644
index 0000000..1f17189
--- /dev/null
+++ b/examples/executor/src/main/java/org/superbiz/executor/AsyncBookService.java
@@ -0,0 +1,77 @@
+package org.superbiz.executor;
+
+import javax.annotation.Resource;
+import javax.ejb.Asynchronous;
+import javax.enterprise.concurrent.ManagedExecutorService;
+import javax.enterprise.context.RequestScoped;
+import java.io.IOException;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Future;
+import java.util.function.Supplier;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@RequestScoped
+public class AsyncBookService {
+
+ @Resource
+ private ManagedExecutorService executor;
+
+ @Asynchronous
+ public Future<String> serviceA() {
+ CompletableFuture<String> future = new CompletableFuture<>();
+ future.completeExceptionally(new IOException("Simulated error"));
+ return future;
+ }
+
+ @Asynchronous
+ public CompletableFuture<Integer> serviceB() {
+ return CompletableFuture.supplyAsync(delayedSupplier(1, 100), executor)
+ .thenApply(i -> i + 1);
+ }
+
+ @Asynchronous
+ public CompletableFuture<Integer> serviceB() {
+ return CompletableFuture.supplyAsync(delayedWithExceptionSupplier(100, new RuntimeException("test")), executor);
+ }
+
+ private Supplier<Integer> delayedSupplier(final int value,
+ final int delayMs) {
+ return () -> {
+ try {
+ Thread.sleep(delayMs);
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Problem while waiting");
+ }
+ return value;
+ };
+ }
+
+ private CompletableFuture<Integer> delayedWithExceptionSupplier(final int delayMs,
+ final Throwable t) {
+ final CompletableFuture<Integer> future = new CompletableFuture<>();
+ try {
+ Thread.sleep(delayMs);
+ future.completeExceptionally(t);
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Problem while waiting");
+ }
+ return future;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/b3d8edcc/examples/executor/src/test/java/org/superbiz/executor/AsyncBookServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/executor/src/test/java/org/superbiz/executor/AsyncBookServiceTest.java b/examples/executor/src/test/java/org/superbiz/executor/AsyncBookServiceTest.java
new file mode 100644
index 0000000..e567da4
--- /dev/null
+++ b/examples/executor/src/test/java/org/superbiz/executor/AsyncBookServiceTest.java
@@ -0,0 +1,73 @@
+package org.superbiz.executor;
+
+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.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@RunWith(Arquillian.class)
+public class AsyncBookServiceTest {
+
+ @Inject
+ private AsyncBookService service;
+
+ @Deployment()
+ public static final WebArchive app() {
+ return ShrinkWrap.create(WebArchive.class, "example.war")
+ .addClasses(AsyncBookService.class)
+ .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
+ }
+
+ @Test
+ public void testServiceA() {
+ final Future<String> future = service.serviceA();
+ try {
+ future.get(200, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException | TimeoutException e) {
+ fail("Unexpected exception" + e);
+ } catch (ExecutionException ioe) {
+ assertEquals("Simulated error", ioe.getCause().getMessage());
+ }
+ }
+
+ @Test
+ public void testServiceB() {
+ final CompletableFuture<Integer> future = service.serviceB();
+ try {
+ assertEquals(2, future.get(200, TimeUnit.MILLISECONDS).intValue());
+ } catch (Exception e) {
+ fail("Unexpected exception" + e);
+ }
+ }
+
+}
\ No newline at end of file
[23/27] tomee git commit: Merge branch 'embedded-main-interactive' of
https://github.com/jetbridge/tomee
Posted by jg...@apache.org.
Merge branch 'embedded-main-interactive' of https://github.com/jetbridge/tomee
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/2785ba50
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/2785ba50
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/2785ba50
Branch: refs/heads/master
Commit: 2785ba50296d0943c4165cac7d1922764e7c7544
Parents: ab07eaa 3f6959d
Author: Jonathan Gallimore <jg...@tomitribe.com>
Authored: Thu Dec 6 20:23:05 2018 +0000
Committer: Jonathan Gallimore <jg...@tomitribe.com>
Committed: Thu Dec 6 20:23:05 2018 +0000
----------------------------------------------------------------------
----------------------------------------------------------------------
[09/27] tomee git commit: TOMEE-2301 - Add javadoc and use a Logger
instead of System.out.println
Posted by jg...@apache.org.
TOMEE-2301 - Add javadoc and use a Logger instead of System.out.println
Signed-off-by: brunobat <br...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/ce01d8d9
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/ce01d8d9
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/ce01d8d9
Branch: refs/heads/master
Commit: ce01d8d9b362e56a121925dd070dba53290d6ffc
Parents: 934814e
Author: brunobat <br...@gmail.com>
Authored: Tue Dec 4 11:43:47 2018 +0000
Committer: brunobat <br...@gmail.com>
Committed: Wed Dec 5 15:27:04 2018 +0000
----------------------------------------------------------------------
examples/concurrency-utils/pom.xml | 2 +-
.../executor/ManagedScheduledService.java | 67 ++++++++++++++++----
.../org/superbiz/executor/ManagedService.java | 11 ++--
.../executor/ManagedScheduledServiceTest.java | 41 +++++++++---
.../superbiz/executor/ManagedServiceTest.java | 5 +-
5 files changed, 101 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/ce01d8d9/examples/concurrency-utils/pom.xml
----------------------------------------------------------------------
diff --git a/examples/concurrency-utils/pom.xml b/examples/concurrency-utils/pom.xml
index 0e0fba6..8a9de66 100644
--- a/examples/concurrency-utils/pom.xml
+++ b/examples/concurrency-utils/pom.xml
@@ -56,7 +56,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <version>3.7.1</version>
+ <version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
http://git-wip-us.apache.org/repos/asf/tomee/blob/ce01d8d9/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedScheduledService.java
----------------------------------------------------------------------
diff --git a/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedScheduledService.java b/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedScheduledService.java
index 07760a3..e5c1e75 100644
--- a/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedScheduledService.java
+++ b/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedScheduledService.java
@@ -24,6 +24,7 @@ import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
+import java.util.logging.Logger;
import static java.util.Objects.nonNull;
@@ -31,41 +32,85 @@ import static java.util.Objects.nonNull;
@RequestScoped
public class ManagedScheduledService {
+ private static final Logger LOGGER = Logger.getLogger(ManagedScheduledService.class.getSimpleName());
+
@Resource
private ManagedScheduledExecutorService executor;
- public Future<Integer> singleFixedDelayTask(final int value, final String errorMessage) {
- System.out.println("longCallableTask scheduled");
- return executor.schedule(longCallableTask(value, 10, errorMessage), 100, TimeUnit.MILLISECONDS);
+ /**
+ * Execute a task after a planned delay and get the result back by using a {@link Callable}
+ *
+ * @param value The value to compute
+ * @param errorMessage If not null an exception with be thrown with this message
+ * @return the processed result
+ */
+ public Future<Integer> singleFixedDelayTask(final int value,
+ final String errorMessage) {
+ LOGGER.info("longCallableTask scheduled");
+ return executor.schedule(
+ longCallableTask(value, 10, errorMessage), 100, TimeUnit.MILLISECONDS);
}
- public ScheduledFuture<?> periodicFixedDelayTask(final int value, final String errorMessage) {
- System.out.println("longRunnableTask scheduled");
- return executor.scheduleAtFixedRate(longRunnableTask(value, 10, errorMessage), 0, 100, TimeUnit.MILLISECONDS);
+ /**
+ * Execute a task periodically. Although a future is returned, it will not contain a result because the
+ * executor uses a runnable to perform the operations.<br>
+ * If an exception happens, the task will stop and you can catch the exception with the {@link ScheduledFuture}.
+ *
+ * @param value The value to compute
+ * @param errorMessage If not null an exception with be thrown with this message
+ * @return An object where you can cancel the periodic task and check for exceptions.
+ */
+ public ScheduledFuture<?> periodicFixedDelayTask(final int value,
+ final String errorMessage) {
+ LOGGER.info("longRunnableTask scheduled");
+ return executor.scheduleAtFixedRate(
+ longRunnableTask(value, 10, errorMessage), 0, 100, TimeUnit.MILLISECONDS);
}
+ /**
+ * Will simulate a long running operation
+ *
+ * @param value The value to compute
+ * @param taskDurationMs the time lenght of the operation
+ * @param errorMessage If not null an exception with be thrown with this message
+ * @return a {@link Runnable}
+ */
private Runnable longRunnableTask(final int value,
final int taskDurationMs,
final String errorMessage) {
return () -> {
if (nonNull(errorMessage)) {
- System.out.println("Exception will be thrown");
+ LOGGER.severe("Exception will be thrown");
throw new RuntimeException(errorMessage);
}
+ try {
+ // Simulate a long processing task using TimeUnit to sleep.
+ TimeUnit.MILLISECONDS.sleep(taskDurationMs);
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Problem while waiting");
+ }
Integer result = value + 1;
- System.out.println("longRunnableTask complete. Value is " + result);
+ LOGGER.info("longRunnableTask complete. Value is " + result);
// Cannot return result with a Runnable.
};
}
+ /**
+ * Will simulate a long running operation
+ *
+ * @param value The value to compute
+ * @param taskDurationMs the time lenght of the operation
+ * @param errorMessage If not null an exception with be thrown with this message
+ * @return a {@link Callable} with the result
+ */
private Callable<Integer> longCallableTask(final int value,
final int taskDurationMs,
final String errorMessage) {
return () -> {
- System.out.println("longCallableTask start");
+ LOGGER.info("longCallableTask start");
if (nonNull(errorMessage)) {
- System.out.println("Exception will be thrown");
+ LOGGER.severe("Exception will be thrown");
throw new RuntimeException(errorMessage);
}
@@ -75,7 +120,7 @@ public class ManagedScheduledService {
} catch (InterruptedException e) {
throw new RuntimeException("Problem while waiting");
}
- System.out.println("longCallableTask complete");
+ LOGGER.info("longCallableTask complete");
// We can return a result with a Callable.
return value + 1;
};
http://git-wip-us.apache.org/repos/asf/tomee/blob/ce01d8d9/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedService.java
----------------------------------------------------------------------
diff --git a/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedService.java b/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedService.java
index eecbb46..a8aa2cb 100644
--- a/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedService.java
+++ b/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedService.java
@@ -23,6 +23,7 @@ import javax.enterprise.context.RequestScoped;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
+import java.util.logging.Logger;
import static java.util.Objects.nonNull;
@@ -30,6 +31,8 @@ import static java.util.Objects.nonNull;
@RequestScoped
public class ManagedService {
+ private static final Logger LOGGER = Logger.getLogger(ManagedService.class.getSimpleName());
+
@Resource
private ManagedExecutorService executor;
@@ -41,7 +44,7 @@ public class ManagedService {
* @return A {@link CompletableFuture} that will return immediately.
*/
public CompletableFuture<Integer> asyncTask(final int value) {
- System.out.println("Create asyncTask");
+ LOGGER.info("Create asyncTask");
return CompletableFuture
.supplyAsync(longTask(value, 100, null), executor) // Execute asynchronously.
.thenApply(i -> i + 1); // After the return of the task, do something else with the result.
@@ -55,7 +58,7 @@ public class ManagedService {
* @return A {@link CompletableFuture} that will return immediately.
*/
public CompletableFuture<Integer> asyncTaskWithException(final int value) {
- System.out.println("Create asyncTaskWithException");
+ LOGGER.info("Create asyncTaskWithException");
return CompletableFuture
.supplyAsync(longTask(value, 100, "Planned exception"), executor) // Execute asynchronously.
.thenApply(i -> i + 1); // After the return of the task, do something else with the result.
@@ -74,7 +77,7 @@ public class ManagedService {
final String errorMessage) {
return () -> {
if (nonNull(errorMessage)) {
- System.out.println("Exception will be thrown");
+ LOGGER.severe("Exception will be thrown");
throw new RuntimeException(errorMessage);
}
@@ -84,7 +87,7 @@ public class ManagedService {
} catch (InterruptedException e) {
throw new RuntimeException("Problem while waiting");
}
- System.out.println("longTask complete");
+ LOGGER.info("longTask complete");
return value + 1;
};
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/ce01d8d9/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedScheduledServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedScheduledServiceTest.java b/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedScheduledServiceTest.java
index 4baf428..1a859ba 100644
--- a/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedScheduledServiceTest.java
+++ b/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedScheduledServiceTest.java
@@ -30,6 +30,7 @@ import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
+import java.util.logging.Logger;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -37,6 +38,8 @@ import static org.junit.Assert.fail;
@RunWith(Arquillian.class)
public class ManagedScheduledServiceTest {
+ private static final Logger LOGGER = Logger.getLogger(ManagedScheduledServiceTest.class.getSimpleName());
+
@Inject
private ManagedScheduledService scheduledService;
@@ -48,29 +51,44 @@ public class ManagedScheduledServiceTest {
}
+ /**
+ * Happy path with multiple tasks to be executed after a planed amount of time.
+ *
+ * @throws InterruptedException we don't expect it
+ * @throws ExecutionException we don't expect it
+ * @throws TimeoutException we don't expect it
+ */
@Test
public void singleFixedDelayTask() throws InterruptedException, ExecutionException, TimeoutException {
final Future<Integer> futureA = scheduledService.singleFixedDelayTask(1, null);
final Future<Integer> futureB = scheduledService.singleFixedDelayTask(50, null);
- System.out.println("Do some other work while we wait for the tasks");
+ LOGGER.info("Do some other work while we wait for the tasks");
assertEquals(2, futureA.get(200, TimeUnit.MILLISECONDS).intValue());
assertEquals(51, futureB.get(200, TimeUnit.MILLISECONDS).intValue());
}
+ /**
+ * Happy path with single task to be executed periodically until it's canceled.
+ *
+ * @throws InterruptedException we don't expect it
+ */
@Test
- public void periodicFixedDelayTask() throws InterruptedException, TimeoutException, ExecutionException {
+ public void periodicFixedDelayTask() throws InterruptedException {
final ScheduledFuture<?> scheduledFuture = scheduledService.periodicFixedDelayTask(1, null);
+ LOGGER.info("Do some other work while we wait for the tasks");
TimeUnit.MILLISECONDS.sleep(500);
if (!scheduledFuture.isCancelled()) {
scheduledFuture.cancel(true);
- System.out.println("task stopped");
+ LOGGER.info("task stopped");
}
}
-
+ /**
+ * Exception happens while processing the task executed after a planed amount of time.
+ */
@Test
- public void singleFixedDelayTaskWithException() throws InterruptedException, ExecutionException, TimeoutException {
+ public void singleFixedDelayTaskWithException() {
final Future<Integer> future = scheduledService.singleFixedDelayTask(1, "Planned exception");
try {
future.get(200, TimeUnit.MILLISECONDS);
@@ -82,12 +100,19 @@ public class ManagedScheduledServiceTest {
}
}
+ /**
+ * Exception happens while processing the periodic task.
+ *
+ * @throws InterruptedException we don't expect it
+ */
@Test
- public void periodicFixedDelayTaskWithException() throws InterruptedException {
+ public void periodicFixedDelayTaskWithException() {
final ScheduledFuture<?> scheduledFuture = scheduledService.periodicFixedDelayTask(1, "Planned exception");
- TimeUnit.MILLISECONDS.sleep(500);
try {
+ TimeUnit.MILLISECONDS.sleep(500);
+ // please note that this thread will pause here until an exception is thrown.
+ // The scheduler uses a Runnable that will never return a result.
scheduledFuture.get(200, TimeUnit.MILLISECONDS);
} catch (ExecutionException e) {
// the thrown RuntimeException will be wrapped around an ExecutionException
@@ -98,7 +123,7 @@ public class ManagedScheduledServiceTest {
if (!scheduledFuture.isCancelled()) {
scheduledFuture.cancel(true);
- System.out.println("task stopped");
+ LOGGER.info("task stopped");
}
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/ce01d8d9/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedServiceTest.java b/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedServiceTest.java
index 30b6f6f..8ab7138 100644
--- a/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedServiceTest.java
+++ b/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedServiceTest.java
@@ -30,6 +30,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
+import java.util.logging.Logger;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -38,6 +39,8 @@ import static org.junit.Assert.fail;
@RunWith(Arquillian.class)
public class ManagedServiceTest {
+ private static final Logger LOGGER = Logger.getLogger(ManagedServiceTest.class.getName());
+
@Inject
private ManagedService managedService;
@@ -54,7 +57,7 @@ public class ManagedServiceTest {
@Test
public void managedInvocationTest() {
final CompletableFuture<Integer> future = managedService.asyncTask(1);
- System.out.println("You can do something else in the meantime and later get the future value");
+ LOGGER.info("You can do something else in the meantime and later get the future value");
try {
// To prevent hanged tasks, you should obtain the value of a future with a timeout.
assertEquals(3, future.get(200, TimeUnit.MILLISECONDS).intValue());
[04/27] tomee git commit: uses EnumSet instead of HasSet
Posted by jg...@apache.org.
uses EnumSet instead of HasSet
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/d1135d33
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/d1135d33
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/d1135d33
Branch: refs/heads/master
Commit: d1135d3318fb82c2c67a08100f4202a250f26832
Parents: a381b9f
Author: Otavio Santana <ot...@gmail.com>
Authored: Tue Dec 4 12:36:20 2018 -0200
Committer: Otavio Santana <ot...@gmail.com>
Committed: Tue Dec 4 12:36:20 2018 -0200
----------------------------------------------------------------------
.../openejb/assembler/classic/InterceptorBindingBuilder.java | 4 ++--
.../org/apache/openejb/assembler/classic/ValidatorBuilder.java | 3 ++-
.../main/java/org/apache/openejb/config/DeploymentLoader.java | 5 ++---
3 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/d1135d33/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/InterceptorBindingBuilder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/InterceptorBindingBuilder.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/InterceptorBindingBuilder.java
index 70c42ce..c330ca9 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/InterceptorBindingBuilder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/InterceptorBindingBuilder.java
@@ -30,8 +30,8 @@ import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
+import java.util.EnumSet;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -206,7 +206,7 @@ public class InterceptorBindingBuilder {
// - Any addition for current level and/or exclusion for a lower level
// (lowest)
//
- final Set<Level> excludes = new HashSet<>();
+ final Set<Level> excludes = EnumSet.noneOf(Level.class);
for (final InterceptorBindingInfo info : bindings) {
final Level level = level(info);
http://git-wip-us.apache.org/repos/asf/tomee/blob/d1135d33/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java
index f55d165..92a6fae 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java
@@ -50,6 +50,7 @@ import javax.validation.valueextraction.ValueExtractor;
import java.io.InputStream;
import java.io.Serializable;
import java.util.Collection;
+import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
@@ -161,7 +162,7 @@ public final class ValidatorBuilder {
thread.setContextClassLoader(classLoader);
}
- final Set<ExecutableType> types = new HashSet<>();
+ final Set<ExecutableType> types = EnumSet.noneOf(ExecutableType.class);
for (final String type : info.validatedTypes) {
types.add(ExecutableType.valueOf(type));
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/d1135d33/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
index c9aafc4..a66be39 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
@@ -75,6 +75,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -93,8 +94,6 @@ import java.util.jar.JarFile;
import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
-import static java.util.Arrays.asList;
-
/**
* @version $Revision$ $Date$
*/
@@ -1907,7 +1906,7 @@ public class DeploymentLoader implements DeploymentFilterable {
}
public Class<? extends DeploymentModule> discoverModuleType(final URL baseUrl, final ClassLoader classLoader, final boolean searchForDescriptorlessApplications) throws IOException, UnknownModuleTypeException {
- final Set<RequireDescriptors> search = new HashSet<>();
+ final Set<RequireDescriptors> search = EnumSet.noneOf(RequireDescriptors.class);
if (!searchForDescriptorlessApplications) {
search.addAll(Arrays.asList(RequireDescriptors.values()));
[25/27] tomee git commit: Merge branch 'minor-pom-xml-fix' of
https://github.com/sendilkumarn/tomee
Posted by jg...@apache.org.
Merge branch 'minor-pom-xml-fix' of https://github.com/sendilkumarn/tomee
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/bbe21c75
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/bbe21c75
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/bbe21c75
Branch: refs/heads/master
Commit: bbe21c75062c21a0d3353acc652ce419b0edf2e4
Parents: 68e3fa6 92309e9
Author: Jonathan Gallimore <jg...@tomitribe.com>
Authored: Thu Dec 6 20:24:27 2018 +0000
Committer: Jonathan Gallimore <jg...@tomitribe.com>
Committed: Thu Dec 6 20:24:27 2018 +0000
----------------------------------------------------------------------
examples/mp-metrics-counted/pom.xml | 2 +-
examples/mp-metrics-timed/pom.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------