This is the implementation of the BuilderFactory service. It constructs service implementations and wires services together automatically, as determined by their dependencies in the configuration files.

Methods
Constants
SETTERS = [ "%s=", "set_%s" ]
  This is the list of patterns that are recognized as "setter" methods. These are used when determining how to set properties.
Public Instance methods
create_instance( point, parms )

This is the factory method used to construct new services. Based on the parms argument, the new service is instantiated, initialized, and returned.

     # File lib/copland/impl/builder-factory.rb, line 53
 53:       def create_instance( point, parms )
 54:         ensure_log( point )
 55: 
 56:         klass = Copland::get_class( parms['class'] )
 57: 
 58:         args = ( parms['parameters'] || [] )
 59: 
 60:         if klass.include?( Singleton )
 61:           if args.length > 0
 62:             raise CoplandException,
 63:               "Singleton instances cannot have constructor parameters"
 64:           end
 65:           obj = klass.instance
 66:         else
 67:           obj = klass.new( *args )
 68:         end
 69: 
 70:         if parms['properties']
 71:           parms['properties'].each_pair do |name, value|
 72:             catch( :property_set ) do
 73:               SETTERS.each do |pattern|
 74:                 setter = pattern % name
 75:                 if obj.respond_to?( setter )
 76:                   obj.__send__( setter, value )
 77:                   throw :property_set
 78:                 end
 79:               end
 80: 
 81:               @log.warn "no setter for #{name.inspect} found on " +
 82:                         "#{klass} (#{point.full_name})"
 83:               obj.instance_variable_set "@#{name}".intern, value
 84:             end
 85:           end
 86:         end
 87: 
 88:         if parms['invoke']
 89:           parms['invoke'].each_pair do |name, value|
 90:             obj.__send__( name, *( value || [] ) )
 91:           end
 92:         end
 93: 
 94:         initialize_method = parms[ 'initialize-method' ] ||
 95:           "initialize_service"
 96: 
 97:         if obj.respond_to?( initialize_method )
 98:           obj.__send__( initialize_method )
 99:         end
100: 
101:         return obj
102:       end
ensure_log( point )
     # File lib/copland/impl/builder-factory.rb, line 104
104:       def ensure_log( point )
105:         return if @log
106:         @log = point.owner.registry.logs.get( "copland.BuilderFactory" )
107:       end