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
7a7db14a
Commit
7a7db14a
authored
Oct 30, 2015
by
Dave Cridland
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #342 from wmz7year/PluginClassLoader
Fix PluginClassLoader load resource path issue
parents
32b85e8e
ee30e18c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
PluginClassLoader.java
...rg/jivesoftware/openfire/container/PluginClassLoader.java
+17
-11
No files found.
src/java/org/jivesoftware/openfire/container/PluginClassLoader.java
View file @
7a7db14a
...
@@ -510,25 +510,25 @@ public class PluginClassLoader extends URLClassLoader {
...
@@ -510,25 +510,25 @@ public class PluginClassLoader extends URLClassLoader {
// Add classes directory to classpath.
// Add classes directory to classpath.
File
classesDir
=
new
File
(
directory
,
"classes"
);
File
classesDir
=
new
File
(
directory
,
"classes"
);
if
(
classesDir
.
exists
())
{
if
(
classesDir
.
exists
())
{
addResource
(
classesDir
.
toURI
().
toURL
());
addResource
(
classesDir
.
toURI
().
toURL
()
,
"/"
);
}
}
// Add i18n directory to classpath.
// Add i18n directory to classpath.
File
databaseDir
=
new
File
(
directory
,
"database"
);
File
databaseDir
=
new
File
(
directory
,
"database"
);
if
(
databaseDir
.
exists
())
{
if
(
databaseDir
.
exists
())
{
addResource
(
databaseDir
.
toURI
().
toURL
());
addResource
(
databaseDir
.
toURI
().
toURL
()
,
"/"
);
}
}
// Add i18n directory to classpath.
// Add i18n directory to classpath.
File
i18nDir
=
new
File
(
directory
,
"i18n"
);
File
i18nDir
=
new
File
(
directory
,
"i18n"
);
if
(
i18nDir
.
exists
())
{
if
(
i18nDir
.
exists
())
{
addResource
(
i18nDir
.
toURI
().
toURL
());
addResource
(
i18nDir
.
toURI
().
toURL
()
,
"/"
);
}
}
// Add web directory to classpath.
// Add web directory to classpath.
File
webDir
=
new
File
(
directory
,
"web"
);
File
webDir
=
new
File
(
directory
,
"web"
);
if
(
webDir
.
exists
())
{
if
(
webDir
.
exists
())
{
addResource
(
webDir
.
toURI
().
toURL
());
addResource
(
webDir
.
toURI
().
toURL
()
,
"/"
);
}
}
// Add lib directory to classpath.
// Add lib directory to classpath.
...
@@ -545,10 +545,10 @@ public class PluginClassLoader extends URLClassLoader {
...
@@ -545,10 +545,10 @@ public class PluginClassLoader extends URLClassLoader {
if
(
developmentMode
)
{
if
(
developmentMode
)
{
// Do not add plugin-pluginName.jar to classpath.
// Do not add plugin-pluginName.jar to classpath.
if
(!
jars
[
i
].
getName
().
equals
(
"plugin-"
+
directory
.
getName
()
+
".jar"
))
{
if
(!
jars
[
i
].
getName
().
equals
(
"plugin-"
+
directory
.
getName
()
+
".jar"
))
{
addResource
(
new
URL
(
"jar"
,
""
,
-
1
,
jarFileUri
));
addResource
(
new
URL
(
"jar"
,
""
,
-
1
,
jarFileUri
)
,
"/"
);
}
}
}
else
{
}
else
{
addResource
(
new
URL
(
"jar"
,
""
,
-
1
,
jarFileUri
));
addResource
(
new
URL
(
"jar"
,
""
,
-
1
,
jarFileUri
)
,
"/"
);
}
}
}
}
}
}
...
@@ -596,7 +596,7 @@ public class PluginClassLoader extends URLClassLoader {
...
@@ -596,7 +596,7 @@ public class PluginClassLoader extends URLClassLoader {
* URL for the JAR file or directory to append to classpath
* URL for the JAR file or directory to append to classpath
*/
*/
public
void
addURLFile
(
URL
file
)
{
public
void
addURLFile
(
URL
file
)
{
addResource
(
file
);
addResource
(
file
,
"/"
);
}
}
/**
/**
...
@@ -606,14 +606,17 @@ public class PluginClassLoader extends URLClassLoader {
...
@@ -606,14 +606,17 @@ public class PluginClassLoader extends URLClassLoader {
resourceEntries
.
clear
();
resourceEntries
.
clear
();
}
}
private
void
addResource
(
URL
url
)
{
private
void
addResource
(
URL
url
,
String
parent
)
{
// check file is directory and list files
// check file is directory and list files
try
{
try
{
File
file
=
new
File
(
url
.
toURI
());
File
file
=
new
File
(
url
.
toURI
());
if
(
file
.
isDirectory
())
{
if
(
file
.
isDirectory
())
{
File
[]
files
=
file
.
listFiles
();
File
[]
files
=
file
.
listFiles
();
for
(
File
temp
:
files
)
{
for
(
File
temp
:
files
)
{
addResource
(
temp
.
toURI
().
toURL
());
if
(
temp
.
isDirectory
()){
parent
=
String
.
format
(
"%s%s/"
,
parent
,
temp
.
getName
());
}
addResource
(
temp
.
toURI
().
toURL
(),
parent
);
}
}
return
;
return
;
}
}
...
@@ -638,8 +641,9 @@ public class PluginClassLoader extends URLClassLoader {
...
@@ -638,8 +641,9 @@ public class PluginClassLoader extends URLClassLoader {
entry
.
codeBase
=
url
;
entry
.
codeBase
=
url
;
entry
.
lastModified
=
file
.
lastModified
();
entry
.
lastModified
=
file
.
lastModified
();
entry
.
binaryContent
=
readBytes
(
new
FileInputStream
(
file
));
entry
.
binaryContent
=
readBytes
(
new
FileInputStream
(
file
));
if
(
Log
.
isDebugEnabled
())
resourceEntries
.
put
(
"/"
+
file
.
getName
(),
entry
);
Log
.
debug
(
"add resource path:"
+
parent
+
file
.
getName
());
resourceEntries
.
put
(
parent
+
file
.
getName
(),
entry
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
Log
.
warn
(
"Failed to load plugin resource: "
+
url
.
toExternalForm
());
Log
.
warn
(
"Failed to load plugin resource: "
+
url
.
toExternalForm
());
...
@@ -662,6 +666,8 @@ public class PluginClassLoader extends URLClassLoader {
...
@@ -662,6 +666,8 @@ 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
;
if
(
Log
.
isDebugEnabled
())
Log
.
debug
(
"add resource path:/"
+
jarEntry
.
getName
());
resourceEntries
.
put
(
"/"
+
jarEntry
.
getName
(),
entry
);
resourceEntries
.
put
(
"/"
+
jarEntry
.
getName
(),
entry
);
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
...
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