{"id":24525640,"url":"https://github.com/hammock-project/hammock","last_synced_at":"2025-04-14T14:12:30.482Z","repository":{"id":14482364,"uuid":"17194860","full_name":"hammock-project/hammock","owner":"hammock-project","description":"CDI Based Microservices","archived":false,"fork":false,"pushed_at":"2023-01-13T01:56:38.000Z","size":1160,"stargazers_count":106,"open_issues_count":36,"forks_count":24,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-03-28T03:11:59.408Z","etag":null,"topics":["cdi","hammock","java","microservices"],"latest_commit_sha":null,"homepage":"https://hammock-project.github.io","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/hammock-project.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":"security-jose/pom.xml","support":null}},"created_at":"2014-02-26T01:35:28.000Z","updated_at":"2025-01-29T14:20:59.000Z","dependencies_parsed_at":"2023-01-14T12:31:57.769Z","dependency_job_id":null,"html_url":"https://github.com/hammock-project/hammock","commit_stats":null,"previous_names":["johnament/hammock"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hammock-project%2Fhammock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hammock-project%2Fhammock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hammock-project%2Fhammock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hammock-project%2Fhammock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hammock-project","download_url":"https://codeload.github.com/hammock-project/hammock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248894938,"owners_count":21179152,"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","hammock","java","microservices"],"created_at":"2025-01-22T05:19:31.682Z","updated_at":"2025-04-14T14:12:30.463Z","avatar_url":"https://github.com/hammock-project.png","language":"Java","readme":"Hammock\n=======\n\n[![Gitter chat](https://badges.gitter.im/hammock-project/gitter.png)](https://gitter.im/hammock-project/Lobby)\n[![Build Status](https://travis-ci.org/hammock-project/hammock.png)](https://travis-ci.org/hammock-project/hammock)\n[![Maven Central](https://img.shields.io/maven-central/v/ws.ament.hammock/hammock-core.svg)](http://search.maven.org/#search%7Cga%7C1%7Cws.ament.hammock)\n\n![Hammock](https://hammock-project.github.io/img/src/Large.png)\n\n_Building Microservices so easily you're laying in a Hammock!_\n\nHammock is a simple to use framework for bootstrapping CDI, launching a web server and being able to deploy REST APIs.  It takes a best practice approach to creating a runtime for you, so that you can focus on the important stuff.\n\nRead through some of the basics to get started, or view the [wiki](https://github.com/hammock-project/hammock/wiki)\n\n## Getting Started\n\nFirst, add some dependencies to your project.  Easiest way to start is with a Micrprofile Distribution - Standard or Cochise\n\n### Using Maven\n\nContainers bring in transitive dependencies to bring up your runtime.\n\n#### Using Undertow, Weld, Apache Johnzon, CXF\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ews.ament.hammock\u003c/groupId\u003e\n    \u003cartifactId\u003edist-microprofile\u003c/artifactId\u003e\n    \u003cversion\u003e2.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n#### Using Apache Tomcat, OpenWebBeans, Johnzon, CXF\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ews.ament.hammock\u003c/groupId\u003e\n    \u003cartifactId\u003edist-microprofile-cochise\u003c/artifactId\u003e\n    \u003cversion\u003e2.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Launching your first app\n\nNow that you have your dependencies in order, you can launch your first app.  \n\n#### Using Hammock's Bootstrap\n\nHammock has a bootstrap class, `ws.ament.hammock.Bootstrap` which will start CDI for you.  It uses implementations of `Bootstrapper` to start the appropriate container.\n\n#### Using Your Container's Bootstrap\n\nYou can also bootstrap your container directly.  Since Hammock is implemented as a suite of CDI components, no extra work is required.\n\n#### Use your own Bootstrap\n\nYou may want your own bootstrap, to do some pre-flight checks.  Just make sure you either initialize Hammock or Weld when you're done.  Your main might look as simple as\n\n```java\npublic class CustomBootstrapper implements Bootstrapper {\n\n    public void start() {\n        new PreflightChecks().verify();\n        new Weld().initialize();\n    }\n\n    public void stop() { }\n}\n```\n\nMake sure you add this to the `ServiceLoader`\n\n#### Executable JARs\n\nYou'll likely want to create an executable JAR.  Just shade in all dependencies using your favorite build tool, and set the main class to your choice of main class.  I recommend using [Capsule](http://www.capsule.io/)\n\n### Configuration\n\nConfiguration is provided via Apache DeltaSpike.  The default configuration uses port 8080 for your webserver and /tmp for your static file directory.  You'll likely want to configure those for your project.\n\n### Security\n\nBasic security support is available.  Two CDI interceptors are in use, one for verifying a user is logged in and another for verifying roles.  To make use of security, you'll need to implement the `Identity` interface and make it a bean to represent the user currently be acted upon, usually of `RequestScope`.  \n* `@LoggedIn` annotate a class or method, and an interceptor will check that the user is logged in for this method invocation.\n* `@HasAllRoles()` annotate a class or method, and an interceptor will check that the current identity has all of the roles defined.\n\nTo add the security runtime to your app, just include this dependency.\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ews.ament.hammock\u003c/groupId\u003e\n    \u003cartifactId\u003esecurity-spi\u003c/artifactId\u003e\n    \u003cversion\u003e2.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Issue Tracking\n\nHave a feature request? Or found an issue? Please use [github issues](https://github.com/hammock-project/hammock/issues) to let us know!","funding_links":[],"categories":["开发框架"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhammock-project%2Fhammock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhammock-project%2Fhammock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhammock-project%2Fhammock/lists"}