All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Search JAR files by class name

Explore the source code of the class


 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.

import org.codehaus.plexus.spring.PlexusBeanDefinitionDocumentReader;
import org.codehaus.plexus.spring.PlexusConfigurationPropertyEditor;
import org.codehaus.plexus.spring.PlexusContainerAdapter;
import org.codehaus.plexus.spring.PlexusLifecycleBeanPostProcessor;
import org.codehaus.plexus.spring.editors.CollectionPropertyEditor;
import org.codehaus.plexus.spring.editors.MapPropertyEditor;
import org.codehaus.plexus.spring.editors.PropertiesPropertyEditor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.ApplicationContext;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class PlexusApplicationContextDelegate
     * Logger used by this class.
    protected Logger logger = LoggerFactory.getLogger( getClass() );

    private PlexusLifecycleBeanPostProcessor lifecycleBeanPostProcessor;

     * @see
    protected void loadBeanDefinitions( XmlBeanDefinitionReader reader )
        throws BeansException, IOException
    { "Registering Plexus to Spring XML translation" );
        reader.setDocumentReaderClass( PlexusBeanDefinitionDocumentReader.class );

     * @see
    protected void postProcessBeanFactory( ConfigurableListableBeanFactory beanFactory, ApplicationContext context )
        // Register a PlexusContainerAdapter bean to allow context lookups using plexus API
        PlexusContainerAdapter plexus = new PlexusContainerAdapter();
        plexus.setApplicationContext( context );
        beanFactory.registerSingleton( "plexusContainer", plexus );

        // Register a beanPostProcessor to handle plexus interface-based lifecycle management
        lifecycleBeanPostProcessor = new PlexusLifecycleBeanPostProcessor();
        lifecycleBeanPostProcessor.setBeanFactory( context );
        beanFactory.addBeanPostProcessor( lifecycleBeanPostProcessor );

        // Register a PropertyEditor to support plexus XML  set as CDATA in
        // a spring context XML file.
        beanFactory.addPropertyEditorRegistrar( new PlexusConfigurationPropertyEditor() );
        beanFactory.addPropertyEditorRegistrar( new PropertiesPropertyEditor() );
        beanFactory.addPropertyEditorRegistrar( new CollectionPropertyEditor( List.class, ArrayList.class ) );
        beanFactory.addPropertyEditorRegistrar( new CollectionPropertyEditor( Set.class, HashSet.class ) );
        beanFactory.addPropertyEditorRegistrar( new MapPropertyEditor( Map.class, HashMap.class ) );

     * @see
    protected void doClose()
        catch ( Throwable ex )
            logger.error( "Exception thrown from PlexusLifecycleBeanPostProcessor handling ContextClosedEvent", ex );

© 2018 Weber Informatics LLC