com.backendless.servercode.InvocationContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of backendless Show documentation
Show all versions of backendless Show documentation
Android SDK used by developers to provide Backendless API in apps.
/*
* ********************************************************************************************************************
*
* BACKENDLESS.COM CONFIDENTIAL
*
* ********************************************************************************************************************
*
* Copyright 2012 BACKENDLESS.COM. All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains the property of Backendless.com and its suppliers,
* if any. The intellectual and technical concepts contained herein are proprietary to Backendless.com and its
* suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret
* or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden
* unless prior written permission is obtained from Backendless.com.
*
* ********************************************************************************************************************
*/
package com.backendless.servercode;
import com.backendless.commons.DeviceType;
import java.util.List;
import java.util.Map;
/**
* Created by oleg on 22.07.15.
*/
public class InvocationContext extends AbstractContext
{
private static ThreadLocal threadLocal = new InheritableThreadLocal(){
@Override
protected InvocationContext initialValue()
{
return new InvocationContext( );
}
};
private static InvocationContext getCurrentContext()
{
return threadLocal.get();
}
private String httpPath;
private Map httpPathParams;
private Map httpQueryParams;
private InvocationContext( String appId, String userId, String userToken, List userRoles,
String deviceType, String httpPath, Map httpHeaders,
Map httpPathParams, Map httpQueryParams)
{
this.appId = appId;
this.userId = userId;
this.userToken = userToken;
this.userRoles = userRoles;
this.deviceType = DeviceType.valueOf( deviceType );
this.httpHeaders = httpHeaders;
this.httpPath = httpPath;
this.httpPathParams = httpPathParams;
this.httpQueryParams = httpQueryParams;
}
private InvocationContext( ) {}
public static String asString()
{
return getCurrentContext().toString();
}
@Override
public String toString()
{
final StringBuilder sb = new StringBuilder( "InvocationContext{" );
sb.append( super.toString() );
sb.append( "}" );
return sb.toString();
}
public static String getAppId()
{
return getCurrentContext().appId;
}
public static void setAppId( String appId )
{
getCurrentContext().appId = appId;
}
public static String getUserId()
{
return getCurrentContext().userId;
}
public static void setUserId( String userId )
{
getCurrentContext().userId = userId;
}
public static String getUserToken()
{
return getCurrentContext().userToken;
}
public static void setUserToken( String userToken )
{
getCurrentContext().userToken = userToken;
}
public static List getUserRoles()
{
return getCurrentContext().userRoles;
}
public static void setUserRoles( List userRoles )
{
getCurrentContext().userRoles = userRoles;
}
public static DeviceType getDeviceType()
{
return getCurrentContext().deviceType;
}
public static void setDeviceType( DeviceType deviceType )
{
getCurrentContext().deviceType = deviceType;
}
public static Map getHttpHeaders()
{
return getCurrentContext().httpHeaders;
}
public static void setHttpHeaders( Map httpHeaders )
{
getCurrentContext().httpHeaders = httpHeaders;
}
public static String getHttpPath()
{
return getCurrentContext().httpPath;
}
public static void setHttpPath( String httpPath )
{
getCurrentContext().httpPath = httpPath;
}
public static Map getHttpPathParams()
{
return getCurrentContext().httpPathParams;
}
public static void setHttpPathParams( Map httpPathParams )
{
getCurrentContext().httpPathParams = httpPathParams;
}
public static Map getHttpQueryParams()
{
return getCurrentContext().httpQueryParams;
}
public static void setHttpQueryParams( Map httpQueryParams )
{
getCurrentContext().httpQueryParams = httpQueryParams;
}
}