[jboss-cvs] JBossAS SVN: r66318 - in projects/aop/trunk/asintegration/src/main/org/jboss/aop: asintegration/jboss5 and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Oct 20 11:24:28 EDT 2007
Author: kabir.khan at jboss.com
Date: 2007-10-20 11:24:28 -0400 (Sat, 20 Oct 2007)
New Revision: 66318
Added:
projects/aop/trunk/asintegration/src/main/org/jboss/aop/domain/DomainInitializer.java
projects/aop/trunk/asintegration/src/main/org/jboss/aop/domain/DomainInitializerCallback.java
projects/aop/trunk/asintegration/src/main/org/jboss/aop/domain/DomainInitializerCallbackHandler.java
Removed:
projects/aop/trunk/asintegration/src/main/org/jboss/aop/domain/NewClassLoaderDomainInitializer.java
projects/aop/trunk/asintegration/src/main/org/jboss/aop/domain/RepositoryClassLoaderDomainIntializer.java
Modified:
projects/aop/trunk/asintegration/src/main/org/jboss/aop/asintegration/jboss4/RepositoryClassLoaderScopingPolicy.java
projects/aop/trunk/asintegration/src/main/org/jboss/aop/asintegration/jboss5/NewClassLoaderScopingPolicy.java
projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/AspectDeployer.java
Log:
[JBAOP-409] Redo how we pass in the required data to initialise domains in the policy
Modified: projects/aop/trunk/asintegration/src/main/org/jboss/aop/asintegration/jboss4/RepositoryClassLoaderScopingPolicy.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/asintegration/jboss4/RepositoryClassLoaderScopingPolicy.java 2007-10-20 12:43:41 UTC (rev 66317)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/asintegration/jboss4/RepositoryClassLoaderScopingPolicy.java 2007-10-20 15:24:28 UTC (rev 66318)
@@ -28,7 +28,9 @@
import org.jboss.aop.Domain;
import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
import org.jboss.aop.classpool.AOPClassPoolRepository;
-import org.jboss.aop.domain.RepositoryClassLoaderDomainIntializer;
+import org.jboss.aop.domain.DomainInitializer;
+import org.jboss.aop.domain.DomainInitializerCallback;
+import org.jboss.aop.domain.DomainInitializerCallbackHandler;
import org.jboss.aop.domain.ScopedRepositoryClassLoaderDomain;
import org.jboss.logging.Logger;
import org.jboss.mx.loading.HeirarchicalLoaderRepository3;
@@ -39,7 +41,7 @@
* @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
-public class RepositoryClassLoaderScopingPolicy implements AOPClassLoaderScopingPolicy, RepositoryClassLoaderDomainIntializer
+public class RepositoryClassLoaderScopingPolicy implements AOPClassLoaderScopingPolicy, DomainInitializer
{
Logger log = Logger.getLogger(RepositoryClassLoaderScopingPolicy.class);
@@ -47,8 +49,13 @@
private Map<Object, Domain> scopedClassLoaderDomains = new WeakHashMap<Object, Domain>();
- public Domain initScopedDomain(ClassLoader loader)
+ public Domain initializeDomain(DomainInitializerCallbackHandler handler)
{
+ DomainInitializerCallback<ClassLoader> callback = new DomainInitializerCallback<ClassLoader>(ClassLoader.class);
+ DomainInitializerCallback[] callbacks = new DomainInitializerCallback[]{callback};
+ handler.handle(callbacks);
+
+ ClassLoader loader = callback.getValue();
Domain domain = getDomain(loader, AspectManager.getTopLevelAspectManager());
AspectManager.instance().registerClassLoader(loader); //Ends up in classpool factory create method
@@ -154,4 +161,5 @@
}
return null;
}
+
}
Modified: projects/aop/trunk/asintegration/src/main/org/jboss/aop/asintegration/jboss5/NewClassLoaderScopingPolicy.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/asintegration/jboss5/NewClassLoaderScopingPolicy.java 2007-10-20 12:43:41 UTC (rev 66317)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/asintegration/jboss5/NewClassLoaderScopingPolicy.java 2007-10-20 15:24:28 UTC (rev 66318)
@@ -28,7 +28,9 @@
import org.jboss.aop.Domain;
import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
import org.jboss.aop.classpool.ExtraClassPoolFactoryParameters;
-import org.jboss.aop.domain.NewClassLoaderDomainInitializer;
+import org.jboss.aop.domain.DomainInitializer;
+import org.jboss.aop.domain.DomainInitializerCallback;
+import org.jboss.aop.domain.DomainInitializerCallbackHandler;
import org.jboss.classloader.spi.ClassLoaderDomain;
import org.jboss.classloader.spi.ClassLoaderSystem;
import org.jboss.deployers.plugins.classloading.Module;
@@ -40,7 +42,7 @@
* @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
-public class NewClassLoaderScopingPolicy implements AOPClassLoaderScopingPolicy, NewClassLoaderDomainInitializer
+public class NewClassLoaderScopingPolicy implements AOPClassLoaderScopingPolicy, DomainInitializer
{
static Logger log = Logger.getLogger(NewClassLoaderScopingPolicy.class);
NewClassLoaderDomainRegistry registry;
@@ -55,8 +57,17 @@
this.registry = registry;
}
- public Domain initScopedDomain(ClassLoader loader, Module module)
+
+ public Domain initializeDomain(DomainInitializerCallbackHandler handler)
{
+ DomainInitializerCallback<ClassLoader> loaderCb = new DomainInitializerCallback<ClassLoader>(ClassLoader.class);
+ DomainInitializerCallback<Module> moduleCb = new DomainInitializerCallback<Module>(Module.class);
+ DomainInitializerCallback[] callbacks = new DomainInitializerCallback[]{loaderCb, moduleCb};
+ handler.handle(callbacks);
+
+ ClassLoader loader = loaderCb.getValue();
+ Module module = moduleCb.getValue();
+
ScopedNewClassLoaderDomain scopedDomain = (ScopedNewClassLoaderDomain)registry.getRegisteredDomain(loader);
if (scopedDomain == null)
{
Modified: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/AspectDeployer.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/AspectDeployer.java 2007-10-20 12:43:41 UTC (rev 66317)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/AspectDeployer.java 2007-10-20 15:24:28 UTC (rev 66318)
@@ -35,8 +35,9 @@
import org.jboss.aop.AspectXmlLoader;
import org.jboss.aop.Domain;
import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
-import org.jboss.aop.domain.NewClassLoaderDomainInitializer;
-import org.jboss.aop.domain.RepositoryClassLoaderDomainIntializer;
+import org.jboss.aop.domain.DomainInitializer;
+import org.jboss.aop.domain.DomainInitializerCallback;
+import org.jboss.aop.domain.DomainInitializerCallbackHandler;
import org.jboss.deployers.plugins.classloading.Module;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.DeploymentStages;
@@ -362,32 +363,44 @@
return (realName.endsWith(AOP_JAR_SUFFIX));
}
- private AspectManager getCorrectManager(VFSDeploymentUnit unit)
+ private AspectManager getCorrectManager(final VFSDeploymentUnit unit)
{
//Scoped AOP deployments are only available when deployed as part of a scoped sar, ear etc.
//It can contain an aop.xml file, or it can be part of a .aop file
//Linking a standalone -aop.xml file onto a scoped deployment is not possible at the moment
AOPClassLoaderScopingPolicy policy = AspectManager.getClassLoaderScopingPolicy();
- ClassLoader cl = unit.getClassLoader();
- Module module = unit.getTopLevel().getAttachment(Module.class);
Domain domain = null;
if (policy != null)
{
- if (policy instanceof NewClassLoaderDomainInitializer)
+ if (policy instanceof DomainInitializer == false)
{
- domain = ((NewClassLoaderDomainInitializer)policy).initScopedDomain(cl, module);
+ throw new RuntimeException(policy + " must implement DomainInitializer");
}
- else if (policy instanceof RepositoryClassLoaderDomainIntializer)
- {
- domain = ((RepositoryClassLoaderDomainIntializer)policy).initScopedDomain(cl);
- }
- else
- {
- throw new RuntimeException("No domain intitialiser could be found");
- }
+ DomainInitializer initializer = (DomainInitializer)policy;
+ domain = initializer.initializeDomain(new DomainInitializerCallbackHandler() {
+ public void handle(DomainInitializerCallback[] callbacks)
+ {
+ for (DomainInitializerCallback callback : callbacks)
+ {
+ if (callback.getDataType() == Module.class)
+ {
+ callback.setValue(unit.getTopLevel().getAttachment(Module.class));
+ }
+ else if (callback.getDataType() == ClassLoader.class)
+ {
+ callback.setValue(unit.getClassLoader());
+ }
+ else
+ {
+ throw new RuntimeException("Invalid data type passed in by callback " + callback.getDataType());
+ }
+ }
+ }
+ });
}
+
if (domain != null)
{
return domain;
@@ -411,4 +424,6 @@
}
}
+
+
}
Added: projects/aop/trunk/asintegration/src/main/org/jboss/aop/domain/DomainInitializer.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/domain/DomainInitializer.java (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/domain/DomainInitializer.java 2007-10-20 15:24:28 UTC (rev 66318)
@@ -0,0 +1,34 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.aop.domain;
+
+import org.jboss.aop.Domain;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface DomainInitializer
+{
+ Domain initializeDomain(DomainInitializerCallbackHandler handler);
+}
Added: projects/aop/trunk/asintegration/src/main/org/jboss/aop/domain/DomainInitializerCallback.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/domain/DomainInitializerCallback.java (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/domain/DomainInitializerCallback.java 2007-10-20 15:24:28 UTC (rev 66318)
@@ -0,0 +1,53 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.aop.domain;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class DomainInitializerCallback<T>
+{
+ private Class<T> dataType;
+ T value;
+
+ public DomainInitializerCallback(Class<T> dataType)
+ {
+ this.dataType = dataType;
+ }
+
+ public Class<T> getDataType()
+ {
+ return dataType;
+ }
+
+ public T getValue()
+ {
+ return value;
+ }
+
+ public void setValue(T value)
+ {
+ this.value = value;
+ }
+}
Added: projects/aop/trunk/asintegration/src/main/org/jboss/aop/domain/DomainInitializerCallbackHandler.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/domain/DomainInitializerCallbackHandler.java (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/domain/DomainInitializerCallbackHandler.java 2007-10-20 15:24:28 UTC (rev 66318)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.aop.domain;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface DomainInitializerCallbackHandler
+{
+ void handle(DomainInitializerCallback[] callbacks);
+}
Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/domain/NewClassLoaderDomainInitializer.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/domain/NewClassLoaderDomainInitializer.java 2007-10-20 12:43:41 UTC (rev 66317)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/domain/NewClassLoaderDomainInitializer.java 2007-10-20 15:24:28 UTC (rev 66318)
@@ -1,36 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, 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.aop.domain;
-
-import org.jboss.aop.Domain;
-import org.jboss.deployers.plugins.classloading.Module;
-
-/**
- *
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public interface NewClassLoaderDomainInitializer
-{
- Domain initScopedDomain(ClassLoader loader, Module module);
-
-}
Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/domain/RepositoryClassLoaderDomainIntializer.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/domain/RepositoryClassLoaderDomainIntializer.java 2007-10-20 12:43:41 UTC (rev 66317)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/domain/RepositoryClassLoaderDomainIntializer.java 2007-10-20 15:24:28 UTC (rev 66318)
@@ -1,34 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, 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.aop.domain;
-
-import org.jboss.aop.Domain;
-
-/**
- *
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public interface RepositoryClassLoaderDomainIntializer
-{
- Domain initScopedDomain(ClassLoader loader);
-}
More information about the jboss-cvs-commits
mailing list