Skip to content
This repository has been archived by the owner on Jul 7, 2020. It is now read-only.

Dynamic loader implementation #27

Merged
merged 3 commits into from
Feb 27, 2014

Conversation

mspiegel
Copy link
Contributor

This is an alternate proposal for #24. Dynamic class loading is specified with the command-line option -Dhydra.loader=[URI to configuration]. The configuration file is a CSV formatted file. Each row must have either two columns or four columns.

A row with two columns has the format:

[fully qualified class name], [URI to jar with with class].

A row with four columns has the format:

[fully qualified class name], [URI to jar with with class], "executable", [name of executable]

I have tested the four column format by creating a jar that contained a class HelloWorld with a static main() method that prints out "Hello World". In my configuration file I specified:

"HelloWorld", "file:///path/to/archive.jar", "executable", "task"

By running on the command line the following command:

java -Dhydra.loader=file:///path/to/hydra.conf -jar hydra-uber/target/hydra-uber-4.1.3-SNAPSHOT-exec.jar task

I was able to print out "hello world" instead of running a hydra task. Hooray for class injection.

I have not tested the two column version of this implementation. The Codec library is not designed to load classes from alternate class loaders. The same deficiancy applies to the original proposal #24. It is outside of scope to fix that bug. This proposal is only for executable classes and we can address the Codec issue at a later time.

Michael Spiegel added 2 commits February 12, 2014 10:40
…, then

Class#forName(String) will not be able to find that class when called from
a class that uses the default loader.
string ("") in 2nd column of the csv file to avoid the need
to type out duplicate JAR locations.
@mspiegel
Copy link
Contributor Author

You can now specify the empty string for the second column if you don't want to type out the URL to the external jar on multiple rows:

[fully qualified class name], "", "executable", [name of executable]

@stewartoallen
Copy link
Contributor

i have not tried this yet. is it in theory possible to extend PathElements and TreeData? can i do this through code alone or do i need to inject classmap spring files?

@mspiegel
Copy link
Contributor Author

I think it is possible to extend classes that are found in hydra.

@mspiegel
Copy link
Contributor Author

Merging this pull request. We can revise it later if it is inadequate.

mspiegel added a commit that referenced this pull request Feb 27, 2014
@mspiegel mspiegel merged commit 8bfbdd8 into addthis:master Feb 27, 2014
@mspiegel mspiegel deleted the dynamic-loader-merge branch February 27, 2014 19:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants