Skip to content

Commit

Permalink
Fix nar extract directory
Browse files Browse the repository at this point in the history
  • Loading branch information
codelipenghui committed Jun 2, 2020
1 parent 0e069fd commit e848d25
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public class BrokerEventListenerUtils {
* @return the broker listener definition
* @throws IOException when fail to load the broker listener or get the definition
*/
public static BrokerEventListenerDefinition getBrokerListenerDefinition(String narPath) throws IOException {
try (NarClassLoader ncl = NarClassLoader.getFromArchive(new File(narPath), Collections.emptySet())) {
public static BrokerEventListenerDefinition getBrokerListenerDefinition(String narPath, String narExtractionDirectory) throws IOException {
try (NarClassLoader ncl = NarClassLoader.getFromArchive(new File(narPath), Collections.emptySet(), narExtractionDirectory)) {
return getBrokerListenerDefinition(ncl);
}
}
Expand All @@ -71,7 +71,7 @@ private static BrokerEventListenerDefinition getBrokerListenerDefinition(NarClas
* @return a collection of broker listeners
* @throws IOException when fail to load the available broker listeners from the provided directory.
*/
public static BrokerEventListenerDefinitions searchForListeners(String listenersDirectory) throws IOException {
public static BrokerEventListenerDefinitions searchForListeners(String listenersDirectory, String narExtractionDirectory) throws IOException {
Path path = Paths.get(listenersDirectory).toAbsolutePath();
log.info("Searching for broker listeners in {}", path);

Expand All @@ -85,7 +85,7 @@ public static BrokerEventListenerDefinitions searchForListeners(String listeners
for (Path archive : stream) {
try {
BrokerEventListenerDefinition def =
BrokerEventListenerUtils.getBrokerListenerDefinition(archive.toString());
BrokerEventListenerUtils.getBrokerListenerDefinition(archive.toString(), narExtractionDirectory);
log.info("Found broker listeners from {} : {}", archive, def);

checkArgument(StringUtils.isNotBlank(def.getName()));
Expand Down Expand Up @@ -114,11 +114,11 @@ public static BrokerEventListenerDefinitions searchForListeners(String listeners
* @param metadata the broker listeners definition.
* @return
*/
static SafeBrokerEventListenerWithClassLoader load(BrokerEventListenerMetadata metadata) throws IOException {
static SafeBrokerEventListenerWithClassLoader load(BrokerEventListenerMetadata metadata, String narExtractionDirectory) throws IOException {
NarClassLoader ncl = NarClassLoader.getFromArchive(
metadata.getArchivePath().toAbsolutePath().toFile(),
Collections.emptySet(),
BrokerEventListener.class.getClassLoader());
BrokerEventListener.class.getClassLoader(), narExtractionDirectory);

BrokerEventListenerDefinition def = getBrokerListenerDefinition(ncl);
if (StringUtils.isBlank(def.getListenerClass())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void close() {
*/
public static BrokerEventListeners load(ServiceConfiguration conf) throws IOException {
BrokerEventListenerDefinitions definitions =
BrokerEventListenerUtils.searchForListeners(conf.getBrokerListenersDirectory());
BrokerEventListenerUtils.searchForListeners(conf.getBrokerListenersDirectory(), conf.getNarExtractionDirectory());

ImmutableMap.Builder<String, SafeBrokerEventListenerWithClassLoader> builder = ImmutableMap.builder();

Expand All @@ -99,7 +99,7 @@ public static BrokerEventListeners load(ServiceConfiguration conf) throws IOExce

SafeBrokerEventListenerWithClassLoader listener;
try {
listener = BrokerEventListenerUtils.load(definition);
listener = BrokerEventListenerUtils.load(definition, conf.getNarExtractionDirectory());
if (listener != null) {
builder.put(listenerName, listener);
}
Expand Down

0 comments on commit e848d25

Please sign in to comment.