From 4e9fccaa823d4d93f6468c607cc54e9820d4e88c Mon Sep 17 00:00:00 2001 From: trisberg Date: Wed, 28 Jul 2010 15:57:03 -0400 Subject: [PATCH] moving to datastore-graph project due to AspectJ compiler issue --- ...AbstractConstructorEntityInstantiator.java | 61 ------------------- .../support/AbstractMixinFields.aj | 54 ---------------- .../AbstractTypeAnnotatingMixinFields.aj | 21 ------- .../support/EntityInstantiator.java | 32 ---------- 4 files changed, 168 deletions(-) delete mode 100644 src/main/java/org/springframework/persistence/support/AbstractConstructorEntityInstantiator.java delete mode 100644 src/main/java/org/springframework/persistence/support/AbstractMixinFields.aj delete mode 100644 src/main/java/org/springframework/persistence/support/AbstractTypeAnnotatingMixinFields.aj delete mode 100644 src/main/java/org/springframework/persistence/support/EntityInstantiator.java diff --git a/src/main/java/org/springframework/persistence/support/AbstractConstructorEntityInstantiator.java b/src/main/java/org/springframework/persistence/support/AbstractConstructorEntityInstantiator.java deleted file mode 100644 index 9d7efbc10..000000000 --- a/src/main/java/org/springframework/persistence/support/AbstractConstructorEntityInstantiator.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.springframework.persistence.support; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.util.ClassUtils; - -/** - * Try for a constructor taking state: failing that, try a no-arg - * constructor and then setUnderlyingNode(). - * - * @author Rod Johnson - */ -public abstract class AbstractConstructorEntityInstantiator implements EntityInstantiator { - - private final Log log = LogFactory.getLog(getClass()); - - final public T createEntityFromState(STATE n, Class c) { - try { - return fromStateInternal(n, c); - } catch (InstantiationException e) { - throw new IllegalArgumentException(e); - } catch (IllegalAccessException e) { - throw new IllegalArgumentException(e); - } catch (InvocationTargetException e) { - throw new IllegalArgumentException(e); - } - } - - final private T fromStateInternal(STATE n, Class c) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { - // TODO this is fragile - Class stateInterface = (Class) n.getClass().getInterfaces()[0]; - Constructor nodeConstructor = ClassUtils.getConstructorIfAvailable(c, stateInterface); - if (nodeConstructor != null) { - // TODO is this the correct way to instantiate or does Spring have a preferred way? - log.info("Using " + c + " constructor taking " + stateInterface); - return nodeConstructor.newInstance(n); - } - - Constructor noArgConstructor = ClassUtils.getConstructorIfAvailable(c); - if (noArgConstructor != null) { - log.info("Using " + c + " no-arg constructor"); - T t = noArgConstructor.newInstance(); - setState(t, n); - return t; - } - - throw new IllegalArgumentException(getClass().getSimpleName() + ": entity " + c + " must have either a constructor taking [" + stateInterface + - "] or a no-arg constructor and state set method"); - } - - /** - * Subclasses must implement to set state - * @param entity - * @param s - */ - protected abstract void setState(BACKING_INTERFACE entity, STATE s); - -} diff --git a/src/main/java/org/springframework/persistence/support/AbstractMixinFields.aj b/src/main/java/org/springframework/persistence/support/AbstractMixinFields.aj deleted file mode 100644 index 9e6473ea3..000000000 --- a/src/main/java/org/springframework/persistence/support/AbstractMixinFields.aj +++ /dev/null @@ -1,54 +0,0 @@ -package org.springframework.persistence.support; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.annotation.Configurable; -import org.springframework.persistence.RelatedEntity; - -/** - * Abstract superaspect to advise field read and write - * and introduce a mixin interface. - * - * @param type of introduced interface - * - * @author Rod Johnson - */ -privileged abstract public aspect AbstractMixinFields { - - protected final Log log = LogFactory.getLog(getClass()); - - //------------------------------------------------------------------------- - // ITDs to add behavior and state to classes - //------------------------------------------------------------------------- - // Enable Spring DI for all mixed-in objects - declare @type: N+: @Configurable; - - //------------------------------------------------------------------------- - // Advice for field get/set to delegate to backing Node. - //------------------------------------------------------------------------- - protected pointcut entityFieldGet(N entity) : - get(* N+.*) && - this(entity) && - !(get(@RelatedEntity * *) - || get(* N.*) - || getsNotToAdvise()); - - /** - * Never matches. Subclasses can override to exempt certain field reads from advice - */ - protected pointcut getsNotToAdvise(); - - protected pointcut entityFieldSet(N entity, Object newVal) : - set(* N+.*) && - this(entity) && - args(newVal) && - !(set(@RelatedEntity * *) || - set(* N.*) || - setsNotToAdvise()); - - /** - * Never matches. Subclasses can override to exempt certain field writes from advice - */ - protected pointcut setsNotToAdvise(); - -} diff --git a/src/main/java/org/springframework/persistence/support/AbstractTypeAnnotatingMixinFields.aj b/src/main/java/org/springframework/persistence/support/AbstractTypeAnnotatingMixinFields.aj deleted file mode 100644 index ba63e81e4..000000000 --- a/src/main/java/org/springframework/persistence/support/AbstractTypeAnnotatingMixinFields.aj +++ /dev/null @@ -1,21 +0,0 @@ -package org.springframework.persistence.support; - -import java.lang.annotation.Annotation; - -/** - * Abstract superaspect for aspects that advice - * field access with a mixin for all types annotated with - * a given annotation. - * - * @param annotation on entity - * @param type of introduced interface - * - * @author Rod Johnson - */ -privileged abstract public aspect AbstractTypeAnnotatingMixinFields - extends AbstractMixinFields { - - // ITD to introduce N state to Annotated objects - declare parents : (@ET *) implements N; - -} diff --git a/src/main/java/org/springframework/persistence/support/EntityInstantiator.java b/src/main/java/org/springframework/persistence/support/EntityInstantiator.java deleted file mode 100644 index f17db133e..000000000 --- a/src/main/java/org/springframework/persistence/support/EntityInstantiator.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.springframework.persistence.support; - - -/** - * Interface to be implemented by classes that can instantiate and - * configure entities. - * The framework must do this when creating objects resulting from finders, - * even when there may be no no-arg constructor supplied by the user. - * - * @author Rod Johnson - */ -public interface EntityInstantiator { - - /* - * The best solution if available is to add a constructor that takes Node - * to each GraphEntity. This means generating an aspect beside every - * class as Roo presently does. - * - * An alternative that does not require Roo - * is a user-authored constructor taking Node and calling setUnderlyingNode() - * but this is less elegant and pollutes the domain object. - * - * If the user supplies a no-arg constructor, instantiation can occur by invoking it - * prior to calling setUnderlyingNode(). - * - * If the user does NOT supply a no-arg constructor, we must rely on Sun-specific - * code to instantiate entities without invoking a constructor. - */ - - T createEntityFromState(STATE s, Class c); - -}