alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Struts example source code file (LocatableConstantFactory.java)

This example Struts source code file (LocatableConstantFactory.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Struts tags/keywords

factory, factory, locatableconstantfactory, locatableconstantfactory, located, object, override, string, stringbuilder, stringbuilder, t, t

The Struts LocatableConstantFactory.java source code

/**
 * 
 */
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<T> 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();
    }

}

Other Struts examples (source code examples)

Here is a short list of links related to this Struts LocatableConstantFactory.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.