public void configure()

in src/java/org/apache/fulcrum/yaafi/framework/container/ServiceContainerImpl.java [234:354]


    public void configure(Configuration configuration) throws ConfigurationException
    {
        Validate.notNull( configuration, "configuration" );

        // retrieve the reconfigurationDelay

        this.reconfigurationDelay = configuration.getChild( RECONFIGURATION_DELAY_KEY )
                .getValueAsInteger( RECONFIGURATION_DELAY_DEFAULT );

        // retrieve the disposal delay

        this.disposalDelay = configuration.getChild( DISPOSAL_DELAY_KEY ).getValueAsInteger( DISPOSAL_DELAY_DEFAULT );

        // evaluate if we are using dynamic proxies

        this.hasDynamicProxies = configuration.getChild( DYNAMICPROXY_ENABLED_KEY ).getValueAsBoolean( false );

        // retrieve the container flavour

        this.setContainerFlavour(
                configuration.getChild( CONTAINERFLAVOUR_CONFIG_KEY ).getValue( COMPONENT_CONTAINERFLAVOUR_VALUE ) );

        this.getLogger().debug( "Using the following container type : " + this.getContainerFlavour() );

        // process the caller-supplied context here

        try
        {
            // instantiate a mapper using the existing context - it might
            // contain application specific entries we are not aware of

            AvalonToYaafiContextMapper mapper = new AvalonToYaafiContextMapper( this.getTempRootDir(),
                    this.callerContext, this.getClassLoader() );

            // do the magic mapping

            this.context = mapper.mapFrom( this.callerContext, this.getContainerFlavour() );

            // don't keep a reference of the caller-supplied context

            this.callerContext = null;
        } catch (ContextException e)
        {
            String msg = "Failed to parse the caller-supplied context";
            this.getLogger().error( msg, e );
            throw new ConfigurationException( msg );
        }

        // evaluate componentRoles

        Configuration currComponentRoles = configuration.getChild( COMPONENT_ROLE_KEYS );

        this.setComponentRolesLocation(
                currComponentRoles.getChild( COMPONENT_LOCATION_KEY ).getValue( COMPONENT_ROLE_VALUE ) );

        this.setComponentRolesFlavour( currComponentRoles.getChild( CONTAINERFLAVOUR_CONFIG_KEY )
                .getValue( COMPONENT_ROLECONFIGFLAVOUR_VALUE ) );

        this.setComponentRolesEncrypted( currComponentRoles.getChild( COMPONENT_ISENCRYPTED_KEY ).getValue( "false" ) );

        // evaluate componentConfiguraion

        Configuration currComponentConfiguration = configuration.getChild( COMPONENT_CONFIG_KEY );

        this.setComponentConfigurationLocation(
                currComponentConfiguration.getChild( COMPONENT_LOCATION_KEY ).getValue( COMPONENT_CONFIG_VALUE ) );

        this.setComponentConfigurationEncrypted(
                currComponentConfiguration.getChild( COMPONENT_ISENCRYPTED_KEY ).getValue( "false" ) );

        // get the configuration for componentConfigurationPropertiesResolver

        this.componentConfigurationPropertiesResolverConfig = configuration.getChild( COMPONENT_CONFIG_PROPERTIES_KEY );

        // evaluate parameters

        Configuration currParameters = configuration.getChild( COMPONENT_PARAMETERS_KEY );

        this.setParametersLocation(
                currParameters.getChild( COMPONENT_LOCATION_KEY ).getValue( COMPONENT_PARAMETERS_VALUE ) );

        this.setParametersEncrypted( currParameters.getChild( COMPONENT_ISENCRYPTED_KEY ).getValue( "false" ) );

        // evaluate the default interceptors

        Configuration currInterceptorList = configuration.getChild( INTERCEPTOR_LIST_KEY );

        Configuration[] interceptorConfigList = currInterceptorList.getChildren( INTERCEPTOR_KEY );

        for (int i = 0; i < interceptorConfigList.length; i++)
        {
            String interceptorServiceName = interceptorConfigList[i].getValue( null );

            if (!StringUtils.isEmpty( interceptorServiceName ) && this.hasDynamicProxies())
            {
                this.defaultInterceptorServiceList.add( interceptorServiceName );

                this.getLogger().debug( "Using the following default interceptor service : " + interceptorServiceName );
            }
        }

        // evaluate a list of service managers managing their own set of services
        // independent from the Avalon container. This service managers are used
        // to find services implemented as Spring bean or remote web services.

        Configuration currServiceManagerList = configuration.getChild( SERVICEMANAGER_LIST_KEY );

        Configuration[] serviceManagerConfigList = currServiceManagerList.getChildren( SERVICEMANAGER_KEY );

        for (int i = 0; i < serviceManagerConfigList.length; i++)
        {
            String serviceManagerName = serviceManagerConfigList[i].getValue( null );

            if (!StringUtils.isEmpty( serviceManagerName ))
            {
                this.fallbackServiceManagerList.add( serviceManagerName );

                this.getLogger().debug( "Using the following fallback service manager : " + serviceManagerName );
            }
        }
    }