All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tangosol.coherence.config.xml.processor.PersistenceEnvironmentsProcessor Maven / Gradle / Ivy

There is a newer version: 24.03
Show newest version
/*
 * Copyright (c) 2000, 2020, Oracle and/or its affiliates.
 *
 * Licensed under the Universal Permissive License v 1.0 as shown at
 * http://oss.oracle.com/licenses/upl.
 */
package com.tangosol.coherence.config.xml.processor;

import com.oracle.coherence.persistence.PersistenceEnvironment;
import com.tangosol.coherence.config.builder.ParameterizedBuilder;
import com.tangosol.coherence.config.builder.ParameterizedBuilderRegistry;
import com.tangosol.coherence.config.builder.PersistenceEnvironmentParamBuilder;
import com.tangosol.config.ConfigurationException;
import com.tangosol.config.xml.ElementProcessor;
import com.tangosol.config.xml.ProcessingContext;
import com.tangosol.config.xml.XmlSimpleName;
import com.tangosol.run.xml.XmlElement;
import com.tangosol.util.Base;

import java.util.Map;

/**
 * An {@link ElementProcessor} for the <persistence-environments%gt; element of
 * Coherence Operational Configuration files.
 *
 * @author jf  2015.03.03
 * @since Coherence 12.2.1
 */
@XmlSimpleName("persistence-environments")
public class PersistenceEnvironmentsProcessor
        implements ElementProcessor
    {
    // ----- ElementProcessor methods ---------------------------------------

    @Override
    public Void process(ProcessingContext context, XmlElement xmlElement)
            throws ConfigurationException
        {
        // process the children of the 
        Map mapProcessedChildren = context.processElementsOf(xmlElement);

        // add all of the ParameterizedBuilders to the ParameterizedBuilderRegistry
        ParameterizedBuilderRegistry registry = context.getCookie(ParameterizedBuilderRegistry.class);

        assert registry != null;

        for (Map.Entry entry : mapProcessedChildren.entrySet())
            {
            String sName    = entry.getKey();
            Object oBuilder = entry.getValue();

            if (oBuilder instanceof ParameterizedBuilder)
                {
                @SuppressWarnings("unchecked")
                ParameterizedBuilder builder =
                        (ParameterizedBuilder) oBuilder;

                registry.registerBuilder(PersistenceEnvironment.class, sName, builder);
                }
            else
                {
                throw new ConfigurationException("The specified  [" + sName
                            + "] is not a ParameterizedBuilder",
                        "Use  element to specify a ParameterizedBuilder implementation");

                }
            }

        return null;
        }

    // ----- inner class: PersistenceEnvironmentProcessor -------------------

    /**
     * An {@link com.tangosol.config.xml.ElementProcessor} for children elements
     * of  <persistence-environments%gt; element of Coherence Operational
     * Configuration files. Produces a {@link PersistenceEnvironmentParamBuilder}.
     */
    @XmlSimpleName("persistence-environment")
    public static class PersistenceEnvironmentProcessor
            extends AbstractEmptyElementProcessor
        {
        @Override
        protected PersistenceEnvironmentParamBuilder onProcess(ProcessingContext context, XmlElement xmlElement)
                throws ConfigurationException
            {
            return context.inject(new PersistenceEnvironmentParamBuilder(), xmlElement);
            }
        }
    }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy