Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.aendvari.cerberus.component.assembly
Class ComponentAssembler  view ComponentAssembler download ComponentAssembler.java

java.lang.Object
  extended bycom.aendvari.cerberus.component.assembly.ComponentAssembler

public class ComponentAssembler
extends java.lang.Object

Builds the components defined in a com.aendvari.cerberus.component.descriptor.AssemblyDescriptor.

The AssemblyContext may be used to provide context specific information during the build process.


Nested Class Summary
private  class ComponentAssembler.AttributeResolver
          An implementation of the PropertyResolver for component attributes.
private  class ComponentAssembler.MessageResolver
          An implementation of the PropertyResolver for component messages.
private static interface ComponentAssembler.PropertyResolver
          Allows various resolution methods to act on both attributes and messages.
 
Field Summary
private  com.aendvari.cerberus.component.descriptor.AssemblyDescriptor assembly
          The com.aendvari.cerberus.component.descriptor.AssemblyDescriptor to build the components from.
private  AssemblyContext context
          The AssemblyContext supplying context specific information.
private  com.aendvari.cerberus.component.directory.ComponentDirectory directory
          The com.aendvari.cerberus.component.directory.ComponentDirectory to register components into.
 
Constructor Summary
ComponentAssembler(AssemblyContext setAssemblyContext, com.aendvari.cerberus.component.descriptor.AssemblyDescriptor setAssembly, com.aendvari.cerberus.component.directory.ComponentDirectory setDirectory)
          Constructs a ComponentAssembler instance.
 
Method Summary
private  java.lang.String addNamespace(java.lang.String namespace, java.lang.String name)
          Adds the supplied namespace to a property name if one does not exist.
 void assemble()
          Assembles the components defined in the com.aendvari.cerberus.component.descriptor.AssemblyDescriptor.
private  void assembleComponent(java.lang.String instanceNamespace, com.aendvari.cerberus.component.descriptor.ComponentInstance instance, com.aendvari.cerberus.component.descriptor.ComponentDefinition ownerDefinition, com.aendvari.cerberus.component.descriptor.ComponentDescriptor ownerDescriptor)
          Assembles the specified component from the com.aendvari.cerberus.component.descriptor.ComponentInstance.
private  void assembleComponentAttributes(com.aendvari.cerberus.component.descriptor.ComponentDefinition definition, com.aendvari.cerberus.component.descriptor.ComponentInstance instance, com.aendvari.cerberus.component.descriptor.ComponentDescriptor descriptor)
          Creates and stores attribute values in the com.aendvari.cerberus.component.descriptor.ComponentDescriptor.
private  void assembleComponentMessages(com.aendvari.cerberus.component.descriptor.ComponentDefinition definition, com.aendvari.cerberus.component.descriptor.ComponentInstance instance, com.aendvari.cerberus.component.descriptor.ComponentDescriptor descriptor)
          Creates and stores message topic values in the com.aendvari.cerberus.component.descriptor.ComponentDescriptor.
private  void assembleDefinition(com.aendvari.cerberus.component.descriptor.ComponentDefinition baseDefinition, com.aendvari.cerberus.component.descriptor.ComponentDefinition fullDefinition)
          Stores the information of the base definition into the full definition.
private  java.lang.String assemblePropertyValue(com.aendvari.cerberus.component.descriptor.ComponentDescriptor descriptor, java.lang.String name, com.aendvari.cerberus.component.descriptor.MultiPartValue value)
          Creates a property value based on the com.aendvari.cerberus.component.descriptor.MultiPartValue and the attributes defined in the com.aendvari.cerberus.component.descriptor.ComponentDescriptor.
private  java.lang.String createAmbiguousPropertyMessage(java.lang.String type, java.lang.String property, java.util.Collection namespaces, java.lang.String reference)
          Creates a string describing an ambiguous property reference.
private  void createComponent(com.aendvari.cerberus.component.descriptor.ComponentInstance instance, com.aendvari.cerberus.component.descriptor.ComponentDefinition definition, com.aendvari.cerberus.component.descriptor.ComponentDescriptor descriptor)
          Creates the specified component from the com.aendvari.cerberus.component.descriptor.ComponentInstance and com.aendvari.cerberus.component.descriptor.ComponentDescriptor.
private  com.aendvari.cerberus.component.descriptor.ComponentDescriptor createDefinitionDescriptor(com.aendvari.cerberus.component.descriptor.ComponentDefinition specification, com.aendvari.cerberus.component.descriptor.ComponentDescriptor descriptor)
          Creates a new descriptor containing only attributes and messages of the specified definition.
