Java Code Examples for org.springframework.util.ClassUtils#createCompositeInterface()

The following examples show how to use org.springframework.util.ClassUtils#createCompositeInterface() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AspectJExpressionPointcut.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private ShadowMatch getTargetShadowMatch(Method method, Class<?> targetClass) {
	Method targetMethod = AopUtils.getMostSpecificMethod(method, targetClass);
	if (targetMethod.getDeclaringClass().isInterface()) {
		// Try to build the most specific interface possible for inherited methods to be
		// considered for sub-interface matches as well, in particular for proxy classes.
		// Note: AspectJ is only going to take Method.getDeclaringClass() into account.
		Set<Class<?>> ifcs = ClassUtils.getAllInterfacesForClassAsSet(targetClass);
		if (ifcs.size() > 1) {
			try {
				Class<?> compositeInterface = ClassUtils.createCompositeInterface(
						ClassUtils.toClassArray(ifcs), targetClass.getClassLoader());
				targetMethod = ClassUtils.getMostSpecificMethod(targetMethod, compositeInterface);
			}
			catch (IllegalArgumentException ex) {
				// Implemented interfaces probably expose conflicting method signatures...
				// Proceed with original target method.
			}
		}
	}
	return getShadowMatch(targetMethod, method);
}
 
Example 2
Source File: AspectJExpressionPointcut.java    From java-technology-stack with MIT License 6 votes vote down vote up
private ShadowMatch getTargetShadowMatch(Method method, Class<?> targetClass) {
	Method targetMethod = AopUtils.getMostSpecificMethod(method, targetClass);
	if (targetMethod.getDeclaringClass().isInterface()) {
		// Try to build the most specific interface possible for inherited methods to be
		// considered for sub-interface matches as well, in particular for proxy classes.
		// Note: AspectJ is only going to take Method.getDeclaringClass() into account.
		Set<Class<?>> ifcs = ClassUtils.getAllInterfacesForClassAsSet(targetClass);
		if (ifcs.size() > 1) {
			try {
				Class<?> compositeInterface = ClassUtils.createCompositeInterface(
						ClassUtils.toClassArray(ifcs), targetClass.getClassLoader());
				targetMethod = ClassUtils.getMostSpecificMethod(targetMethod, compositeInterface);
			}
			catch (IllegalArgumentException ex) {
				// Implemented interfaces probably expose conflicting method signatures...
				// Proceed with original target method.
			}
		}
	}
	return getShadowMatch(targetMethod, method);
}
 
Example 3
Source File: StandardScriptFactory.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Nullable
protected Object adaptToInterfaces(
		@Nullable Object script, ScriptSource scriptSource, Class<?>... actualInterfaces) {

	Class<?> adaptedIfc;
	if (actualInterfaces.length == 1) {
		adaptedIfc = actualInterfaces[0];
	}
	else {
		adaptedIfc = ClassUtils.createCompositeInterface(actualInterfaces, this.beanClassLoader);
	}

	if (adaptedIfc != null) {
		ScriptEngine scriptEngine = this.scriptEngine;
		if (!(scriptEngine instanceof Invocable)) {
			throw new ScriptCompilationException(scriptSource,
					"ScriptEngine must implement Invocable in order to adapt it to an interface: " + scriptEngine);
		}
		Invocable invocable = (Invocable) scriptEngine;
		if (script != null) {
			script = invocable.getInterface(script, adaptedIfc);
		}
		if (script == null) {
			script = invocable.getInterface(adaptedIfc);
			if (script == null) {
				throw new ScriptCompilationException(scriptSource,
						"Could not adapt script to interface [" + adaptedIfc.getName() + "]");
			}
		}
	}

	return script;
}
 
Example 4
Source File: StandardScriptFactory.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
protected Object adaptToInterfaces(Object script, ScriptSource scriptSource, Class<?>... actualInterfaces) {
	Class<?> adaptedIfc;
	if (actualInterfaces.length == 1) {
		adaptedIfc = actualInterfaces[0];
	}
	else {
		adaptedIfc = ClassUtils.createCompositeInterface(actualInterfaces, this.beanClassLoader);
	}

	if (adaptedIfc != null) {
		if (!(this.scriptEngine instanceof Invocable)) {
			throw new ScriptCompilationException(scriptSource,
					"ScriptEngine must implement Invocable in order to adapt it to an interface: " +
							this.scriptEngine);
		}
		Invocable invocable = (Invocable) this.scriptEngine;
		if (script != null) {
			script = invocable.getInterface(script, adaptedIfc);
		}
		if (script == null) {
			script = invocable.getInterface(adaptedIfc);
			if (script == null) {
				throw new ScriptCompilationException(scriptSource,
						"Could not adapt script to interface [" + adaptedIfc.getName() + "]");
			}
		}
	}

	return script;
}
 
