1 // SECTION-START[License Header] 2 // <editor-fold defaultstate="collapsed" desc=" Generated License "> 3 /* 4 * jDTAUS 5 * Copyright (C) Christian Schulte, 2012-039 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU Lesser General Public License as published 9 * by the Free Software Foundation, either version 2.1 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * 20 * $JDTAUS: ContextScope.java 8518 2012-04-02 20:55:41Z schulte2005 $ 21 * 22 */ 23 // </editor-fold> 24 // SECTION-END 25 package org.jdtaus.core.container.ri.jomc; 26 27 import java.util.Collection; 28 import java.util.Collections; 29 import java.util.HashMap; 30 import java.util.Map; 31 import org.jdtaus.core.container.ContextFactory; 32 33 // SECTION-START[Documentation] 34 // <editor-fold defaultstate="collapsed" desc=" Generated Documentation "> 35 /** 36 * JOMC {@code Scope} implementation delegating to the jDTAUS {@code Context}. 37 * 38 * <dl> 39 * <dt><b>Identifier:</b></dt><dd>jDTAUS Core JOMC Container :: Context Scope</dd> 40 * <dt><b>Name:</b></dt><dd>jDTAUS Context</dd> 41 * <dt><b>Specifications:</b></dt> 42 * <dd>org.jomc.spi.Scope @ 1.0</dd> 43 * <dt><b>Abstract:</b></dt><dd>No</dd> 44 * <dt><b>Final:</b></dt><dd>No</dd> 45 * <dt><b>Stateless:</b></dt><dd>No</dd> 46 * </dl> 47 * 48 * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0 49 * @version 1.11 50 */ 51 // </editor-fold> 52 // SECTION-END 53 // SECTION-START[Annotations] 54 // <editor-fold defaultstate="collapsed" desc=" Generated Annotations "> 55 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.3", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.3" ) 56 // </editor-fold> 57 // SECTION-END 58 public class ContextScope 59 implements 60 org.jomc.spi.Scope 61 { 62 // SECTION-START[Scope] 63 64 @Override 65 public Map<String, Object> getObjects() 66 { 67 final Collection<String> objectKeys = ContextFactory.getContext().getObjectKeys(); 68 final Map<String, Object> objectMap = new HashMap<String, Object>( objectKeys.size() ); 69 70 for ( final String objectKey : objectKeys ) 71 { 72 objectMap.put( objectKey, this.getObject( objectKey ) ); 73 } 74 75 return Collections.unmodifiableMap( objectMap ); 76 } 77 78 @Override 79 public Object getObject( final String string ) throws NullPointerException 80 { 81 return ContextFactory.getContext().getObject( string ); 82 } 83 84 @Override 85 public Object putObject( final String string, final Object o ) throws NullPointerException 86 { 87 return ContextFactory.getContext().setObject( string, o ); 88 } 89 90 @Override 91 public Object removeObject( final String string ) throws NullPointerException 92 { 93 return ContextFactory.getContext().removeObject( string ); 94 } 95 96 // SECTION-END 97 // SECTION-START[ContextScope] 98 // SECTION-END 99 // 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.2.3", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.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 }