Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8582575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:19:33+00:00 2026-06-11T21:19:33+00:00

From Apache velocity guide property lookup rules are: for adress property ($object.address) getaddress() getAddress()

  • 0

From Apache velocity guide property lookup rules are:

for adress property ($object.address)

getaddress()
getAddress()
get("address")
isAddress()

I would like to change get rule to accept varargs Object parameters. So it will not call

get(String name)

but

get(String name, Object...params)

I know it could be propably done by creating custom ubespector. But I have absolutely no idea how.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:19:35+00:00Added an answer on June 11, 2026 at 9:19 pm

    Finaly after 2 days of digging I was able to make custom Uberspector. Which if no corresponding method is found will call “run(String, Object[])” method. Standard “get(String)” will call

    run(name, new Object[]{});
    

    CustomUbersector

    import java.lang.reflect.Method;
    import org.apache.velocity.util.introspection.Info;
    import org.apache.velocity.util.introspection.UberspectImpl;
    import org.apache.velocity.util.introspection.VelMethod;
    
    public class CustomUberspector extends UberspectImpl {
    
    public VelMethod getMethod(Object obj, String methodName, Object[] args, Info i)
            throws Exception  {
    
            if (obj == null) return null;
    
            VelMethod vm = super.getMethod(obj, methodName, args, i);
            if(vm != null) return vm;
    
            Object[] iargs = {methodName, new Object[] {}} ;
            Method m = introspector.getMethod(obj.getClass(), "run", iargs);
            if (m != null) return new PortalVelMethodImpl(m, methodName);
    
            return null;
    }
    
    public class PortalVelMethodImpl extends VelMethodImpl {
        final Method method;
        final String name;
    
        public PortalVelMethodImpl(Method m, String methodName) {
            super(m);
            method = m;
            name   = methodName;            
        }
    
        protected Object doInvoke(Object o, Object[] actual) throws Exception  {
            /* "run" method argumens are String and Object[] so we need to get plain Object[] array
             * From [Arg0,[Arg1..ArgN] to [Arg0,Arg1..ArgN]
             * */
            List<Object> args = new ArrayList<Object>();
            if(actual.length >= 1) {
                args.add(actual[0]);
    
                if(actual.length >= 2) {
                    Object[] nestedArgs = (Object[])actual[1];
                    for(int i=1; i<nestedArgs.length; i++) args.add(nestedArgs[i]);
                }
            }
    
            return method.invoke(o, name, args.toArray());
        }
    
    }
    

    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to use Derby from apache in order to include database management
I get this error while accessing a php script: W/System.err: Error reading from ./org/apache/harmony/awt/www/content/text/html.class
I need to sort the results I get back from apache solr based on
Is it possible to write a DLL that would take input from Apache and
What benefits do I get from Apache C++ standard library that I don't get
Is there any library in .net for common utils like the one from apache
I need to rewrite this rules (from apache's .htaccess): <files *.*> Allow from 84.47.125.0/19
I'd like to find out why UnmodifiableMap.decorate(Map map) from Apache Commons operates on Map
I need to work in velocity, I read the getting started sections from velocity.apache.org
My hosting company recently upgraded me from Apache 1 to Apache 2, and I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.