{"id":22127497,"url":"https://github.com/akarazhev/metacfg4j","last_synced_at":"2025-06-23T07:02:10.689Z","repository":{"id":36425924,"uuid":"215487377","full_name":"akarazhev/metacfg4j","owner":"akarazhev","description":"The metacfg4j project (that stands for the meta configuration for java) is a library that can be used as the solution by creating a business abstraction or may extend an existed implementation to provide such software solutions as: various configuration (application, user's and etc.), CRUD services, DSL, MVP.","archived":false,"fork":false,"pushed_at":"2024-02-21T00:11:52.000Z","size":769,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T08:29:39.309Z","etag":null,"topics":["crud","dsl","h2db","http-client","http-server","https-server","java","mvp","rest-api"],"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/akarazhev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2019-10-16T07:41:42.000Z","updated_at":"2023-03-07T10:09:24.000Z","dependencies_parsed_at":"2025-06-23T07:01:58.543Z","dependency_job_id":null,"html_url":"https://github.com/akarazhev/metacfg4j","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/akarazhev/metacfg4j","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akarazhev%2Fmetacfg4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akarazhev%2Fmetacfg4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akarazhev%2Fmetacfg4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akarazhev%2Fmetacfg4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akarazhev","download_url":"https://codeload.github.com/akarazhev/metacfg4j/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akarazhev%2Fmetacfg4j/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261433936,"owners_count":23157196,"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":["crud","dsl","h2db","http-client","http-server","https-server","java","mvp","rest-api"],"created_at":"2024-12-01T17:19:09.859Z","updated_at":"2025-06-23T07:02:05.681Z","avatar_url":"https://github.com/akarazhev.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# metacfg4j\n\n[![Build Status](https://travis-ci.com/akarazhev/metacfg4j.svg?branch=master)](https://travis-ci.com/akarazhev/metacfg4j)\n[![codecov.io](https://codecov.io/github/akarazhev/metacfg4j/coverage.svg?branch=master)](https://codecov.io/github/akarazhev/metacfg4j?branch=master)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.akarazhev/metacfg4j/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.akarazhev/metacfg4j)\n\nThe `metacfg4j` project (that stands for the `meta configuration for java`) is a library that can be used as the solution by creating a business abstraction or \nmay extend an existed implementation to provide such software solutions as: various configuration (application, user's and etc.), CRUD services, DSL, MVP.\n\n## Architecture\n\nThis is a high-level abstraction based on the low-level API. It has been written without frameworks and delivered with one dependency:\n\n\u0026#8658; JSON simple (https://cliftonlabs.github.io/json-simple/)\u003cbr/\u003e\n\nThis library has the implementation of a simple web-client/server, repositories, services, controllers. The web-server\nprovides implementation of REST methods.\nData is persisted into a DB, by using any configured datasource.\n\nThe size of the library is ~200 Kb.\n  \n## Configuration and Usage\n\n### Basic Configuration\n\nAdd a maven dependency into your project:\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.akarazhev\u003c/groupId\u003e\n    \u003cartifactId\u003emetacfg4j\u003c/artifactId\u003e\n    \u003cversion\u003e2.4\u003c/version\u003e\n\u003c/dependency\u003e\n```\nInstantiate the meta configuration class in your project with the default configuration:\n```java\npublic MetaConfig metaConfig() {\n    return new MetaConfig.Builder().defaultConfig().build();\n}\n```\nIf you have the configured data source, you can use it:\n```java\npublic MetaConfig metaConfig() {\n    return new MetaConfig.Builder().dataSource(getDataSource()).build();\n}\n```\nNOTE: The web-server will not be started, since it requires the related configuration.\n\n### Advanced Configuration\n\nYou can instantiate the meta configuration with the custom configuration:\n\n```java\npublic MetaConfig metaConfig() {\n    // Create the custom data mapping\n    final Map\u003cString, String\u003e dataMapping = new HashMap\u003c\u003e();\n    dataMapping.put(Constants.Mapping.CONFIGS_TABLE, \"CONFIGS\");\n    dataMapping.put(Constants.Mapping.CONFIG_ATTRIBUTES_TABLE, \"CONFIG_ATTRIBUTES\");\n    dataMapping.put(Constants.Mapping.PROPERTIES_TABLE, \"PROPERTIES\");\n    dataMapping.put(Constants.Mapping.PROPERTY_ATTRIBUTES_TABLE, \"PROPERTY_ATTRIBUTES\");\n    // Set a fetch size\n    final Map\u003cString, Object\u003e settings = new HashMap\u003c\u003e();\n    settings.put(FETCH_SIZE, 100);\n    settings.put(DB_DIALECT, POSTGRE);\n    // Create the web server config\n    final Config webServer = new Config.Builder(Server.Settings.CONFIG_NAME,\n        Arrays.asList(\n            new Property.Builder(Server.Settings.HOSTNAME, \"localhost\").build(),\n            new Property.Builder(Server.Settings.API_PATH, \"/api/metacfg/\").build(),\n            new Property.Builder(Constants.Endpoints.ACCEPT_CONFIG, \"accept_config\").build(),\n            new Property.Builder(Constants.Endpoints.CONFIG_NAMES, \"config_names\").build(),\n            new Property.Builder(Constants.Endpoints.CONFIG, \"config\").build(),\n            new Property.Builder(Server.Settings.PORT, 8000).build(),\n            new Property.Builder(Server.Settings.BACKLOG, 0).build(),\n            new Property.Builder(Server.Settings.KEY_STORE_FILE, \"./data/metacfg4j.keystore\").build(),\n            new Property.Builder(Server.Settings.ALIAS, \"alias\").build(),\n            new Property.Builder(Server.Settings.STORE_PASSWORD, \"password\").build(),\n            new Property.Builder(Server.Settings.KEY_PASSWORD, \"password\").build())).build();\n    // Create the meta configuration\n    return new MetaConfig.Builder().webServer(webServer).dataSource(getDataSource()).dataMapping(dataMapping).dbSettings(settings).build();\n}\n```\n\nIt's possible to configure the meta configuration as a client:\n\n```java\npublic MetaConfig metaConfig() {\n    // Create the web client config\n    final Config webClient=new Config.Builder(WebClient.Settings.CONFIG_NAME,\n        Arrays.asList(\n            new Property.Builder(WebClient.Settings.URL, \"https://localhost:8000/api/metacfg\").build(),\n            new Property.Builder(Constants.Endpoints.ACCEPT_CONFIG_ENDPOINT, \"accept_config\").build(),\n            new Property.Builder(Constants.Endpoints.CONFIG_NAMES_ENDPOINT, \"config_names\").build(),\n            new Property.Builder(Constants.Endpoints.CONFIG_ENDPOINT, \"config\").build(),\n            new Property.Builder(WebClient.Settings.ACCEPT_ALL_HOSTS, true).build())).build();\n    // Create the meta configuration\n    return new MetaConfig.Builder().webClient(webClient).build();\n}\n```\nNOTE: you need to call the close method at the end of processing.\n\n### Certificate generation\n\nTo generate a certificate, you need open a command line and and enter:\n```bash\nkeytool -genkeypair -keyalg RSA -alias alias -keypass password -keystore metacfg4j.keystore -storepass password\n```\nIf you have certificate that's signed by CA (Certificate Authority), please use it.\n\n### Settings\n\n#### Web Server settings\n\nThe following settings are available:\n\n * `config-server` - the name of the configuration. \u003cbr/\u003e\n * `hostname` - the server hostname. \u003cbr/\u003e\n * `port` - the server port. \u003cbr/\u003e\n * `backlog` - the server backlog. \u003cbr/\u003e\n * `key-store-file` - the path to a certificate. \u003cbr/\u003e\n * `alias` - the alias of a certificate. \u003cbr/\u003e\n * `store-password` - the store password of a certificate. \u003cbr/\u003e\n * `key-password` - the key password of a certificate. \u003cbr/\u003e\n\n### Java Usage\n\nThe Java API is available:\n\n```java\n/**\n * Provides service methods to create, read, update and delete operations.\n */\npublic interface ConfigService {\n    /**\n     * Updates configuration models.\n     *\n     * @param stream   a stream of configuration models.\n     * @return a stream of updated configuration models.\n     */\n    Stream\u003cConfig\u003e update(final Stream\u003cConfig\u003e stream);\n\n    /**\n     * Returns all configuration names.\n     *\n     * @return a stream of configuration names.\n     */\n    Stream\u003cString\u003e getNames();\n\n    /**\n     * Returns selected configuration names by a config page request.\n     *\n     * @param request a configuration page request that has parameters: page, size, ascending.\n     * @return a page with configuration names.\n     */\n    PageResponse getNames(final PageRequest request);\n\n    /**\n     * Returns all configuration models.\n     *\n     * @return a stream of configurations models.\n     */\n    Stream\u003cConfig\u003e get();\n\n    /**\n     * Returns configuration models by names.\n     *\n     * @param stream a stream of names.\n     * @return a stream of configurations models.\n     */\n    Stream\u003cConfig\u003e get(final Stream\u003cString\u003e stream);\n\n    /**\n     * Removes configuration models by names.\n     *\n     * @param stream a stream of names.\n     * @return a number of deleted models.\n     */\n    int remove(final Stream\u003cString\u003e stream);\n\n    /**\n     * Accepts a configuration model by names.\n     *\n     * @param stream a stream of names.\n     */\n    void accept(final Stream\u003cString\u003e stream);\n\n    /**\n     * Adds a consumer to provide an action.\n     *\n     * @param consumer an implementation of the consumer.\n     */\n    void addConsumer(final Consumer\u003cConfig\u003e consumer);\n}\n```\n\n### REST Usage\n\nThe REST API is available via the `https` protocol:\n\n**`POST api/metacfg/accept_config/ARRAY_OF_CONFIG_NAMES_IN_BASE64`** - calls the logic for configs. \u003cbr/\u003e\n**`GET api/metacfg/config_names`** - returns a list of config names. \u003cbr/\u003e\n**`GET api/metacfg/config_names?page_request=ARRAY_OF_CONFIG_NAMES_IN_BASE64`** - returns a page response based on a\npage request that has a list of config names and pagination settings. \u003cbr/\u003e\n**`GET api/metacfg/config?names=ARRAY_OF_CONFIG_NAMES_IN_BASE64`** - returns a list of configs. \u003cbr/\u003e\n**`PUT api/metacfg/config`** - creates or updates a config, request body must have json with array of objects. \u003cbr/\u003e\n**`DELETE api/metacfg/config?names=ARRAY_OF_CONFIG_NAMES_IN_BASE64`** - removes a list of configs. \u003cbr/\u003e\n\n`ARRAY_OF_CONFIG_NAMES_IN_BASE64` means that every request param should be in the json format (with array of strings\ninside)\nencoded to `base64` format.\n\nFor example:\n\n`[\"Name1\",\"Name2\"]` encoded to the `base64` format will be `WyJOYW1lMSIsIk5hbWUyIl0=`\n\n**`GET api/metacfg/config?names=WyJOYW1lMSIsIk5hbWUyIl0=`** - returns a list of configs with names Name1, Name2.\n\n### JSON examples\n\nAn array with a config and property:\n\n```json\n[\n {\n  \"name\": \"New Config\",\n  \"description\": \"Description\",\n  \"attributes\": {\n   \"key_1\": \"value-1\",\n   \"key_4\": \"value_4\"\n  },\n  \"properties\": [\n   {\n    \"name\": \"Value\",\n    \"caption\": \"Caption\",\n    \"description\": \"Description\",\n    \"attributes\": {\n     \"key_1\": \"value-1\",\n     \"key_4\": \"value_4\"\n    },\n    \"type\": \"LONG\",\n    \"value\": \"1000\",\n    \"properties\": []\n   }\n  ]\n }\n]\n```\n\nConfig new a property:\n\n```json\n{\n \"name\": \"New Config\",\n \"attributes\": {\n  \"key_3\": \"value_3\",\n  \"key_2\": \"value_2\",\n  \"key_1\": \"value_1\"\n },\n \"properties\": [\n  {\n   \"name\": \"Property\",\n   \"caption\": \"Caption\",\n   \"description\": \"Description\",\n   \"attributes\": {\n    \"key\": \"value\"\n   },\n   \"type\": \"STRING\",\n   \"value\": \"Value\",\n   \"properties\": [\n    {\n     \"name\": \"Property-1\",\n     \"attributes\": {\n      \"key_1\": \"value_1\"\n     },\n     \"type\": \"STRING\",\n     \"value\": \"Value-1\",\n     \"properties\": []\n    },\n    {\n     \"name\": \"Property-2\",\n     \"attributes\": {\n      \"key_2\": \"value_2\"\n     },\n     \"type\": \"STRING\",\n     \"value\": \"Value-2\",\n     \"properties\": []\n    },\n    {\n     \"name\": \"Property-3\",\n     \"attributes\": {\n      \"key_3\": \"value_3\"\n     },\n     \"type\": \"STRING\",\n     \"value\": \"Value-3\",\n     \"properties\": []\n    }\n   ]\n  }\n ]\n}\n```\n\n## Build Requirements\n\n\u0026#8658; Java 8+ \u003cbr/\u003e\n\u0026#8658; Maven 3.6+ \u003cbr/\u003e\n \n## Contribution\n \nContribution is always welcome. Please perform changes and submit pull requests into this branch.  \nPlease set your editor to use spaces instead of tabs, and adhere to the apparent style of the code you are editing.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakarazhev%2Fmetacfg4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakarazhev%2Fmetacfg4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakarazhev%2Fmetacfg4j/lists"}