From d6f04399f61ca8156968edffda9a39ec276d97a2 Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 3 Aug 2010 22:24:05 +0000 Subject: [PATCH] 278496: world managing a set of type delegate resolvers --- .../org/aspectj/weaver/bcel/BcelWorld.java | 20 +++++++++++++ .../weaver/bcel/TypeDelegateResolver.java | 28 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 weaver/src/org/aspectj/weaver/bcel/TypeDelegateResolver.java diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java b/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java index f9579da17..837c19b9b 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java @@ -91,6 +91,7 @@ public class BcelWorld extends World implements Repository { private final BcelWeavingSupport bcelWeavingSupport = new BcelWeavingSupport(); private boolean isXmlConfiguredWorld = false; private WeavingXmlConfig xmlConfiguration; + private List typeDelegateResolvers; private static Trace trace = TraceFactory.getTraceFactory().getTrace(BcelWorld.class); @@ -373,6 +374,15 @@ public class BcelWorld extends World implements Repository { ensureAdvancedConfigurationProcessed(); JavaClass jc = lookupJavaClass(classPath, name); if (jc == null) { + // Anyone else to ask? + if (typeDelegateResolvers != null) { + for (TypeDelegateResolver tdr : typeDelegateResolvers) { + ReferenceTypeDelegate delegate = tdr.getDelegate(ty); + if (delegate != null) { + return delegate; + } + } + } return null; } else { return buildBcelDelegate(ty, jc, false, false); @@ -1180,4 +1190,14 @@ public class BcelWorld extends World implements Repository { return false; } + public void addTypeDelegateResolver(TypeDelegateResolver typeDelegateResolver) { + if (typeDelegateResolvers == null) { + typeDelegateResolvers = new ArrayList(); + } + typeDelegateResolvers.add(typeDelegateResolver); + } + + public void classWriteEvent(char[] classname) { + typeMap.classWriteEvent(new String(classname)); + } } diff --git a/weaver/src/org/aspectj/weaver/bcel/TypeDelegateResolver.java b/weaver/src/org/aspectj/weaver/bcel/TypeDelegateResolver.java new file mode 100644 index 000000000..2a29c927a --- /dev/null +++ b/weaver/src/org/aspectj/weaver/bcel/TypeDelegateResolver.java @@ -0,0 +1,28 @@ +/* ******************************************************************* + * Copyright (c) 2010 Contributors + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement, SpringSource + * ******************************************************************/ +package org.aspectj.weaver.bcel; + +import org.aspectj.weaver.ReferenceType; +import org.aspectj.weaver.ReferenceTypeDelegate; + +/** + * A type delegate resolver is able to create type delegates for a named reference type. A type delegate will implement + * ReferenceTypeDelegate. There are three kind of delegate already in existence: those created for eclipse structures, those + * created for bytecode structures, and those created based on reflection. + * + * @author Andy Clement + */ +public interface TypeDelegateResolver { + + ReferenceTypeDelegate getDelegate(ReferenceType referenceType); + +} -- 2.39.5