Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * echo-messaging / ActionContext
- *
- * Copyright (c) 2011 Digital Chocolate, Inc. This program is not published or
- * distributed in source code form; accordingly, this source code is and remains
- * confidential to and a trade secret of Digital Chocolate, Inc.
- *
- * All rights reserved. SVN Version: $Revision: 323165 $
- */
- package com.dchoc.echo.messaging.command;
- import java.util.HashMap;
- import java.util.Map;
- import com.dchoc.echo.dao.IBaseType;
- import com.google.inject.Singleton;
- /**
- * Keeps track of entities used by the actions.
- *
- * @author mrazola
- * @created May 27, 2011
- * @version 1
- * @serial $Id: ExtendedActionContext.java 323165 2011-06-08 15:45:05Z jmartin $
- */
- @Singleton
- @Deprecated
- public class ExtendedActionContext {
- private static ThreadLocal<ExtendedActionContext> contextHolder = new ThreadLocal<ExtendedActionContext>();
- @SuppressWarnings("rawtypes")
- private final Map<Class<? extends IBaseType>, Map<String, IBaseType>> entities;
- @SuppressWarnings("rawtypes")
- private ExtendedActionContext() {
- this.entities = new HashMap<Class<? extends IBaseType>, Map<String, IBaseType>>();
- }
- public static void createContext() {
- contextHolder.set(new ExtendedActionContext());
- }
- public static void releaseContext() {
- contextHolder.remove();
- }
- public static ExtendedActionContext getContext() {
- return contextHolder.get();
- }
- @SuppressWarnings("rawtypes")
- public <T extends IBaseType> ExtendedActionContext put(final String key, final Class<T> type, final T object) {
- if (this.entities.get(type) == null) {
- this.entities.put(type, new HashMap<String, IBaseType>());
- }
- Map<String, IBaseType> objects = this.entities.get(type);
- objects.put(key, object);
- return this;
- }
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public <T extends IBaseType> T get(final String key, final Class<T> type) {
- if (this.entities.get(type) != null) {
- return (T) this.entities.get(type).get(key);
- }
- return null;
- }
- }
Add Comment
Please, Sign In to add comment