private  java.lang.String createNonParentDefinitionMessage(java.lang.String definition, java.lang.String parent, java.lang.String reference)
          Creates a string describing an non-parent definition.
private  java.lang.String createUndefinedComponentDefinitionMessage(java.lang.String definition, java.lang.String reference)
          Creates a string describing an undefined component.
private  java.lang.String createUndefinedInstanceName(java.lang.String definition)
          Creates a string describing an undefined instance name.
private  java.lang.String createUndefinedParentsMessage(java.util.Collection definitions)
          Creates an exception describing undefined parent definitions.
private  java.lang.String createUndefinedPropertyMessage(java.lang.String type, java.lang.String property, java.lang.String reference)
          Creates a string describing an undefined property.
private  java.lang.String createUndefinedPropertyValueMessage(java.lang.String type, java.lang.String property, java.lang.String reference)
          Creates a string describing an undefined property value.
private  java.lang.String createUnresolvedAttributesMessage(com.aendvari.cerberus.component.descriptor.ComponentDescriptor component, java.util.Collection attributes)
          Creates a string describing cyclic attribute values.
private  java.lang.String createUnresolvedMessageTopicsMessage(com.aendvari.cerberus.component.descriptor.ComponentDescriptor component, java.util.Collection messages)
          Creates a string describing undefined message topic.
private  boolean dependenciesAvailable(com.aendvari.cerberus.component.descriptor.ComponentDescriptor descriptor, com.aendvari.cerberus.component.descriptor.MultiPartValue value)
          Checks that the attributes used in the supplied com.aendvari.cerberus.component.descriptor.MultiPartValue have been defined in the com.aendvari.cerberus.component.descriptor.ComponentDescriptor.
private  void includeDefinition(com.aendvari.cerberus.component.descriptor.ComponentDefinition source, com.aendvari.cerberus.component.descriptor.ComponentDefinition destination)
          Copies the attributes and messages of the source definition into the destination definition.
private  void mapMessage(com.aendvari.cerberus.component.descriptor.ComponentDescriptor descriptor, com.aendvari.cerberus.component.descriptor.ComponentMessage definitionMessage, com.aendvari.cerberus.component.descriptor.ComponentMessage resolveMessage, java.util.Collection unresolved)
          Determines the message topic referenced by the supplied message.
private  void resolveDefinition(com.aendvari.cerberus.component.descriptor.ComponentDefinition definition)
          Resolves the namespaces and references within the supplied component definition.
private  void resolveDefinitions(java.util.Collection definitions)
          Resolves the namespaces and references within the supplied component definitions.
private  void resolveInstance(com.aendvari.cerberus.component.descriptor.ComponentInstance instance, com.aendvari.cerberus.component.descriptor.ComponentDefinition definition)
          Resolves the namespaces and references within the supplied component instance.
private  java.lang.String resolveProperty(com.aendvari.cerberus.component.descriptor.ComponentDefinition definition, java.lang.String property, ComponentAssembler.PropertyResolver resolver, java.lang.String context)
          Resolves the namespace for the specified property.
private  void resolveReferencedAttributes(com.aendvari.cerberus.component.descriptor.ComponentDefinition definition, com.aendvari.cerberus.component.descriptor.MultiPartValue value, java.lang.String context)
          Resolves the namespaces for the attributes referenced within the supplied value.
private  void resolveReferencedMessage(com.aendvari.cerberus.component.descriptor.ComponentDefinition definition, com.aendvari.cerberus.component.descriptor.MultiPartValue topic, java.lang.String context)
          Resolves the namespaces for the message referenced within the supplied topic.
private  void validateProperty(com.aendvari.cerberus.component.descriptor.ComponentDefinition definition, java.lang.String property, ComponentAssembler.PropertyResolver resolver, java.lang.String context)
          Determines whether the supplied property name is valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

private AssemblyContext context
The AssemblyContext supplying context specific information.


assembly

private com.aendvari.cerberus.component.descriptor.AssemblyDescriptor assembly
The com.aendvari.cerberus.component.descriptor.AssemblyDescriptor to build the components from.


directory

private com.aendvari.cerberus.component.directory.ComponentDirectory directory
The com.aendvari.cerberus.component.directory.ComponentDirectory to register components into.

Constructor Detail

ComponentAssembler

public ComponentAssembler(AssemblyContext setAssemblyContext,
                          com.aendvari.cerberus.component.descriptor.AssemblyDescriptor setAssembly,
                          com.aendvari.cerberus.component.directory.ComponentDirectory setDirectory)
