Package org.soybeanMilk.core

Examples of org.soybeanMilk.core.ObjectSourceException


      {
        return getGenericConverter().convert(sourceObj, targetType);
      }
      catch(ConvertException e)
      {
        throw new ObjectSourceException(e);
      }
    }
  }
View Full Code Here


    if(WebConstants.Scope.REQUEST.equalsIgnoreCase(scopedKeys[0]))
    {
      if(scopedKeys.length > 1)
        getRequest().setAttribute(scopedKeys[1], obj);
      else
        throw new ObjectSourceException("key "+SbmUtils.toString(key)+" is illegal, you can not replace "
            +SbmUtils.toString(WebConstants.Scope.REQUEST)+" scope object");
    }
    else if(WebConstants.Scope.SESSION.equalsIgnoreCase(scopedKeys[0]))
    {
      if(scopedKeys.length > 1)
        getRequest().getSession().setAttribute(scopedKeys[1], obj);
      else
        throw new ObjectSourceException("key "+SbmUtils.toString(key)+" is illegal, you can not replace "
            +SbmUtils.toString(WebConstants.Scope.SESSION)+" scope object");
    }
    else if(WebConstants.Scope.APPLICATION.equalsIgnoreCase(scopedKeys[0]))
    {
      if(scopedKeys.length > 1)
        getApplication().setAttribute(scopedKeys[1], obj);
      else
        throw new ObjectSourceException("key "+SbmUtils.toString(key)+" is illegal, you can not replace "
            +SbmUtils.toString(WebConstants.Scope.APPLICATION)+" scope object");
    }
    else if(WebConstants.Scope.PARAM.equalsIgnoreCase(scopedKeys[0]))
    {
      throw new ObjectSourceException("key "+SbmUtils.toString(key)+" is illegal, set object to "
          +SbmUtils.toString(WebConstants.Scope.PARAM)+" scope is not supported");
    }
    else if(WebConstants.Scope.RESPONSE.equalsIgnoreCase(scopedKeys[0]))
    {
      throw new ObjectSourceException("key "+SbmUtils.toString(key)+" is illegal, set object to "
          +SbmUtils.toString(WebConstants.Scope.RESPONSE)+" scope is not supported");
    }
    else if(WebConstants.Scope.OBJECT_SOURCE.equalsIgnoreCase(scopedKeys[0]))
    {
      throw new ObjectSourceException("key "+SbmUtils.toString(key)+" is illegal, set object to "
          +SbmUtils.toString(WebConstants.Scope.OBJECT_SOURCE)+" scope is not supported");
    }
    else
      setObjectWithScopeUnknownKey(strKey, obj);
   
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  protected Object getObject(Serializable key, Type expectType) throws ObjectSourceException
  {
    if(key == null)
      throw new ObjectSourceException("[key] must not be null");
   
    Object result = null;
   
    String strKey=(key instanceof String ? (String)key : key.toString());
    String[] scopedKeys=SbmUtils.splitByFirstAccessor(strKey);
   
    if(WebConstants.Scope.PARAM.equalsIgnoreCase(scopedKeys[0]))
    {
      result=getParamFilterValue(getRequest().getParameterMap(), (scopedKeys.length > 1 ? scopedKeys[1] : null), expectType);
    }
    else if(WebConstants.Scope.REQUEST.equalsIgnoreCase(scopedKeys[0]))
    {
      if(scopedKeys.length > 1)
        result=getRequest().getAttribute(scopedKeys[1]);
      else
        result=getRequest();
    }
    else if(WebConstants.Scope.SESSION.equalsIgnoreCase(scopedKeys[0]))
    {
      if(scopedKeys.length > 1)
        result=getRequest().getSession().getAttribute(scopedKeys[1]);
      else
        result=getRequest().getSession();
    }
    else if(WebConstants.Scope.APPLICATION.equalsIgnoreCase(scopedKeys[0]))
    {
      if(scopedKeys.length > 1)
        result=getApplication().getAttribute(scopedKeys[1]);
      else
        result=getApplication();
    }
    else if(WebConstants.Scope.RESPONSE.equalsIgnoreCase(scopedKeys[0]))
    {
      if(scopedKeys.length > 1)
        throw new ObjectSourceException("key "+SbmUtils.toString(key)+" is illegal, get object from "
            +HttpServletResponse.class.getSimpleName()+" is not supported");
      else
        result=getResponse();
    }
    else if(WebConstants.Scope.OBJECT_SOURCE.equalsIgnoreCase(scopedKeys[0]))
    {
      if(scopedKeys.length > 1)
        throw new ObjectSourceException("key "+SbmUtils.toString(key)+" is illegal, get object from "
            +WebObjectSource.class.getSimpleName()+" is not supported");
      else
        result=this;
    }
    else
View Full Code Here

        }
       
        throw new ParamIllegalException(paramName, e.getSourceObject(), e.getTargetType(), e);
      }
      else
        throw new ObjectSourceException(e);
    }
   
    return result;
  }
View Full Code Here

  }
 
  @Test
  public void get_responseScope_keyWithScope() throws Exception
  {
    ObjectSourceException re=null;
   
    try
    {
      webObjectSource.get("response.obj");
    }
    catch(ObjectSourceException e)
    {
      re=e;
    }
   
    Assert.assertTrue( (re.getMessage().startsWith("key \"response.obj\" is illegal")) );
  }
View Full Code Here

  }
 
  @Test
  public void get_objectSourceScope_keyInScope() throws Exception
  {
    ObjectSourceException re=null;
   
    try
    {
      webObjectSource.get("objectSource.obj");
    }
    catch(ObjectSourceException e)
    {
      re=e;
    }
   
    Assert.assertTrue( (re.getMessage().startsWith("key \"objectSource.obj\" is illegal")) );
  }
View Full Code Here

  }
 
  @Test
  public void set_requestScope_keyIsScope() throws Exception
  {
    ObjectSourceException re=null;
   
    try
    {
      webObjectSource.set("request", "v");
    }
    catch(ObjectSourceException e)
    {
      re=e;
    }
   
    Assert.assertTrue( (re.getMessage().startsWith("key \"request\" is illegal")) );
  }
View Full Code Here

  }
 
  @Test
  public void set_sessionScope_keyIsScope() throws Exception
  {
    ObjectSourceException re=null;
   
    try
    {
      webObjectSource.set("sessIon", "v");
    }
    catch(ObjectSourceException e)
    {
      re=e;
    }
   
    Assert.assertTrue( (re.getMessage().startsWith("key \"sessIon\" is illegal")) );
  }
View Full Code Here

  }
 
  @Test
  public void set_applicationScope_keyIsScope() throws Exception
  {
    ObjectSourceException re=null;
   
    try
    {
      webObjectSource.set("appLication", "v");
    }
    catch(ObjectSourceException e)
    {
      re=e;
    }
   
    Assert.assertTrue( (re.getMessage().startsWith("key \"appLication\" is illegal")) );
  }
View Full Code Here

  }
 
  @Test
  public void set_paramScope_keyIsScope() throws Exception
  {
    ObjectSourceException re=null;
   
    try
    {
      webObjectSource.set("paRam", "v");
    }
    catch(ObjectSourceException e)
    {
      re=e;
    }
   
    Assert.assertTrue( (re.getMessage().startsWith("key \"paRam\" is illegal")) );
  }
View Full Code Here

TOP

Related Classes of org.soybeanMilk.core.ObjectSourceException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.