1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.render.groovy; |
21 |
|
|
22 |
|
import java.net.URL; |
23 |
|
import java.net.URLClassLoader; |
24 |
|
import java.net.URLStreamHandlerFactory; |
25 |
|
import java.util.List; |
26 |
|
|
27 |
|
import org.slf4j.Logger; |
28 |
|
import org.slf4j.LoggerFactory; |
29 |
|
|
30 |
|
import com.xpn.xwiki.XWikiContext; |
31 |
|
import com.xpn.xwiki.XWikiException; |
32 |
|
import com.xpn.xwiki.doc.XWikiAttachment; |
33 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
34 |
|
|
|
|
| 0% |
Uncovered Elements: 31 (31) |
Complexity: 10 |
Complexity Density: 0.56 |
|
35 |
|
public class XWikiPageClassLoader extends URLClassLoader |
36 |
|
{ |
37 |
|
private static final Logger LOGGER = LoggerFactory.getLogger(XWikiPageClassLoader.class); |
38 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
39 |
0 |
public XWikiPageClassLoader(URL[] urls, ClassLoader parent)... |
40 |
|
{ |
41 |
0 |
super(urls, parent); |
42 |
|
} |
43 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
44 |
0 |
public XWikiPageClassLoader(URL[] urls)... |
45 |
|
{ |
46 |
0 |
super(urls); |
47 |
|
} |
48 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
49 |
0 |
public XWikiPageClassLoader(URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory)... |
50 |
|
{ |
51 |
0 |
super(urls, parent, factory); |
52 |
|
} |
53 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
54 |
0 |
public XWikiPageClassLoader(String jarWikiPage, XWikiContext context) throws XWikiException... |
55 |
|
{ |
56 |
0 |
this(jarWikiPage, Thread.currentThread().getContextClassLoader(), context); |
57 |
|
} |
58 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 6 |
Complexity Density: 0.43 |
|
59 |
0 |
public XWikiPageClassLoader(String jarWikiPage, ClassLoader parent, XWikiContext context) throws XWikiException... |
60 |
|
{ |
61 |
0 |
super(new URL[0], parent); |
62 |
|
|
63 |
0 |
XWikiDocument doc = context.getWiki().getDocument(jarWikiPage, context); |
64 |
0 |
if (!doc.isNew()) { |
65 |
0 |
List attachList = doc.getAttachmentList(); |
66 |
0 |
for (int i = 0; i < attachList.size(); i++) { |
67 |
0 |
XWikiAttachment attach = (XWikiAttachment) attachList.get(i); |
68 |
0 |
String filename = attach.getFilename(); |
69 |
0 |
if (filename.endsWith(".jar")) { |
70 |
0 |
String downloadURL = doc.getExternalAttachmentURL(filename, "download", context); |
71 |
0 |
try { |
72 |
0 |
addURL(new URL(downloadURL)); |
73 |
0 |
if (LOGGER.isDebugEnabled()) { |
74 |
0 |
LOGGER.debug("Adding [" + downloadURL + "] JAR from page [" + jarWikiPage |
75 |
|
+ "] to Groovy classloader"); |
76 |
|
} |
77 |
|
} catch (Exception e) { |
78 |
0 |
LOGGER.warn("Failed to add [" + downloadURL + "] JAR from page [" + jarWikiPage |
79 |
|
+ "], ignoring it."); |
80 |
|
} |
81 |
|
} |
82 |
|
} |
83 |
|
} |
84 |
|
} |
85 |
|
} |