Constructs a ComponentAssembler instance. The components defined in the supplied com.aendvari.cerberus.component.descriptor.AssemblyDescriptor are assembled in context of the supplied AssemblyContext.

Method Detail

addNamespace

private java.lang.String addNamespace(java.lang.String namespace,
                                      java.lang.String name)
Adds the supplied namespace to a property name if one does not exist.


resolveProperty

private java.lang.String resolveProperty(com.aendvari.cerberus.component.descriptor.ComponentDefinition definition,
                                         java.lang.String property,
                                         ComponentAssembler.PropertyResolver resolver,
                                         java.lang.String context)
                                  throws AssemblyException
Resolves the namespace for the specified property. The definition hierarchy is traversed to find the namespace for the property.


validateProperty

private void validateProperty(com.aendvari.cerberus.component.descriptor.ComponentDefinition definition,
                              java.lang.String property,
                              ComponentAssembler.PropertyResolver resolver,
                              java.lang.String context)
                       throws AssemblyException
Determines whether the supplied property name is valid.


resolveReferencedAttributes

private void resolveReferencedAttributes(com.aendvari.cerberus.component.descriptor.ComponentDefinition definition,
                                         com.aendvari.cerberus.component.descriptor.MultiPartValue value,
                                         java.lang.String context)
                                  throws AssemblyException
Resolves the namespaces for the attributes referenced within the supplied value.


resolveReferencedMessage

private void resolveReferencedMessage(com.aendvari.cerberus.component.descriptor.ComponentDefinition definition,
                                      com.aendvari.cerberus.component.descriptor.MultiPartValue topic,
                                      java.lang.String context)
                               throws AssemblyException
Resolves the namespaces for the message referenced within the supplied topic.


resolveDefinition

private void resolveDefinition(com.aendvari.cerberus.component.descriptor.ComponentDefinition definition)
                        throws AssemblyException
Resolves the namespaces and references within the supplied component definition.


resolveDefinitions

private void resolveDefinitions(java.util.Collection definitions)
                         throws AssemblyException
Resolves the namespaces and references within the supplied component definitions.


resolveInstance

private void resolveInstance(com.aendvari.cerberus.component.descriptor.ComponentInstance instance,
                             com.aendvari.cerberus.component.descriptor.ComponentDefinition definition)
                      throws AssemblyException
Resolves the namespaces and references within the supplied component instance.


assemblePropertyValue

private java.lang.String assemblePropertyValue(com.aendvari.cerberus.component.descriptor.ComponentDescriptor descriptor,
                                               java.lang.String name,
                                               com.aendvari.cerberus.component.descriptor.MultiPartValue value)
                                        throws AssemblyException
Creates a property value based on the com.aendvari.cerberus.component.descriptor.MultiPartValue and the attributes defined in the com.aendvari.cerberus.component.descriptor.ComponentDescriptor.


dependenciesAvailable

private boolean dependenciesAvailable(com.aendvari.cerberus.component.descriptor.ComponentDescriptor descriptor,
                                      com.aendvari.cerberus.component.descriptor.MultiPartValue value)
Checks that the attributes used in the supplied com.aendvari.cerberus.component.descriptor.MultiPartValue have been defined in the com.aendvari.cerberus.component.descriptor.ComponentDescriptor.


assembleComponentAttributes

private void assembleComponentAttributes(com.aendvari.cerberus.component.descriptor.ComponentDefinition definition,
                                         com.aendvari.cerberus.component.descriptor.ComponentInstance instance,
                                         com.aendvari.cerberus.component.descriptor.ComponentDescriptor descriptor)
                                  throws AssemblyException
Creates and stores attribute values in the com.aendvari.cerberus.component.descriptor.ComponentDescriptor. Any attributes referenced by the com.aendvari.cerberus.component.descriptor.MultiPartValue are taken from the other attributes in the com.aendvari.cerberus.component.descriptor.ComponentDescriptor. Those attributes must have their values specified before being used by another attribute.


mapMessage

private void mapMessage(com.aendvari.cerberus.component.descriptor.ComponentDescriptor descriptor,
                        com.aendvari.cerberus.component.descriptor.ComponentMessage definitionMessage,
                        com.aendvari.cerberus.component.descriptor.ComponentMessage resolveMessage,
                        java.util.Collection unresolved)
Determines the message topic referenced by the supplied message.


assembleComponentMessages

private void assembleComponentMessages(com.aendvari.cerberus.component.descriptor.ComponentDefinition definition,
                                       com.aendvari.cerberus.component.descriptor.ComponentInstance instance,
                                       com.aendvari.cerberus.component.descriptor.ComponentDescriptor descriptor)
                                throws AssemblyException
