Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
1b446529
Commit
1b446529
authored
Nov 02, 2015
by
wmz7year
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix PluginClassloader not implement getResources Method
Hazelcast plugin work fine.
parent
ee30e18c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
1 deletion
+57
-1
PluginClassLoader.java
...rg/jivesoftware/openfire/container/PluginClassLoader.java
+57
-1
No files found.
src/java/org/jivesoftware/openfire/container/PluginClassLoader.java
View file @
1b446529
...
@@ -36,9 +36,13 @@ import java.security.AccessControlException;
...
@@ -36,9 +36,13 @@ import java.security.AccessControlException;
import
java.security.CodeSource
;
import
java.security.CodeSource
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Enumeration
;
import
java.util.Enumeration
;
import
java.util.Iterator
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.jar.JarEntry
;
import
java.util.jar.JarEntry
;
import
java.util.jar.JarFile
;
import
java.util.jar.JarFile
;
...
@@ -58,6 +62,7 @@ import org.slf4j.LoggerFactory;
...
@@ -58,6 +62,7 @@ import org.slf4j.LoggerFactory;
* </ul>
* </ul>
*
*
* @author Derek DeMoro
* @author Derek DeMoro
* @author wmz7year
*/
*/
public
class
PluginClassLoader
extends
URLClassLoader
{
public
class
PluginClassLoader
extends
URLClassLoader
{
private
static
final
Logger
Log
=
LoggerFactory
.
getLogger
(
PluginClassLoader
.
class
);
private
static
final
Logger
Log
=
LoggerFactory
.
getLogger
(
PluginClassLoader
.
class
);
...
@@ -495,6 +500,46 @@ public class PluginClassLoader extends URLClassLoader {
...
@@ -495,6 +500,46 @@ public class PluginClassLoader extends URLClassLoader {
}
}
/**
* Return an enumeration of <code>URLs</code> representing all of the
* resources with the given name. If no resources with this name are found,
* return an empty enumeration.
*
* @param name
* Name of the resources to be found
*
* @exception IOException
* if an input/output error occurs
*/
public
Enumeration
<
URL
>
getResources
(
String
name
)
throws
IOException
{
if
(
Log
.
isDebugEnabled
())
Log
.
debug
(
" findResources("
+
name
+
")"
);
LinkedHashSet
<
URL
>
result
=
new
LinkedHashSet
<>();
String
path
=
nameToPath
(
name
);
// find local Classloader
Iterator
<
Entry
<
String
,
ResourceEntry
>>
iterator
=
resourceEntries
.
entrySet
().
iterator
();
while
(
iterator
.
hasNext
())
{
Entry
<
String
,
ResourceEntry
>
resource
=
iterator
.
next
();
String
loadedResourceName
=
resource
.
getKey
();
if
(
loadedResourceName
.
endsWith
(
path
))
{
// path to name
loadedResourceName
=
pathToName
(
loadedResourceName
);
result
.
add
(
findResource
(
loadedResourceName
));
}
}
// find from parent Classloader
Enumeration
<
URL
>
parentResources
=
super
.
getResources
(
name
);
while
(
parentResources
.
hasMoreElements
())
{
result
.
add
(
parentResources
.
nextElement
());
}
return
Collections
.
enumeration
(
result
);
}
/**
/**
* Adds a directory to the class loader.
* Adds a directory to the class loader.
*
*
...
@@ -613,7 +658,7 @@ public class PluginClassLoader extends URLClassLoader {
...
@@ -613,7 +658,7 @@ public class PluginClassLoader extends URLClassLoader {
if
(
file
.
isDirectory
())
{
if
(
file
.
isDirectory
())
{
File
[]
files
=
file
.
listFiles
();
File
[]
files
=
file
.
listFiles
();
for
(
File
temp
:
files
)
{
for
(
File
temp
:
files
)
{
if
(
temp
.
isDirectory
())
{
if
(
temp
.
isDirectory
())
{
parent
=
String
.
format
(
"%s%s/"
,
parent
,
temp
.
getName
());
parent
=
String
.
format
(
"%s%s/"
,
parent
,
temp
.
getName
());
}
}
addResource
(
temp
.
toURI
().
toURL
(),
parent
);
addResource
(
temp
.
toURI
().
toURL
(),
parent
);
...
@@ -666,6 +711,7 @@ public class PluginClassLoader extends URLClassLoader {
...
@@ -666,6 +711,7 @@ public class PluginClassLoader extends URLClassLoader {
entry
.
lastModified
=
jarEntry
.
getTime
();
entry
.
lastModified
=
jarEntry
.
getTime
();
entry
.
binaryContent
=
readBytes
(
jarFile
.
getInputStream
(
jarEntry
));
entry
.
binaryContent
=
readBytes
(
jarFile
.
getInputStream
(
jarEntry
));
entry
.
codeBase
=
codebase
;
entry
.
codeBase
=
codebase
;
entry
.
source
=
new
URL
(
codebase
+
jarEntry
.
getName
());
if
(
Log
.
isDebugEnabled
())
if
(
Log
.
isDebugEnabled
())
Log
.
debug
(
"add resource path:/"
+
jarEntry
.
getName
());
Log
.
debug
(
"add resource path:/"
+
jarEntry
.
getName
());
resourceEntries
.
put
(
"/"
+
jarEntry
.
getName
(),
entry
);
resourceEntries
.
put
(
"/"
+
jarEntry
.
getName
(),
entry
);
...
@@ -708,6 +754,16 @@ public class PluginClassLoader extends URLClassLoader {
...
@@ -708,6 +754,16 @@ public class PluginClassLoader extends URLClassLoader {
return
path
.
toString
();
return
path
.
toString
();
}
}
private
String
pathToName
(
String
path
)
{
if
(
path
.
length
()
<=
1
)
{
throw
new
IllegalStateException
(
path
);
}
if
(!
path
.
startsWith
(
"/"
))
{
return
path
;
}
return
path
.
substring
(
1
,
path
.
length
());
}
/**
/**
* Locates the best parent class loader based on context.
* Locates the best parent class loader based on context.
*
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment