001// SECTION-START[License Header]
002// <editor-fold defaultstate="collapsed" desc=" Generated License ">
003/*
004 *   jDTAUS
005 *   Copyright (C) Christian Schulte, 2012-039
006 *
007 *   This program is free software: you can redistribute it and/or modify
008 *   it under the terms of the GNU Lesser General Public License as published
009 *   by the Free Software Foundation, either version 2.1 of the License, or
010 *   (at your option) any later version.
011 *
012 *   This program is distributed in the hope that it will be useful,
013 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
014 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015 *   GNU General Public License for more details.
016 *
017 *   You should have received a copy of the GNU Lesser General Public License
018 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
019 *
020 *   $JDTAUS: ContextScope.java 8561 2012-06-04 02:44:14Z schulte2005 $
021 *
022 */
023// </editor-fold>
024// SECTION-END
025package org.jdtaus.core.container.ri.jomc;
026
027import java.util.Collection;
028import java.util.Collections;
029import java.util.HashMap;
030import java.util.Map;
031import org.jdtaus.core.container.ContextFactory;
032
033// SECTION-START[Documentation]
034// <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
035/**
036 * JOMC {@code Scope} implementation delegating to the jDTAUS {@code Context}.
037 *
038 * <dl>
039 *   <dt><b>Identifier:</b></dt><dd>jDTAUS Core JOMC Container :: Context Scope</dd>
040 *   <dt><b>Name:</b></dt><dd>jDTAUS Context</dd>
041 *   <dt><b>Specifications:</b></dt>
042 *     <dd>org.jomc.spi.Scope @ 1.0</dd>
043 *   <dt><b>Abstract:</b></dt><dd>No</dd>
044 *   <dt><b>Final:</b></dt><dd>No</dd>
045 *   <dt><b>Stateless:</b></dt><dd>No</dd>
046 * </dl>
047 *
048 * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0
049 * @version 1.12-SNAPSHOT
050 */
051// </editor-fold>
052// SECTION-END
053// SECTION-START[Annotations]
054// <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
055@javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" )
056// </editor-fold>
057// SECTION-END
058public class ContextScope
059    implements
060    org.jomc.spi.Scope
061{
062    // SECTION-START[Scope]
063
064    @Override
065    public Map<String, Object> getObjects()
066    {
067        final Collection<String> objectKeys = ContextFactory.getContext().getObjectKeys();
068        final Map<String, Object> objectMap = new HashMap<String, Object>( objectKeys.size() );
069
070        for ( final String objectKey : objectKeys )
071        {
072            objectMap.put( objectKey, this.getObject( objectKey ) );
073        }
074
075        return Collections.unmodifiableMap( objectMap );
076    }
077
078    @Override
079    public Object getObject( final String string ) throws NullPointerException
080    {
081        return ContextFactory.getContext().getObject( string );
082    }
083
084    @Override
085    public Object putObject( final String string, final Object o ) throws NullPointerException
086    {
087        return ContextFactory.getContext().setObject( string, o );
088    }
089
090    @Override
091    public Object removeObject( final String string ) throws NullPointerException
092    {
093        return ContextFactory.getContext().removeObject( string );
094    }
095
096    // SECTION-END
097    // SECTION-START[ContextScope]
098    // SECTION-END
099    // SECTION-START[Constructors]
100    // <editor-fold defaultstate="collapsed" desc=" Generated Constructors ">
101    /** Creates a new {@code ContextScope} instance. */
102    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" )
103    public ContextScope()
104    {
105        // SECTION-START[Default Constructor]
106        super();
107        // SECTION-END
108    }
109    // </editor-fold>
110    // SECTION-END
111    // SECTION-START[Dependencies]
112    // SECTION-END
113    // SECTION-START[Properties]
114    // SECTION-END
115    // SECTION-START[Messages]
116    // SECTION-END
117}