org.apache.avalon.fortress.tools
Class Component

java.lang.Object
  extended by org.apache.avalon.fortress.tools.Component

final class Component
extends java.lang.Object

Represents a component, and output the meta information.

Version:
CVS $Revision: 1.1 $ $Date: 2004/04/02 08:29:44 $
Author:
The Avalon Team

Field Summary
(package private) static java.lang.String ATTR_NAME
           
(package private) static java.lang.String ATTR_TYPE
           
private  java.util.Properties m_attributes
           
private  java.util.List m_dependencies
           
private  java.util.List m_dependencyNames
           
private  com.thoughtworks.qdox.model.JavaClass m_javaClass
           
(package private) static java.util.Set m_repository
          The repository of components.
private  java.util.List m_serviceNames
           
private  org.apache.avalon.fortress.util.dag.Vertex m_vertex
           
private static java.lang.String META_NAME
           
private static java.lang.String METH_SERVICE
           
private static java.lang.String POOLABLE
           
private static java.lang.String RECYCLABLE
           
private static java.lang.String SERVICE_MANAGER
           
private static java.lang.String SINGLE_THREADED
           
private static java.lang.String TAG_DEPENDENCY
           
private static java.lang.String TAG_HANDLER
           
private static java.lang.String TAG_INFO
           
private static java.lang.String TAG_LIFESTYLE
           
private static java.lang.String TAG_NAME
           
private static java.lang.String TAG_SERVICE
           
private static java.lang.String THREAD_SAFE
           
 
Constructor Summary
Component(com.thoughtworks.qdox.model.JavaClass javaClass)
          Initialize a service with the type name.
 
Method Summary
 void addDependency(Service service)
          Add a dependency to this type.
private  java.lang.String checkImport(com.thoughtworks.qdox.model.JavaSource sourceCode, java.lang.String type, java.lang.String className)
           
private  java.lang.String checkPackage(com.thoughtworks.qdox.model.JavaSource sourceCode, java.lang.String pack, java.lang.String serviceName)
           
private  void discoverDependencies()
          Recursively discover dependencies from the local class hierarchy.
private  boolean discoverDependencies(com.thoughtworks.qdox.model.JavaClass fromClass)
          Discover the dependencies that this component class requires.
private  void discoverLifecycleType()
           
private  void discoverNameInfo()
           
 java.util.Iterator getDependencyNames()
           
 java.util.Iterator getServiceNames()
           
 java.lang.String getType()
          Get the type name.
 org.apache.avalon.fortress.util.dag.Vertex getVertex()
           
protected  java.lang.String resolveClassName(com.thoughtworks.qdox.model.JavaSource sourceCode, java.lang.String serviceName)
          Resolve the classname from the "@avalon.service" javadoc tags.
 void serialize(java.io.File rootDir)
          Output the meta information.
 void setAttribute(java.lang.String name, java.lang.String value)
          Set the component attribute.
private  java.lang.String stripQuotes(java.lang.String value)
           
private  void writeIfChanged(java.util.Properties props, java.io.File file, java.lang.String desc)
          Only writes the properties file if it is new or if the existing file contains different values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SINGLE_THREADED

private static final java.lang.String SINGLE_THREADED
See Also:
Constant Field Values

THREAD_SAFE

private static final java.lang.String THREAD_SAFE
See Also:
Constant Field Values

POOLABLE

private static final java.lang.String POOLABLE
See Also:
Constant Field Values

RECYCLABLE

private static final java.lang.String RECYCLABLE
See Also:
Constant Field Values

SERVICE_MANAGER

private static final java.lang.String SERVICE_MANAGER
See Also:
Constant Field Values

ATTR_TYPE

static final java.lang.String ATTR_TYPE
See Also:
Constant Field Values

ATTR_NAME

static final java.lang.String ATTR_NAME
See Also:
Constant Field Values

TAG_SERVICE

private static final java.lang.String TAG_SERVICE
See Also:
Constant Field Values

TAG_DEPENDENCY

private static final java.lang.String TAG_DEPENDENCY
See Also:
Constant Field Values

TAG_LIFESTYLE

private static final java.lang.String TAG_LIFESTYLE
See Also:
Constant Field Values

TAG_HANDLER

private static final java.lang.String TAG_HANDLER
See Also:
Constant Field Values

TAG_INFO

private static final java.lang.String TAG_INFO
See Also:
Constant Field Values

TAG_NAME

private static final java.lang.String TAG_NAME
See Also:
Constant Field Values

META_NAME

private static final java.lang.String META_NAME
See Also:
Constant Field Values

METH_SERVICE

private static final java.lang.String METH_SERVICE
See Also:
Constant Field Values

m_repository

static final java.util.Set m_repository
The repository of components.


m_javaClass

private final com.thoughtworks.qdox.model.JavaClass m_javaClass

m_attributes

private final java.util.Properties m_attributes

m_dependencies

private final java.util.List m_dependencies

m_vertex

private final org.apache.avalon.fortress.util.dag.Vertex m_vertex

m_dependencyNames

private final java.util.List m_dependencyNames

m_serviceNames

private final java.util.List m_serviceNames
Constructor Detail

Component

public Component(com.thoughtworks.qdox.model.JavaClass javaClass)
Initialize a service with the type name.

Parameters:
javaClass -
Method Detail

discoverDependencies

private void discoverDependencies()
Recursively discover dependencies from the local class hierarchy. This does not, and cannot discover dependencies from classes from other JARs.


discoverDependencies

private boolean discoverDependencies(com.thoughtworks.qdox.model.JavaClass fromClass)
Discover the dependencies that this component class requires.

Parameters:
fromClass - The JavaClass object to gather the dependency set from.

discoverNameInfo

private void discoverNameInfo()

discoverLifecycleType

private void discoverLifecycleType()

getType

public java.lang.String getType()
Get the type name.

Returns:
String

getDependencyNames

public java.util.Iterator getDependencyNames()

getServiceNames

public java.util.Iterator getServiceNames()

addDependency

public void addDependency(Service service)
Add a dependency to this type.

Parameters:
service - The name of the service that depends on this.

getVertex

public org.apache.avalon.fortress.util.dag.Vertex getVertex()

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)
Set the component attribute.

Parameters:
name - The name of the attribute
value - The attribute value

writeIfChanged

private void writeIfChanged(java.util.Properties props,
                            java.io.File file,
                            java.lang.String desc)
                     throws java.io.IOException
Only writes the properties file if it is new or if the existing file contains different values.

Throws:
java.io.IOException

serialize

public void serialize(java.io.File rootDir)
               throws java.io.IOException
Output the meta information.

Parameters:
rootDir -
Throws:
java.io.IOException

stripQuotes

private java.lang.String stripQuotes(java.lang.String value)

resolveClassName

protected java.lang.String resolveClassName(com.thoughtworks.qdox.model.JavaSource sourceCode,
                                            java.lang.String serviceName)
Resolve the classname from the "@avalon.service" javadoc tags.

Parameters:
serviceName - The service type name
Returns:
The fully qualified class name

checkImport

private java.lang.String checkImport(com.thoughtworks.qdox.model.JavaSource sourceCode,
                                     java.lang.String type,
                                     java.lang.String className)

checkPackage

private java.lang.String checkPackage(com.thoughtworks.qdox.model.JavaSource sourceCode,
                                      java.lang.String pack,
                                      java.lang.String serviceName)