{"action":"opened","number":71,"pull_request":{"url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/pulls/71","id":237608274,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM3NjA4Mjc0","html_url":"https://github.com/folio-org/mod-kb-ebsco-java/pull/71","diff_url":"https://github.com/folio-org/mod-kb-ebsco-java/pull/71.diff","patch_url":"https://github.com/folio-org/mod-kb-ebsco-java/pull/71.patch","issue_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/issues/71","number":71,"state":"open","locked":false,"title":"Modkbekbj 106 add spring di","user":{"login":"andrii-paias","id":43238569,"node_id":"MDQ6VXNlcjQzMjM4NTY5","avatar_url":"https://avatars0.githubusercontent.com/u/43238569?v=4","gravatar_id":"","url":"https://api.github.com/users/andrii-paias","html_url":"https://github.com/andrii-paias","followers_url":"https://api.github.com/users/andrii-paias/followers","following_url":"https://api.github.com/users/andrii-paias/following{/other_user}","gists_url":"https://api.github.com/users/andrii-paias/gists{/gist_id}","starred_url":"https://api.github.com/users/andrii-paias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrii-paias/subscriptions","organizations_url":"https://api.github.com/users/andrii-paias/orgs","repos_url":"https://api.github.com/users/andrii-paias/repos","events_url":"https://api.github.com/users/andrii-paias/events{/privacy}","received_events_url":"https://api.github.com/users/andrii-paias/received_events","type":"User","site_admin":false},"body":"## Purpose\r\nUse Spring for dependency injection instead of creating objects when they are used\r\n\r\n## Approach\r\nDependency injection with spring is implemented in the following way:\r\nSpring context is created in InitAPIImpl and added to Vertx context.\r\nSpring context uses configuration ApplicationConfig, this configuration\r\nuses @ComponentScan annotation to find and instantiate classes annotated\r\nwith @Component. It also declares PropertySourcesPlaceholderConfigurer that reads\r\napplication.properties file and uses its properties to populate beans.\r\nSpring doesn't control api classes(e.g. EholdingsPackagesImpl) so beans\r\nfrom context are autowired to api classes by using SpringContextUtil.autowireDependencies\r\nmethod. This method gets Spring context from Vertx context and uses it\r\nto populate api class.\r\n\r\n## Learning\r\nThere are several libraries that integrate Vertx with Spring:\r\nhttps://github.com/amoAHCP/spring-vertx-ext\r\nhttps://github.com/rworsnop/vertx-beans\r\nhttps://github.com/juanavelez/vertx-spring-verticle-factory\r\n\r\nMost of the libraries integrate with Spring context by requiring user to add a custom verticle, since we already use RestVerticle and we can't replace it, we can't use those libraries.\r\n\r\nI see two approaches for adding Spring context to Vertx:\r\n1)Use Vertx context to store Spring context. With this approach each verticle has a separate Spring context, this creates some memory overhead because context is constructed multiple times, but it preserves the guarantee of thread-safety, because verticles don't share objects.\r\nI used this approach. Also we currently only create 1 verticle per module (if module is deployed through fat jar, it will always default to having 1 verticle, and I don't see a way to customize amout of verticles when running jar file)\r\n2) Second approach is to share Spring context by storing it in a static field (or in Vertx LocalMap), that way all verticles will have access to the same objects. This will allow to, for example, share cache between verticles. \r\nBut Vertx discourages sharing of mutable objects because it removes thread safety guarantees and requires blocking of event loop threads.","created_at":"2018-12-11T09:38:43Z","updated_at":"2018-12-11T09:38:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/pulls/71/commits","review_comments_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/pulls/71/comments","review_comment_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/issues/71/comments","statuses_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/statuses/f48f574f2c322f6ccf9be98bbdabcef4dbf54847","head":{"label":"folio-org:MODKBEKBJ-106-add-spring-DI","ref":"MODKBEKBJ-106-add-spring-DI","sha":"f48f574f2c322f6ccf9be98bbdabcef4dbf54847","user":{"login":"folio-org","id":16495055,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2NDk1MDU1","avatar_url":"https://avatars2.githubusercontent.com/u/16495055?v=4","gravatar_id":"","url":"https://api.github.com/users/folio-org","html_url":"https://github.com/folio-org","followers_url":"https://api.github.com/users/folio-org/followers","following_url":"https://api.github.com/users/folio-org/following{/other_user}","gists_url":"https://api.github.com/users/folio-org/gists{/gist_id}","starred_url":"https://api.github.com/users/folio-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/folio-org/subscriptions","organizations_url":"https://api.github.com/users/folio-org/orgs","repos_url":"https://api.github.com/users/folio-org/repos","events_url":"https://api.github.com/users/folio-org/events{/privacy}","received_events_url":"https://api.github.com/users/folio-org/received_events","type":"Organization","site_admin":false},"repo":{"id":151560298,"node_id":"MDEwOlJlcG9zaXRvcnkxNTE1NjAyOTg=","name":"mod-kb-ebsco-java","full_name":"folio-org/mod-kb-ebsco-java","private":false,"owner":{"login":"folio-org","id":16495055,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2NDk1MDU1","avatar_url":"https://avatars2.githubusercontent.com/u/16495055?v=4","gravatar_id":"","url":"https://api.github.com/users/folio-org","html_url":"https://github.com/folio-org","followers_url":"https://api.github.com/users/folio-org/followers","following_url":"https://api.github.com/users/folio-org/following{/other_user}","gists_url":"https://api.github.com/users/folio-org/gists{/gist_id}","starred_url":"https://api.github.com/users/folio-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/folio-org/subscriptions","organizations_url":"https://api.github.com/users/folio-org/orgs","repos_url":"https://api.github.com/users/folio-org/repos","events_url":"https://api.github.com/users/folio-org/events{/privacy}","received_events_url":"https://api.github.com/users/folio-org/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/folio-org/mod-kb-ebsco-java","description":"Broker communication with the EBSCO knowledge base (Java)","fork":false,"url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java","forks_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/forks","keys_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/teams","hooks_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/hooks","issue_events_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/issues/events{/number}","events_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/events","assignees_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/assignees{/user}","branches_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/branches{/branch}","tags_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/tags","blobs_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/statuses/{sha}","languages_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/languages","stargazers_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/stargazers","contributors_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/contributors","subscribers_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/subscribers","subscription_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/subscription","commits_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/contents/{+path}","compare_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/merges","archive_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/downloads","issues_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/issues{/number}","pulls_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/pulls{/number}","milestones_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/milestones{/number}","notifications_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/labels{/name}","releases_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/releases{/id}","deployments_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/deployments","created_at":"2018-10-04T11:20:44Z","updated_at":"2018-12-10T17:30:28Z","pushed_at":"2018-12-10T17:30:26Z","git_url":"git://github.com/folio-org/mod-kb-ebsco-java.git","ssh_url":"git@github.com:folio-org/mod-kb-ebsco-java.git","clone_url":"https://github.com/folio-org/mod-kb-ebsco-java.git","svn_url":"https://github.com/folio-org/mod-kb-ebsco-java","homepage":null,"size":770,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":1,"open_issues":2,"watchers":1,"default_branch":"master"}},"base":{"label":"folio-org:MODKBEKBJ-114-use-vertx-shared-data","ref":"MODKBEKBJ-114-use-vertx-shared-data","sha":"78552654c5e06a21cc032255d330bbc37f0313f9","user":{"login":"folio-org","id":16495055,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2NDk1MDU1","avatar_url":"https://avatars2.githubusercontent.com/u/16495055?v=4","gravatar_id":"","url":"https://api.github.com/users/folio-org","html_url":"https://github.com/folio-org","followers_url":"https://api.github.com/users/folio-org/followers","following_url":"https://api.github.com/users/folio-org/following{/other_user}","gists_url":"https://api.github.com/users/folio-org/gists{/gist_id}","starred_url":"https://api.github.com/users/folio-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/folio-org/subscriptions","organizations_url":"https://api.github.com/users/folio-org/orgs","repos_url":"https://api.github.com/users/folio-org/repos","events_url":"https://api.github.com/users/folio-org/events{/privacy}","received_events_url":"https://api.github.com/users/folio-org/received_events","type":"Organization","site_admin":false},"repo":{"id":151560298,"node_id":"MDEwOlJlcG9zaXRvcnkxNTE1NjAyOTg=","name":"mod-kb-ebsco-java","full_name":"folio-org/mod-kb-ebsco-java","private":false,"owner":{"login":"folio-org","id":16495055,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2NDk1MDU1","avatar_url":"https://avatars2.githubusercontent.com/u/16495055?v=4","gravatar_id":"","url":"https://api.github.com/users/folio-org","html_url":"https://github.com/folio-org","followers_url":"https://api.github.com/users/folio-org/followers","following_url":"https://api.github.com/users/folio-org/following{/other_user}","gists_url":"https://api.github.com/users/folio-org/gists{/gist_id}","starred_url":"https://api.github.com/users/folio-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/folio-org/subscriptions","organizations_url":"https://api.github.com/users/folio-org/orgs","repos_url":"https://api.github.com/users/folio-org/repos","events_url":"https://api.github.com/users/folio-org/events{/privacy}","received_events_url":"https://api.github.com/users/folio-org/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/folio-org/mod-kb-ebsco-java","description":"Broker communication with the EBSCO knowledge base (Java)","fork":false,"url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java","forks_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/forks","keys_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/teams","hooks_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/hooks","issue_events_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/issues/events{/number}","events_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/events","assignees_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/assignees{/user}","branches_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/branches{/branch}","tags_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/tags","blobs_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/statuses/{sha}","languages_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/languages","stargazers_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/stargazers","contributors_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/contributors","subscribers_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/subscribers","subscription_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/subscription","commits_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/contents/{+path}","compare_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/merges","archive_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/downloads","issues_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/issues{/number}","pulls_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/pulls{/number}","milestones_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/milestones{/number}","notifications_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/labels{/name}","releases_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/releases{/id}","deployments_url":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/deployments","created_at":"2018-10-04T11:20:44Z","updated_at":"2018-12-10T17:30:28Z","pushed_at":"2018-12-10T17:30:26Z","git_url":"git://github.com/folio-org/mod-kb-ebsco-java.git","ssh_url":"git@github.com:folio-org/mod-kb-ebsco-java.git","clone_url":"https://github.com/folio-org/mod-kb-ebsco-java.git","svn_url":"https://github.com/folio-org/mod-kb-ebsco-java","homepage":null,"size":770,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":1,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/pulls/71"},"html":{"href":"https://github.com/folio-org/mod-kb-ebsco-java/pull/71"},"issue":{"href":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/issues/71"},"comments":{"href":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/issues/71/comments"},"review_comments":{"href":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/pulls/71/comments"},"review_comment":{"href":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/pulls/71/commits"},"statuses":{"href":"https://api.github.com/repos/folio-org/mod-kb-ebsco-java/statuses/f48f574f2c322f6ccf9be98bbdabcef4dbf54847"}},"author_association":"CONTRIBUTOR","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":false,"commits":2,"additions":460,"deletions":329,"changed_files":42}}
{"actor":{"display_login":"andrii-paias"}}