[jboss-cvs] JBossAS SVN: r84506 - in projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop: instrument and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Feb 20 06:51:10 EST 2009
Author: kabir.khan at jboss.com
Date: 2009-02-20 06:51:10 -0500 (Fri, 20 Feb 2009)
New Revision: 84506
Added:
projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/LoadInterceptedClassesStrategy.java
projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultAOPLock.java
projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/AOPLock.java
Removed:
projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/LoadInterceptedClassesStrategy.java
Modified:
projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/AspectManager.java
projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/instrument/InstrumentorFactory.java
projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultAOPSystem.java
projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultConfiguration.java
projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultWeaver.java
projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/AOPSystem.java
projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/Configuration.java
projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/Weaver.java
Log:
It compiles now. Make AOPSystem push AOPLock into places that nead it such as the Weaver. Revisit how the WeavingStrategy is created
Modified: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/AspectManager.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/AspectManager.java 2009-02-20 11:50:52 UTC (rev 84505)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/AspectManager.java 2009-02-20 11:51:10 UTC (rev 84506)
@@ -61,11 +61,7 @@
import org.jboss.aop.array.ArrayReplacement;
import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
import org.jboss.aop.classpool.AOPClassPoolRepository;
-import org.jboss.aop.instrument.GeneratedAdvisorInstrumentor;
import org.jboss.aop.instrument.Instrumentor;
-import org.jboss.aop.instrument.InstrumentorFactory;
-import org.jboss.aop.instrument.JoinPointGenerator;
-import org.jboss.aop.instrument.TransformerCommon;
import org.jboss.aop.introduction.AnnotationIntroduction;
import org.jboss.aop.introduction.InterfaceIntroduction;
import org.jboss.aop.metadata.ClassMetaDataBinding;
@@ -2015,6 +2011,7 @@
lifecycleManager.removeLifecycleBinding(name);
}
+ @Deprecated
public static boolean hasTransformationStarted()
{
return WeavingStrategySupport.transformationStarted();
Copied: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/LoadInterceptedClassesStrategy.java (from rev 84505, projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/LoadInterceptedClassesStrategy.java)
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/LoadInterceptedClassesStrategy.java (rev 0)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/LoadInterceptedClassesStrategy.java 2009-02-20 11:51:10 UTC (rev 84506)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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;
+
+import javassist.CodeConverter;
+import javassist.CtClass;
+import javassist.CtField;
+
+import org.jboss.aop.DynamicAOPStrategy;
+import org.jboss.aop.instrument.DynamicTransformationObserver;
+import org.jboss.aop.instrument.JoinpointClassifier;
+import org.jboss.aop.instrument.JoinpointSimpleClassifier;
+
+
+/**
+ * Dynamic AOP Strategy that instruments prepared classes code
+ * for interception before they get loaded in the system.
+ * This way, no change to a class code has to be made during runtime.
+ * @author Flavia Rainone
+ */
+public class LoadInterceptedClassesStrategy implements DynamicAOPStrategy
+{
+ /**
+ * Dummy DynamicTransformationObserver. No action is need when a dynamic
+ * transformation occurs.
+ */
+ private DynamicTransformationObserver dynamicTransformationObserver =
+ new DynamicTransformationObserver(){
+ public void fieldReadDynamicalyWrapped(CtField field) {}
+ public void fieldWriteDynamicalyWrapped(CtField field) {}
+ public void constructorDynamicalyWrapped() {}
+ public void transformationFinished(CtClass clazz, CodeConverter converter) {}
+ };
+
+ /**
+ * Simple classifier to be used during transformation.
+ */
+ JoinpointClassifier joinpointClassifier = new JoinpointSimpleClassifier();
+
+ /**
+ * Returns <code>null</code> because, as long as no runtime action is required
+ * in this strategy, no observer is required.
+ * @see org.jboss.aop.DynamicAOPStrategy#getInterceptorChainObserver(Class)
+ */
+ public InterceptorChainObserver getInterceptorChainObserver(Class<?> clazz)
+ {
+ return null;
+ }
+
+ /**
+ * Notifies the strategy that one or more interceptor chains in the
+ * system may have been updated.
+ * This method does nothing because no runtime action is required.
+ * @see org.jboss.aop.DynamicAOPStrategy#interceptorChainsUpdated()
+ */
+ public void interceptorChainsUpdated() { }
+
+ /**
+ * Returns a <code>org.jboss.aop.instrument.JoinpointSimpleClassifier</code>
+ * instance. This classifier assures that prepared classes will be fully instrumented
+ * for interception before they get loaded in the system.
+ * @see org.jboss.aop.DynamicAOPStrategy#getJoinpointClassifier()
+ */
+ public JoinpointClassifier getJoinpointClassifier()
+ {
+ return this.joinpointClassifier;
+ }
+
+ /**
+ * Returns a dynamic transformation observer to be notified of the dynamic
+ * events during the <code>clazz</code> transformation. This observer does nothing
+ * because no action is required when a dynamic transformation happens.
+ * @see org.jboss.aop.DynamicAOPStrategy#getJoinpointClassifier()
+ */
+ public DynamicTransformationObserver getDynamicTransformationObserver(CtClass clazz)
+ {
+ return this.dynamicTransformationObserver;
+ }
+}
\ No newline at end of file
Modified: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/instrument/InstrumentorFactory.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/instrument/InstrumentorFactory.java 2009-02-20 11:50:52 UTC (rev 84505)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/instrument/InstrumentorFactory.java 2009-02-20 11:51:10 UTC (rev 84506)
@@ -24,6 +24,9 @@
import java.lang.reflect.Constructor;
import org.jboss.aop.AspectManager;
+import org.jboss.aop.ClassicWeavingStrategy;
+import org.jboss.aop.SuperClassesFirstWeavingStrategy;
+import org.jboss.aop.WeavingStrategy;
import org.jboss.aop.classpool.AOPClassPool;
import org.jboss.aop.util.logging.AOPLogger;
@@ -116,10 +119,8 @@
throw new RuntimeException(e);
}
}
- else
- {
- throw new RuntimeException("Instrumentor is not set");
- }
+
+ throw new RuntimeException("Instrumentor is not set");
}
@@ -139,6 +140,20 @@
}
}
+ public static WeavingStrategy getWeavingStrategy()
+ {
+ if (instrumentor == InstrumentorEnum.CLASSIC)
+ {
+ return new ClassicWeavingStrategy();
+ }
+ else if (instrumentor == InstrumentorEnum.GENERATED_ADVISOR)
+ {
+ return new SuperClassesFirstWeavingStrategy();
+ }
+
+ throw new RuntimeException("Instrumentor is not set");
+ }
+
public static String getInstrumentorName()
{
if (instrumentor == InstrumentorEnum.CLASSIC)
Copied: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultAOPLock.java (from rev 84505, projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultAOPSystem.java)
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultAOPLock.java (rev 0)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultAOPLock.java 2009-02-20 11:51:10 UTC (rev 84506)
@@ -0,0 +1,68 @@
+/*
+* 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.plugins;
+
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import org.jboss.aop.spi.AOPLock;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class DefaultAOPLock implements AOPLock
+{
+ private ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
+
+ /**
+ * Read-lock just this level
+ */
+ public final void lockRead()
+ {
+ lock.readLock().lock();
+ }
+
+ /**
+ * Read-unlock just this level
+ */
+ public final void unlockRead()
+ {
+ lock.readLock().unlock();
+ }
+
+ /**
+ * Write-lock just this level
+ */
+ public final void lockWrite()
+ {
+ lock.writeLock().lock();
+ }
+
+ /**
+ * Write-unlock this level
+ */
+ public final void unlockWrite()
+ {
+ lock.writeLock().unlock();
+ }
+}
Modified: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultAOPSystem.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultAOPSystem.java 2009-02-20 11:50:52 UTC (rev 84505)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultAOPSystem.java 2009-02-20 11:51:10 UTC (rev 84506)
@@ -76,7 +76,7 @@
@Override
protected Weaver getWeaver(AOPSystem system)
{
- return null;
+ return weaver;
}
}
Modified: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultConfiguration.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultConfiguration.java 2009-02-20 11:50:52 UTC (rev 84505)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultConfiguration.java 2009-02-20 11:51:10 UTC (rev 84506)
@@ -31,8 +31,11 @@
import org.jboss.aop.classpool.AOPClassPoolRepository;
import org.jboss.aop.instrument.InstrumentorFactory;
import org.jboss.aop.pointcut.ast.ClassExpression;
+import org.jboss.aop.spi.AOPSystem;
import org.jboss.aop.spi.Configuration;
import org.jboss.aop.spi.ConfigurationProperties;
+import org.jboss.aop.spi.Weaver;
+import org.jboss.aop.util.logging.AOPLogger;
/**
*
@@ -41,6 +44,9 @@
*/
public class DefaultConfiguration implements Configuration, ConfigurationProperties
{
+ AOPLogger log = AOPLogger.getLogger(this.getClass());
+
+ private Weaver weaver;
private boolean optimize;
private boolean verbose;
private List<String> exclude = new CopyOnWriteArrayList<String>();
@@ -58,6 +64,15 @@
initialise();
}
+ public void setWeaver(AOPSystem system, Weaver weaver)
+ {
+ if (weaver != null)
+ {
+ throw new IllegalStateException("Weaver is already set");
+ }
+ this.weaver = weaver;
+ }
+
public boolean isOptimize()
{
return optimize;
@@ -65,6 +80,11 @@
public void setOptimize(boolean optimize)
{
+ if (isNotStartup() && optimize != this.optimize)
+ {
+ log.warn("Attempt to change optimize to '" + optimize + "' from '" + this.optimize + "' is ignored since weaving has started");
+ return;
+ }
this.optimize = optimize;
}
@@ -164,6 +184,11 @@
public void setMaintainAdvisorMethodInterceptors(boolean maintainMethodInterceptors)
{
+ if (isNotStartup() && maintainAdvisorMethodInterceptors != this.maintainAdvisorMethodInterceptors)
+ {
+ log.warn("Attempt to change maintainMethodInterceptors to '" + maintainAdvisorMethodInterceptors + "' from '" + this.maintainAdvisorMethodInterceptors + "' is ignored since weaving has started");
+ return;
+ }
this.maintainAdvisorMethodInterceptors = maintainMethodInterceptors;
}
@@ -174,6 +199,11 @@
public void setClassLoaderScopingPolicy(AOPClassLoaderScopingPolicy classLoaderScopingPolicy)
{
+ if (isNotStartup() && classLoaderScopingPolicy != this.classLoaderScopingPolicy)
+ {
+ log.warn("Attempt to change classLoaderScopingPolicy to '" + classLoaderScopingPolicy + "' from '" + this.classLoaderScopingPolicy + "' is ignored since weaving has started");
+ return;
+ }
this.classLoaderScopingPolicy = classLoaderScopingPolicy;
}
@@ -184,6 +214,11 @@
public void setClassLoaderValidator(ClassLoaderValidation classLoaderValidator)
{
+ if (isNotStartup() && classLoaderValidator != this.classLoaderValidator)
+ {
+ log.warn("Attempt to change classLoaderScopingPolicy to '" + classLoaderValidator + "' from '" + this.classLoaderValidator + "' is ignored since weaving has started");
+ return;
+ }
this.classLoaderValidator = classLoaderValidator;
}
@@ -294,4 +329,13 @@
}
return null;
}
+
+ private boolean isNotStartup()
+ {
+ if (weaver == null || !weaver.hasTransformationStarted())
+ {
+ return false;
+ }
+ return true;
+ }
}
Modified: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultWeaver.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultWeaver.java 2009-02-20 11:50:52 UTC (rev 84505)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/DefaultWeaver.java 2009-02-20 11:51:10 UTC (rev 84506)
@@ -24,15 +24,16 @@
import java.security.ProtectionDomain;
import java.util.List;
+import org.jboss.aop.AspectManager;
import org.jboss.aop.ClassicWeavingStrategy;
import org.jboss.aop.DynamicAOPStrategy;
-import org.jboss.aop.SuperClassesFirstWeavingStrategy;
+import org.jboss.aop.LoadInterceptedClassesStrategy;
import org.jboss.aop.WeavingStrategy;
-import org.jboss.aop.instrument.GeneratedAdvisorInstrumentor;
import org.jboss.aop.instrument.InstrumentorFactory;
import org.jboss.aop.instrument.JoinPointGenerator;
import org.jboss.aop.instrument.TransformerCommon;
import org.jboss.aop.pointcut.ast.ClassExpression;
+import org.jboss.aop.spi.AOPLock;
import org.jboss.aop.spi.AOPSystem;
import org.jboss.aop.spi.Configuration;
import org.jboss.aop.spi.Weaver;
@@ -44,36 +45,30 @@
*/
public class DefaultWeaver implements Weaver
{
- Configuration configuration;
+ private AOPLock lock;
- WeavingStrategy weavingStrategy;
+ private Configuration configuration;
- protected DynamicAOPStrategy dynamicStrategy = new LoadInterceptedClassesStrategy();
+ private DynamicAOPStrategy dynamicStrategy = new LoadInterceptedClassesStrategy();
protected DefaultWeaver(Configuration configuration)
{
this.configuration = configuration;
}
- private void initWeavingStrategy()
+ /**
+ * Sets the AOPLock. This method can only be called by AOPSystem and
+ * should only be called once
+ */
+ public void setAOPLock(AOPSystem system, AOPLock lock)
{
- if (weavingStrategy == null)
- {
- if (TransformerCommon.isCompileTime())
- {
- weavingStrategy = new ClassicWeavingStrategy();
- }
- else if(InstrumentorFactory.getInstrumentor(this,dynamicStrategy.getJoinpointClassifier())
- instanceof GeneratedAdvisorInstrumentor)
- {
- weavingStrategy = new SuperClassesFirstWeavingStrategy();
- }
- else
- {
- weavingStrategy = new ClassicWeavingStrategy();
- }
- }
+ this.lock = lock;
}
+
+ public boolean hasTransformationStarted()
+ {
+ return false;
+ }
/**
* Returns the dynamic aop strategy to be used.
@@ -83,11 +78,6 @@
return this.dynamicStrategy;
}
- /**
- * Sets the dynamic aop strategy to be used.
- * Should be called only before any class is transformed.
- * @param strategy the new dynamic aop strategy.
- */
public void setDynamicAOPStrategy(DynamicAOPStrategy strategy)
{
// avoid users calling this method in run time
@@ -154,26 +144,9 @@
lock.lockRead();
try
{
- synchronized(this){
- if (weavingStrategy == null)
- {
- if (TransformerCommon.isCompileTime())
- {
- weavingStrategy = new ClassicWeavingStrategy();
- }
- else if(InstrumentorFactory.getInstrumentor(this,dynamicStrategy.getJoinpointClassifier())
- instanceof GeneratedAdvisorInstrumentor)
- {
- weavingStrategy = new SuperClassesFirstWeavingStrategy();
- }
- else
- {
- weavingStrategy = new ClassicWeavingStrategy();
- }
- }
-
- return weavingStrategy.translate(this, className, loader, classfileBuffer);
- }
+ //TODO This should be an instance of Manager
+ AspectManager manager = AspectManager.instance(loader);
+ return getWeavingStrategy().translate(manager, className, loader, classfileBuffer);
}
finally
{
@@ -193,9 +166,9 @@
private boolean ignoreClass(String classname)
{
- List<String> ignore = AOPSystem.getConfiguration().getIgnore();
+ List<String> ignore = configuration.getIgnore();
if (ignore == null) return false;
- ClassExpression[] ignoreExprs = AOPSystem.getConfiguration().getIgnoreExpressions();
+ ClassExpression[] ignoreExprs = configuration.getIgnoreExpressions();
for (int i = 0; i < ignoreExprs.length; i++)
{
if(ignoreExprs[i].matches(classname)) return true;
@@ -203,9 +176,9 @@
return false;
}
- public boolean includeClass(String classname)
+ private boolean includeClass(String classname)
{
- List<String> include = AOPSystem.getConfiguration().getInclude();
+ List<String> include = configuration.getInclude();
if (include == null) return false;
for (int i = 0; i < include.size(); i++)
{
@@ -215,9 +188,9 @@
return false;
}
- public boolean excludeClass(String classname)
+ private boolean excludeClass(String classname)
{
- List<String> exclude = AOPSystem.getConfiguration().getExclude();
+ List<String> exclude = configuration.getExclude();
if (exclude == null) return false;
for (int i = 0; i < exclude.size(); i++)
{
@@ -228,5 +201,30 @@
return false;
}
-
+ private WeavingStrategy getWeavingStrategy()
+ {
+ return WeavingStrategyInitialiser.weavingStrategy;
+ }
+
+ /**
+ * Initilises the weaving strategy on first load to avoid having to synchronize every time
+ *
+ */
+ private static class WeavingStrategyInitialiser
+ {
+ private static final WeavingStrategy weavingStrategy;
+ static
+ {
+ if (TransformerCommon.isCompileTime())
+ {
+ weavingStrategy = new ClassicWeavingStrategy();
+ }
+ else
+ {
+ weavingStrategy = InstrumentorFactory.getWeavingStrategy();
+ }
+ }
+
+ }
+
}
Deleted: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/LoadInterceptedClassesStrategy.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/LoadInterceptedClassesStrategy.java 2009-02-20 11:50:52 UTC (rev 84505)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/plugins/LoadInterceptedClassesStrategy.java 2009-02-20 11:51:10 UTC (rev 84506)
@@ -1,98 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.plugins;
-
-import javassist.CodeConverter;
-import javassist.CtClass;
-import javassist.CtField;
-
-import org.jboss.aop.DynamicAOPStrategy;
-import org.jboss.aop.instrument.DynamicTransformationObserver;
-import org.jboss.aop.instrument.JoinpointClassifier;
-import org.jboss.aop.instrument.JoinpointSimpleClassifier;
-
-
-/**
- * Dynamic AOP Strategy that instruments prepared classes code
- * for interception before they get loaded in the system.
- * This way, no change to a class code has to be made during runtime.
- * @author Flavia Rainone
- */
-class LoadInterceptedClassesStrategy implements DynamicAOPStrategy
-{
- /**
- * Dummy DynamicTransformationObserver. No action is need when a dynamic
- * transformation occurs.
- */
- private DynamicTransformationObserver dynamicTransformationObserver =
- new DynamicTransformationObserver(){
- public void fieldReadDynamicalyWrapped(CtField field) {}
- public void fieldWriteDynamicalyWrapped(CtField field) {}
- public void constructorDynamicalyWrapped() {}
- public void transformationFinished(CtClass clazz, CodeConverter converter) {}
- };
-
- /**
- * Simple classifier to be used during transformation.
- */
- JoinpointClassifier joinpointClassifier = new JoinpointSimpleClassifier();
-
- /**
- * Returns <code>null</code> because, as long as no runtime action is required
- * in this strategy, no observer is required.
- * @see org.jboss.aop.DynamicAOPStrategy#getInterceptorChainObserver(Class)
- */
- public InterceptorChainObserver getInterceptorChainObserver(Class<?> clazz)
- {
- return null;
- }
-
- /**
- * Notifies the strategy that one or more interceptor chains in the
- * system may have been updated.
- * This method does nothing because no runtime action is required.
- * @see org.jboss.aop.DynamicAOPStrategy#interceptorChainsUpdated()
- */
- public void interceptorChainsUpdated() { }
-
- /**
- * Returns a <code>org.jboss.aop.instrument.JoinpointSimpleClassifier</code>
- * instance. This classifier assures that prepared classes will be fully instrumented
- * for interception before they get loaded in the system.
- * @see org.jboss.aop.DynamicAOPStrategy#getJoinpointClassifier()
- */
- public JoinpointClassifier getJoinpointClassifier()
- {
- return this.joinpointClassifier;
- }
-
- /**
- * Returns a dynamic transformation observer to be notified of the dynamic
- * events during the <code>clazz</code> transformation. This observer does nothing
- * because no action is required when a dynamic transformation happens.
- * @see org.jboss.aop.DynamicAOPStrategy#getJoinpointClassifier()
- */
- public DynamicTransformationObserver getDynamicTransformationObserver(CtClass clazz)
- {
- return this.dynamicTransformationObserver;
- }
-}
\ No newline at end of file
Added: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/AOPLock.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/AOPLock.java (rev 0)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/AOPLock.java 2009-02-20 11:51:10 UTC (rev 84506)
@@ -0,0 +1,52 @@
+/*
+* 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.spi;
+
+
+/**
+ * A lock
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface AOPLock
+{
+ /**
+ * Read-lock
+ */
+ void lockRead();
+
+ /**
+ * Read-unlock
+ */
+ void unlockRead();
+
+ /**
+ * Write-lock
+ */
+ void lockWrite();
+
+ /**
+ * Write-unlock
+ */
+ void unlockWrite();
+}
Modified: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/AOPSystem.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/AOPSystem.java 2009-02-20 11:50:52 UTC (rev 84505)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/AOPSystem.java 2009-02-20 11:51:10 UTC (rev 84506)
@@ -28,6 +28,7 @@
import java.security.PrivilegedExceptionAction;
import org.jboss.aop.Deployment;
+import org.jboss.aop.plugins.DefaultAOPLock;
import org.jboss.aop.util.logging.AOPLogger;
import org.jboss.logging.Logger;
@@ -44,6 +45,8 @@
private static final AOPSystem INSTANCE;
+ private static final AOPLock LOCK = new DefaultAOPLock();
+
/**
* The AbstractAOPSystem called by our static methods
*/
@@ -59,6 +62,10 @@
{
System.out.println(SYSTEM);
SYSTEM.setConfiguration(INSTANCE, initialiseConfiguration());
+ if (SYSTEM.getConfiguration(INSTANCE) == null)
+ {
+ throw new IllegalStateException("Null Configuration");
+ }
try
{
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
@@ -67,6 +74,13 @@
{
SYSTEM.initRootManager(INSTANCE);
SYSTEM.initWeaver(INSTANCE);
+ final Weaver weaver = SYSTEM.getWeaver(INSTANCE);
+ if (weaver == null)
+ {
+ throw new IllegalStateException("Null Weaver");
+ }
+ weaver.setAOPLock(INSTANCE, LOCK);
+ SYSTEM.getConfiguration(INSTANCE).setWeaver(INSTANCE, weaver);
Deployment.deploy();
return null;
}});
Modified: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/Configuration.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/Configuration.java 2009-02-20 11:50:52 UTC (rev 84505)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/Configuration.java 2009-02-20 11:51:10 UTC (rev 84506)
@@ -39,13 +39,23 @@
public interface Configuration
{
/**
- * Gets whether invocation classes should be generated to avoid reflection when using classic weaving
+ * Sets the weaver once initialised. This method can only be called by AOPSystem and
+ * should only be called once
+ * @param system The calling AOPSystem
+ * @param Weaver The weaver set. This is guaranteed not-null
+ * @throws IllegalStateException if the weaver is already set
+ */
+ void setWeaver(AOPSystem system, Weaver weaver);
+
+ /**
+ * Gets whether invocation classes should be generated to avoid reflection when using classic weaving.
* @return whether to generate invocation classes
*/
boolean isOptimize();
/**
- * Sets whether invocation classes should be generated to avoid reflection when using classic weaving
+ * Sets whether invocation classes should be generated to avoid reflection when using classic weaving.
+ * This should only get set on startup, subsequent attempts to change this are ignored
* @param optimize true to generate invocation classes
*/
void setOptimize(boolean optimize);
@@ -130,14 +140,15 @@
/**
* Gets whether or not we should maintain the deprecated {@link Advisor#methodInterceptors} field (boolean). This is required
- * in jboss 4.x for backwards compatibility with EJB 3. See JBAOP-517
+ * in jboss 4.x for backwards compatibility with EJB 3. See JBAOP-517.
* @return whether Advisor.methodinterceptors should be maintained
*/
boolean isMaintainAdvisorMethodInterceptors();
/**
* Gets whether or not we should maintain the deprecated {@link Advisor#methodInterceptors} field (boolean). This is required
- * in jboss 4.x for backwards compatibility with EJB 3. See JBAOP-517
+ * in jboss 4.x for backwards compatibility with EJB 3. See JBAOP-517.
+ * This should only get set on startup, subsequent attempts to change this are ignored.
* @param maintainMethodInterceptors whether Advisor.methodinterceptors should be maintained
*/
void setMaintainAdvisorMethodInterceptors(boolean maintainMethodInterceptors);
@@ -152,7 +163,8 @@
/**
* Sets the classloader scoping policy. This is normally only used when running in a managed environment
- * such as JBoss Application Server
+ * such as JBoss Application Server.
+ * This should only get set on startup, subsequent attempts to change this are ignored.
* @param classLoaderScopingPolicy The classloader scoping policy
*/
//TODO SPI interface needed for AOPClassLoaderScopingPolicy
@@ -160,7 +172,7 @@
/**
* Gets the classloader validation. This is normally only used whhen running in a managed environment
- * such as JBoss Application Server
+ * such as JBoss Application Server.
* @return The classloader validation
*/
//TODO SPI interface needed for ClassLoaderValidation
@@ -169,6 +181,7 @@
/**
* Sets the classloader validation. This is normally only used whhen running in a managed environment
* such as JBoss Application Server
+ * This should only get set on startup, subsequent attempts to change this are ignored.
* @param classLoaderValidator The classloader validation
*/
//TODO SPI interface needed for ClassLoaderValidation
Modified: projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/Weaver.java
===================================================================
--- projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/Weaver.java 2009-02-20 11:50:52 UTC (rev 84505)
+++ projects/aop/branches/createspi/aop/src/main/java/org/jboss/aop/spi/Weaver.java 2009-02-20 11:51:10 UTC (rev 84506)
@@ -33,6 +33,16 @@
public interface Weaver extends Translator
{
/**
+ * Sets the AOPLock. This method can only be called by AOPSystem and
+ * should only be called once
+ * @param system The calling AOPSystem
+ * @param lock The lock, guaranteed to not be null
+ * @throws IllegalStateException if the lock has already been set
+ */
+ void setAOPLock(AOPSystem system, AOPLock lock);
+
+
+ /**
* Entry point for weaving a class
* @param className The name of the class we are loading
* @param loader The classloader used to load the class
@@ -64,4 +74,9 @@
//TODO DynamicAOPStrategy needs an SPI interface
public DynamicAOPStrategy getDynamicAOPStrategy();
+ /**
+ * Check if we have started transforming classes
+ * @return true if classes have been transformed
+ */
+ public boolean hasTransformationStarted();
}
More information about the jboss-cvs-commits
mailing list