public final class ServiceMetaManager extends AbstractMetaInfoManager implements org.apache.avalon.framework.activity.Initializable
/services.list
This lists all the services that are defined in this jar.
/META-INF/services/my.class.Name
One entry for each service where there are implementations for a role. This follows the JAR services mechanism.
/my/class/Implementation.meta
There is one entry sitting right beside every implementation class. This holds all the meta information for the associated class. It is a simple properties file.
We have a couple of ANT tasks to make this really easy. If you add this to your ANT build script (customizing it to make it work in your environment), it will make your life alot easier:
<taskdef name="collect-metainfo" classname="org.apache.avalon.fortress.tools.ComponentMetaAntTask">
<classpath>
<path refid="project.class.path"/>
<pathelement path="${tools.dir}/guiapp-tools.jar"/>
</classpath>
</taskdef>
<collect-metainfo destdir="${build.classes}">
<fileset dir="${src.dir}"/>
</collect-metainfo>
| Constructor and Description |
|---|
ServiceMetaManager()
Create a ServiceMetaManager.
|
ServiceMetaManager(org.apache.avalon.fortress.MetaInfoManager parent)
Create a ServiceMetaManager with a parent RoleManager.
|
ServiceMetaManager(org.apache.avalon.fortress.MetaInfoManager parent,
java.lang.ClassLoader loader)
Create a ServiceMetaManager with the supplied classloader and
parent RoleManager.
|
ServiceMetaManager(org.apache.avalon.fortress.RoleManager parent)
Create a ServiceMetaManager with a parent RoleManager.
|
| Modifier and Type | Method and Description |
|---|---|
private java.lang.String |
getDepFile(java.lang.String implementation)
Translate a class name into the meta file name.
|
private java.lang.String |
getMetaFile(java.lang.String implementation)
Translate a class name into the meta file name.
|
void |
initialize()
Initialize the ServiceMetaManager by looking at all the services and
classes available in the system.
|
private void |
readEntries(java.util.Set entries,
java.net.URL url)
Read entries in a list file and add them all to the provided Set.
|
private void |
readMeta(java.lang.String role,
java.lang.String implementation)
Read the meta information in and actually add the role.
|
private void |
setupImplementations(java.lang.String role)
Get all the implementations of a service and set up their meta
information.
|
addComponent, getLoader, getMetaInfoForClassname, getMetaInfoForShortName, isAlreadyAddedpublic ServiceMetaManager()
public ServiceMetaManager(org.apache.avalon.fortress.RoleManager parent)
parent - public ServiceMetaManager(org.apache.avalon.fortress.MetaInfoManager parent)
parent - public ServiceMetaManager(org.apache.avalon.fortress.MetaInfoManager parent,
java.lang.ClassLoader loader)
parent - loader - public void initialize()
throws java.lang.Exception
initialize in interface org.apache.avalon.framework.activity.Initializablejava.lang.Exception - if there is a problemprivate void setupImplementations(java.lang.String role)
throws java.lang.ClassNotFoundException
role - The role name we are reading implementations for.java.lang.ClassNotFoundException - if the role or component cannot be foundprivate void readMeta(java.lang.String role,
java.lang.String implementation)
role - implementation - private java.lang.String getMetaFile(java.lang.String implementation)
implementation - private java.lang.String getDepFile(java.lang.String implementation)
implementation - private void readEntries(java.util.Set entries,
java.net.URL url)
throws java.io.IOException
entries - url - java.io.IOException - if we cannot read the entries