[ 
https://issues.apache.org/jira/browse/GEODE-8043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17111407#comment-17111407
 ] 

ASF GitHub Bot commented on GEODE-8043:
---------------------------------------

kohlmu-pivotal commented on a change in pull request #5081:
URL: https://github.com/apache/geode/pull/5081#discussion_r427501647



##########
File path: geode-assembly/build.gradle
##########
@@ -577,6 +579,9 @@ distributions {
         from {project(':geode-core').tasks.named('raJar')}
         from {project(':geode-core').tasks.named('jcaJar')}
 
+        from project(':geode-modules').tasks.named('module1Jar')
+        from project(':geode-modules').tasks.named('module2Jar')

Review comment:
       I don't think it should exposed outside of the original module

##########
File path: 
geode-modules/src/main/java/org/apache/geode/services/module/impl/JBossModuleService.java
##########
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+
+package org.apache.geode.services.module.impl;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.JarFile;
+
+import org.apache.logging.log4j.Logger;
+import org.jboss.modules.LocalDependencySpecBuilder;
+import org.jboss.modules.Module;
+import org.jboss.modules.ModuleDependencySpecBuilder;
+import org.jboss.modules.ModuleLoadException;
+import org.jboss.modules.ModuleSpec;
+import org.jboss.modules.ResourceLoader;
+import org.jboss.modules.ResourceLoaderSpec;
+import org.jboss.modules.ResourceLoaders;
+import org.jboss.modules.Version;
+
+import org.apache.geode.annotations.Experimental;
+import org.apache.geode.logging.internal.log4j.api.LogService;
+import org.apache.geode.services.module.ModuleDescriptor;
+import org.apache.geode.services.module.ModuleService;
+
+/**
+ * Implementation of {@link ModuleService} using JBoss-Modules.
+ */
+@Experimental
+public class JBossModuleService implements ModuleService {
+
+  private final Map<String, Module> modules = new HashMap<>();
+
+  private final GeodeModuleLoader moduleLoader = new GeodeModuleLoader();
+
+  private final Logger logger;
+
+  public JBossModuleService() {
+    this(LogService.getLogger());
+  }
+
+  public JBossModuleService(Logger logger) {
+    this.logger = logger;
+  }
+
+  public Module getModule(String name) {
+    return modules.get(name);
+  }
+
+  @Override
+  public boolean loadModule(ModuleDescriptor moduleDescriptor) {
+    logger.debug(String.format("Beginning to load module %s", 
moduleDescriptor.getVersionedName()));
+
+    if (modules.containsKey(moduleDescriptor.getVersionedName())) {
+      logger
+          .warn(String.format("Module %s is already loaded.", 
moduleDescriptor.getVersionedName()));
+      return false;
+    }
+
+    ModuleSpec.Builder builder = 
ModuleSpec.build(moduleDescriptor.getVersionedName());
+    builder.setVersion(Version.parse(moduleDescriptor.getVersion()));
+    builder.addDependency(new LocalDependencySpecBuilder()
+        .setImportServices(true)
+        .setExport(true)
+        .build());
+
+    moduleDescriptor.getDependedOnModules().forEach(dependency -> {
+      logger.debug(String.format("Adding dependency on module %s", 
dependency));
+      builder.addDependency(new ModuleDependencySpecBuilder()
+          .setName(dependency)
+          .build());
+    });
+
+    try {
+      for (String source : moduleDescriptor.getSources()) {
+        logger.debug(String.format("Adding resource %s to module", source));
+        ResourceLoader resourceLoader =
+            ResourceLoaders.createJarResourceLoader(new JarFile(source));
+        
builder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec(resourceLoader));
+      }
+    } catch (IOException e) {
+      logger.error(e);
+      return false;
+    }
+
+    ModuleSpec moduleSpec = builder.create();
+    moduleLoader.addModuleSpec(moduleSpec);
+
+    try {
+      modules.put(moduleDescriptor.getVersionedName(),
+          moduleLoader.loadModule(moduleSpec.getName()));
+    } catch (ModuleLoadException e) {
+      logger.error(e);
+      return false;
+    }
+
+    logger
+        .debug(String.format("Module %s successfully loaded", 
moduleDescriptor.getVersionedName()));
+
+    return true;
+  }
+
+  @Override
+  public boolean unloadModule(String moduleName) {
+    return false;
+  }
+
+  @Override
+  public <T> List<T> loadService(Class<T> service) {
+    return null;
+  }
+
+  @Override
+  public <T> List<T> loadService(String serviceName) {
+    return null;
+  }
+
+  @Override
+  public boolean unloadService(String serviceName) {
+    return false;
+  }

Review comment:
       possibly we need to remove these add them into their respective JIRA

##########
File path: geode-assembly/src/integrationTest/resources/expected_jars.txt
##########
@@ -75,6 +76,8 @@ lucene-queries
 lucene-queryparser
 mapstruct
 micrometer-core
+module1.jar
+module2.jar

Review comment:
       why are these showing up here?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Create JBoss-Modules ModuleService Implementation - loadModule
> --------------------------------------------------------------
>
>                 Key: GEODE-8043
>                 URL: https://issues.apache.org/jira/browse/GEODE-8043
>             Project: Geode
>          Issue Type: Sub-task
>            Reporter: Patrick Johnsn
>            Assignee: Patrick Johnsn
>            Priority: Major
>
> Implement the loadModule method of the ModuleService interface using 
> JBoss-Modules.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to