Skip to content

Commit

Permalink
feat: include logs at GraphSupplier
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <[email protected]>
  • Loading branch information
otaviojava committed Jan 15, 2025
1 parent 5fc92a8 commit 97d26e1
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,32 @@
import org.eclipse.jnosql.mapping.reflection.Reflections;

import java.util.function.Supplier;
import java.util.logging.Logger;

import static org.eclipse.jnosql.mapping.core.config.MappingConfigurations.GRAPH_PROVIDER;


@ApplicationScoped
class GraphSupplier implements Supplier<Graph> {

public static Logger LOGGER = Logger.getLogger(GraphSupplier.class.getName());

@SuppressWarnings("unchecked")
@Override
@Produces
@ApplicationScoped
public Graph get(){
var settings = MicroProfileSettings.INSTANCE;

GraphConfiguration configuration = settings.get(GRAPH_PROVIDER, Class.class)
LOGGER.fine("Loading the Graph configuration");
var configuration = settings.get(GRAPH_PROVIDER, Class.class)
.filter(GraphConfiguration.class::isAssignableFrom)
.map(c -> (GraphConfiguration) Reflections.newInstance(c)).orElseGet(GraphConfiguration::getConfiguration);

LOGGER.fine("The Graph configuration loaded successfully with: " + configuration.getClass());
return configuration.apply(settings);
}

public void close(@Disposes Graph graph) throws Exception {
LOGGER.fine("Closing the Graph");
graph.close();
}
}

0 comments on commit 97d26e1

Please sign in to comment.