[jboss-cvs] JBossAS SVN: r86652 - projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Apr 2 06:36:04 EDT 2009
Author: alesj
Date: 2009-04-02 06:36:03 -0400 (Thu, 02 Apr 2009)
New Revision: 86652
Added:
projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/ModuleRegistry.java
Modified:
projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/ClassLoading.java
Log:
[JBCL-96]; add ModuleRegistry.
Modified: projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/ClassLoading.java
===================================================================
--- projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/ClassLoading.java 2009-04-02 10:12:05 UTC (rev 86651)
+++ projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/ClassLoading.java 2009-04-02 10:36:03 UTC (rev 86652)
@@ -21,6 +21,7 @@
*/
package org.jboss.classloading.spi.dependency;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -28,27 +29,36 @@
import org.jboss.classloader.spi.ClassLoaderSystem;
import org.jboss.classloading.spi.metadata.Capability;
+import org.jboss.logging.Logger;
import org.jboss.util.collection.ConcurrentSet;
/**
* ClassLoading.
*
* @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
* @version $Revision: 1.1 $
*/
public class ClassLoading
{
+ /** The log */
+ private static final Logger log = Logger.getLogger(ClassLoading.class);
+
/** An empty default domain */
private Domain EMPTY_DOMAIN = new Domain(this, ClassLoaderSystem.DEFAULT_DOMAIN_NAME, null, true);
/** The classloading domains by name */
- private Map<String, Domain> domains = new ConcurrentHashMap<String, Domain>();
-
+ private final Map<String, Domain> domains = new ConcurrentHashMap<String, Domain>();
+
+ /** The global capabilities provider */
private final Set<GlobalCapabilitiesProvider> globalCapabilitiesProviders = new ConcurrentSet<GlobalCapabilitiesProvider>();
-
+
+ /** The module registries */
+ private final Set<ModuleRegistry> moduleRegistries = new ConcurrentSet<ModuleRegistry>();
+
/**
* Add a module
- *
+ *
* @param module the module
* @throws IllegalArgumentException for a null module
*/
@@ -62,6 +72,31 @@
String parentDomainName = module.getDeterminedParentDomainName();
Domain domain = getDomain(domainName, parentDomainName, parentFirst);
domain.addModule(module);
+
+ Set<ModuleRegistry> added = new HashSet<ModuleRegistry>();
+ try
+ {
+ for (ModuleRegistry mr : moduleRegistries)
+ {
+ mr.addModule(module);
+ added.add(mr);
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("Exception while registering module: " + e);
+
+ for (ModuleRegistry mr : added)
+ {
+ try
+ {
+ mr.removeModule(module);
+ }
+ catch (Exception ignored)
+ {
+ }
+ }
+ }
}
/**
@@ -74,6 +109,19 @@
{
if (module == null)
throw new IllegalArgumentException("Null module");
+
+ for (ModuleRegistry mr : moduleRegistries)
+ {
+ try
+ {
+ mr.removeModule(module);
+ }
+ catch (Exception e)
+ {
+ log.warn("Exception unregistering module, registry: " + mr + ", cause: " + e);
+ }
+ }
+
module.release();
}
@@ -211,4 +259,26 @@
}
return capabilities;
}
+
+ /**
+ * Add module registry.
+ *
+ * @param moduleRegistry the module registry
+ * @return see Set#add
+ */
+ public boolean addModuleRegistry(ModuleRegistry moduleRegistry)
+ {
+ return moduleRegistries.add(moduleRegistry);
+ }
+
+ /**
+ * Add module registry.
+ *
+ * @param moduleRegistry the module registry
+ * @return see Set#remove
+ */
+ public boolean removeModuleRegistry(ModuleRegistry moduleRegistry)
+ {
+ return moduleRegistries.remove(moduleRegistry);
+ }
}
Added: projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/ModuleRegistry.java
===================================================================
--- projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/ModuleRegistry.java (rev 0)
+++ projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/ModuleRegistry.java 2009-04-02 10:36:03 UTC (rev 86652)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.classloading.spi.dependency;
+
+/**
+ * Track Module instances.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface ModuleRegistry
+{
+ /**
+ * Add the module.
+ *
+ * @param module the module
+ */
+ void addModule(Module module);
+
+ /**
+ * Remove module.
+ *
+ * @param module the module
+ */
+ void removeModule(Module module);
+}
More information about the jboss-cvs-commits
mailing list