protected void incarnateInstance()

in src/java/org/apache/fulcrum/yaafi/framework/component/AvalonServiceComponentImpl.java [77:140]


    protected void incarnateInstance() throws Exception
    {
        this.getParentLogger().debug( "Incarnating the service " + this.getShorthand() );

        if( this.getLogger() != null )
        {
            this.enableLogging( this.getLogger() );
        }

        if( this.getContext() != null )
        {
            this.contextualize( this.getContext() );
        }

        if( this.getServiceManager() != null )
        {
            this.service( this.getServiceManager() );
        }

        if( this.getConfiguration() != null )
        {
            this.configure( this.getConfiguration() );
        }

        if( this.getParamaters() != null )
        {
            this.parameterize( this.getParamaters() );
        }

        this.initialize();
        this.execute();
        this.start();

        // create a dynamic proxy only if
        //
        // +) interceptors are enabled
        // +) the instance is not an AvalonServiceInterceptor

        boolean isInterceptor = AvalonInterceptorService.class.isAssignableFrom(
            this.getImplementationClazz()
            );

        if( this.getRoleEntry().hasDynamicProxy() && isInterceptor == false )
        {
            if( this.getParentLogger().isDebugEnabled() )
            {
                this.getParentLogger().debug( "Creating a dynamic proxy for " + this.getShorthand() );
            }

            Object proxyInstance = AvalonInterceptorFactory.create(
                this.getName(),
                this.getShorthand(),
                this.getServiceManager(),
                this.getRoleEntry().getInterceptorList(),
                this.getRawInstance(false)
                );

            this.setProxyInstance(proxyInstance);
        }
        else
        {
            this.getRoleEntry().setHasDynamicProxy(false);
        }
    }