package gov.nasa.arc.mct.scenario.component;

import gov.nasa.arc.mct.components.AbstractComponent;
import gov.nasa.arc.mct.components.JAXBModelStatePersistence;
import gov.nasa.arc.mct.components.ModelStatePersistence;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

public class TagRepositoryComponent extends AbstractComponent implements RepositoryCapability {
	private TagRepositoryModel model;
	
	@Override
	public <T> T handleGetCapability(Class<T> capabilityClass) {
		return (capabilityClass.isAssignableFrom(ModelStatePersistence.class)) ?
			capabilityClass.cast(persistence) :
			super.handleGetCapability(capabilityClass);
	}
	
	@Override
	public Class<?> getCapabilityClass() {
		return TagComponent.class;
	}

	@Override
	public String getUserScope() {
		return model.scope;
	}
	
	@XmlRootElement
	@XmlAccessorType(XmlAccessType.FIELD)
	public static class TagRepositoryModel {
		private String scope;
	}
	
	private final ModelStatePersistence persistence = 
			new JAXBModelStatePersistence<TagRepositoryModel>() {
		@Override
		protected TagRepositoryModel getStateToPersist() {
			return model;
		}

		@Override
		protected void setPersistentState(TagRepositoryModel modelState) {
			model = (TagRepositoryModel) modelState;
		}

		@Override
		protected Class<TagRepositoryModel> getJAXBClass() {
			return TagRepositoryModel.class;
		}		
	};
}

@@ -214,16 +214,69 @@
 tence;%0A%0A
+import java.util.concurrent.atomic.AtomicReference;%0A%0A
 import j
@@ -311,24 +311,24 @@
 AccessType;%0A
-
 import javax
@@ -520,16 +520,32 @@
 private 
+AtomicReference%3C
 TagRepos
@@ -554,25 +554,96 @@
 oryModel
+%3E
  model
+ =%0A%09%09%09new AtomicReference%3CTagRepositoryModel%3E(new TagRepositoryModel())
 ;%0A
-%09
 %0A%09@Overr
@@ -1016,16 +1016,98 @@
 n model.
+get().scope;%0A%09%7D%0A%09%0A%09public void setUserScope(String scope) %7B%0A%09%09model.get().scope = 
 scope;%0A%09
@@ -1226,24 +1226,29 @@
 String scope
+ = %22%22
 ;%0A%09%7D%0A%09%0A%09priv
@@ -1431,16 +1431,22 @@
 rn model
+.get()
 ;%0A%09%09%7D%0A%0A%09
@@ -1537,32 +1537,13 @@
 odel
- = (TagRepositoryModel) 
+.set(
 mode
@@ -1548,16 +1548,17 @@
 delState
+)
 ;%0A%09%09%7D%0A%0A%09

Use atomic reference for tag repo model