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 7651629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:33:20+00:00 2026-05-31T11:33:20+00:00

I need a way to write a command call that will be executed in

  • 0

I need a way to write a command call that will be executed in compiled code. However, the command will be store in a database as a String because it’s configurable by the user. Each command would match a class but there could be multiple commands that need to be executed with input parameters.

How is the best way of handling this?

Example Class that would be called:

public class CreateUser {
   protected User user; 

   public static void create(User user){
      CreateUser cu = new CreateUser(user);
      cu.newUserFunction();
   }

   public CreateUser(User user){
      this.user = user;
   }

   public void newUserFunction(){
      doSomething();
   }
}

Example Method that would call the command:

public void createUser(User user){
  dclCommand.createUser(user.getUsername(), user.getPassword());

  // Get special commands to run after user is created
  List<Command> cmds = this.dbRepository.findCommand(database, Method.CREATE_USER);
  for(Command cmd : cmds){
     // Here is where the cmd will be executed with input parameters
     // In example the command executed would be 'org.example.CreateUser.create(user)'
  }
} 

The call to ‘org.example.CreateUser.create(user)’ will be stored in a database and I need to be able to run it from a function that will get it out of the database and call it adding the parameter User.

  • 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-05-31T11:33:22+00:00Added an answer on May 31, 2026 at 11:33 am

    Have you considered using the Command Pattern?

    Basically, you create an interface like

    interface DoStuff{
        void doIt();
    }
    

    Then, for every method that the user could call, you create class that implements that interface. Each implementation^ calls their associate method in the body of their doIt() method. Then, you store each user’s chosen implementation class’s cannononical name as a string field in the database. When the user logins you fetch than field, instantiate the instance using Class.forName(String), and cast the return to DoStuff. Then, whenever the user’s chose method would be called call userStuffDoer.doIt() and their chosen method will be called.

    If there is a near infinite number of methods a user could call you will have to use reflection and store class and method names and how to get the method data etc.

    ^ The implementation classes will need to have empty constructors.

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

Sidebar

Related Questions

I need to write AVL-tree with generic type in C. The best way I
I need a way to store application-level data (i.e. cross user sessions) in ASP.NET.
I need a way to insert new articles straight into my MediaWiki database without
I need to have a command handler for a ToggleButton that can take multiple
Whilst writing working my way through a list of scripts I need to write
I am attempting to write an sql command into an sql file so that
Edit: my final code goes something like this: #WARNING: all in command need to
I'm trying to write a project that will have some autonomous components. One of
I am trying to write a basic app that will read data off a
I need to write a script that would get hostname and all physical addresses

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.