locatablefactory.java
来自「在Struts2中的jar包xwork的源代码.版本为2.0.7」· Java 代码 · 共 51 行
JAVA
51 行
package com.opensymphony.xwork2.config.impl;import com.opensymphony.xwork2.util.location.Located;import com.opensymphony.xwork2.util.location.LocationUtils;import com.opensymphony.xwork2.inject.Factory;import com.opensymphony.xwork2.inject.Scope;import com.opensymphony.xwork2.inject.Context;import java.util.LinkedHashMap;/** * Attaches location information to the factory. */public class LocatableFactory<T> extends Located implements Factory<T> { private Class implementation; private Class type; private String name; private Scope scope; public LocatableFactory(String name, Class type, Class implementation, Scope scope, Object location) { this.implementation = implementation; this.type = type; this.name = name; this.scope = scope; setLocation(LocationUtils.getLocation(location)); } @SuppressWarnings("unchecked") public T create(Context context) { Object obj = context.getContainer().inject(implementation); return (T) obj; } public String toString() { String fields = new LinkedHashMap<String, Object>() { { put("type", type); put("name", name); put("implementation", implementation); put("scope", scope); } }.toString(); StringBuilder sb = new StringBuilder(fields); sb.append(super.toString()); sb.append(" defined at "); sb.append(getLocation().toString()); return sb.toString(); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?