{"action":"created","comment":{"url":"https://api.github.com/repos/mulesoft/mule/pulls/comments/75346411","id":75346411,"diff_hunk":"@@ -0,0 +1,91 @@\n+/*\n+ * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com\n+ * The software in this package is published under the terms of the CPAL v1.0\n+ * license, a copy of which has been included with this distribution in the\n+ * LICENSE.txt file.\n+ */\n+package org.mule.runtime.module.extension.internal.capability.xml.schema;\n+\n+import static org.mule.runtime.core.util.annotation.AnnotationUtils.getAnnotation;\n+import static org.reflections.util.ClasspathHelper.forClassLoader;\n+import static org.reflections.util.ClasspathHelper.forJavaClassPath;\n+import org.mule.runtime.core.registry.SpiServiceRegistry;\n+import org.mule.runtime.extension.api.annotation.Extension;\n+import org.mule.runtime.extension.api.introspection.ExtensionFactory;\n+import org.mule.runtime.extension.api.introspection.ExtensionModel;\n+import org.mule.runtime.extension.api.introspection.declaration.DescribingContext;\n+import org.mule.runtime.extension.api.introspection.declaration.spi.Describer;\n+import org.mule.runtime.extension.xml.dsl.api.resolver.DslResolvingContext;\n+import org.mule.runtime.module.extension.internal.DefaultDescribingContext;\n+import org.mule.runtime.module.extension.internal.introspection.DefaultExtensionFactory;\n+import org.mule.runtime.module.extension.internal.introspection.describer.AnnotationsBasedDescriber;\n+import org.mule.runtime.module.extension.internal.introspection.version.StaticVersionResolver;\n+\n+import java.net.URL;\n+import java.util.Collection;\n+import java.util.HashMap;\n+import java.util.Map;\n+import java.util.Optional;\n+import java.util.Set;\n+\n+import org.reflections.Reflections;\n+import org.reflections.scanners.SubTypesScanner;\n+import org.reflections.scanners.TypeAnnotationsScanner;\n+import org.reflections.util.ConfigurationBuilder;\n+\n+/**\n+ * Implementation of {@link DslResolvingContext} that\n+ * scans the Classpath looking for the {@link Class} associated to the\n+ * provided Extension {@code name}\n+ *\n+ * @since 4.0\n+ */\n+class ClasspathBasedDslContext implements DslResolvingContext {\n+\n+  private final ClassLoader classLoader;\n+  private final Map<String, Class<?>> extensionsByName = new HashMap<>();\n+  private final Map<String, ExtensionModel> resolvedModels = new HashMap<>();\n+  private final ExtensionFactory extensionFactory =\n+      new DefaultExtensionFactory(new SpiServiceRegistry(), getClass().getClassLoader());\n+\n+  ClasspathBasedDslContext(ClassLoader classLoader) {\n+    this.classLoader = classLoader;\n+    findExtensionsInClasspath();\n+  }\n+\n+  /**\n+   * {@inheritDoc}\n+   */\n+  @Override\n+  public Optional<ExtensionModel> getExtension(String name) {\n+\n+    if (!resolvedModels.containsKey(name) && extensionsByName.containsKey(name)) {\n+      Describer describer = new AnnotationsBasedDescriber(extensionsByName.get(name), new StaticVersionResolver(\"4.0\"));\n+      DescribingContext context = new DefaultDescribingContext(getClass().getClassLoader());\n+      resolvedModels.put(name, extensionFactory.createFrom(describer.describe(context), context));\n+    }\n+    return Optional.ofNullable(resolvedModels.get(name));\n+  }\n+\n+\n+  private void findExtensionsInClasspath() {\n+\n+    // default classpath for testing environment, were the extension classloader is not useful\n+    Set<Class<?>> annotated = getExtensionTypes(forJavaClassPath());\n+\n+    if (annotated.isEmpty()) {\n+      // we are building an standalone extension, thus the classloader of the extension is required","path":"modules/extensions-spring-support/src/main/java/org/mule/runtime/module/extension/internal/capability/xml/schema/ClasspathBasedDslContext.java","position":77,"original_position":77,"commit_id":"78fb356c37cf9e782ae96a240bdb3be7a4b4d222","original_commit_id":"78fb356c37cf9e782ae96a240bdb3be7a4b4d222","user":{"login":"alegmarra","id":1502904,"avatar_url":"https://avatars.githubusercontent.com/u/1502904?v=3","gravatar_id":"","url":"https://api.github.com/users/alegmarra","html_url":"https://github.com/alegmarra","followers_url":"https://api.github.com/users/alegmarra/followers","following_url":"https://api.github.com/users/alegmarra/following{/other_user}","gists_url":"https://api.github.com/users/alegmarra/gists{/gist_id}","starred_url":"https://api.github.com/users/alegmarra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alegmarra/subscriptions","organizations_url":"https://api.github.com/users/alegmarra/orgs","repos_url":"https://api.github.com/users/alegmarra/repos","events_url":"https://api.github.com/users/alegmarra/events{/privacy}","received_events_url":"https://api.github.com/users/alegmarra/received_events","type":"User","site_admin":false},"body":"Having the test classpath first and falling back to this case adds a penalty of >100ms during the compilation of the Http extension, while avoiding a 300 lines warning trace for each test that requires this classpath.","created_at":"2016-08-18T16:58:12Z","updated_at":"2016-08-18T16:58:12Z","html_url":"https://github.com/mulesoft/mule/pull/3143#discussion_r75346411","pull_request_url":"https://api.github.com/repos/mulesoft/mule/pulls/3143","_links":{"self":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/comments/75346411"},"html":{"href":"https://github.com/mulesoft/mule/pull/3143#discussion_r75346411"},"pull_request":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/3143"}}},"pull_request":{"url":"https://api.github.com/repos/mulesoft/mule/pulls/3143","id":81817419,"html_url":"https://github.com/mulesoft/mule/pull/3143","diff_url":"https://github.com/mulesoft/mule/pull/3143.diff","patch_url":"https://github.com/mulesoft/mule/pull/3143.patch","issue_url":"https://api.github.com/repos/mulesoft/mule/issues/3143","number":3143,"state":"open","locked":false,"title":"MULE-10214: @Import should not require a class element","user":{"login":"alegmarra","id":1502904,"avatar_url":"https://avatars.githubusercontent.com/u/1502904?v=3","gravatar_id":"","url":"https://api.github.com/users/alegmarra","html_url":"https://github.com/alegmarra","followers_url":"https://api.github.com/users/alegmarra/followers","following_url":"https://api.github.com/users/alegmarra/following{/other_user}","gists_url":"https://api.github.com/users/alegmarra/gists{/gist_id}","starred_url":"https://api.github.com/users/alegmarra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alegmarra/subscriptions","organizations_url":"https://api.github.com/users/alegmarra/orgs","repos_url":"https://api.github.com/users/alegmarra/repos","events_url":"https://api.github.com/users/alegmarra/events{/privacy}","received_events_url":"https://api.github.com/users/alegmarra/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-18T13:40:21Z","updated_at":"2016-08-18T16:58:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1605dcabf944d94cbfe9f3958d4eafb34f8ef849","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mulesoft/mule/pulls/3143/commits","review_comments_url":"https://api.github.com/repos/mulesoft/mule/pulls/3143/comments","review_comment_url":"https://api.github.com/repos/mulesoft/mule/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mulesoft/mule/issues/3143/comments","statuses_url":"https://api.github.com/repos/mulesoft/mule/statuses/78fb356c37cf9e782ae96a240bdb3be7a4b4d222","head":{"label":"mulesoft:MULE-10214","ref":"MULE-10214","sha":"78fb356c37cf9e782ae96a240bdb3be7a4b4d222","user":{"login":"mulesoft","id":185740,"avatar_url":"https://avatars.githubusercontent.com/u/185740?v=3","gravatar_id":"","url":"https://api.github.com/users/mulesoft","html_url":"https://github.com/mulesoft","followers_url":"https://api.github.com/users/mulesoft/followers","following_url":"https://api.github.com/users/mulesoft/following{/other_user}","gists_url":"https://api.github.com/users/mulesoft/gists{/gist_id}","starred_url":"https://api.github.com/users/mulesoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulesoft/subscriptions","organizations_url":"https://api.github.com/users/mulesoft/orgs","repos_url":"https://api.github.com/users/mulesoft/repos","events_url":"https://api.github.com/users/mulesoft/events{/privacy}","received_events_url":"https://api.github.com/users/mulesoft/received_events","type":"Organization","site_admin":false},"repo":{"id":7058562,"name":"mule","full_name":"mulesoft/mule","owner":{"login":"mulesoft","id":185740,"avatar_url":"https://avatars.githubusercontent.com/u/185740?v=3","gravatar_id":"","url":"https://api.github.com/users/mulesoft","html_url":"https://github.com/mulesoft","followers_url":"https://api.github.com/users/mulesoft/followers","following_url":"https://api.github.com/users/mulesoft/following{/other_user}","gists_url":"https://api.github.com/users/mulesoft/gists{/gist_id}","starred_url":"https://api.github.com/users/mulesoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulesoft/subscriptions","organizations_url":"https://api.github.com/users/mulesoft/orgs","repos_url":"https://api.github.com/users/mulesoft/repos","events_url":"https://api.github.com/users/mulesoft/events{/privacy}","received_events_url":"https://api.github.com/users/mulesoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mulesoft/mule","description":"Mule Community Edition","fork":false,"url":"https://api.github.com/repos/mulesoft/mule","forks_url":"https://api.github.com/repos/mulesoft/mule/forks","keys_url":"https://api.github.com/repos/mulesoft/mule/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mulesoft/mule/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mulesoft/mule/teams","hooks_url":"https://api.github.com/repos/mulesoft/mule/hooks","issue_events_url":"https://api.github.com/repos/mulesoft/mule/issues/events{/number}","events_url":"https://api.github.com/repos/mulesoft/mule/events","assignees_url":"https://api.github.com/repos/mulesoft/mule/assignees{/user}","branches_url":"https://api.github.com/repos/mulesoft/mule/branches{/branch}","tags_url":"https://api.github.com/repos/mulesoft/mule/tags","blobs_url":"https://api.github.com/repos/mulesoft/mule/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mulesoft/mule/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mulesoft/mule/git/refs{/sha}","trees_url":"https://api.github.com/repos/mulesoft/mule/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mulesoft/mule/statuses/{sha}","languages_url":"https://api.github.com/repos/mulesoft/mule/languages","stargazers_url":"https://api.github.com/repos/mulesoft/mule/stargazers","contributors_url":"https://api.github.com/repos/mulesoft/mule/contributors","subscribers_url":"https://api.github.com/repos/mulesoft/mule/subscribers","subscription_url":"https://api.github.com/repos/mulesoft/mule/subscription","commits_url":"https://api.github.com/repos/mulesoft/mule/commits{/sha}","git_commits_url":"https://api.github.com/repos/mulesoft/mule/git/commits{/sha}","comments_url":"https://api.github.com/repos/mulesoft/mule/comments{/number}","issue_comment_url":"https://api.github.com/repos/mulesoft/mule/issues/comments{/number}","contents_url":"https://api.github.com/repos/mulesoft/mule/contents/{+path}","compare_url":"https://api.github.com/repos/mulesoft/mule/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mulesoft/mule/merges","archive_url":"https://api.github.com/repos/mulesoft/mule/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mulesoft/mule/downloads","issues_url":"https://api.github.com/repos/mulesoft/mule/issues{/number}","pulls_url":"https://api.github.com/repos/mulesoft/mule/pulls{/number}","milestones_url":"https://api.github.com/repos/mulesoft/mule/milestones{/number}","notifications_url":"https://api.github.com/repos/mulesoft/mule/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mulesoft/mule/labels{/name}","releases_url":"https://api.github.com/repos/mulesoft/mule/releases{/id}","deployments_url":"https://api.github.com/repos/mulesoft/mule/deployments","created_at":"2012-12-07T19:23:06Z","updated_at":"2016-08-18T13:00:00Z","pushed_at":"2016-08-18T16:36:24Z","git_url":"git://github.com/mulesoft/mule.git","ssh_url":"git@github.com:mulesoft/mule.git","clone_url":"https://github.com/mulesoft/mule.git","svn_url":"https://github.com/mulesoft/mule","homepage":null,"size":265155,"stargazers_count":358,"watchers_count":358,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":371,"mirror_url":null,"open_issues_count":22,"forks":371,"open_issues":22,"watchers":358,"default_branch":"mule-4.x"}},"base":{"label":"mulesoft:mule-4.x","ref":"mule-4.x","sha":"7b0c144d6bd99c10c4d0f07b7f016f01e34e48ed","user":{"login":"mulesoft","id":185740,"avatar_url":"https://avatars.githubusercontent.com/u/185740?v=3","gravatar_id":"","url":"https://api.github.com/users/mulesoft","html_url":"https://github.com/mulesoft","followers_url":"https://api.github.com/users/mulesoft/followers","following_url":"https://api.github.com/users/mulesoft/following{/other_user}","gists_url":"https://api.github.com/users/mulesoft/gists{/gist_id}","starred_url":"https://api.github.com/users/mulesoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulesoft/subscriptions","organizations_url":"https://api.github.com/users/mulesoft/orgs","repos_url":"https://api.github.com/users/mulesoft/repos","events_url":"https://api.github.com/users/mulesoft/events{/privacy}","received_events_url":"https://api.github.com/users/mulesoft/received_events","type":"Organization","site_admin":false},"repo":{"id":7058562,"name":"mule","full_name":"mulesoft/mule","owner":{"login":"mulesoft","id":185740,"avatar_url":"https://avatars.githubusercontent.com/u/185740?v=3","gravatar_id":"","url":"https://api.github.com/users/mulesoft","html_url":"https://github.com/mulesoft","followers_url":"https://api.github.com/users/mulesoft/followers","following_url":"https://api.github.com/users/mulesoft/following{/other_user}","gists_url":"https://api.github.com/users/mulesoft/gists{/gist_id}","starred_url":"https://api.github.com/users/mulesoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulesoft/subscriptions","organizations_url":"https://api.github.com/users/mulesoft/orgs","repos_url":"https://api.github.com/users/mulesoft/repos","events_url":"https://api.github.com/users/mulesoft/events{/privacy}","received_events_url":"https://api.github.com/users/mulesoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mulesoft/mule","description":"Mule Community Edition","fork":false,"url":"https://api.github.com/repos/mulesoft/mule","forks_url":"https://api.github.com/repos/mulesoft/mule/forks","keys_url":"https://api.github.com/repos/mulesoft/mule/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mulesoft/mule/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mulesoft/mule/teams","hooks_url":"https://api.github.com/repos/mulesoft/mule/hooks","issue_events_url":"https://api.github.com/repos/mulesoft/mule/issues/events{/number}","events_url":"https://api.github.com/repos/mulesoft/mule/events","assignees_url":"https://api.github.com/repos/mulesoft/mule/assignees{/user}","branches_url":"https://api.github.com/repos/mulesoft/mule/branches{/branch}","tags_url":"https://api.github.com/repos/mulesoft/mule/tags","blobs_url":"https://api.github.com/repos/mulesoft/mule/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mulesoft/mule/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mulesoft/mule/git/refs{/sha}","trees_url":"https://api.github.com/repos/mulesoft/mule/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mulesoft/mule/statuses/{sha}","languages_url":"https://api.github.com/repos/mulesoft/mule/languages","stargazers_url":"https://api.github.com/repos/mulesoft/mule/stargazers","contributors_url":"https://api.github.com/repos/mulesoft/mule/contributors","subscribers_url":"https://api.github.com/repos/mulesoft/mule/subscribers","subscription_url":"https://api.github.com/repos/mulesoft/mule/subscription","commits_url":"https://api.github.com/repos/mulesoft/mule/commits{/sha}","git_commits_url":"https://api.github.com/repos/mulesoft/mule/git/commits{/sha}","comments_url":"https://api.github.com/repos/mulesoft/mule/comments{/number}","issue_comment_url":"https://api.github.com/repos/mulesoft/mule/issues/comments{/number}","contents_url":"https://api.github.com/repos/mulesoft/mule/contents/{+path}","compare_url":"https://api.github.com/repos/mulesoft/mule/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mulesoft/mule/merges","archive_url":"https://api.github.com/repos/mulesoft/mule/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mulesoft/mule/downloads","issues_url":"https://api.github.com/repos/mulesoft/mule/issues{/number}","pulls_url":"https://api.github.com/repos/mulesoft/mule/pulls{/number}","milestones_url":"https://api.github.com/repos/mulesoft/mule/milestones{/number}","notifications_url":"https://api.github.com/repos/mulesoft/mule/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mulesoft/mule/labels{/name}","releases_url":"https://api.github.com/repos/mulesoft/mule/releases{/id}","deployments_url":"https://api.github.com/repos/mulesoft/mule/deployments","created_at":"2012-12-07T19:23:06Z","updated_at":"2016-08-18T13:00:00Z","pushed_at":"2016-08-18T16:36:24Z","git_url":"git://github.com/mulesoft/mule.git","ssh_url":"git@github.com:mulesoft/mule.git","clone_url":"https://github.com/mulesoft/mule.git","svn_url":"https://github.com/mulesoft/mule","homepage":null,"size":265155,"stargazers_count":358,"watchers_count":358,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":371,"mirror_url":null,"open_issues_count":22,"forks":371,"open_issues":22,"watchers":358,"default_branch":"mule-4.x"}},"_links":{"self":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/3143"},"html":{"href":"https://github.com/mulesoft/mule/pull/3143"},"issue":{"href":"https://api.github.com/repos/mulesoft/mule/issues/3143"},"comments":{"href":"https://api.github.com/repos/mulesoft/mule/issues/3143/comments"},"review_comments":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/3143/comments"},"review_comment":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/3143/commits"},"statuses":{"href":"https://api.github.com/repos/mulesoft/mule/statuses/78fb356c37cf9e782ae96a240bdb3be7a4b4d222"}}}}
{"actor":{"display_login":"alegmarra"}}