Skip to content

Commit

Permalink
More improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Nov 13, 2018
1 parent 1ba6c40 commit 1ce4ad9
Show file tree
Hide file tree
Showing 42 changed files with 259 additions and 570 deletions.
4 changes: 0 additions & 4 deletions agroal/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-transactions-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-arc-deployment</artifactId>
</dependency>
</dependencies>


Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,29 @@
package org.jboss.shamrock.agroal;

import java.util.Collections;

import javax.enterprise.inject.Default;

import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.DotName;
import org.jboss.protean.arc.processor.BeanConfigurator;
import org.jboss.protean.arc.processor.BeanRegistrar;
import org.jboss.shamrock.agroal.runtime.DataSourceCreator;
import org.jboss.shamrock.agroal.runtime.DataSourceDetails;
import org.jboss.shamrock.agroal.runtime.DataSourceProducer;
import org.jboss.shamrock.agroal.runtime.DataSourceTemplate;
import org.jboss.shamrock.annotations.BuildProducer;
import org.jboss.shamrock.annotations.BuildStep;
import org.jboss.shamrock.annotations.Record;
import org.jboss.shamrock.arc.deployment.BeanRegistrarBuildItem;
import org.jboss.shamrock.deployment.buildconfig.BuildConfig;
import org.jboss.shamrock.deployment.builditem.AdditionalBeanBuildItem;
import org.jboss.shamrock.deployment.builditem.BeanContainerBuildItem;
import org.jboss.shamrock.deployment.builditem.ReflectiveClassBuildItem;
import org.jboss.shamrock.deployment.cdi.BeanContainerListenerBuildItem;
import org.jboss.shamrock.deployment.recording.BytecodeRecorder;
import org.jboss.shamrock.runtime.ConfiguredValue;

class AgroalProcessor {


@BuildStep
AdditionalBeanBuildItem addBeans() {
AdditionalBeanBuildItem registerBean() {
return new AdditionalBeanBuildItem(DataSourceProducer.class);
}

@Record(staticInit = true)
@BuildStep
public void build(BuildConfig config,
BuildProducer<ReflectiveClassBuildItem> reflectiveClass, BuildProducer<BeanRegistrarBuildItem> beanRegistrars) throws Exception {
BeanContainerListenerBuildItem build(BuildConfig config,
BuildProducer<ReflectiveClassBuildItem> reflectiveClass, DataSourceTemplate template, BytecodeRecorder bc) throws Exception {
reflectiveClass.produce(new ReflectiveClassBuildItem(false, false,
io.agroal.pool.ConnectionHandler[].class.getName(),
io.agroal.pool.ConnectionHandler.class.getName(),
Expand All @@ -42,7 +34,7 @@ public void build(BuildConfig config,
));
BuildConfig.ConfigNode ds = config.getApplicationConfig().get("datasource");
if (ds.isNull()) {
return;
return null;
}
String driver = ds.get("driver").asString();
String url = ds.get("url").asString();
Expand All @@ -65,28 +57,7 @@ public void build(BuildConfig config,

reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, driver));

BeanRegistrar reg = new BeanRegistrar() {
@Override
public void register(RegistrationContext registrationContext) {
BeanConfigurator<DataSourceDetails> res = registrationContext.configure(DataSourceDetails.class);
res.creator(DataSourceCreator.class);
res.qualifiers(AnnotationInstance.create(DotName.createSimple(Default.class.getName()), null, Collections.emptyList()));
res.types(DataSourceDetails.class);
res.param("driver", configuredDriver.getValue());
res.param("url", configuredURL.getValue());
res.param("username", configuredUsername.getValue());
res.param("password", configuredPassword.getValue());
if(minSize != null) {
res.param("minsize", minSize);
}
if(maxSize != null) {
res.param("maxsize", maxSize);
}
res.done();

}
};
beanRegistrars.produce(new BeanRegistrarBuildItem(reg));
return new BeanContainerListenerBuildItem(template.addDatasource(configuredURL.getValue(), bc.classProxy(configuredDriver.getValue()), configuredUsername.getValue(), configuredPassword.getValue(), minSize, maxSize));

}
}
4 changes: 0 additions & 4 deletions agroal/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@
<groupId>io.agroal</groupId>
<artifactId>agroal-pool</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-arc-runtime</artifactId>
</dependency>
</dependencies>

<build>
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 1ce4ad9

Please sign in to comment.