{"action":"created","comment":{"url":"https://api.github.com/repos/linagora/james-project/pulls/comments/194675668","pull_request_review_id":127889293,"id":194675668,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NDY3NTY2OA==","diff_hunk":"@@ -18,22 +18,75 @@\n  ****************************************************************/\n package org.apache.james.modules.mailbox;\n \n+import java.util.Optional;\n+\n import javax.inject.Inject;\n \n+import org.apache.commons.configuration.HierarchicalConfiguration;\n import org.apache.james.mailbox.MailboxListener;\n \n+import com.google.common.base.Preconditions;\n import com.google.inject.Injector;\n \n public class MailboxListenerFactory {\n \n+    public static class MailboxListenerBuilder {\n+        private final Injector injector;\n+        private Optional<Class<MailboxListener>> clazz;\n+        private Optional<MailboxListener.ExecutionMode> executionMode;\n+        private Optional<HierarchicalConfiguration> configuration;\n+\n+        public MailboxListenerBuilder(Injector injector) {\n+            this.injector = injector;\n+            this.clazz = Optional.empty();\n+            this.executionMode = Optional.empty();\n+            this.configuration = Optional.empty();\n+        }\n+\n+        public MailboxListenerBuilder withExecutionMode(MailboxListener.ExecutionMode executionMode) {\n+            this.executionMode = Optional.of(executionMode);\n+            return this;\n+        }\n+\n+        public MailboxListenerBuilder withConfiguration(HierarchicalConfiguration configuration) {\n+            this.configuration = Optional.of(configuration);\n+            return this;\n+        }\n+\n+        public MailboxListenerBuilder withExecutionMode(Optional<MailboxListener.ExecutionMode> executionMode) {\n+            executionMode.ifPresent(this::withExecutionMode);\n+            return this;\n+        }\n+\n+        public MailboxListenerBuilder withConfiguration(Optional<HierarchicalConfiguration> configuration) {\n+            configuration.ifPresent(this::withConfiguration);\n+            return this;\n+        }\n+\n+        public MailboxListenerBuilder clazz(Class<MailboxListener> clazz) {\n+            this.clazz = Optional.of(clazz);\n+            return this;\n+        }\n+\n+        public MailboxListener build() {\n+            Preconditions.checkState(clazz.isPresent(), \"'clazz' is mandatory\");\n+            return injector.createChildInjector(\n+                binder -> binder.bind(MailboxListener.ExecutionMode.class)\n+                    .toInstance(executionMode.orElse(MailboxListener.ExecutionMode.SYNCHRONOUS)),\n+                binder -> binder.bind(HierarchicalConfiguration.class)\n+                    .toInstance(configuration.orElse(new HierarchicalConfiguration())))\n+                .getInstance(clazz.get());","path":"server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/MailboxListenerFactory.java","position":61,"original_position":61,"commit_id":"3d1d481508454358b52d8336080d6fee8fa7a706","original_commit_id":"b5338a87921a472824a2605dbd8648b1ae0331fd","user":{"login":"chibenwa","id":6928740,"node_id":"MDQ6VXNlcjY5Mjg3NDA=","avatar_url":"https://avatars1.githubusercontent.com/u/6928740?v=4","gravatar_id":"","url":"https://api.github.com/users/chibenwa","html_url":"https://github.com/chibenwa","followers_url":"https://api.github.com/users/chibenwa/followers","following_url":"https://api.github.com/users/chibenwa/following{/other_user}","gists_url":"https://api.github.com/users/chibenwa/gists{/gist_id}","starred_url":"https://api.github.com/users/chibenwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chibenwa/subscriptions","organizations_url":"https://api.github.com/users/chibenwa/orgs","repos_url":"https://api.github.com/users/chibenwa/repos","events_url":"https://api.github.com/users/chibenwa/events{/privacy}","received_events_url":"https://api.github.com/users/chibenwa/received_events","type":"User","site_admin":false},"body":"Well, you can not call the contructor of MailboxListener as : \r\n - There is a hierarchy which do not occurs in `RealPaymentFactory` exemple\r\n - We want a context specific for **each** listener, not global for the application.\r\n\r\nI'm not convinced at all, and do belive we can not apply this pattern.","created_at":"2018-06-12T09:40:33Z","updated_at":"2018-06-12T09:40:33Z","html_url":"https://github.com/linagora/james-project/pull/1462#discussion_r194675668","pull_request_url":"https://api.github.com/repos/linagora/james-project/pulls/1462","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/linagora/james-project/pulls/comments/194675668"},"html":{"href":"https://github.com/linagora/james-project/pull/1462#discussion_r194675668"},"pull_request":{"href":"https://api.github.com/repos/linagora/james-project/pulls/1462"}},"in_reply_to_id":194324244},"pull_request":{"url":"https://api.github.com/repos/linagora/james-project/pulls/1462","id":193261313,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkzMjYxMzEz","html_url":"https://github.com/linagora/james-project/pull/1462","diff_url":"https://github.com/linagora/james-project/pull/1462.diff","patch_url":"https://github.com/linagora/james-project/pull/1462.patch","issue_url":"https://api.github.com/repos/linagora/james-project/issues/1462","number":1462,"state":"closed","locked":false,"title":"JAMES-2141 Allow to configure custom MailboxListener execution mode","user":{"login":"chibenwa","id":6928740,"node_id":"MDQ6VXNlcjY5Mjg3NDA=","avatar_url":"https://avatars1.githubusercontent.com/u/6928740?v=4","gravatar_id":"","url":"https://api.github.com/users/chibenwa","html_url":"https://github.com/chibenwa","followers_url":"https://api.github.com/users/chibenwa/followers","following_url":"https://api.github.com/users/chibenwa/following{/other_user}","gists_url":"https://api.github.com/users/chibenwa/gists{/gist_id}","starred_url":"https://api.github.com/users/chibenwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chibenwa/subscriptions","organizations_url":"https://api.github.com/users/chibenwa/orgs","repos_url":"https://api.github.com/users/chibenwa/repos","events_url":"https://api.github.com/users/chibenwa/events{/privacy}","received_events_url":"https://api.github.com/users/chibenwa/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-06-07T09:42:32Z","updated_at":"2018-06-12T09:40:33Z","closed_at":"2018-06-12T00:06:41Z","merged_at":null,"merge_commit_sha":"eb8762aa5a9b5bff034ad768dab9efc041b50388","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":236896055,"node_id":"MDU6TGFiZWwyMzY4OTYwNTU=","url":"https://api.github.com/repos/linagora/james-project/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"milestone":{"url":"https://api.github.com/repos/linagora/james-project/milestones/4","html_url":"https://github.com/linagora/james-project/milestone/4","labels_url":"https://api.github.com/repos/linagora/james-project/milestones/4/labels","id":3401301,"node_id":"MDk6TWlsZXN0b25lMzQwMTMwMQ==","number":4,"title":"Sprint38","description":"","creator":{"login":"chibenwa","id":6928740,"node_id":"MDQ6VXNlcjY5Mjg3NDA=","avatar_url":"https://avatars1.githubusercontent.com/u/6928740?v=4","gravatar_id":"","url":"https://api.github.com/users/chibenwa","html_url":"https://github.com/chibenwa","followers_url":"https://api.github.com/users/chibenwa/followers","following_url":"https://api.github.com/users/chibenwa/following{/other_user}","gists_url":"https://api.github.com/users/chibenwa/gists{/gist_id}","starred_url":"https://api.github.com/users/chibenwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chibenwa/subscriptions","organizations_url":"https://api.github.com/users/chibenwa/orgs","repos_url":"https://api.github.com/users/chibenwa/repos","events_url":"https://api.github.com/users/chibenwa/events{/privacy}","received_events_url":"https://api.github.com/users/chibenwa/received_events","type":"User","site_admin":false},"open_issues":8,"closed_issues":12,"state":"open","created_at":"2018-06-05T07:49:07Z","updated_at":"2018-06-12T08:21:44Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/linagora/james-project/pulls/1462/commits","review_comments_url":"https://api.github.com/repos/linagora/james-project/pulls/1462/comments","review_comment_url":"https://api.github.com/repos/linagora/james-project/pulls/comments{/number}","comments_url":"https://api.github.com/repos/linagora/james-project/issues/1462/comments","statuses_url":"https://api.github.com/repos/linagora/james-project/statuses/3d1d481508454358b52d8336080d6fee8fa7a706","head":{"label":"chibenwa:JAMES-2414-2","ref":"JAMES-2414-2","sha":"3d1d481508454358b52d8336080d6fee8fa7a706","user":{"login":"chibenwa","id":6928740,"node_id":"MDQ6VXNlcjY5Mjg3NDA=","avatar_url":"https://avatars1.githubusercontent.com/u/6928740?v=4","gravatar_id":"","url":"https://api.github.com/users/chibenwa","html_url":"https://github.com/chibenwa","followers_url":"https://api.github.com/users/chibenwa/followers","following_url":"https://api.github.com/users/chibenwa/following{/other_user}","gists_url":"https://api.github.com/users/chibenwa/gists{/gist_id}","starred_url":"https://api.github.com/users/chibenwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chibenwa/subscriptions","organizations_url":"https://api.github.com/users/chibenwa/orgs","repos_url":"https://api.github.com/users/chibenwa/repos","events_url":"https://api.github.com/users/chibenwa/events{/privacy}","received_events_url":"https://api.github.com/users/chibenwa/received_events","type":"User","site_admin":false},"repo":{"id":42459504,"node_id":"MDEwOlJlcG9zaXRvcnk0MjQ1OTUwNA==","name":"james-project","full_name":"chibenwa/james-project","owner":{"login":"chibenwa","id":6928740,"node_id":"MDQ6VXNlcjY5Mjg3NDA=","avatar_url":"https://avatars1.githubusercontent.com/u/6928740?v=4","gravatar_id":"","url":"https://api.github.com/users/chibenwa","html_url":"https://github.com/chibenwa","followers_url":"https://api.github.com/users/chibenwa/followers","following_url":"https://api.github.com/users/chibenwa/following{/other_user}","gists_url":"https://api.github.com/users/chibenwa/gists{/gist_id}","starred_url":"https://api.github.com/users/chibenwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chibenwa/subscriptions","organizations_url":"https://api.github.com/users/chibenwa/orgs","repos_url":"https://api.github.com/users/chibenwa/repos","events_url":"https://api.github.com/users/chibenwa/events{/privacy}","received_events_url":"https://api.github.com/users/chibenwa/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chibenwa/james-project","description":"Mirror of Apache James Project","fork":true,"url":"https://api.github.com/repos/chibenwa/james-project","forks_url":"https://api.github.com/repos/chibenwa/james-project/forks","keys_url":"https://api.github.com/repos/chibenwa/james-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chibenwa/james-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chibenwa/james-project/teams","hooks_url":"https://api.github.com/repos/chibenwa/james-project/hooks","issue_events_url":"https://api.github.com/repos/chibenwa/james-project/issues/events{/number}","events_url":"https://api.github.com/repos/chibenwa/james-project/events","assignees_url":"https://api.github.com/repos/chibenwa/james-project/assignees{/user}","branches_url":"https://api.github.com/repos/chibenwa/james-project/branches{/branch}","tags_url":"https://api.github.com/repos/chibenwa/james-project/tags","blobs_url":"https://api.github.com/repos/chibenwa/james-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chibenwa/james-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chibenwa/james-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/chibenwa/james-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chibenwa/james-project/statuses/{sha}","languages_url":"https://api.github.com/repos/chibenwa/james-project/languages","stargazers_url":"https://api.github.com/repos/chibenwa/james-project/stargazers","contributors_url":"https://api.github.com/repos/chibenwa/james-project/contributors","subscribers_url":"https://api.github.com/repos/chibenwa/james-project/subscribers","subscription_url":"https://api.github.com/repos/chibenwa/james-project/subscription","commits_url":"https://api.github.com/repos/chibenwa/james-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/chibenwa/james-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/chibenwa/james-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/chibenwa/james-project/issues/comments{/number}","contents_url":"https://api.github.com/repos/chibenwa/james-project/contents/{+path}","compare_url":"https://api.github.com/repos/chibenwa/james-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chibenwa/james-project/merges","archive_url":"https://api.github.com/repos/chibenwa/james-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chibenwa/james-project/downloads","issues_url":"https://api.github.com/repos/chibenwa/james-project/issues{/number}","pulls_url":"https://api.github.com/repos/chibenwa/james-project/pulls{/number}","milestones_url":"https://api.github.com/repos/chibenwa/james-project/milestones{/number}","notifications_url":"https://api.github.com/repos/chibenwa/james-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chibenwa/james-project/labels{/name}","releases_url":"https://api.github.com/repos/chibenwa/james-project/releases{/id}","deployments_url":"https://api.github.com/repos/chibenwa/james-project/deployments","created_at":"2015-09-14T15:57:25Z","updated_at":"2017-10-03T11:59:27Z","pushed_at":"2018-06-12T09:01:37Z","git_url":"git://github.com/chibenwa/james-project.git","ssh_url":"git@github.com:chibenwa/james-project.git","clone_url":"https://github.com/chibenwa/james-project.git","svn_url":"https://github.com/chibenwa/james-project","homepage":null,"size":43065,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":2,"open_issues":2,"watchers":0,"default_branch":"trunk"}},"base":{"label":"linagora:master","ref":"master","sha":"b9531d6f54b9e8d88c9e466c785aca72c21ce4a1","user":{"login":"linagora","id":1230365,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyMzAzNjU=","avatar_url":"https://avatars3.githubusercontent.com/u/1230365?v=4","gravatar_id":"","url":"https://api.github.com/users/linagora","html_url":"https://github.com/linagora","followers_url":"https://api.github.com/users/linagora/followers","following_url":"https://api.github.com/users/linagora/following{/other_user}","gists_url":"https://api.github.com/users/linagora/gists{/gist_id}","starred_url":"https://api.github.com/users/linagora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linagora/subscriptions","organizations_url":"https://api.github.com/users/linagora/orgs","repos_url":"https://api.github.com/users/linagora/repos","events_url":"https://api.github.com/users/linagora/events{/privacy}","received_events_url":"https://api.github.com/users/linagora/received_events","type":"Organization","site_admin":false},"repo":{"id":39182136,"node_id":"MDEwOlJlcG9zaXRvcnkzOTE4MjEzNg==","name":"james-project","full_name":"linagora/james-project","owner":{"login":"linagora","id":1230365,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyMzAzNjU=","avatar_url":"https://avatars3.githubusercontent.com/u/1230365?v=4","gravatar_id":"","url":"https://api.github.com/users/linagora","html_url":"https://github.com/linagora","followers_url":"https://api.github.com/users/linagora/followers","following_url":"https://api.github.com/users/linagora/following{/other_user}","gists_url":"https://api.github.com/users/linagora/gists{/gist_id}","starred_url":"https://api.github.com/users/linagora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linagora/subscriptions","organizations_url":"https://api.github.com/users/linagora/orgs","repos_url":"https://api.github.com/users/linagora/repos","events_url":"https://api.github.com/users/linagora/events{/privacy}","received_events_url":"https://api.github.com/users/linagora/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/linagora/james-project","description":"Mirror of Apache James Project","fork":true,"url":"https://api.github.com/repos/linagora/james-project","forks_url":"https://api.github.com/repos/linagora/james-project/forks","keys_url":"https://api.github.com/repos/linagora/james-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/linagora/james-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/linagora/james-project/teams","hooks_url":"https://api.github.com/repos/linagora/james-project/hooks","issue_events_url":"https://api.github.com/repos/linagora/james-project/issues/events{/number}","events_url":"https://api.github.com/repos/linagora/james-project/events","assignees_url":"https://api.github.com/repos/linagora/james-project/assignees{/user}","branches_url":"https://api.github.com/repos/linagora/james-project/branches{/branch}","tags_url":"https://api.github.com/repos/linagora/james-project/tags","blobs_url":"https://api.github.com/repos/linagora/james-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/linagora/james-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/linagora/james-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/linagora/james-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/linagora/james-project/statuses/{sha}","languages_url":"https://api.github.com/repos/linagora/james-project/languages","stargazers_url":"https://api.github.com/repos/linagora/james-project/stargazers","contributors_url":"https://api.github.com/repos/linagora/james-project/contributors","subscribers_url":"https://api.github.com/repos/linagora/james-project/subscribers","subscription_url":"https://api.github.com/repos/linagora/james-project/subscription","commits_url":"https://api.github.com/repos/linagora/james-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/linagora/james-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/linagora/james-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/linagora/james-project/issues/comments{/number}","contents_url":"https://api.github.com/repos/linagora/james-project/contents/{+path}","compare_url":"https://api.github.com/repos/linagora/james-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/linagora/james-project/merges","archive_url":"https://api.github.com/repos/linagora/james-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/linagora/james-project/downloads","issues_url":"https://api.github.com/repos/linagora/james-project/issues{/number}","pulls_url":"https://api.github.com/repos/linagora/james-project/pulls{/number}","milestones_url":"https://api.github.com/repos/linagora/james-project/milestones{/number}","notifications_url":"https://api.github.com/repos/linagora/james-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/linagora/james-project/labels{/name}","releases_url":"https://api.github.com/repos/linagora/james-project/releases{/id}","deployments_url":"https://api.github.com/repos/linagora/james-project/deployments","created_at":"2015-07-16T07:04:59Z","updated_at":"2018-06-12T00:03:52Z","pushed_at":"2018-06-12T09:39:47Z","git_url":"git://github.com/linagora/james-project.git","ssh_url":"git@github.com:linagora/james-project.git","clone_url":"https://github.com/linagora/james-project.git","svn_url":"https://github.com/linagora/james-project","homepage":null,"size":33462,"stargazers_count":21,"watchers_count":21,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":25,"mirror_url":null,"archived":false,"open_issues_count":69,"license":null,"forks":25,"open_issues":69,"watchers":21,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/linagora/james-project/pulls/1462"},"html":{"href":"https://github.com/linagora/james-project/pull/1462"},"issue":{"href":"https://api.github.com/repos/linagora/james-project/issues/1462"},"comments":{"href":"https://api.github.com/repos/linagora/james-project/issues/1462/comments"},"review_comments":{"href":"https://api.github.com/repos/linagora/james-project/pulls/1462/comments"},"review_comment":{"href":"https://api.github.com/repos/linagora/james-project/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/linagora/james-project/pulls/1462/commits"},"statuses":{"href":"https://api.github.com/repos/linagora/james-project/statuses/3d1d481508454358b52d8336080d6fee8fa7a706"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"chibenwa"}}