This repository has been archived by the owner on Apr 6, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improving bean deployment management
- Loading branch information
Alex Stockinger
committed
Sep 7, 2017
1 parent
4cec8f3
commit 598ace9
Showing
7 changed files
with
81 additions
and
33 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
core/src/main/java/fi/testee/deployment/BeanDeployment.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,58 @@ | ||
/* | ||
* Copyright (C) 2017 Alex Stockinger | ||
* | ||
* 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 fi.testee.deployment; | ||
|
||
import fi.testee.spi.DynamicArchiveContributor; | ||
import org.jboss.weld.bootstrap.api.ServiceRegistry; | ||
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive; | ||
|
||
import java.util.Collection; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.function.Predicate; | ||
import java.util.function.Supplier; | ||
|
||
import static java.util.stream.Collectors.toSet; | ||
|
||
public class BeanDeployment implements DynamicArchiveContributor { | ||
private final BeanArchiveDiscovery beanArchiveDiscovery; | ||
private final Predicate<BeanArchive> beanArchiveFilter; | ||
|
||
public BeanDeployment( | ||
final BeanArchiveDiscovery beanArchiveDiscovery, | ||
final Predicate<BeanArchive> beanArchiveFilter | ||
) { | ||
this.beanArchiveDiscovery = beanArchiveDiscovery; | ||
this.beanArchiveFilter = beanArchiveFilter; | ||
} | ||
|
||
@Override | ||
public Collection<BeanDeploymentArchive> contribute( | ||
final ServiceRegistry serviceRegistry, | ||
final Supplier<Collection<BeanDeploymentArchive>> archives | ||
) { | ||
final Set<BeanArchive> beanArchives = beanArchiveDiscovery.getBeanArchives().stream().filter(beanArchiveFilter).collect(toSet()); | ||
return beanArchives.stream() | ||
.map(it -> new BeanDeploymentArchiveImpl(serviceRegistry, it, archives)) | ||
.collect(toSet()); | ||
} | ||
|
||
public static <T> Collection<T> and(Collection<T> c, T t) { | ||
final HashSet<T> ts = new HashSet<>(c); | ||
ts.add(t); | ||
return ts; | ||
} | ||
} |
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
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
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
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
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
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