{"id":22907431,"url":"https://github.com/oswaldobapvicjr/agents","last_synced_at":"2025-05-08T22:18:04.084Z","repository":{"id":40331390,"uuid":"352374321","full_name":"oswaldobapvicjr/agents","owner":"oswaldobapvicjr","description":"A lightweight timer/cron agents framework for Java applications","archived":false,"fork":false,"pushed_at":"2025-04-15T21:23:01.000Z","size":272,"stargazers_count":4,"open_issues_count":4,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-08T22:17:52.844Z","etag":null,"topics":["agent","cron","cron-jobs","cronjob-scheduler","crontab","executor","java","scheduler","timer","timer-agent"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oswaldobapvicjr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-03-28T16:04:29.000Z","updated_at":"2025-03-31T21:13:58.000Z","dependencies_parsed_at":"2024-04-03T03:28:47.167Z","dependency_job_id":"9065404f-2dc8-46bc-974b-4b572391096e","html_url":"https://github.com/oswaldobapvicjr/agents","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oswaldobapvicjr%2Fagents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oswaldobapvicjr%2Fagents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oswaldobapvicjr%2Fagents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oswaldobapvicjr%2Fagents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oswaldobapvicjr","download_url":"https://codeload.github.com/oswaldobapvicjr/agents/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253155004,"owners_count":21862625,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","cron","cron-jobs","cronjob-scheduler","crontab","executor","java","scheduler","timer","timer-agent"],"created_at":"2024-12-14T03:15:12.263Z","updated_at":"2025-05-08T22:18:04.053Z","avatar_url":"https://github.com/oswaldobapvicjr.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# agents\n\n[![Known Vulnerabilities](https://snyk.io/test/github/oswaldobapvicjr/agents/badge.svg)](https://snyk.io/test/github/oswaldobapvicjr/agents)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/oswaldobapvicjr/agents/maven.yml)](https://github.com/oswaldobapvicjr/agents/actions/workflows/maven.yml)\n[![Coverage](https://img.shields.io/codecov/c/github/oswaldobapvicjr/agents)](https://codecov.io/gh/oswaldobapvicjr/agents)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/net.obvj/agents/badge.svg)](https://maven-badges.herokuapp.com/maven-central/net.obvj/agents)\n[![Javadoc](https://javadoc.io/badge2/net.obvj/agents/javadoc.svg)](https://javadoc.io/doc/net.obvj/agents)\n\nA lightweight timer/cron agents framework for Java applications.\n\n---\n\n## Agents overview\n\nConvert any Java class into an Agent by adding the **@Agent** annotation at the class, then mark one method with the **@Run** annotation so it will be called automatically. The framework looks up for agent classes by scanning user-specified packages at runtime and can run particular tasks periodically in the JVM.\n\nAn agent can be of type **Timer** or **Cron**:\n\n### Timer agents\n\nA Timer agent can be executed periodically, in a fixed run frequency, which must be in seconds, minutes, or hours. For example:\n\n```java\npackage com.mycompany.agents;\n...\n@Agent(type = AgentType.TIMER, interval = \"30 seconds\", modulate = true)\npublic class MyTimerAgent {\n    @Run\n    public void execute() {\n       // This method will be called every 30 seconds...\n    }\n}\n```\n\n### Cron agents\n\nA Cron agent can be executed at specific dates and times, comparable to the Cron Service available in Unix/Linux systems. Although they are more robust in terms of configuration flexibility, the interval between executions cannot be lower than 1 minute.\n\nCron systax has five fields separated by a space, and each field represent a unit of time.\n\n```bash\n┌───────────── minute (0 - 59)\n│ ┌───────────── hour (0 - 23)\n│ │ ┌───────────── day of the month (1 - 31)\n│ │ │ ┌───────────── month (1 - 12 or JAN-DEC)\n│ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)\n│ │ │ │ │                                   \n│ │ │ │ │\n│ │ │ │ │\n* * * * *\n```\n\nFor example, the following agent is configured to execute every weekday at 2:00 AM:\n\n```java\npackage com.mycompany.agents;\n...\n@Agent(type = AgentType.CRON, interval = \"0 2 * * MON-FRI\")\npublic class MyCronAgent {\n    @Run\n    public void execute() {\n        // This method will be called every weekday at 2:00 AM\n    }\n}\n```\n\n---\n\n## Usage\n\n1. Scan one or more base packages to search for agents\n\n```java\nAgentManager manager = AgentManager.defaultInstance();\nmanager.scanPackage(\"com.mycompany.agents\");\n```\n\n3. Start all agents\n\n```java\nmanager.startAllAgents();\n```\n\n---\n\n## How to include it\n\nIf you are using Maven, add **Agents** as a dependency on your pom.xml file:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003enet.obvj\u003c/groupId\u003e\n    \u003cartifactId\u003eagents\u003c/artifactId\u003e\n    \u003cversion\u003e0.3.3\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nIf you use other dependency managers (such as Gradle, Grape, Ivy, etc.) click [here](https://maven-badges.herokuapp.com/maven-central/net.obvj/agents).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foswaldobapvicjr%2Fagents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foswaldobapvicjr%2Fagents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foswaldobapvicjr%2Fagents/lists"}