{"action":"created","comment":{"url":"https://api.github.com/repos/gamerson/liferay-ide/pulls/comments/49246783","id":49246783,"diff_hunk":"@@ -0,0 +1,294 @@\n+/*******************************************************************************\n+ * Copyright (c) 2000-present Liferay, Inc. All rights reserved.\n+ *\n+ * This library is free software; you can redistribute it and/or modify it under\n+ * the terms of the GNU Lesser General Public License as published by the Free\n+ * Software Foundation; either version 2.1 of the License, or (at your option)\n+ * any later version.\n+ *\n+ * This library is distributed in the hope that it will be useful, but WITHOUT\n+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more\n+ * details.\n+ *\n+ *******************************************************************************/\n+\n+package com.liferay.ide.project.core.modules;\n+\n+import java.io.InputStream;\n+import java.net.InetSocketAddress;\n+import java.net.Socket;\n+import java.util.ArrayList;\n+import java.util.HashSet;\n+import java.util.Iterator;\n+import java.util.List;\n+import java.util.Set;\n+import java.util.regex.Matcher;\n+import java.util.regex.Pattern;\n+\n+\n+import aQute.remote.api.Agent;\n+import aQute.remote.api.Event;\n+import aQute.remote.api.Supervisor;\n+import aQute.remote.util.AgentSupervisor;\n+\n+/**\n+ * @author Lovett Li\n+ */\n+public class ServiceCommand {\n+\n+    private String _serviceName;\n+\n+    public ServiceCommand()\n+    {\n+    }\n+    public ServiceCommand( String serviceName )\n+    {\n+        _serviceName = serviceName;\n+    }\n+\n+    public String[] execute() throws Exception\n+    {\n+        ServicesSupervisor supervisor = null;\n+        String[] result = null;\n+\n+        synchronized( ServiceCommand.class )\n+        {\n+\n+            try\n+            {\n+                supervisor = connectRemote();\n+\n+                if( _serviceName == null )\n+                {\n+                    result = getServices( supervisor );\n+                }\n+                else\n+                {\n+                    result = getServiceBundle( _serviceName, supervisor );\n+                }\n+\n+                return result;\n+            }\n+            finally\n+            {\n+                if( supervisor != null )\n+                {\n+                    supervisor.close();\n+                }\n+\n+            }\n+        }\n+    }\n+\n+    private ServicesSupervisor connectRemote() throws Exception\n+    {\n+        if( !canConnect( \"localhost\", Agent.DEFAULT_PORT ) )\n+        {\n+            return null;\n+        }\n+\n+        ServicesSupervisor supervisor = new ServicesSupervisor();\n+        supervisor.connect( \"localhost\", Agent.DEFAULT_PORT );\n+\n+        if( !supervisor.getAgent().redirect( -1 ) )\n+        {\n+            supervisor.close();\n+            return null;\n+        }\n+\n+        return supervisor;\n+    }\n+\n+    static boolean canConnect( String host, int port )\n+    {\n+        InetSocketAddress address = new InetSocketAddress( host, Integer.valueOf( port ) );\n+        InetSocketAddress local = new InetSocketAddress( 0 );\n+\n+        InputStream in = null;\n+\n+        try(Socket socket = new Socket())\n+        {\n+            socket.bind( local );\n+            socket.connect( address, 3000 );\n+            in = socket.getInputStream();\n+\n+            return true;\n+        }\n+        catch( Exception e )\n+        {\n+        }\n+        finally\n+        {\n+            if( in != null )\n+            {\n+                try\n+                {\n+                    in.close();\n+                }\n+                catch( Exception e )\n+                {\n+                }\n+            }\n+        }\n+\n+        return false;\n+    }\n+\n+    private String[] getServices( ServicesSupervisor supervisor ) throws Exception\n+    {\n+        supervisor.getAgent().stdin( \"services\" );","path":"tools/plugins/com.liferay.ide.project.core/src/com/liferay/ide/project/core/modules/ServiceCommand.java","position":140,"original_position":140,"commit_id":"ac38a448af64ffa883d58c485f9394f4541d93e8","original_commit_id":"ac38a448af64ffa883d58c485f9394f4541d93e8","user":{"login":"gamerson","id":595221,"avatar_url":"https://avatars.githubusercontent.com/u/595221?v=3","gravatar_id":"","url":"https://api.github.com/users/gamerson","html_url":"https://github.com/gamerson","followers_url":"https://api.github.com/users/gamerson/followers","following_url":"https://api.github.com/users/gamerson/following{/other_user}","gists_url":"https://api.github.com/users/gamerson/gists{/gist_id}","starred_url":"https://api.github.com/users/gamerson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gamerson/subscriptions","organizations_url":"https://api.github.com/users/gamerson/orgs","repos_url":"https://api.github.com/users/gamerson/repos","events_url":"https://api.github.com/users/gamerson/events{/privacy}","received_events_url":"https://api.github.com/users/gamerson/received_events","type":"User","site_admin":false},"body":"always add a newlien before return unless return is the only statement in the block.  ","created_at":"2016-01-08T22:33:16Z","updated_at":"2016-01-08T22:33:16Z","html_url":"https://github.com/gamerson/liferay-ide/pull/1282#discussion_r49246783","pull_request_url":"https://api.github.com/repos/gamerson/liferay-ide/pulls/1282","_links":{"self":{"href":"https://api.github.com/repos/gamerson/liferay-ide/pulls/comments/49246783"},"html":{"href":"https://github.com/gamerson/liferay-ide/pull/1282#discussion_r49246783"},"pull_request":{"href":"https://api.github.com/repos/gamerson/liferay-ide/pulls/1282"}}},"pull_request":{"url":"https://api.github.com/repos/gamerson/liferay-ide/pulls/1282","id":55433919,"html_url":"https://github.com/gamerson/liferay-ide/pull/1282","diff_url":"https://github.com/gamerson/liferay-ide/pull/1282.diff","patch_url":"https://github.com/gamerson/liferay-ide/pull/1282.patch","issue_url":"https://api.github.com/repos/gamerson/liferay-ide/issues/1282","number":1282,"state":"open","locked":false,"title":"IDE-2155 Add function to dynamically get liferay extension point","user":{"login":"lovettli","id":10591143,"avatar_url":"https://avatars.githubusercontent.com/u/10591143?v=3","gravatar_id":"","url":"https://api.github.com/users/lovettli","html_url":"https://github.com/lovettli","followers_url":"https://api.github.com/users/lovettli/followers","following_url":"https://api.github.com/users/lovettli/following{/other_user}","gists_url":"https://api.github.com/users/lovettli/gists{/gist_id}","starred_url":"https://api.github.com/users/lovettli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lovettli/subscriptions","organizations_url":"https://api.github.com/users/lovettli/orgs","repos_url":"https://api.github.com/users/lovettli/repos","events_url":"https://api.github.com/users/lovettli/events{/privacy}","received_events_url":"https://api.github.com/users/lovettli/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-08T07:55:52Z","updated_at":"2016-01-08T22:33:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0a524885afa7c3afe0972c4d6a5e18c6ce696514","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gamerson/liferay-ide/pulls/1282/commits","review_comments_url":"https://api.github.com/repos/gamerson/liferay-ide/pulls/1282/comments","review_comment_url":"https://api.github.com/repos/gamerson/liferay-ide/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gamerson/liferay-ide/issues/1282/comments","statuses_url":"https://api.github.com/repos/gamerson/liferay-ide/statuses/ac38a448af64ffa883d58c485f9394f4541d93e8","head":{"label":"lovettli:IDE-2155","ref":"IDE-2155","sha":"ac38a448af64ffa883d58c485f9394f4541d93e8","user":{"login":"lovettli","id":10591143,"avatar_url":"https://avatars.githubusercontent.com/u/10591143?v=3","gravatar_id":"","url":"https://api.github.com/users/lovettli","html_url":"https://github.com/lovettli","followers_url":"https://api.github.com/users/lovettli/followers","following_url":"https://api.github.com/users/lovettli/following{/other_user}","gists_url":"https://api.github.com/users/lovettli/gists{/gist_id}","starred_url":"https://api.github.com/users/lovettli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lovettli/subscriptions","organizations_url":"https://api.github.com/users/lovettli/orgs","repos_url":"https://api.github.com/users/lovettli/repos","events_url":"https://api.github.com/users/lovettli/events{/privacy}","received_events_url":"https://api.github.com/users/lovettli/received_events","type":"User","site_admin":false},"repo":{"id":33589792,"name":"liferay-ide","full_name":"lovettli/liferay-ide","owner":{"login":"lovettli","id":10591143,"avatar_url":"https://avatars.githubusercontent.com/u/10591143?v=3","gravatar_id":"","url":"https://api.github.com/users/lovettli","html_url":"https://github.com/lovettli","followers_url":"https://api.github.com/users/lovettli/followers","following_url":"https://api.github.com/users/lovettli/following{/other_user}","gists_url":"https://api.github.com/users/lovettli/gists{/gist_id}","starred_url":"https://api.github.com/users/lovettli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lovettli/subscriptions","organizations_url":"https://api.github.com/users/lovettli/orgs","repos_url":"https://api.github.com/users/lovettli/repos","events_url":"https://api.github.com/users/lovettli/events{/privacy}","received_events_url":"https://api.github.com/users/lovettli/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lovettli/liferay-ide","description":"","fork":true,"url":"https://api.github.com/repos/lovettli/liferay-ide","forks_url":"https://api.github.com/repos/lovettli/liferay-ide/forks","keys_url":"https://api.github.com/repos/lovettli/liferay-ide/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lovettli/liferay-ide/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lovettli/liferay-ide/teams","hooks_url":"https://api.github.com/repos/lovettli/liferay-ide/hooks","issue_events_url":"https://api.github.com/repos/lovettli/liferay-ide/issues/events{/number}","events_url":"https://api.github.com/repos/lovettli/liferay-ide/events","assignees_url":"https://api.github.com/repos/lovettli/liferay-ide/assignees{/user}","branches_url":"https://api.github.com/repos/lovettli/liferay-ide/branches{/branch}","tags_url":"https://api.github.com/repos/lovettli/liferay-ide/tags","blobs_url":"https://api.github.com/repos/lovettli/liferay-ide/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lovettli/liferay-ide/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lovettli/liferay-ide/git/refs{/sha}","trees_url":"https://api.github.com/repos/lovettli/liferay-ide/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lovettli/liferay-ide/statuses/{sha}","languages_url":"https://api.github.com/repos/lovettli/liferay-ide/languages","stargazers_url":"https://api.github.com/repos/lovettli/liferay-ide/stargazers","contributors_url":"https://api.github.com/repos/lovettli/liferay-ide/contributors","subscribers_url":"https://api.github.com/repos/lovettli/liferay-ide/subscribers","subscription_url":"https://api.github.com/repos/lovettli/liferay-ide/subscription","commits_url":"https://api.github.com/repos/lovettli/liferay-ide/commits{/sha}","git_commits_url":"https://api.github.com/repos/lovettli/liferay-ide/git/commits{/sha}","comments_url":"https://api.github.com/repos/lovettli/liferay-ide/comments{/number}","issue_comment_url":"https://api.github.com/repos/lovettli/liferay-ide/issues/comments{/number}","contents_url":"https://api.github.com/repos/lovettli/liferay-ide/contents/{+path}","compare_url":"https://api.github.com/repos/lovettli/liferay-ide/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lovettli/liferay-ide/merges","archive_url":"https://api.github.com/repos/lovettli/liferay-ide/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lovettli/liferay-ide/downloads","issues_url":"https://api.github.com/repos/lovettli/liferay-ide/issues{/number}","pulls_url":"https://api.github.com/repos/lovettli/liferay-ide/pulls{/number}","milestones_url":"https://api.github.com/repos/lovettli/liferay-ide/milestones{/number}","notifications_url":"https://api.github.com/repos/lovettli/liferay-ide/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lovettli/liferay-ide/labels{/name}","releases_url":"https://api.github.com/repos/lovettli/liferay-ide/releases{/id}","created_at":"2015-04-08T06:48:32Z","updated_at":"2015-04-08T06:48:35Z","pushed_at":"2016-01-08T07:54:26Z","git_url":"git://github.com/lovettli/liferay-ide.git","ssh_url":"git@github.com:lovettli/liferay-ide.git","clone_url":"https://github.com/lovettli/liferay-ide.git","svn_url":"https://github.com/lovettli/liferay-ide","homepage":"","size":197979,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"gamerson:master","ref":"master","sha":"a1958019a53ea3434e7f5bda9226d7e82c568ccd","user":{"login":"gamerson","id":595221,"avatar_url":"https://avatars.githubusercontent.com/u/595221?v=3","gravatar_id":"","url":"https://api.github.com/users/gamerson","html_url":"https://github.com/gamerson","followers_url":"https://api.github.com/users/gamerson/followers","following_url":"https://api.github.com/users/gamerson/following{/other_user}","gists_url":"https://api.github.com/users/gamerson/gists{/gist_id}","starred_url":"https://api.github.com/users/gamerson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gamerson/subscriptions","organizations_url":"https://api.github.com/users/gamerson/orgs","repos_url":"https://api.github.com/users/gamerson/repos","events_url":"https://api.github.com/users/gamerson/events{/privacy}","received_events_url":"https://api.github.com/users/gamerson/received_events","type":"User","site_admin":false},"repo":{"id":1926534,"name":"liferay-ide","full_name":"gamerson/liferay-ide","owner":{"login":"gamerson","id":595221,"avatar_url":"https://avatars.githubusercontent.com/u/595221?v=3","gravatar_id":"","url":"https://api.github.com/users/gamerson","html_url":"https://github.com/gamerson","followers_url":"https://api.github.com/users/gamerson/followers","following_url":"https://api.github.com/users/gamerson/following{/other_user}","gists_url":"https://api.github.com/users/gamerson/gists{/gist_id}","starred_url":"https://api.github.com/users/gamerson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gamerson/subscriptions","organizations_url":"https://api.github.com/users/gamerson/orgs","repos_url":"https://api.github.com/users/gamerson/repos","events_url":"https://api.github.com/users/gamerson/events{/privacy}","received_events_url":"https://api.github.com/users/gamerson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gamerson/liferay-ide","description":"","fork":true,"url":"https://api.github.com/repos/gamerson/liferay-ide","forks_url":"https://api.github.com/repos/gamerson/liferay-ide/forks","keys_url":"https://api.github.com/repos/gamerson/liferay-ide/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gamerson/liferay-ide/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gamerson/liferay-ide/teams","hooks_url":"https://api.github.com/repos/gamerson/liferay-ide/hooks","issue_events_url":"https://api.github.com/repos/gamerson/liferay-ide/issues/events{/number}","events_url":"https://api.github.com/repos/gamerson/liferay-ide/events","assignees_url":"https://api.github.com/repos/gamerson/liferay-ide/assignees{/user}","branches_url":"https://api.github.com/repos/gamerson/liferay-ide/branches{/branch}","tags_url":"https://api.github.com/repos/gamerson/liferay-ide/tags","blobs_url":"https://api.github.com/repos/gamerson/liferay-ide/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gamerson/liferay-ide/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gamerson/liferay-ide/git/refs{/sha}","trees_url":"https://api.github.com/repos/gamerson/liferay-ide/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gamerson/liferay-ide/statuses/{sha}","languages_url":"https://api.github.com/repos/gamerson/liferay-ide/languages","stargazers_url":"https://api.github.com/repos/gamerson/liferay-ide/stargazers","contributors_url":"https://api.github.com/repos/gamerson/liferay-ide/contributors","subscribers_url":"https://api.github.com/repos/gamerson/liferay-ide/subscribers","subscription_url":"https://api.github.com/repos/gamerson/liferay-ide/subscription","commits_url":"https://api.github.com/repos/gamerson/liferay-ide/commits{/sha}","git_commits_url":"https://api.github.com/repos/gamerson/liferay-ide/git/commits{/sha}","comments_url":"https://api.github.com/repos/gamerson/liferay-ide/comments{/number}","issue_comment_url":"https://api.github.com/repos/gamerson/liferay-ide/issues/comments{/number}","contents_url":"https://api.github.com/repos/gamerson/liferay-ide/contents/{+path}","compare_url":"https://api.github.com/repos/gamerson/liferay-ide/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gamerson/liferay-ide/merges","archive_url":"https://api.github.com/repos/gamerson/liferay-ide/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gamerson/liferay-ide/downloads","issues_url":"https://api.github.com/repos/gamerson/liferay-ide/issues{/number}","pulls_url":"https://api.github.com/repos/gamerson/liferay-ide/pulls{/number}","milestones_url":"https://api.github.com/repos/gamerson/liferay-ide/milestones{/number}","notifications_url":"https://api.github.com/repos/gamerson/liferay-ide/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gamerson/liferay-ide/labels{/name}","releases_url":"https://api.github.com/repos/gamerson/liferay-ide/releases{/id}","created_at":"2011-06-20T23:49:28Z","updated_at":"2015-05-07T04:04:01Z","pushed_at":"2016-01-08T22:20:54Z","git_url":"git://github.com/gamerson/liferay-ide.git","ssh_url":"git@github.com:gamerson/liferay-ide.git","clone_url":"https://github.com/gamerson/liferay-ide.git","svn_url":"https://github.com/gamerson/liferay-ide","homepage":"","size":267232,"stargazers_count":6,"watchers_count":6,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":2,"forks":6,"open_issues":2,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gamerson/liferay-ide/pulls/1282"},"html":{"href":"https://github.com/gamerson/liferay-ide/pull/1282"},"issue":{"href":"https://api.github.com/repos/gamerson/liferay-ide/issues/1282"},"comments":{"href":"https://api.github.com/repos/gamerson/liferay-ide/issues/1282/comments"},"review_comments":{"href":"https://api.github.com/repos/gamerson/liferay-ide/pulls/1282/comments"},"review_comment":{"href":"https://api.github.com/repos/gamerson/liferay-ide/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gamerson/liferay-ide/pulls/1282/commits"},"statuses":{"href":"https://api.github.com/repos/gamerson/liferay-ide/statuses/ac38a448af64ffa883d58c485f9394f4541d93e8"}}}}