⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 beanselectionprovider.java

📁 struts 2 核心包 的源码 有错误是难免的
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   BeanSelectionProvider.java

package org.apache.struts2.config;

import com.opensymphony.xwork2.*;
import com.opensymphony.xwork2.config.*;
import com.opensymphony.xwork2.inject.*;
import com.opensymphony.xwork2.util.*;
import com.opensymphony.xwork2.util.location.LocatableProperties;
import java.util.Properties;
import java.util.StringTokenizer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.dispatcher.mapper.ActionMapper;
import org.apache.struts2.dispatcher.multipart.MultiPartRequest;
import org.apache.struts2.views.freemarker.FreemarkerManager;
import org.apache.struts2.views.velocity.VelocityManager;

public class BeanSelectionProvider
	implements ConfigurationProvider
{
	class ObjectFactoryDelegateFactory
		implements Factory
	{

		String name;
		Class type;
		final BeanSelectionProvider this$0;

		public Object create(Context context)
			throws Exception
		{
			ObjectFactory objFactory = (ObjectFactory)context.getContainer().getInstance(com/opensymphony/xwork2/ObjectFactory);
			return objFactory.buildBean(name, null, true);
			ClassNotFoundException ex;
			ex;
			throw new ConfigurationException((new StringBuilder()).append("Unable to load bean ").append(type.getName()).append(" (").append(name).append(")").toString());
		}

		ObjectFactoryDelegateFactory(String name, Class type)
		{
			this$0 = BeanSelectionProvider.this;
			super();
			this.name = name;
			this.type = type;
		}
	}


	public static final String DEFAULT_BEAN_NAME = "struts";
	private static final Log LOG = LogFactory.getLog(org/apache/struts2/config/BeanSelectionProvider);

	public BeanSelectionProvider()
	{
	}

	public void destroy()
	{
	}

	public void loadPackages()
		throws ConfigurationException
	{
	}

	public void init(Configuration configuration1)
		throws ConfigurationException
	{
	}

	public boolean needsReload()
	{
		return false;
	}

	public void register(ContainerBuilder builder, LocatableProperties props)
	{
		alias(com/opensymphony/xwork2/ObjectFactory, "struts.objectFactory", builder, props);
		alias(com/opensymphony/xwork2/util/XWorkConverter, "struts.xworkConverter", builder, props);
		alias(com/opensymphony/xwork2/TextProvider, "struts.xworkTextProvider", builder, props);
		alias(com/opensymphony/xwork2/ActionProxyFactory, "struts.actionProxyFactory", builder, props);
		alias(com/opensymphony/xwork2/util/ObjectTypeDeterminer, "struts.objectTypeDeterminer", builder, props);
		alias(org/apache/struts2/dispatcher/mapper/ActionMapper, "struts.mapper.class", builder, props);
		alias(org/apache/struts2/dispatcher/multipart/MultiPartRequest, "struts.multipart.parser", builder, props, Scope.DEFAULT);
		alias(org/apache/struts2/views/freemarker/FreemarkerManager, "struts.freemarker.manager.classname", builder, props);
		alias(org/apache/struts2/views/velocity/VelocityManager, "struts.velocity.manager.classname", builder, props);
		if ("true".equalsIgnoreCase(props.getProperty("struts.devMode")))
		{
			props.setProperty("struts.i18n.reload", "true");
			props.setProperty("struts.configuration.xml.reload", "true");
			props.setProperty("struts.freemarker.templatesCache", "false");
			props.setProperty("devMode", "true");
		} else
		{
			props.setProperty("devMode", "false");
		}
		LocalizedTextUtil.addDefaultResourceBundle("org/apache/struts2/struts-messages");
		String bundles = props.getProperty("struts.custom.i18n.resources");
		if (bundles != null && bundles.length() > 0)
		{
			for (StringTokenizer customBundles = new StringTokenizer(props.getProperty("struts.custom.i18n.resources"), ", "); customBundles.hasMoreTokens();)
			{
				String name = customBundles.nextToken();
				try
				{
					LOG.info((new StringBuilder()).append("Loading global messages from ").append(name).toString());
					LocalizedTextUtil.addDefaultResourceBundle(name);
				}
				catch (Exception e)
				{
					LOG.error((new StringBuilder()).append("Could not find messages file ").append(name).append(".properties. Skipping").toString());
				}
			}

		}
	}

	void alias(Class type, String key, ContainerBuilder builder, Properties props)
	{
		alias(type, key, builder, props, Scope.SINGLETON);
	}

	void alias(Class type, String key, ContainerBuilder builder, Properties props, Scope scope)
	{
		if (!builder.contains(type))
		{
			String foundName = props.getProperty(key, "struts");
			if (builder.contains(type, foundName))
			{
				if (LOG.isDebugEnabled())
					LOG.info((new StringBuilder()).append("Choosing bean (").append(foundName).append(") for ").append(type).toString());
				builder.alias(type, foundName, "default");
			} else
			{
				try
				{
					Class cls = ClassLoaderUtil.loadClass(foundName, getClass());
					if (LOG.isDebugEnabled())
						LOG.debug((new StringBuilder()).append("Choosing bean (").append(cls).append(") for ").append(type).toString());
					builder.factory(type, cls, scope);
				}
				catch (ClassNotFoundException ex)
				{
					if (LOG.isDebugEnabled())
						LOG.debug((new StringBuilder()).append("Choosing bean (").append(foundName).append(") for ").append(type).append(" to be loaded from the ObjectFactory").toString());
					if (!"struts".equals(foundName))
						if (com/opensymphony/xwork2/ObjectFactory != type)
							builder.factory(type, new ObjectFactoryDelegateFactory(foundName, type), scope);
						else
							throw new ConfigurationException((new StringBuilder()).append("Cannot locate the chosen ObjectFactory implementation: ").append(foundName).toString());
				}
			}
		} else
		{
			LOG.warn((new StringBuilder()).append("Unable to alias bean type ").append(type).append(", default mapping already assigned.").toString());
		}
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -