Skip to content

Commit

Permalink
Merge pull request #515 from mkouba/get-rid-of-di-abst-layer
Browse files Browse the repository at this point in the history
Get rid of DI abstraction layer
  • Loading branch information
stuartwdouglas authored Jan 16, 2019
2 parents 4fee31a + d5179a1 commit d1a2a09
Show file tree
Hide file tree
Showing 71 changed files with 239 additions and 318 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ void run() {
final Execution execution = this.execution;
final StepInfo stepInfo = this.stepInfo;
final BuildStep buildStep = stepInfo.getBuildStep();
final long start = System.currentTimeMillis();
log.tracef("Starting step \"%s\"", buildStep);
try {
if (! execution.isErrorReported()) {
Expand All @@ -408,7 +409,7 @@ void run() {
}
}
} finally {
log.tracef("Finished step \"%s\"", buildStep);
log.tracef("Finished step \"%s\" in %s ms", buildStep, System.currentTimeMillis() - start);
execution.removeBuildContext(stepInfo, this);
}
final Set<StepInfo> dependents = stepInfo.getDependents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ final class Execution {
final EnhancedQueueExecutor.Builder executorBuilder = new EnhancedQueueExecutor.Builder();
executorBuilder.setCorePoolSize(8).setMaximumPoolSize(1024);
executorBuilder.setExceptionHandler(JBossExecutors.loggingExceptionHandler());
executorBuilder.setThreadFactory(new JBossThreadFactory(new ThreadGroup("build group"), Boolean.FALSE, null, "build-%n", JBossExecutors.loggingExceptionHandler(), null));
executorBuilder.setThreadFactory(new JBossThreadFactory(new ThreadGroup("build group"), Boolean.FALSE, null, "build-%t", JBossExecutors.loggingExceptionHandler(), null));
buildTargetName = builder.getBuildTargetName();
executor = executorBuilder.build();
lastStepCount.set(builder.getChain().getEndStepCount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public final class Capabilities extends SimpleBuildItem {

public static final String CDI_ARC = "org.jboss.shamrock.cdi";
public static final String TRANSACTIONS = "org.jboss.shamrock.transactions";
public static final String UNDERTOW = "org.jboss.shamrock.undertow";

private final Set<String> capabilities;

Expand Down

This file was deleted.

This file was deleted.

4 changes: 4 additions & 0 deletions extensions/agroal/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-arc-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-agroal-runtime</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import org.jboss.shamrock.annotations.BuildProducer;
import org.jboss.shamrock.annotations.BuildStep;
import org.jboss.shamrock.annotations.Record;
import org.jboss.shamrock.deployment.builditem.AdditionalBeanBuildItem;
import org.jboss.shamrock.arc.deployment.AdditionalBeanBuildItem;
import org.jboss.shamrock.arc.deployment.BeanContainerListenerBuildItem;
import org.jboss.shamrock.deployment.builditem.substrate.ReflectiveClassBuildItem;
import org.jboss.shamrock.deployment.cdi.BeanContainerListenerBuildItem;

class AgroalProcessor {

Expand Down
4 changes: 4 additions & 0 deletions extensions/agroal/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-core-runtime</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-arc-runtime</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package org.jboss.shamrock.agroal.runtime;

import org.jboss.shamrock.arc.runtime.BeanContainer;
import org.jboss.shamrock.arc.runtime.BeanContainerListener;
import org.jboss.shamrock.runtime.Template;
import org.jboss.shamrock.runtime.cdi.BeanContainer;
import org.jboss.shamrock.runtime.cdi.BeanContainerListener;

@Template
public class DataSourceTemplate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.jboss.shamrock.deployment.builditem;
package org.jboss.shamrock.arc.deployment;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -31,9 +31,9 @@ public AdditionalBeanBuildItem(String... beanNames) {
this.beanNames = Arrays.asList(beanNames);
}

public AdditionalBeanBuildItem(Class... beanClasss) {
public AdditionalBeanBuildItem(Class<?>... beanClasss) {
beanNames = new ArrayList<>(beanClasss.length);
for (Class i : beanClasss) {
for (Class<?> i : beanClasss) {
beanNames.add(i.getName());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.jboss.shamrock.arc.deployment;

import static org.jboss.shamrock.annotations.ExecutionTime.RUNTIME_INIT;
import static org.jboss.shamrock.annotations.ExecutionTime.STATIC_INIT;

import java.io.ByteArrayInputStream;
Expand Down Expand Up @@ -44,39 +43,29 @@
import org.jboss.protean.arc.processor.BeanDefiningAnnotation;
import org.jboss.protean.arc.processor.BeanProcessor;
import org.jboss.protean.arc.processor.BeanProcessor.Builder;
import org.jboss.protean.arc.processor.DotNames;
import org.jboss.protean.arc.processor.ReflectionRegistration;
import org.jboss.protean.arc.processor.ResourceOutput;
import org.jboss.shamrock.annotations.BuildProducer;
import org.jboss.shamrock.annotations.BuildStep;
import org.jboss.shamrock.annotations.Record;
import org.jboss.shamrock.arc.runtime.ArcDeploymentTemplate;
import org.jboss.shamrock.arc.runtime.BeanContainer;
import org.jboss.shamrock.arc.runtime.LifecycleEventRunner;
import org.jboss.shamrock.deployment.Capabilities;
import org.jboss.shamrock.deployment.builditem.AdditionalBeanBuildItem;
import org.jboss.shamrock.deployment.builditem.ApplicationArchivesBuildItem;
import org.jboss.shamrock.deployment.builditem.BeanArchiveIndexBuildItem;
import org.jboss.shamrock.deployment.builditem.BeanContainerBuildItem;
import org.jboss.shamrock.deployment.builditem.FeatureBuildItem;
import org.jboss.shamrock.deployment.builditem.GeneratedClassBuildItem;
import org.jboss.shamrock.deployment.builditem.GeneratedResourceBuildItem;
import org.jboss.shamrock.deployment.builditem.HotDeploymentConfigFileBuildItem;
import org.jboss.shamrock.deployment.builditem.InjectionProviderBuildItem;
import org.jboss.shamrock.deployment.builditem.ServiceStartBuildItem;
import org.jboss.shamrock.deployment.builditem.ShutdownContextBuildItem;
import org.jboss.shamrock.deployment.builditem.substrate.ReflectiveClassBuildItem;
import org.jboss.shamrock.deployment.builditem.substrate.ReflectiveFieldBuildItem;
import org.jboss.shamrock.deployment.builditem.substrate.ReflectiveMethodBuildItem;
import org.jboss.shamrock.deployment.cdi.BeanContainerListenerBuildItem;
import org.jboss.shamrock.deployment.cdi.BeanDefiningAnnotationBuildItem;
import org.jboss.shamrock.deployment.cdi.GeneratedBeanBuildItem;
import org.jboss.shamrock.deployment.cdi.ResourceAnnotationBuildItem;
import org.jboss.shamrock.runtime.cdi.BeanContainer;
import org.jboss.shamrock.undertow.ServletExtensionBuildItem;

public class ArcAnnotationProcessor {

private static final DotName JAVA_LANG_OBJECT = DotName.createSimple(Object.class.getName());

private static final Logger log = Logger.getLogger("org.jboss.shamrock.arc.deployment.processor");

@Inject
Expand Down Expand Up @@ -212,13 +201,6 @@ public void writeResource(Resource resource) throws IOException {
return new BeanContainerBuildItem(bc);
}

@BuildStep
@Record(RUNTIME_INIT)
void startupEvent(ArcDeploymentTemplate template, List<ServiceStartBuildItem> startList, BeanContainerBuildItem beanContainer,
ShutdownContextBuildItem shutdown) {
template.handleLifecycleEvents(shutdown, beanContainer.getValue());
}

private void indexBeanClass(String beanClass, Indexer indexer, IndexView shamrockIndex, Set<DotName> additionalIndex) {
DotName beanClassName = DotName.createSimple(beanClass);
if (additionalIndex.contains(beanClassName)) {
Expand Down Expand Up @@ -249,15 +231,9 @@ private void indexBeanClass(String beanClass, Indexer indexer, IndexView shamroc
}
}
}
if (!beanInfo.superName().equals(JAVA_LANG_OBJECT)) {
if (!beanInfo.superName().equals(DotNames.OBJECT)) {
indexBeanClass(beanInfo.superName().toString(), indexer, shamrockIndex, additionalIndex);
}

}

@BuildStep
HotDeploymentConfigFileBuildItem configFile() {
return new HotDeploymentConfigFileBuildItem("META-INF/beans.xml");
}

private void indexBeanClass(String beanClass, Indexer indexer, IndexView shamrockIndex, Set<DotName> additionalIndex, byte[] beanData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.jboss.shamrock.deployment.builditem;
package org.jboss.shamrock.arc.deployment;

import org.jboss.builder.item.SimpleBuildItem;
import org.jboss.jandex.IndexView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
import org.jboss.shamrock.annotations.BuildStep;
import org.jboss.shamrock.deployment.ApplicationArchive;
import org.jboss.shamrock.deployment.builditem.ApplicationArchivesBuildItem;
import org.jboss.shamrock.deployment.builditem.BeanArchiveIndexBuildItem;
import org.jboss.shamrock.deployment.cdi.BeanDefiningAnnotationBuildItem;

public class BeanArchiveProcessor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/

package org.jboss.shamrock.deployment.builditem;
package org.jboss.shamrock.arc.deployment;

import org.jboss.builder.item.SimpleBuildItem;
import org.jboss.shamrock.runtime.cdi.BeanContainer;
import org.jboss.shamrock.arc.runtime.BeanContainer;

public final class BeanContainerBuildItem extends SimpleBuildItem {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/

package org.jboss.shamrock.deployment.cdi;
package org.jboss.shamrock.arc.deployment;

import org.jboss.builder.item.MultiBuildItem;
import org.jboss.shamrock.runtime.cdi.BeanContainerListener;
import org.jboss.shamrock.arc.runtime.BeanContainerListener;

public final class BeanContainerListenerBuildItem extends MultiBuildItem {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@
* limitations under the License.
*/

package org.jboss.shamrock.deployment.cdi;
package org.jboss.shamrock.arc.deployment;

import org.jboss.builder.item.MultiBuildItem;
import org.jboss.jandex.DotName;
import org.jboss.shamrock.deployment.Capabilities;

/**
* This build item is used to specify additional bean defining annotations. See also
* <a href="http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#bean_defining_annotations">2.5.1. Bean defining annotations</a>.
*
* @see Capabilities#CDI_ARC
*/
public final class BeanDefiningAnnotationBuildItem extends MultiBuildItem {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.jboss.shamrock.arc.deployment;

import org.jboss.jandex.DotName;
import org.jboss.shamrock.annotations.BuildProducer;
import org.jboss.shamrock.annotations.BuildStep;
import org.jboss.shamrock.deployment.Capabilities;
import org.jboss.shamrock.undertow.UndertowBuildStep;

public class BeanDefiningAnnotationsBuildStep {

@BuildStep
void beanDefiningAnnotations(Capabilities capabilities, BuildProducer<BeanDefiningAnnotationBuildItem> annotations) {
if (capabilities.isCapabilityPresent(Capabilities.UNDERTOW)) {
// Arc integration depends on undertow so we want to avoid cyclic dependencies
annotations.produce(new BeanDefiningAnnotationBuildItem(UndertowBuildStep.WEB_FILTER));
annotations.produce(new BeanDefiningAnnotationBuildItem(UndertowBuildStep.WEB_SERVLET));
annotations.produce(new BeanDefiningAnnotationBuildItem(UndertowBuildStep.WEB_LISTENER));
}

// TODO: we should only add this when running the tests
annotations.produce(new BeanDefiningAnnotationBuildItem(DotName.createSimple("org.junit.runner.RunWith")));
}

}
Loading

0 comments on commit d1a2a09

Please sign in to comment.