1 22 package org.jboss.deployers.plugins.attachments; 23 24 import java.util.Collections ; 25 import java.util.Map ; 26 import java.util.concurrent.ConcurrentHashMap ; 27 28 34 public class AttachmentsImpl extends AbstractAttachments 35 { 36 37 private Map <String , Object > attachments = new ConcurrentHashMap <String , Object >(); 38 39 public Map <String , Object > getAttachments() 40 { 41 return Collections.unmodifiableMap(attachments); 42 } 43 44 public Object addAttachment(String name, Object attachment) 45 { 46 if (name == null) 47 throw new IllegalArgumentException ("Null name"); 48 if (attachment == null) 49 throw new IllegalArgumentException ("Null attachment"); 50 return attachments.put(name, attachment); 51 } 52 53 public Object getAttachment(String name) 54 { 55 if (name == null) 56 throw new IllegalArgumentException ("Null name"); 57 return attachments.get(name); 58 } 59 60 public boolean isAttachmentPresent(String name) 61 { 62 if (name == null) 63 throw new IllegalArgumentException ("Null name"); 64 return attachments.containsKey(name); 65 } 66 67 public Object removeAttachment(String name) 68 { 69 if (name == null) 70 throw new IllegalArgumentException ("Null name"); 71 return attachments.remove(name); 72 } 73 74 public void clear() 75 { 76 attachments.clear(); 77 } 78 } 79 | Popular Tags |