View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.orchestra.conversation.spring;
20  
21  /***
22   * <p>Various Spring utilities used by the conversation framework</p>
23   * <p>Notice: this class is not meant to be used outside of this library</p>
24   */
25  public final class _SpringUtils
26  {
27  	private final static String SCOPED_TARGET_PREFIX = "scopedTarget.";
28  
29  	private _SpringUtils()
30  	{
31  	}
32  
33  	public static boolean isAlternateBeanName(String beanName)
34  	{
35  		return beanName.startsWith(SCOPED_TARGET_PREFIX);
36  	}
37  
38  	public static String getRealBeanName(String beanName)
39  	{
40  		if (beanName != null && isAlternateBeanName(beanName))
41  		{
42  			return beanName.substring(SCOPED_TARGET_PREFIX.length());
43  		}
44  
45  		return beanName;
46  	}
47  
48  	public static String getAlternateBeanName(String beanName)
49  	{
50  		if (beanName != null && !isAlternateBeanName(beanName))
51  		{
52  			return SCOPED_TARGET_PREFIX + beanName;
53  		}
54  
55  		return beanName;
56  	}
57  
58  	/*
59  	public static Set getConversationManagedScopeNames()
60  	{
61  		ConfigurableApplicationContext applicationContext = FrameworkAdapter.getInstance().getApplicationContext();
62  		ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();
63  
64  		Set managedScopes = new TreeSet();
65  		String[] scopes = beanFactory.getRegisteredScopeNames();
66  		for (int i = 0; i < scopes.length; i++)
67  		{
68  			String scopeName = scopes[i];
69  
70  			Scope scope = beanFactory.getRegisteredScope(scopeName);
71  			if (scope instanceof SpringConversationScope)
72  			{
73  				managedScopes.add(scopeName);
74  			}
75  		}
76  
77  		return managedScopes;
78  	}
79  	*/
80  }