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

  • Home
  • SEARCH
  • 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 903987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:58:39+00:00 2026-05-15T15:58:39+00:00

I’m trying to develop an application where in the people will get notified if

  • 0

I’m trying to develop an application where in the people will get notified if there is any change in the PartNumber. Its a Spring based application. Following is the code snippet.

I’ve abstracted the storing mechanism here in SaveSubscriptionIF. The actual details of storing and retrieving are in the implementation class of this interface. The implementation class will be injected by Spring.

The external application calls my setState() method- passing the new information.

The store.getObservers() method returns me the Map which have the Observers and the corresponding info to update.

So far so good. Am struck in the implementation part of store.getObservers(). This method implementation needs the state data – i.e the new information passed from the external application.

How do i pass the ‘state’ data to an implementation class of ‘SaveSubscriptionIF’??

public class PartNumberSubject implements Observable {
     private SaveSubscriptionIF store;
     private Object state;
     @Override
     public void addObserver(final ObserverIF o, final Object subscriptionDetails) {
      store.addObserver(o, subscriptionDetails);
     }
     @Override
     public void notifyObservers() {
      @SuppressWarnings("unchecked")
      final Map<ObserverIF, List<PartInformationVO>> observers =(Map<ObserverIF,List<PartInformationVO>>) store                 .getObservers();
  for (final Entry<ObserverIF, List<PartInformationVO>> observer : observers
                        .entrySet()) {
     observer.getKey().update(observer.getValue());
     }
    }
    @Override
    public void setState(final Object state) {
     this.state = state;
     notifyObservers();
    }
    }
  • 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-15T15:58:40+00:00Added an answer on May 15, 2026 at 3:58 pm

    I think I understand what you mean.

    Normally in the observer pattern, the value that changed is passed out as a parameter in the Event object that is created.

    So, for example, you could create a StateChangedEvent class which had a value in it – state.

    Then, your setState method would look like this:

    public void setState(final Object state) {
        this.state = state;
        notifyObservers(state);
    }
    

    And notifyObservers:

    public void notifyObservers(Object state) {
        StateChangedEvent event = new StateChangedEvent(state);
        // Pass this event into each observer which you have subscribed...
    }
    

    I’m sorry if I’ve misread the question but this seems to be what you’re asking.

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

Sidebar

Related Questions

I'm trying to select an H1 element which is the second-child in its group
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I know there's a lot of other questions out there that deal with this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.