diff --git a/db/src/main/java/org/trellisldp/ext/db/DBWrappedMementoService.java b/db/src/main/java/org/trellisldp/ext/db/DBWrappedMementoService.java index ca334884..e01c04e1 100644 --- a/db/src/main/java/org/trellisldp/ext/db/DBWrappedMementoService.java +++ b/db/src/main/java/org/trellisldp/ext/db/DBWrappedMementoService.java @@ -23,6 +23,9 @@ import java.util.TreeSet; import java.util.concurrent.CompletionStage; +import javax.decorator.Decorator; +import javax.decorator.Delegate; +import javax.inject.Inject; import javax.sql.DataSource; import org.apache.commons.rdf.api.IRI; @@ -31,6 +34,7 @@ import org.slf4j.Logger; import org.trellisldp.api.*; +@Decorator public class DBWrappedMementoService implements MementoService { private static final Logger LOGGER = getLogger(DBWrappedMementoService.class); @@ -42,7 +46,8 @@ public class DBWrappedMementoService implements MementoService { * @param ds the DataSource object * @param service the memento service implementation */ - public DBWrappedMementoService(final DataSource ds, final MementoService service) { + @Inject + public DBWrappedMementoService(final DataSource ds, @Delegate final MementoService service) { this(Jdbi.create(ds), service); } diff --git a/webapp/src/main/java/org/trellisldp/ext/db/webapp/ServiceProducers.java b/webapp/src/main/java/org/trellisldp/ext/db/webapp/ServiceProducers.java deleted file mode 100644 index 4ebd507f..00000000 --- a/webapp/src/main/java/org/trellisldp/ext/db/webapp/ServiceProducers.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.trellisldp.ext.db.webapp; - -import io.agroal.api.AgroalDataSource; -import io.quarkus.agroal.DataSource; - -import javax.annotation.PostConstruct; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; -import javax.inject.Inject; - -import org.trellisldp.api.*; -import org.trellisldp.ext.db.DBWrappedMementoService; -import org.trellisldp.file.FileBinaryService; -import org.trellisldp.file.FileMementoService; - -@ApplicationScoped -class ServiceProducers { - - @Inject - @DataSource("trellis") - AgroalDataSource db; - - @Produces - BinaryService binaryService = new FileBinaryService(); - - @Produces - MementoService mementoService; - - @PostConstruct - void init() { - mementoService = new DBWrappedMementoService(db, new FileMementoService()); - } -} diff --git a/webapp/src/main/resources/META-INF/beans.xml b/webapp/src/main/resources/META-INF/beans.xml index 1e341328..ea24c811 100644 --- a/webapp/src/main/resources/META-INF/beans.xml +++ b/webapp/src/main/resources/META-INF/beans.xml @@ -4,4 +4,7 @@ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" version="1.1" bean-discovery-mode="all"> + + org.trellisldp.ext.db.DBWrappedMementoService +