org.dynalang.mop.impl
Class AutoDiscovery

java.lang.Object
  extended by org.dynalang.mop.impl.AutoDiscovery

public class AutoDiscovery
extends java.lang.Object

Provides methods for automatic discovery of all metaobject protocols listed in the /META-INF/services/org.dynalang.mop.BaseMetaobjectProtocol resources of all JAR files for a particular class loader.

Version:
$Id: $
Author:
Attila Szegedi

Method Summary
static BaseMetaobjectProtocol[] discoverBaseMetaobjectProtocols()
          Returns an instance of all metaobject protocol classes that are declared in the /META-INF/services/org.dynalang.mop.BaseMetaobjectProtocol resources of all JAR files in the current thread's context class loader's classpath.
static BaseMetaobjectProtocol[] discoverBaseMetaobjectProtocols(java.lang.ClassLoader cl)
          Returns an instance of all metaobject protocol classes that are declared in the /META-INF/services/org.dynalang.mop.BaseMetaobjectProtocol resources of all JAR files in the specified class loader's classpath.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

discoverBaseMetaobjectProtocols

public static BaseMetaobjectProtocol[] discoverBaseMetaobjectProtocols()
                                                                throws java.io.IOException,
                                                                       java.lang.InstantiationException,
                                                                       java.lang.IllegalAccessException,
                                                                       java.lang.ClassNotFoundException
Returns an instance of all metaobject protocol classes that are declared in the /META-INF/services/org.dynalang.mop.BaseMetaobjectProtocol resources of all JAR files in the current thread's context class loader's classpath.

Returns:
an array of base MOPs. The returned array can be empty. You will probably want to run the return value through MetaobjectProtocolAdaptor.toMetaobjectProtocols(BaseMetaobjectProtocol[]) if your code uses the full MOP interface instead of the base one.
Throws:
java.io.IOException - if there is a problem reading classpath resources
java.lang.InstantiationException - if a class declared in a service list can not be instantiated
java.lang.IllegalAccessException - if a class declared in a service list is not public or does not have a publicly visible default constructor
java.lang.ClassNotFoundException - if a class declared in a service list is not found
java.lang.ClassCastException - if a class declared in a service list does not implement the BaseMetaobjectProtocol interface.

discoverBaseMetaobjectProtocols

public static BaseMetaobjectProtocol[] discoverBaseMetaobjectProtocols(java.lang.ClassLoader cl)
                                                                throws java.io.IOException,
                                                                       java.lang.InstantiationException,
                                                                       java.lang.IllegalAccessException,
                                                                       java.lang.ClassNotFoundException
Returns an instance of all metaobject protocol classes that are declared in the /META-INF/services/org.dynalang.mop.BaseMetaobjectProtocol resources of all JAR files in the specified class loader's classpath.

Parameters:
cl - the class loader within which the MOPs are discovered. null can be used to denote the system class loader.
Returns:
an array of base MOPs. The returned array can be empty. You will probably want to run the return value through. MetaobjectProtocolAdaptor.toMetaobjectProtocols(BaseMetaobjectProtocol[]) if your code uses the full MOP interface instead of the base one.
Throws:
java.io.IOException - if there is a problem reading classpath resources
java.lang.InstantiationException - if a class declared in a service list can not be instantiated
java.lang.IllegalAccessException - if a class declared in a service list is not public or does not have a publicly visible default constructor
java.lang.ClassNotFoundException - if a class declared in a service list is not found
java.lang.ClassCastException - if a class declared in a service list does not implement the BaseMetaobjectProtocol interface.