Skip to content
Browse files

Cleanup.

  • Loading branch information...
1 parent ea2a92f commit 77276434e9543ccc09fc00f557da31f4b084be25 @alesj alesj committed Mar 7, 2013
View
34 impl/src/main/java/ceylon/modules/jboss/runtime/CeylonModuleLoader.java
@@ -25,6 +25,14 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import ceylon.modules.api.util.ModuleVersion;
+import ceylon.modules.jboss.repository.ResourceLoaderProvider;
+import com.redhat.ceylon.cmr.api.ArtifactContext;
+import com.redhat.ceylon.cmr.api.ArtifactResult;
+import com.redhat.ceylon.cmr.api.ImportType;
+import com.redhat.ceylon.cmr.api.JDKUtils;
+import com.redhat.ceylon.cmr.api.RepositoryManager;
+import com.redhat.ceylon.common.Versions;
import org.jboss.modules.DependencySpec;
import org.jboss.modules.LocalLoader;
import org.jboss.modules.ModuleIdentifier;
@@ -35,16 +43,6 @@
import org.jboss.modules.ResourceLoaderSpec;
import org.jboss.modules.filter.PathFilters;
-import ceylon.modules.api.util.ModuleVersion;
-import ceylon.modules.jboss.repository.ResourceLoaderProvider;
-
-import com.redhat.ceylon.cmr.api.ArtifactContext;
-import com.redhat.ceylon.cmr.api.ArtifactResult;
-import com.redhat.ceylon.cmr.api.ImportType;
-import com.redhat.ceylon.cmr.api.JDKUtils;
-import com.redhat.ceylon.cmr.api.RepositoryManager;
-import com.redhat.ceylon.common.Versions;
-
/**
* Ceylon JBoss Module loader.
* It understands Ceylon repository notion.
@@ -229,20 +227,15 @@ protected ModuleSpec findModule(ModuleIdentifier moduleIdentifier) throws Module
builder.addDependency(lds); // local resources
deps.add(lds);
- // used moduleDependencies
- Set<String> moduleDependencies = new HashSet<String>();
-
if (isDefault == false) {
Node<ArtifactResult> root = new Node<ArtifactResult>();
for (ArtifactResult i : artifact.dependencies()) {
final String name = i.name();
-
+
// skip JDK modules
- if(JDK_MODULE_NAMES.contains(name)) {
+ if (JDK_MODULE_NAMES.contains(name)) {
continue;
}
-
- moduleDependencies.add(name); // track used module dependencies
if (i.importType() == ImportType.OPTIONAL) {
Node<ArtifactResult> current = root;
@@ -269,10 +262,9 @@ protected ModuleSpec findModule(ModuleIdentifier moduleIdentifier) throws Module
builder.setFallbackLoader(onDemandLoader);
}
}
-
+
// automagically import the JDK module
- DependencySpec mds = JDK_DEPENDENCY;
- builder.addDependency(mds);
+ builder.addDependency(JDK_DEPENDENCY);
// no need to track system deps -- cannot be updated anyway
createModuleDependency(vertex, deps, builder, LANGUAGE, false);
@@ -292,7 +284,7 @@ protected ModuleSpec findModule(ModuleIdentifier moduleIdentifier) throws Module
dependencies.put(moduleIdentifier, deps);
- builder.setClassFileTransformer(new UtilRegistryTransformer(moduleIdentifier, artifact, RUNTIME));
+ builder.setClassFileTransformer(new UtilRegistryTransformer(moduleIdentifier, artifact));
return builder.create();
} catch (Exception e) {
View
37 impl/src/main/java/ceylon/modules/jboss/runtime/UtilRegistryTransformer.java
@@ -22,10 +22,7 @@
import com.redhat.ceylon.cmr.api.ArtifactResult;
import com.redhat.ceylon.cmr.api.RepositoryManager;
-
-import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
-import org.jboss.modules.ModuleLoadException;
/**
* Per module Util registry.
@@ -42,47 +39,17 @@
private final ModuleIdentifier mi;
private final ArtifactResult result;
- private ModuleIdentifier runtime;
-
- public UtilRegistryTransformer(ModuleIdentifier mi, ArtifactResult result, ModuleIdentifier runtime) {
+ public UtilRegistryTransformer(ModuleIdentifier mi, ArtifactResult result) {
this.mi = mi;
this.result = result;
- this.runtime = runtime;
}
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
if (done == false) {
synchronized (this) {
if (done == false) {
done = true;
- ClassLoader runtimeClassLoader = null;
- try {
- Module runtimeModule = org.jboss.modules.Module.getBootModuleLoader().loadModule(runtime);
- runtimeClassLoader = runtimeModule.getClassLoader();
- } catch (ModuleLoadException e) {
- e.printStackTrace();
- }
- ClassLoader oldClassLoader = null;
- boolean setClassLoader = false;
- if(runtimeClassLoader != null){
- try {
- oldClassLoader = SecurityActions.setContextClassLoader(runtimeClassLoader);
- setClassLoader = true;
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- try{
- registerModule(mi.getName(), mi.getSlot(), result, loader);
- }finally{
- if(setClassLoader){
- try {
- SecurityActions.setContextClassLoader(oldClassLoader);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
+ registerModule(mi.getName(), mi.getSlot(), result, loader);
}
}
}

0 comments on commit 7727643

Please sign in to comment.
Something went wrong with that request. Please try again.