Example 5
Source File: StandardScriptFactory.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
protected Object adaptToInterfaces(Object script, ScriptSource scriptSource, Class<?>... actualInterfaces) {
	Class<?> adaptedIfc;
	if (actualInterfaces.length == 1) {
		adaptedIfc = actualInterfaces[0];
	}
	else {
		adaptedIfc = ClassUtils.createCompositeInterface(actualInterfaces, this.beanClassLoader);
	}

	if (adaptedIfc != null) {
		if (!(this.scriptEngine instanceof Invocable)) {
			throw new ScriptCompilationException(scriptSource,
					"ScriptEngine must implement Invocable in order to adapt it to an interface: " +
							this.scriptEngine);
		}
		Invocable invocable = (Invocable) this.scriptEngine;
		if (script != null) {
			script = invocable.getInterface(script, adaptedIfc);
		}
		if (script == null) {
			script = invocable.getInterface(adaptedIfc);
			if (script == null) {
				throw new ScriptCompilationException(scriptSource,
						"Could not adapt script to interface [" + adaptedIfc.getName() + "]");
			}
		}
	}

	return script;
}
 
Example 6
Source File: StandardScriptFactory.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Nullable
protected Object adaptToInterfaces(
		@Nullable Object script, ScriptSource scriptSource, Class<?>... actualInterfaces) {

	Class<?> adaptedIfc;
	if (actualInterfaces.length == 1) {
		adaptedIfc = actualInterfaces[0];
	}
	else {
		adaptedIfc = ClassUtils.createCompositeInterface(actualInterfaces, this.beanClassLoader);
	}

	if (adaptedIfc != null) {
		ScriptEngine scriptEngine = this.scriptEngine;
		if (!(scriptEngine instanceof Invocable)) {
			throw new ScriptCompilationException(scriptSource,
					"ScriptEngine must implement Invocable in order to adapt it to an interface: " + scriptEngine);
		}
		Invocable invocable = (Invocable) scriptEngine;
		if (script != null) {
			script = invocable.getInterface(script, adaptedIfc);
		}
		if (script == null) {
			script = invocable.getInterface(adaptedIfc);
			if (script == null) {
				throw new ScriptCompilationException(scriptSource,
						"Could not adapt script to interface [" + adaptedIfc.getName() + "]");
			}
		}
	}

	return script;
}
 
Example 7
Source File: ProxyFactoryBean.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Create a composite interface Class for the given interfaces,
 * implementing the given interfaces in one single Class.
 * <p>The default implementation builds a JDK proxy class for the
 * given interfaces.
 * @param interfaces the interfaces to merge
 * @return the merged interface as Class
 * @see java.lang.reflect.Proxy#getProxyClass
 */
protected Class<?> createCompositeInterface(Class<?>[] interfaces) {
	return ClassUtils.createCompositeInterface(interfaces, this.proxyClassLoader);
}
 
Example 8
Source File: JndiObjectFactoryBean.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Create a composite interface Class for the given interfaces,
 * implementing the given interfaces in one single Class.
 * <p>The default implementation builds a JDK proxy class for the
 * given interfaces.
 * @param interfaces the interfaces to merge
 * @return the merged interface as Class
 * @see java.lang.reflect.Proxy#getProxyClass
 */
protected Class<?> createCompositeInterface(Class<?>[] interfaces) {
	return ClassUtils.createCompositeInterface(interfaces, this.beanClassLoader);
}
 
Example 9
Source File: ScriptFactoryPostProcessor.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Create a composite interface Class for the given interfaces,
 * implementing the given interfaces in one single Class.
 * <p>The default implementation builds a JDK proxy class
 * for the given interfaces.
 * @param interfaces the interfaces to merge
 * @return the merged interface as Class
 * @see java.lang.reflect.Proxy#getProxyClass
 */
protected Class<?> createCompositeInterface(Class<?>[] interfaces) {
	return ClassUtils.createCompositeInterface(interfaces, this.beanClassLoader);
}
 
Example 10
Source File: ScriptFactoryPostProcessor.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Create a composite interface Class for the given interfaces,
 * implementing the given interfaces in one single Class.
 * <p>The default implementation builds a JDK proxy class
 * for the given interfaces.
 * @param interfaces the interfaces to merge
 * @return the merged interface as Class
 * @see java.lang.reflect.Proxy#getProxyClass
 */
