-
Notifications
You must be signed in to change notification settings - Fork 864
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use ServiceLoader to load RegExp and XML implementations
Use ServiceLoader to load RegExp and XML implementations This is a more modern way than just classloading and could allow for some more flexibility in the future.
- Loading branch information
Showing
9 changed files
with
80 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
module org.mozilla.javascript.xml { | ||
exports org.mozilla.javascript.xmlimpl; | ||
|
||
provides org.mozilla.javascript.xml.XMLLoader with | ||
org.mozilla.javascript.xmlimpl.XMLLoaderImpl; | ||
|
||
requires transitive org.mozilla.rhino; | ||
requires transitive java.xml; | ||
} |
22 changes: 22 additions & 0 deletions
22
rhino-xml/src/main/java/org/mozilla/javascript/xmlimpl/XMLLoaderImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.mozilla.javascript.xmlimpl; | ||
|
||
import org.mozilla.javascript.LazilyLoadedCtor; | ||
import org.mozilla.javascript.ScriptableObject; | ||
import org.mozilla.javascript.xml.XMLLib; | ||
import org.mozilla.javascript.xml.XMLLoader; | ||
|
||
public class XMLLoaderImpl implements XMLLoader { | ||
@Override | ||
public void load(ScriptableObject scope, boolean sealed) { | ||
String implClass = XMLLibImpl.class.getName(); | ||
new LazilyLoadedCtor(scope, "XML", implClass, sealed, true); | ||
new LazilyLoadedCtor(scope, "XMLList", implClass, sealed, true); | ||
new LazilyLoadedCtor(scope, "Namespace", implClass, sealed, true); | ||
new LazilyLoadedCtor(scope, "QName", implClass, sealed, true); | ||
} | ||
|
||
@Override | ||
public XMLLib.Factory getFactory() { | ||
return XMLLib.Factory.create(XMLLibImpl.class.getName()); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
rhino-xml/src/main/resources/META-INF/services/org.mozilla.javascript.xml.XMLLoader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.mozilla.javascript.xmlimpl.XMLLoaderImpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
rhino/src/main/java/org/mozilla/javascript/xml/XMLLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.mozilla.javascript.xml; | ||
|
||
import org.mozilla.javascript.ScriptableObject; | ||
|
||
/** This interface is used to load the XML implementation using the ServiceLoader pattern. */ | ||
public interface XMLLoader { | ||
void load(ScriptableObject scope, boolean sealed); | ||
|
||
XMLLib.Factory getFactory(); | ||
} |
1 change: 1 addition & 0 deletions
1
rhino/src/main/resources/META-INF/services/org.mozilla.javascript.RegExpProxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.mozilla.javascript.regexp.RegExpImpl |