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

org.datanucleus.metadata.annotations.AnnotationManagerImpl Maven / Gradle / Ivy

Go to download

DataNucleus Core provides the primary components of a heterogenous Java persistence solution. It supports persistence API's being layered on top of the core functionality.

There is a newer version: 6.0.7
Show newest version
/**********************************************************************
Copyright (c) 2006 Andy Jefferson and others. All rights reserved.
Licensed 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

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Contributors:
    ...
**********************************************************************/
package org.datanucleus.metadata.annotations;

import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.datanucleus.ClassConstants;
import org.datanucleus.ClassLoaderResolver;
import org.datanucleus.metadata.AbstractClassMetaData;
import org.datanucleus.metadata.MetaDataManager;
import org.datanucleus.metadata.PackageMetaData;
import org.datanucleus.plugin.ConfigurationElement;
import org.datanucleus.plugin.PluginManager;
import org.datanucleus.util.Localiser;
import org.datanucleus.util.NucleusLogger;

/**
 * Manager for annotations.
 * Acts as a registry of the available annotation readers and allows use of all
 * types of registered annotations.
 */
public class AnnotationManagerImpl implements AnnotationManager
{
    /** MetaData Manager that we work for. */
    protected final MetaDataManager metadataMgr;

    /** Lookup of annotation reader name keyed by the annotation class name. */
    Map annotationReaderLookup = new HashMap();

    /** Cache of the available annotation readers (keyed by the class name). */
    Map annotationReaders = new HashMap();

    /** Set of (class) annotations that have handlers. */
    Set classAnnotationHandlerAnnotations = null;

    /** Cache of ClassAnnotationHandler keyed by the annotation name that they handle. */
    Map classAnnotationHandlers = null;

    /** Set of (member) annotations that have handlers. */
    Set memberAnnotationHandlerAnnotations = null;

    /** Cache of MemberAnnotationHandler keyed by the annotation name that they handle. */
    Map memberAnnotationHandlers = null;

    /**
     * Constructor.
     * @param metadataMgr Manager for MetaData
     */
    public AnnotationManagerImpl(MetaDataManager metadataMgr)
    {
        this.metadataMgr = metadataMgr;

        PluginManager pluginMgr = metadataMgr.getNucleusContext().getPluginManager();

        // Load up the registry of available annotation readers
        ConfigurationElement[] elems = pluginMgr.getConfigurationElementsForExtension("org.datanucleus.annotations", null, null);
        if (elems != null)
        {
            for (int i=0;i 0)
        {
            classAnnotationHandlerAnnotations = new HashSet(elems.length);
            classAnnotationHandlers = new HashMap(elems.length);
            for (int i=0; i 0)
        {
            memberAnnotationHandlerAnnotations = new HashSet(elems.length);
            memberAnnotationHandlers = new HashMap(elems.length);
            for (int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy