Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Design of Application Scoped Managed Beans

SteveF-FresnoDec 2 2015 — edited Dec 2 2015

Hi,

We are on JDev 12.1.3. We have some data being queried from the database which doesn't change and is used often. We are querying for this and then holding onto the data in an application-scoped managed bean. We also have multiple request-scoped beans that need to get this data from the application-scoped bean. We only reference this application-scoped bean from the code of the request-scoped beans.

When the request-scoped beans call to a method of the application-scoped bean a NullPointerException is thrown. Also, we have a method in the application-scoped bean that is annotated with @PostConstruct and that method is never called. How do you specify eager instantiation of the application-scoped bean in the adfc-config? It appears that you can't. Is there a different way the app should be designed to hold onto long-lived data referenced by many request-scoped managed beans?

Here's part of the adfc-config.xml:

<adfc-config ...>

     ...

<managed-bean id="__12">

    <managed-bean-name>userSecurityCompaniesBean</managed-bean-name>

    <managed-bean-class>fs.UserSecurityCompanies</managed-bean-class>

    <managed-bean-scope>request</managed-bean-scope>

    <managed-property id="__16">

      <property-name>securityApplicationBeanProperty</property-name>

      <property-class>fs.SecurityApplication</property-class>

      <value>#{applicationScope.securityApplicationBean}</value>

    </managed-property>

  </managed-bean>

  <managed-bean id="__10">

    <managed-bean-name>securityApplicationBean</managed-bean-name>

    <managed-bean-class>fs.SecurityApplication</managed-bean-class>

    <managed-bean-scope>application</managed-bean-scope>

  </managed-bean>

...

</adfc-config>

UserSecurityCompanies has the property and getter and setter code:

    private SecurityApplication securityApplicationBeanProperty;

    public SecurityApplication getSecurityApplicationBeanProperty() {

        return securityApplicationBeanProperty;

    }

    public void setSecurityApplicationBeanProperty(SecurityApplication securityApplicationBeanProperty) {

        this.securityApplicationBeanProperty = securityApplicationBeanProperty;

    }

Thanks,

Steve

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 30 2015
Added on Dec 2 2015
2 comments
629 views