public interface ProxyServices extends Service
Support services related to proxy generation and serialization which are required to be implemented by all containers.
These services are used by all Weld proxy classes to ensure the correct class loaders are used and to aid in the serialization and deserialization of these classes across container instances.
Required in all environments since proxies are always in use. A default implementation will be used if none are provided by the container which will use the information directly from the type of proxy.
ProxyServices is a per-deployment service.
| Modifier and Type | Method and Description |
|---|---|
default Class<?> |
defineClass(Class<?> originalClass,
String className,
byte[] classBytes,
int off,
int len)
Given a base type (class or interface), define a proxy class for this type.
|
default Class<?> |
defineClass(Class<?> originalClass,
String className,
byte[] classBytes,
int off,
int len,
ProtectionDomain protectionDomain)
Given a base type (class or interface), define a proxy class for this type.
|
ClassLoader |
getClassLoader(Class<?> proxiedBeanType)
Deprecated.
defineClass() methods should be used instead.
Returns the class loader that will load the proxy class which extends or implements the given type. This class loader may
simply be the same class loader used for the type, or it may be another class loader designed to hold proxies while still
providing access to the given type and any of its ancestors and used types. |
Class<?> |
loadBeanClass(String className)
Deprecated.
loadClass(Class<?>, String) should be used instead.
Loads classes or interfaces extended/implemented by a bean or in particular a proxy class for a bean. This includes application types of the bean as well as Weld types used for proxy classes. Thus the class loader(s) used here must be able to resolve both application classes and Weld implementation classes.
This method is only called during deserialization of a proxy object. It does not necessarily need to use the same class
loader that the proxy class itself exists in since |
default Class<?> |
loadClass(Class<?> originalClass,
String classBinaryName)
Given a base type (class or interface), attempts to load a proxy of that class.
|
default boolean |
supportsClassDefining()
Works as a differentiator between the old (deprecated) approach of asking for
ClassLoader and the new
one where Weld delegates class loading and creation to the integrator. |
@Deprecated ClassLoader getClassLoader(Class<?> proxiedBeanType)
defineClass() methods should be used instead.
Returns the class loader that will load the proxy class which extends or implements the given type. This class loader may
simply be the same class loader used for the type, or it may be another class loader designed to hold proxies while still
providing access to the given type and any of its ancestors and used types.proxiedBeanType - the base type (class or interface) being proxied@Deprecated Class<?> loadBeanClass(String className)
loadClass(Class<?>, String) should be used instead.
Loads classes or interfaces extended/implemented by a bean or in particular a proxy class for a bean. This includes application types of the bean as well as Weld types used for proxy classes. Thus the class loader(s) used here must be able to resolve both application classes and Weld implementation classes.
This method is only called during deserialization of a proxy object. It does not necessarily need to use the same class
loader that the proxy class itself exists in since getClassLoader(Class) will still be used to get the correct
class loader for the bean type.
className - the class namedefault Class<?> defineClass(Class<?> originalClass, String className, byte[] classBytes, int off, int len) throws ClassFormatError
ClassLoader instance to forward creation to.
Mimics ClassLoader.defineClass(String name, byte[] b, int off, int len).
Returns the created class object or throws an exception if there data are not valid or if there is any other
problem registering the class with the ClassLoader.originalClass - The base type (class or interface) being proxiedclassName - The binary name of the classclassBytes - The bytes that make up the class dataoff - The start offset in classBytes of the class datalen - The length of the class dataClass object created from the dataClassFormatError - If the data did not contain a valid classdefault Class<?> defineClass(Class<?> originalClass, String className, byte[] classBytes, int off, int len, ProtectionDomain protectionDomain) throws ClassFormatError
ClassLoader instance to forward creation to.
The ProtectionDomain passed as an argument can be null (see default implementation of the second
defineClass() method). In such a case a new ProtectionDomain should be derived from the originalClass.
Mimics ClassLoader.defineClass(String name, byte[] b, int off, int len, ProtectionDomain domain).
Returns the created class object or throws an exception if there data are not valid or if there is any other
problem registering the class with the ClassLoader.originalClass - The base type (class or interface) being proxiedclassName - The binary name of the classclassBytes - The bytes that make up the class dataoff - The start offset in classBytes of the class datalen - The length of the class dataprotectionDomain - The ProtectionDomain of the class or nullClass object created from the dataClassFormatError - If the data did not contain a valid classdefault Class<?> loadClass(Class<?> originalClass, String classBinaryName) throws ClassNotFoundException
ClassLoader instance to query.originalClass - The base type (class or interface) whose proxy we try to loadclassBinaryName - The binary name of the classClass object for given binary name of the classClassNotFoundException - If the class was not founddefault boolean supportsClassDefining()
ClassLoader and the new
one where Weld delegates class loading and creation to the integrator. If this method returns true, then Weld
will route all proxy lookup and definition to newly added method. Should it return false, Weld will only
use the old ClassLoader approach.defineClass() and loadClass() methods, false otherwise.Copyright © 2008–2019. All rights reserved.