|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.avalon.fortress.impl.role.AbstractMetaInfoManager
org.apache.avalon.fortress.impl.role.ServiceMetaManager
public final class ServiceMetaManager
ServiceMetaManager follows some simple rules to dynamically gather all services and the meta-information into one role manager. This really gets rid of the need of multiple role managers. It uses a set of entries in your JARs to do its magic.
/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>
Field Summary |
---|
Fields inherited from interface org.apache.avalon.fortress.MetaInfoManager |
---|
ROLE |
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
Methods inherited from class org.apache.avalon.fortress.impl.role.AbstractMetaInfoManager |
---|
addComponent, getLoader, getMetaInfoForClassname, getMetaInfoForShortName, isAlreadyAdded |
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
---|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public 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
- Method Detail |
---|
public void initialize() throws java.lang.Exception
initialize
in interface org.apache.avalon.framework.activity.Initializable
java.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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |