{"action":"created","comment":{"url":"https://api.github.com/repos/wildfly/wildfly-core/pulls/comments/25961594","id":25961594,"diff_hunk":"@@ -41,7 +42,15 @@\n \n     public WildFlyLogContextSelectorImpl() {\n         counter = new AtomicInteger(0);\n-        contextSelector = new ClassLoaderLogContextSelector(true);\n+        // Use the current log context as the default, not LogContext.DEFAULT_LOG_CONTEXT_SELECTOR\n+        // This allows embedding use cases to control the log context\n+        final LogContext defaultLogContext = LogContext.getLogContext();\n+        contextSelector = new ClassLoaderLogContextSelector(new LogContextSelector() {\n+            @Override\n+            public LogContext getLogContext() {\n+                return defaultLogContext;\n+            }\n+        }, true);","path":"logging/src/main/java/org/jboss/as/logging/logmanager/WildFlyLogContextSelectorImpl.java","position":21,"original_position":21,"commit_id":"7fd8fef99de508fc5d77ddf335476400c2fdd8d9","original_commit_id":"7fd8fef99de508fc5d77ddf335476400c2fdd8d9","user":{"login":"jamezp","id":420065,"avatar_url":"https://avatars.githubusercontent.com/u/420065?v=3","gravatar_id":"","url":"https://api.github.com/users/jamezp","html_url":"https://github.com/jamezp","followers_url":"https://api.github.com/users/jamezp/followers","following_url":"https://api.github.com/users/jamezp/following{/other_user}","gists_url":"https://api.github.com/users/jamezp/gists{/gist_id}","starred_url":"https://api.github.com/users/jamezp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamezp/subscriptions","organizations_url":"https://api.github.com/users/jamezp/orgs","repos_url":"https://api.github.com/users/jamezp/repos","events_url":"https://api.github.com/users/jamezp/events{/privacy}","received_events_url":"https://api.github.com/users/jamezp/received_events","type":"User","site_admin":false},"body":"Is there a reason to wrap this in a new `LogContextSelector` rather than just using `new ClassLoaderLogContextSelector(defaultLogContext, true)`? It doesn't really matter all that much really.","created_at":"2015-03-06T17:36:59Z","updated_at":"2015-03-06T17:36:59Z","html_url":"https://github.com/wildfly/wildfly-core/pull/545#discussion_r25961594","pull_request_url":"https://api.github.com/repos/wildfly/wildfly-core/pulls/545","_links":{"self":{"href":"https://api.github.com/repos/wildfly/wildfly-core/pulls/comments/25961594"},"html":{"href":"https://github.com/wildfly/wildfly-core/pull/545#discussion_r25961594"},"pull_request":{"href":"https://api.github.com/repos/wildfly/wildfly-core/pulls/545"}}},"pull_request":{"url":"https://api.github.com/repos/wildfly/wildfly-core/pulls/545","id":30661987,"html_url":"https://github.com/wildfly/wildfly-core/pull/545","diff_url":"https://github.com/wildfly/wildfly-core/pull/545.diff","patch_url":"https://github.com/wildfly/wildfly-core/pull/545.patch","issue_url":"https://api.github.com/repos/wildfly/wildfly-core/issues/545","number":545,"state":"open","locked":false,"title":"[WFCORE-584] Support embedding a standalone server in a CLI process","user":{"login":"bstansberry","id":299242,"avatar_url":"https://avatars.githubusercontent.com/u/299242?v=3","gravatar_id":"","url":"https://api.github.com/users/bstansberry","html_url":"https://github.com/bstansberry","followers_url":"https://api.github.com/users/bstansberry/followers","following_url":"https://api.github.com/users/bstansberry/following{/other_user}","gists_url":"https://api.github.com/users/bstansberry/gists{/gist_id}","starred_url":"https://api.github.com/users/bstansberry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bstansberry/subscriptions","organizations_url":"https://api.github.com/users/bstansberry/orgs","repos_url":"https://api.github.com/users/bstansberry/repos","events_url":"https://api.github.com/users/bstansberry/events{/privacy}","received_events_url":"https://api.github.com/users/bstansberry/received_events","type":"User","site_admin":false},"body":"This is a follow-up to #479, with quite a lot of tests added, issues revealed by those tests fixed, and some changes to the embedded module. I feel it's quite solid now.\r\n\r\nSee https://developer.jboss.org/docs/DOC-53050 for background.\r\n\r\nA couple significant points that are different from what I had before:\r\n\r\n1) I am treating the \"embedded\" module I've added to core as being there to support this usage, not as general purpose embedding solution. Therefore, it uses a different maven GAV from the embedded module that's in full, the classes have been repackaged, and the StandaloneServer API has been changed to remove methods unrelated to this use case.\r\n\r\nThis use case needs an embedding solution, and this module works for this use case. But there's a fair amount of work going on related to embedding WildFly, and I see little benefit of turning this into a general purpose API. If we develop something better, this use case can just switch to it; it's needs are fairly simple.\r\n\r\n2) When the embedding app is non-modular, the org.jboss.logging and org.jboss.logmanager packages are configured as system packages in the embedded server's modular classloading environment. The org.jboss.logmanager.LogManager class is installed as the JDK log manager, and it uses its LogContext class and the static fields therein heavily. If the CLI-side LogContext class and the modular side LogContext class are different, nothing works properly. Since logmanager is a system pkg, the org.jboss.logging API stuff must be too.\r\n\r\n3) The CLI configures the StdioContextSelector and the LogContextSelector (using a ThreadLocal) before making any call into the embedded server. This ensures that the System.out handling is appropriate when the embedded server writes to the console log. This is currently done on the CLI side. It could potentially be moved to the embedded server side. Whether or not that is appropriate is one reason for 1) above. The CLI side knows what setup it wants; if it were moved to the embedded server side, there would need to be some mechanism for the CLI side to indicate what the desired settings are.\r\n\r\nThe test coverage I added is for the case where the embedding app is non-modular. That's because a JUnit test is naturally non-modular. It would be nice to set up some sort of test fixture where the test fixture is modular so regression tests for that case (equivalent to what users will see using jboss-cli.sh) can be added. But that's a fairly big undertaking. Manual tests show the behavior is as expected.","created_at":"2015-03-06T17:12:13Z","updated_at":"2015-03-06T17:36:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"73f7996d5cc658108a15153489725e044079e372","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wildfly/wildfly-core/pulls/545/commits","review_comments_url":"https://api.github.com/repos/wildfly/wildfly-core/pulls/545/comments","review_comment_url":"https://api.github.com/repos/wildfly/wildfly-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wildfly/wildfly-core/issues/545/comments","statuses_url":"https://api.github.com/repos/wildfly/wildfly-core/statuses/7fd8fef99de508fc5d77ddf335476400c2fdd8d9","head":{"label":"bstansberry:cli-embed-server","ref":"cli-embed-server","sha":"7fd8fef99de508fc5d77ddf335476400c2fdd8d9","user":{"login":"bstansberry","id":299242,"avatar_url":"https://avatars.githubusercontent.com/u/299242?v=3","gravatar_id":"","url":"https://api.github.com/users/bstansberry","html_url":"https://github.com/bstansberry","followers_url":"https://api.github.com/users/bstansberry/followers","following_url":"https://api.github.com/users/bstansberry/following{/other_user}","gists_url":"https://api.github.com/users/bstansberry/gists{/gist_id}","starred_url":"https://api.github.com/users/bstansberry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bstansberry/subscriptions","organizations_url":"https://api.github.com/users/bstansberry/orgs","repos_url":"https://api.github.com/users/bstansberry/repos","events_url":"https://api.github.com/users/bstansberry/events{/privacy}","received_events_url":"https://api.github.com/users/bstansberry/received_events","type":"User","site_admin":false},"repo":{"id":21433119,"name":"wildfly-core","full_name":"bstansberry/wildfly-core","owner":{"login":"bstansberry","id":299242,"avatar_url":"https://avatars.githubusercontent.com/u/299242?v=3","gravatar_id":"","url":"https://api.github.com/users/bstansberry","html_url":"https://github.com/bstansberry","followers_url":"https://api.github.com/users/bstansberry/followers","following_url":"https://api.github.com/users/bstansberry/following{/other_user}","gists_url":"https://api.github.com/users/bstansberry/gists{/gist_id}","starred_url":"https://api.github.com/users/bstansberry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bstansberry/subscriptions","organizations_url":"https://api.github.com/users/bstansberry/orgs","repos_url":"https://api.github.com/users/bstansberry/repos","events_url":"https://api.github.com/users/bstansberry/events{/privacy}","received_events_url":"https://api.github.com/users/bstansberry/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bstansberry/wildfly-core","description":"The core runtime that is used by the Wildfly application server","fork":true,"url":"https://api.github.com/repos/bstansberry/wildfly-core","forks_url":"https://api.github.com/repos/bstansberry/wildfly-core/forks","keys_url":"https://api.github.com/repos/bstansberry/wildfly-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bstansberry/wildfly-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bstansberry/wildfly-core/teams","hooks_url":"https://api.github.com/repos/bstansberry/wildfly-core/hooks","issue_events_url":"https://api.github.com/repos/bstansberry/wildfly-core/issues/events{/number}","events_url":"https://api.github.com/repos/bstansberry/wildfly-core/events","assignees_url":"https://api.github.com/repos/bstansberry/wildfly-core/assignees{/user}","branches_url":"https://api.github.com/repos/bstansberry/wildfly-core/branches{/branch}","tags_url":"https://api.github.com/repos/bstansberry/wildfly-core/tags","blobs_url":"https://api.github.com/repos/bstansberry/wildfly-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bstansberry/wildfly-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bstansberry/wildfly-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/bstansberry/wildfly-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bstansberry/wildfly-core/statuses/{sha}","languages_url":"https://api.github.com/repos/bstansberry/wildfly-core/languages","stargazers_url":"https://api.github.com/repos/bstansberry/wildfly-core/stargazers","contributors_url":"https://api.github.com/repos/bstansberry/wildfly-core/contributors","subscribers_url":"https://api.github.com/repos/bstansberry/wildfly-core/subscribers","subscription_url":"https://api.github.com/repos/bstansberry/wildfly-core/subscription","commits_url":"https://api.github.com/repos/bstansberry/wildfly-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/bstansberry/wildfly-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/bstansberry/wildfly-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/bstansberry/wildfly-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/bstansberry/wildfly-core/contents/{+path}","compare_url":"https://api.github.com/repos/bstansberry/wildfly-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bstansberry/wildfly-core/merges","archive_url":"https://api.github.com/repos/bstansberry/wildfly-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bstansberry/wildfly-core/downloads","issues_url":"https://api.github.com/repos/bstansberry/wildfly-core/issues{/number}","pulls_url":"https://api.github.com/repos/bstansberry/wildfly-core/pulls{/number}","milestones_url":"https://api.github.com/repos/bstansberry/wildfly-core/milestones{/number}","notifications_url":"https://api.github.com/repos/bstansberry/wildfly-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bstansberry/wildfly-core/labels{/name}","releases_url":"https://api.github.com/repos/bstansberry/wildfly-core/releases{/id}","created_at":"2014-07-02T17:20:55Z","updated_at":"2015-03-05T21:43:03Z","pushed_at":"2015-03-06T16:40:11Z","git_url":"git://github.com/bstansberry/wildfly-core.git","ssh_url":"git@github.com:bstansberry/wildfly-core.git","clone_url":"https://github.com/bstansberry/wildfly-core.git","svn_url":"https://github.com/bstansberry/wildfly-core","homepage":null,"size":39330,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"wildfly:master","ref":"master","sha":"5173bbc3a6b1b47d5eb72ce3cc1b11a2ecba52d1","user":{"login":"wildfly","id":3066274,"avatar_url":"https://avatars.githubusercontent.com/u/3066274?v=3","gravatar_id":"","url":"https://api.github.com/users/wildfly","html_url":"https://github.com/wildfly","followers_url":"https://api.github.com/users/wildfly/followers","following_url":"https://api.github.com/users/wildfly/following{/other_user}","gists_url":"https://api.github.com/users/wildfly/gists{/gist_id}","starred_url":"https://api.github.com/users/wildfly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wildfly/subscriptions","organizations_url":"https://api.github.com/users/wildfly/orgs","repos_url":"https://api.github.com/users/wildfly/repos","events_url":"https://api.github.com/users/wildfly/events{/privacy}","received_events_url":"https://api.github.com/users/wildfly/received_events","type":"Organization","site_admin":false},"repo":{"id":21394954,"name":"wildfly-core","full_name":"wildfly/wildfly-core","owner":{"login":"wildfly","id":3066274,"avatar_url":"https://avatars.githubusercontent.com/u/3066274?v=3","gravatar_id":"","url":"https://api.github.com/users/wildfly","html_url":"https://github.com/wildfly","followers_url":"https://api.github.com/users/wildfly/followers","following_url":"https://api.github.com/users/wildfly/following{/other_user}","gists_url":"https://api.github.com/users/wildfly/gists{/gist_id}","starred_url":"https://api.github.com/users/wildfly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wildfly/subscriptions","organizations_url":"https://api.github.com/users/wildfly/orgs","repos_url":"https://api.github.com/users/wildfly/repos","events_url":"https://api.github.com/users/wildfly/events{/privacy}","received_events_url":"https://api.github.com/users/wildfly/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wildfly/wildfly-core","description":"The core runtime that is used by the Wildfly application server","fork":false,"url":"https://api.github.com/repos/wildfly/wildfly-core","forks_url":"https://api.github.com/repos/wildfly/wildfly-core/forks","keys_url":"https://api.github.com/repos/wildfly/wildfly-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wildfly/wildfly-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wildfly/wildfly-core/teams","hooks_url":"https://api.github.com/repos/wildfly/wildfly-core/hooks","issue_events_url":"https://api.github.com/repos/wildfly/wildfly-core/issues/events{/number}","events_url":"https://api.github.com/repos/wildfly/wildfly-core/events","assignees_url":"https://api.github.com/repos/wildfly/wildfly-core/assignees{/user}","branches_url":"https://api.github.com/repos/wildfly/wildfly-core/branches{/branch}","tags_url":"https://api.github.com/repos/wildfly/wildfly-core/tags","blobs_url":"https://api.github.com/repos/wildfly/wildfly-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wildfly/wildfly-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wildfly/wildfly-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/wildfly/wildfly-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wildfly/wildfly-core/statuses/{sha}","languages_url":"https://api.github.com/repos/wildfly/wildfly-core/languages","stargazers_url":"https://api.github.com/repos/wildfly/wildfly-core/stargazers","contributors_url":"https://api.github.com/repos/wildfly/wildfly-core/contributors","subscribers_url":"https://api.github.com/repos/wildfly/wildfly-core/subscribers","subscription_url":"https://api.github.com/repos/wildfly/wildfly-core/subscription","commits_url":"https://api.github.com/repos/wildfly/wildfly-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/wildfly/wildfly-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/wildfly/wildfly-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/wildfly/wildfly-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/wildfly/wildfly-core/contents/{+path}","compare_url":"https://api.github.com/repos/wildfly/wildfly-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wildfly/wildfly-core/merges","archive_url":"https://api.github.com/repos/wildfly/wildfly-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wildfly/wildfly-core/downloads","issues_url":"https://api.github.com/repos/wildfly/wildfly-core/issues{/number}","pulls_url":"https://api.github.com/repos/wildfly/wildfly-core/pulls{/number}","milestones_url":"https://api.github.com/repos/wildfly/wildfly-core/milestones{/number}","notifications_url":"https://api.github.com/repos/wildfly/wildfly-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wildfly/wildfly-core/labels{/name}","releases_url":"https://api.github.com/repos/wildfly/wildfly-core/releases{/id}","created_at":"2014-07-01T16:33:34Z","updated_at":"2015-03-05T21:25:26Z","pushed_at":"2015-03-05T21:43:19Z","git_url":"git://github.com/wildfly/wildfly-core.git","ssh_url":"git@github.com:wildfly/wildfly-core.git","clone_url":"https://github.com/wildfly/wildfly-core.git","svn_url":"https://github.com/wildfly/wildfly-core","homepage":null,"size":43353,"stargazers_count":12,"watchers_count":12,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":103,"mirror_url":null,"open_issues_count":13,"forks":103,"open_issues":13,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wildfly/wildfly-core/pulls/545"},"html":{"href":"https://github.com/wildfly/wildfly-core/pull/545"},"issue":{"href":"https://api.github.com/repos/wildfly/wildfly-core/issues/545"},"comments":{"href":"https://api.github.com/repos/wildfly/wildfly-core/issues/545/comments"},"review_comments":{"href":"https://api.github.com/repos/wildfly/wildfly-core/pulls/545/comments"},"review_comment":{"href":"https://api.github.com/repos/wildfly/wildfly-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wildfly/wildfly-core/pulls/545/commits"},"statuses":{"href":"https://api.github.com/repos/wildfly/wildfly-core/statuses/7fd8fef99de508fc5d77ddf335476400c2fdd8d9"}}}}