org.apache.myfaces.orchestra.conversation.spring
Class _SpringUtils

java.lang.Object
  extended by org.apache.myfaces.orchestra.conversation.spring._SpringUtils

public final class _SpringUtils
extends Object

Various Spring utilities used by the conversation framework

Notice: this class is not meant to be used outside of this library


Method Summary
static String getAlternateBeanName(String beanName)
          Deprecated. use getModifiedBeanName instead.
static String getModifiedBeanName(String beanName)
          Given a bean name "foo", if it refers to a scoped proxy then the bean definition that holds the original settings is now under another name, so return that other name so the original BeanDefinition can be found.
static String getOriginalBeanName(String beanName)
          Given the name of a BeanDefinition, if this is a fake name created by spring because an aop:scoped-proxy is now wrapping this object, then return the name of that scoped-proxy bean (ie the name that the user accesses this bean by).
static String getRealBeanName(String beanName)
          Deprecated. use getOriginalBeanName instead.
static Object getTargetObject(Object proxy)
          Given a proxy object, return the underlying object that it currently refers to.
static boolean isAlternateBeanName(String beanName)
          Deprecated. use isModifiedBeanName instead.
static boolean isModifiedBeanName(String beanName)
          Detect the case where a class includes a nested aop:scoped-target tag.
static Object newProxy(AbstractSpringOrchestraScope scope, String conversationName, String targetBeanName, org.springframework.beans.factory.ObjectFactory objectFactory, org.springframework.beans.factory.BeanFactory beanFactory)
          Create an object that subclasses the concrete class of the BeanDefinition for the specified targetBeanName, and when invoked delegates to an instance of that type fetched from a scope object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isModifiedBeanName

public static boolean isModifiedBeanName(String beanName)
Detect the case where a class includes a nested aop:scoped-target tag.

When a definition is present in the config file like this:

  <bean name="foo" class="example.Foo" orchestra:foo="foo">
   <....>
   <aop:scopedProxy/>
  </bean>
 
then what Spring actually does is create two BeanDefinition objects, one with name "foo" that creates a proxy object, and one with name "scopedTarget.foo" that actually defines the bean of type example.Foo (see Spring class ScopedProxyUtils for details.

Using this pattern is very common with Orchestra, so we need to detect it and look for orchestra settings on the renamed bean definition rather than the one with the original name.

Since:
1.1

getOriginalBeanName

public static String getOriginalBeanName(String beanName)
Given the name of a BeanDefinition, if this is a fake name created by spring because an aop:scoped-proxy is now wrapping this object, then return the name of that scoped-proxy bean (ie the name that the user accesses this bean by).

Since:
1.1

getModifiedBeanName

public static String getModifiedBeanName(String beanName)
Given a bean name "foo", if it refers to a scoped proxy then the bean definition that holds the original settings is now under another name, so return that other name so the original BeanDefinition can be found.

Since:
1.1

isAlternateBeanName

public static boolean isAlternateBeanName(String beanName)
Deprecated. use isModifiedBeanName instead.


getAlternateBeanName

public static String getAlternateBeanName(String beanName)
Deprecated. use getModifiedBeanName instead.


getRealBeanName

public static String getRealBeanName(String beanName)
Deprecated. use getOriginalBeanName instead.


newProxy

public static Object newProxy(AbstractSpringOrchestraScope scope,
                              String conversationName,
                              String targetBeanName,
                              org.springframework.beans.factory.ObjectFactory objectFactory,
                              org.springframework.beans.factory.BeanFactory beanFactory)
Create an object that subclasses the concrete class of the BeanDefinition for the specified targetBeanName, and when invoked delegates to an instance of that type fetched from a scope object.

The proxy returned currently also currently implements the standard Spring ScopedObject interface; this is experimental and may be removed if not useful.

Since:
1.1

getTargetObject

public static Object getTargetObject(Object proxy)
                              throws Exception
Given a proxy object, return the underlying object that it currently refers to.

This method is currently experimental; it works for the current Spring implementation of Orchestra but at the current time it is not known whether this functionality can be implemented for all dependency-injection frameworks. If it does, then it might later make sense to promote this up to the public Orchestra API.

Note that invoking this method will create the "target object" if it does not yet exist. There is currently no way of testing whether this will happen, ie null will never be returned from this method.

Throws:
Exception
Since:
1.3


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.