protected Class<?> createCompositeInterface(Class<?>[] interfaces) {
	return ClassUtils.createCompositeInterface(interfaces, this.beanClassLoader);
}
 
Example 11
Source File: JndiObjectFactoryBean.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a composite interface Class for the given interfaces,
 * implementing the given interfaces in one single Class.
 * <p>The default implementation builds a JDK proxy class for the
 * given interfaces.
 * @param interfaces the interfaces to merge
 * @return the merged interface as Class
 * @see java.lang.reflect.Proxy#getProxyClass
 */
protected Class<?> createCompositeInterface(Class<?>[] interfaces) {
	return ClassUtils.createCompositeInterface(interfaces, this.beanClassLoader);
}
 
Example 12
Source File: ScriptFactoryPostProcessor.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a composite interface Class for the given interfaces,
 * implementing the given interfaces in one single Class.
 * <p>The default implementation builds a JDK proxy class
 * for the given interfaces.
 * @param interfaces the interfaces to merge
 * @return the merged interface as Class
 * @see java.lang.reflect.Proxy#getProxyClass
 */
protected Class<?> createCompositeInterface(Class<?>[] interfaces) {
	return ClassUtils.createCompositeInterface(interfaces, this.beanClassLoader);
}
 
Example 13
Source File: JndiObjectFactoryBean.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Create a composite interface Class for the given interfaces,
 * implementing the given interfaces in one single Class.
 * <p>The default implementation builds a JDK proxy class for the
 * given interfaces.
 * @param interfaces the interfaces to merge
 * @return the merged interface as Class
 * @see java.lang.reflect.Proxy#getProxyClass
 */
protected Class<?> createCompositeInterface(Class<?>[] interfaces) {
	return ClassUtils.createCompositeInterface(interfaces, this.beanClassLoader);
}
 
Example 14
Source File: ProxyFactoryBean.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a composite interface Class for the given interfaces,
 * implementing the given interfaces in one single Class.
 * <p>The default implementation builds a JDK proxy class for the
 * given interfaces.
 * @param interfaces the interfaces to merge
 * @return the merged interface as Class
 * @see java.lang.reflect.Proxy#getProxyClass
 */
protected Class<?> createCompositeInterface(Class<?>[] interfaces) {
	return ClassUtils.createCompositeInterface(interfaces, this.proxyClassLoader);
}
 
Example 15
Source File: ProxyFactoryBean.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Create a composite interface Class for the given interfaces,
 * implementing the given interfaces in one single Class.
 * <p>The default implementation builds a JDK proxy class for the
 * given interfaces.
 * @param interfaces the interfaces to merge
 * @return the merged interface as Class
 * @see java.lang.reflect.Proxy#getProxyClass
 */
protected Class<?> createCompositeInterface(Class<?>[] interfaces) {
	return ClassUtils.createCompositeInterface(interfaces, this.proxyClassLoader);
}
 
Example 16
Source File: JndiObjectFactoryBean.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Create a composite interface Class for the given interfaces,
 * implementing the given interfaces in one single Class.
 * <p>The default implementation builds a JDK proxy class for the
 * given interfaces.
 * @param interfaces the interfaces to merge
 * @return the merged interface as Class
 * @see java.lang.reflect.Proxy#getProxyClass
 */
protected Class<?> createCompositeInterface(Class<?>[] interfaces) {
	return ClassUtils.createCompositeInterface(interfaces, this.beanClassLoader);
}
 
Example 17
Source File: ScriptFactoryPostProcessor.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Create a composite interface Class for the given interfaces,
 * implementing the given interfaces in one single Class.
 * <p>The default implementation builds a JDK proxy class
 * for the given interfaces.
 * @param interfaces the interfaces to merge
 * @return the merged interface as Class
 * @see java.lang.reflect.Proxy#getProxyClass
 */
protected Class<?> createCompositeInterface(Class<?>[] interfaces) {
	return ClassUtils.createCompositeInterface(interfaces, this.beanClassLoader);
}
 
Example 18
Source File: ProxyFactoryBean.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Create a composite interface Class for the given interfaces,
 * implementing the given interfaces in one single Class.
 * <p>The default implementation builds a JDK proxy class for the
 * given interfaces.
 * @param interfaces the interfaces to merge
 * @return the merged interface as Class
 * @see java.lang.reflect.Proxy#getProxyClass
 */
protected Class<?> createCompositeInterface(Class<?>[] interfaces) {
	return ClassUtils.createCompositeInterface(interfaces, this.proxyClassLoader);
}