This repository has been archived by the owner on Sep 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Catalin Dinuta edited this page Feb 17, 2022
·
1 revision
Integrate dependency into your custom microservice
Add maven dependency.
<dependency>
<groupId>com.github.dinuta.estuary</groupId>
<artifactId>agent</artifactId>
<version>4.1.0</version>
</dependency>
Make your own main class for your custom service.
@SpringBootApplication
@EnableEurekaClient
@RestController
@EnableSwagger2
public class MyCustomAgentApp implements CommandLineRunner {
public static void main(String[] args) {
new SpringApplication(MyCustomAgentApp.class).run(args);
}
@Override
public void run(String... arg0) {
if (arg0.length > 0 && arg0[0].equals("exitcode")) {
throw new ExitException();
}
}
class ExitException extends RuntimeException implements ExitCodeGenerator {
private static final long serialVersionUID = 1L;
@Override
public int getExitCode() {
return 10;
}
}
}
Annotate MyCustomAgentApp main class with:
@ComponentScan(basePackages = {
"com.github.dinuta.estuary.agent",
"com.github.dinuta.estuary.agent.api",
"com.github.dinuta.estuary.agent.configuration",
"com.github.dinuta.estuary.agent.component",
"com.github.dinuta.estuary.agent.handler"
... add your other custom controllers and configs here
})
Optionally add your custom controllers to the swagger.
@Configuration
public class Swagger2DocumentationConfig {
ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("agent")
.description("Custom Agent will run custom commands")
.termsOfServiceUrl("")
.version("4.0.8")
.contact(new Contact("Catalin Dinuta", "", "cdinuta@example.com"))
.build();
}
@Bean
public Docket customImplementationForAgent() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.example.api")) //your api package where your controllers resides
.build()
.groupName("agent")
.directModelSubstitute(org.threeten.bp.LocalDate.class, java.sql.Date.class)
.directModelSubstitute(org.threeten.bp.OffsetDateTime.class, java.util.Date.class)
.apiInfo(apiInfo());
}
}