com.opensymphony.xwork2.config.impl.LocatableConstantFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xwork Show documentation
Show all versions of xwork Show documentation
XWork is an command-pattern framework that is used to power WebWork
as well as other applications. XWork provides an Inversion of Control
container, a powerful expression language, data type conversion,
validation, and pluggable configuration.
/**
*
*/
package com.opensymphony.xwork2.config.impl;
import com.opensymphony.xwork2.inject.Context;
import com.opensymphony.xwork2.inject.Factory;
import com.opensymphony.xwork2.util.location.Located;
import com.opensymphony.xwork2.util.location.LocationUtils;
/**
* Factory that remembers where a constant came from
*/
public class LocatableConstantFactory extends Located implements Factory {
T constant;
public LocatableConstantFactory(T constant, Object location) {
this.constant = constant;
setLocation(LocationUtils.getLocation(location));
}
public T create(Context ignored) {
return constant;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(super.toString());
sb.append(" defined at ");
sb.append(getLocation().toString());
return sb.toString();
}
}