1 package com.atlassian.plugin;
2
3 import java.io.File;
4 import java.net.URI;
5
6
7
8
9
10
11 public class DefaultPluginArtifactFactory implements PluginArtifactFactory
12 {
13
14
15
16
17
18
19
20 public PluginArtifact create(URI artifactUri)
21 {
22 PluginArtifact artifact = null;
23
24 String protocol = artifactUri.getScheme();
25
26 if ("file".equalsIgnoreCase(protocol))
27 {
28 File artifactFile = new File(artifactUri);
29
30 String file = artifactFile.getName();
31 if (file.endsWith(".jar"))
32 artifact = new JarPluginArtifact(artifactFile);
33 else if (file.endsWith(".xml"))
34 artifact = new XmlPluginArtifact(artifactFile);
35 }
36
37 if (artifact == null)
38 throw new IllegalArgumentException("The artifact URI " + artifactUri + " is not a valid plugin artifact");
39
40 return artifact;
41 }
42 }