Implementations will call the methods in this class to help with the common aspects involved with proxy creation - * of all kinds.
- * - * @paramThe default implementation of this method returns the {@linkplain Thread#getContextClassLoader() context - * classloader}.
- * - * @param e a {@link TypeElement}; must not be {@code null}; must be a {@linkplain - * javax.lang.model.element.ElementKind#isDeclaredType() declared type} - * - * @return a non-{@code null} {@link ClassLoader} - * - * @exception NullPointerException if {@code e} is {@code null} - * - * @exception IllegalArgumentException if {@code e} {@linkplain javax.lang.model.element.ElementKind#isDeclaredType() - * is not a declared type} - */ - protected ClassLoader classLoader(final TypeElement e) { - if (!e.getKind().isDeclaredType()) { - throw new IllegalArgumentException("e: " + e); - } - return Thread.currentThread().getContextClassLoader(); - } - - /** - * Returns the {@link Domain} {@linkplain #AbstractProxier(Domain) supplied at construction time}. - * - * @return a non-{@code null} {@link Domain} - * - * @see #AbstractProxier(Domain) - */ - protected final Domain domain() { - return this.domain; - } - - /** - * Creates a generated class definition from the information present in the supplied {@link ProxySpecification}, and - * returns it for eventual supplying to an inovcation of the {@link #proxyClass(Object, ClassLoader)} method (optional - * operation). - * - *The default implementation of this method throws an {@link UnsupportedOperationException}.
- * - * @param ps a {@link ProxySpecification}; must not be {@code null} - * - * @return a non-{@code null} generated class definition - * - * @exception NullPointerException if {@code ps} is {@code null} - * - * @exception UnsupportedOperationException if this operation is unsupported - * - * @exception Throwable if creation of the generated class definition fails - * - * @see #proxyClass(Object, ClassLoader) - */ - protected T generate(final PS ps) throws Throwable { - throw new UnsupportedOperationException(); - } - - /** - * Creates a new instance of a {@link Proxy Proxy<R>} that proxies contextual instances supplied by - * the supplied {@code instanceSupplier}, and returns it (optional operation). - * - * @paramOverrides of this method must not call the {@link #proxyClass(ProxySpecification)} method or undefined behavior - * may result.
- * - * @param t a class definition; must not be {@code null} - * - * @param cl a {@link ClassLoader}; must not be {@code null} - * - * @return a non-{@code null} {@link Class} - * - * @exception NullPointerException if any argument is {@code null} - * - * @exception UnsupportedOperationException if class generation is not supported by this {@link AbstractProxier} - * - * @exception ClassNotFoundException if an invocation of {@link ClassLoader#loadClass(String)} fails - * - * @see #proxyClass(ProxySpecification) - */ - // Turns a T into a Class (loads it) using a ClassLoader. For reflection-based implementations, t may already be a - // Class. - protected abstract Class> proxyClass(final T t, final ClassLoader cl) throws ClassNotFoundException; - -} diff --git a/src/main/java/org/microbean/proxy/AbstractReflectiveProxier.java b/src/main/java/org/microbean/proxy/AbstractReflectiveProxier.java index 93dbf67..b2d67b1 100644 --- a/src/main/java/org/microbean/proxy/AbstractReflectiveProxier.java +++ b/src/main/java/org/microbean/proxy/AbstractReflectiveProxier.java @@ -35,8 +35,6 @@ import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; -import java.util.function.Supplier; - import org.microbean.construct.Domain; /** @@ -51,10 +49,6 @@ * @author Laird Nelson * * @see #proxy(ProxySpecification, Supplier) - * - * @see #type(Type) - * - * @see #executableElement(Executable) */ public abstract non-sealed class AbstractReflectiveProxier