Skip to content

Commit

Permalink
add aot hints for rometools parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
dashaun committed Jan 19, 2024
1 parent 4990547 commit 23235c7
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/javagrunt/task/youtube/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.task.configuration.EnableTask;
import org.springframework.context.annotation.ImportRuntimeHints;
import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories;

@EnableTask
@EnableJdbcRepositories
@SpringBootApplication
@ImportRuntimeHints(RunTimeHints.class)
public class Application {

public static void main(String[] args) {
Expand Down
47 changes: 47 additions & 0 deletions src/main/java/com/javagrunt/task/youtube/RunTimeHints.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.javagrunt.task.youtube;

import org.springframework.aot.hint.*;

import java.util.HashSet;
import java.util.Set;

public class RunTimeHints implements RuntimeHintsRegistrar {

@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
Set<Class<?>> classes = new HashSet<>();
classes.add(com.rometools.modules.atom.io.AtomModuleParser.class);
classes.add(com.rometools.modules.base.io.CustomTagParser.class);
classes.add(com.rometools.modules.base.io.GoogleBaseParser.class);
classes.add(com.rometools.modules.cc.io.ModuleParserRSS1.class);
classes.add(com.rometools.modules.cc.io.ModuleParserRSS2.class);
classes.add(com.rometools.modules.content.io.ContentModuleParser.class);
classes.add(com.rometools.modules.feedpress.io.FeedpressParser.class);
classes.add(com.rometools.modules.fyyd.io.FyydParser.class);
classes.add(com.rometools.modules.georss.SimpleParser.class);
classes.add(com.rometools.modules.georss.W3CGeoParser.class);
classes.add(com.rometools.modules.itunes.io.ITunesParser.class);
classes.add(com.rometools.modules.itunes.io.ITunesParserOldNamespace.class);
classes.add(com.rometools.modules.mediarss.io.AlternateMediaModuleParser.class);
classes.add(com.rometools.modules.mediarss.io.MediaModuleParser.class);
classes.add(com.rometools.modules.mediarss.io.RSS20YahooParser.class);
classes.add(com.rometools.modules.opensearch.impl.OpenSearchModuleParser.class);
classes.add(com.rometools.modules.photocast.io.Parser.class);
classes.add(com.rometools.modules.psc.io.PodloveSimpleChapterParser.class);
classes.add(com.rometools.modules.slash.io.SlashModuleParser.class);
classes.add(com.rometools.modules.sle.io.ItemParser.class);
classes.add(com.rometools.modules.sle.io.ModuleParser.class);
classes.add(com.rometools.modules.thr.io.ThreadingModuleParser.class);
classes.add(com.rometools.modules.yahooweather.io.WeatherModuleParser.class);
try {
for (Class<?> c : classes) {
hints.reflection().registerType(TypeReference.of(c.getName()),
builder -> builder
.withMembers(MemberCategory.values()));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ class YouTubeFeedRunner implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) {
logger.info("YouTube Feed URL: " + YOUTUBE_FEED_URL);
logger.info("DATASOURCE_URL: " + System.getenv("DATASOURCE_URL"));
logger.info("DATASOURCE_USERNAME: " + System.getenv("DATASOURCE_USERNAME"));
try {
String result = fetchFeedData();
processFeed(result);
Expand Down
34 changes: 34 additions & 0 deletions src/test/java/com/javagrunt/task/youtube/ApplicationTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.javagrunt.task.youtube;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.context.annotation.Bean;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.DockerImageName;

@SpringBootTest
@Testcontainers
@TestConfiguration(proxyBeanMethods = false)
class ApplicationTests {

@Bean
@ServiceConnection
PostgreSQLContainer<?> postgresContainer() {
return new PostgreSQLContainer<>(DockerImageName.parse("postgres:latest"));
}

@Bean
@ServiceConnection(name = "openzipkin/zipkin")
GenericContainer<?> zipkinContainer() {
return new GenericContainer<>(DockerImageName.parse("openzipkin/zipkin:latest")).withExposedPorts(9411);
}

@Test
void contextLoads() {
}

}

0 comments on commit 23235c7

Please sign in to comment.