forked from eclipse/microprofile-context-propagation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request eclipse#30 from FroMage/classloaders
Support per-classloader configuration and specify when to load the ThreadContextProviders
- Loading branch information
Showing
3 changed files
with
180 additions
and
14 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
api/src/main/java/org/eclipse/microprofile/concurrent/spi/ConcurrencyManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) 2018 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.eclipse.microprofile.concurrent.spi; | ||
|
||
import org.eclipse.microprofile.concurrent.ManagedExecutorBuilder; | ||
import org.eclipse.microprofile.concurrent.ThreadContextBuilder; | ||
|
||
/** | ||
* {@link ConcurrencyManager} instances can be used to create {@link #newManagedExecutorBuilder()} | ||
* or {@link #newThreadContextBuilder()}. Each {@link ConcurrencyManager} instance has its own set | ||
* of {@link ThreadContextProvider} as defined during building with {@link ConcurrencyManagerBuilder#build()} | ||
* or {@link ConcurrencyProvider#getConcurrencyManager()}. | ||
* | ||
* @see ConcurrencyProvider#getConcurrencyManager() | ||
* @see ConcurrencyManagerBuilder | ||
*/ | ||
public interface ConcurrencyManager { | ||
/** | ||
* Creates a new <code>ManagedExecutorBuilder</code> instance. | ||
* | ||
* @return a new <code>ManagedExecutorBuilder</code> instance. | ||
*/ | ||
ManagedExecutorBuilder newManagedExecutorBuilder(); | ||
|
||
/** | ||
* Creates a new <code>ThreadContextBuilder</code> instance. | ||
* | ||
* @return a new <code>ThreadContextBuilder</code> instance. | ||
*/ | ||
ThreadContextBuilder newThreadContextBuilder(); | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
api/src/main/java/org/eclipse/microprofile/concurrent/spi/ConcurrencyManagerBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (c) 2018 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.eclipse.microprofile.concurrent.spi; | ||
|
||
/** | ||
* Use this class to configure instances of {@link ConcurrencyManager}. | ||
*/ | ||
public interface ConcurrencyManagerBuilder { | ||
|
||
/** | ||
* Use the specified {@link ThreadContextProvider} instances. | ||
* @param providers the {@link ThreadContextProvider} instances to use. | ||
* @return this builder | ||
*/ | ||
public ConcurrencyManagerBuilder withThreadContextProviders(ThreadContextProvider... providers); | ||
|
||
/** | ||
* Load all discoverable {@link ThreadContextProvider} instances via the {@link ServiceLoader} | ||
* mechanism on the current thread-context {@link ClassLoader} (unless overridden by {@link #forClassLoader(ClassLoader)}). | ||
* | ||
* @return this builder | ||
*/ | ||
public ConcurrencyManagerBuilder addDiscoveredThreadContextProviders(); | ||
|
||
/** | ||
* Use the given {@link ClassLoader} for {@link #addDiscoveredThreadContextProviders()} instead | ||
* of the current thread-context {@link ClassLoader}. | ||
* | ||
* @param classLoader the {@link ClassLoader} to use for {@link #addDiscoveredThreadContextProviders()} | ||
* @return this builder | ||
*/ | ||
public ConcurrencyManagerBuilder forClassLoader(ClassLoader classLoader); | ||
|
||
/** | ||
* Creates a new {@link ConcurrencyManager} with the specified configuration. | ||
* @return a new {@link ConcurrencyManager} with the specified configuration. | ||
*/ | ||
public ConcurrencyManager build(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters