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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:08:55+00:00 2026-06-02T03:08:55+00:00

In my java pojo XOM model , I have a static variable say count.I

  • 0

In my java pojo XOM model , I have a static variable say count.I am executing 5 rules and it is increasing the count variable by one. So in the end of the execution I have value as count = 5 .

Now if I declare a non static variable count and increment its value for each rule execution,will the variable be initialized 5 times and it is non static.

In other words, Will 5 instances of my java XOM model class will be created if the object is not declared as static ?

  • 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-02T03:08:57+00:00Added an answer on June 2, 2026 at 3:08 am

    Not sure I understood your question.
    I you have a rule stating:
    “then set myObj.count to myObj.count + 1;” then you will have as many count variables as myObj object.
    So if you insert in the working memory ONE myObj then you will have only ONE myObj at the end and during execution.
    Each rule will fire as many time as you have “matching” in the working memory.
    So if you pass 5 myObj in the engine, you will have 5 myObj.count each having a final value of ‘5’.

    If you are using static then it will be the same.
    Except if you are using the engine in a stateful mode (which quite rare actually).
    The BRMS is there to be a Decision Service and hence make a decision on the parameters passed in (and the rules of course).
    I am not saying you cannot use it in a stateful mode but this use is rare.
    If you do so, then yes the previous answer is correct and you will end up with an infinitely increasing value. Increasing by five at every run.

    BTW: I never tried this because there are a whole set of attributes to get the number of rules that fired or not and time execution and so on…

    To sum up, you have what you have in the working memory. Meaning that if you have ONE instance of an object the engine will never create more instance at runtime. That would lead to madness ( : : ) due to the RETEPlus algorithm. (which is not frequently used, as well)
    The only way to create more instance of object is to do it yourself a trun time directly via the rules. E.g.: Add an message “hello world” to the messages of the report”.
    Hope it helps

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

Sidebar

Related Questions

I have a DSL Java object, i.e. a POJO which returns this in setters
Let's say I have a simple POJO class: public void Foo { public int
I have a Java class which represents the correlation between two elements (typical POJO):
I have a simple Java POJO that I would copy properties to another instance
In general, is it a best practice to have simple POJO Java classes implement
I have written a Web Service in Java using axis2 and the POJO deployment
I have 2 POJO classes in Java, Answer and Collaborator, in a many-to-many relationship.
So we use Hibernate for Object-relational mapping and we have a Student.java (POJO) and
Using GWT I have a Java class: public class Pojo { private String name;
I have rule configuration on UI which builds to Java POJO. How could I

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.