{"id":20800294,"url":"https://github.com/atbashee/cdi-locked","last_synced_at":"2025-08-16T01:21:21.013Z","repository":{"id":87369517,"uuid":"489728280","full_name":"atbashEE/CDI-locked","owner":"atbashEE","description":"Read and Write locks for CDI","archived":false,"fork":false,"pushed_at":"2022-05-07T17:38:49.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-18T12:26:02.982Z","etag":null,"topics":["cdi","jakarta-ee","java","locks"],"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/atbashEE.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2022-05-07T16:39:13.000Z","updated_at":"2022-06-07T19:19:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"b327a9ec-d377-4f45-b779-1b27cf592db5","html_url":"https://github.com/atbashEE/CDI-locked","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atbashEE%2FCDI-locked","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atbashEE%2FCDI-locked/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atbashEE%2FCDI-locked/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atbashEE%2FCDI-locked/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atbashEE","download_url":"https://codeload.github.com/atbashEE/CDI-locked/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243147274,"owners_count":20243744,"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":["cdi","jakarta-ee","java","locks"],"created_at":"2024-11-17T18:13:10.196Z","updated_at":"2025-03-12T02:41:05.593Z","avatar_url":"https://github.com/atbashEE.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Named locks for CDI\n\nRead and Write locks for CDI.  \n\n## Why this library?\n\nThe Jakarta EJB specification has an annotation `@Lock` to handle the concurrent access to method within a Singleton bean.  In general, sometimes it required that access to some data structures is guarded by some lock to protect the integrity of it. To make sure the data can safely be updated without the risk that some other threads read the partially updated data.\n\nThis can be achieved rather easily achieved by using the `ReentrantReadWriteLock` class from the JVM itself. This library brings _named locks_ to CDI as annotation, similar to the Jakarta EJB specification.\n\n- The _read_ lock can be obtained by several threads.\n- The _write_ lock can be obtained only by one thread when no other threads have a read lock.\n- Lock are _named_ so that you can have multiple within your application.\n- Locks are not limited to one CDI bean but can be used on several beans.\n\nA similar functionality can be found within DeltaSpike Core but is part of the larger framework there.\n\n## Configuration\n\nAdd the following Maven dependency to your project.\n\n```\n    \u003cdependency\u003e\n        \u003cgroupId\u003ebe.atbash.cdi\u003c/groupId\u003e\n        \u003cartifactId\u003elocked\u003c/artifactId\u003e\n        \u003cversion\u003e1.0.0\u003c/version\u003e\n    \u003c/dependency\u003e\n```\n\n## Usage\n\nOn CDI methods you can use the `@Locked` annotation with the following members.\n\n- String name() \n\nThe name of the lock. The default value is _generic_ and doesn't need to be specified if you only need one lock in your application.\n\n- boolean fair()\n\nDo you want to activate the _fair_ mechanism of the JVM functionality.  When set to true, default is false, an approximately arrival-order policy is applied. Setting to true can have a performance impact.\n\n- Operation operation()\n\nDetermines the type of the lock. By default, it is a _read_ lock but a _write_ lock can be specified (`Operation.WRITE`)\n    \n- long timeout()\n\nWhen a non-zero value is specified, a time-out is applied to acquire the lock. This works in combination with the `timeoutUnit` member. When the lock cannot be granted within the specified time-out, an `IllegalStateException` exception will be thrown.\n\n- TimeUnit timeoutUnit()\n\nSpecified the timescale for the `timeout` member, by default it is milliseconds.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatbashee%2Fcdi-locked","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatbashee%2Fcdi-locked","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatbashee%2Fcdi-locked/lists"}