Creates and stores message topic values in the com.aendvari.cerberus.component.descriptor.ComponentDescriptor. Any attributes referenced by the com.aendvari.cerberus.component.descriptor.MultiPartValue are taken from the attributes in the com.aendvari.cerberus.component.descriptor.ComponentDescriptor. Any messages referenced are taken from those in the com.aendvari.cerberus.component.descriptor.ComponentDescriptor.


createComponent

private void createComponent(com.aendvari.cerberus.component.descriptor.ComponentInstance instance,
                             com.aendvari.cerberus.component.descriptor.ComponentDefinition definition,
                             com.aendvari.cerberus.component.descriptor.ComponentDescriptor descriptor)
                      throws AssemblyException
Creates the specified component from the com.aendvari.cerberus.component.descriptor.ComponentInstance and com.aendvari.cerberus.component.descriptor.ComponentDescriptor.


assembleDefinition

private void assembleDefinition(com.aendvari.cerberus.component.descriptor.ComponentDefinition baseDefinition,
                                com.aendvari.cerberus.component.descriptor.ComponentDefinition fullDefinition)
Stores the information of the base definition into the full definition.


includeDefinition

private void includeDefinition(com.aendvari.cerberus.component.descriptor.ComponentDefinition source,
                               com.aendvari.cerberus.component.descriptor.ComponentDefinition destination)
                        throws AssemblyException
Copies the attributes and messages of the source definition into the destination definition. The source definition becomes an implicit parent of the destination definition.


createDefinitionDescriptor

private com.aendvari.cerberus.component.descriptor.ComponentDescriptor createDefinitionDescriptor(com.aendvari.cerberus.component.descriptor.ComponentDefinition specification,
                                                                                                  com.aendvari.cerberus.component.descriptor.ComponentDescriptor descriptor)
                                                                                           throws AssemblyException
Creates a new descriptor containing only attributes and messages of the specified definition. Elliminates temporary properties built during assembly. Whenever possible, simple references (no namespace) to attributes and messages are created.


assembleComponent

private void assembleComponent(java.lang.String instanceNamespace,
                               com.aendvari.cerberus.component.descriptor.ComponentInstance instance,
                               com.aendvari.cerberus.component.descriptor.ComponentDefinition ownerDefinition,
                               com.aendvari.cerberus.component.descriptor.ComponentDescriptor ownerDescriptor)
                        throws AssemblyException
Assembles the specified component from the com.aendvari.cerberus.component.descriptor.ComponentInstance.


assemble

public void assemble()
              throws AssemblyException
Assembles the components defined in the com.aendvari.cerberus.component.descriptor.AssemblyDescriptor.


createUndefinedComponentDefinitionMessage

private java.lang.String createUndefinedComponentDefinitionMessage(java.lang.String definition,
                                                                   java.lang.String reference)
Creates a string describing an undefined component.


createUndefinedParentsMessage

private java.lang.String createUndefinedParentsMessage(java.util.Collection definitions)
Creates an exception describing undefined parent definitions.


createNonParentDefinitionMessage

private java.lang.String createNonParentDefinitionMessage(java.lang.String definition,
                                                          java.lang.String parent,
                                                          java.lang.String reference)
Creates a string describing an non-parent definition.


createUndefinedPropertyMessage

private java.lang.String createUndefinedPropertyMessage(java.lang.String type,
                                                        java.lang.String property,
                                                        java.lang.String reference)
Creates a string describing an undefined property.


createUndefinedPropertyValueMessage

private java.lang.String createUndefinedPropertyValueMessage(java.lang.String type,
                                                             java.lang.String property,
                                                             java.lang.String reference)
Creates a string describing an undefined property value.


createAmbiguousPropertyMessage

private java.lang.String createAmbiguousPropertyMessage(java.lang.String type,
                                                        java.lang.String property,
                                                        java.util.Collection namespaces,
                                                        java.lang.String reference)
Creates a string describing an ambiguous property reference.


createUnresolvedAttributesMessage

private java.lang.String createUnresolvedAttributesMessage(com.aendvari.cerberus.component.descriptor.ComponentDescriptor component,
                                                           java.util.Collection attributes)
Creates a string describing cyclic attribute values.


createUnresolvedMessageTopicsMessage

private java.lang.String createUnresolvedMessageTopicsMessage(com.aendvari.cerberus.component.descriptor.ComponentDescriptor component,
                                                              java.util.Collection messages)
Creates a string describing undefined message topic.


createUndefinedInstanceName

private java.lang.String createUndefinedInstanceName(java.lang.String definition)
Creates a string describing an undefined instance name.