X Tutup
Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

set _instance for Singleton Beans in the constructor. #700

@mwinters-stuff

Description

@mwinters-stuff

I found a problem, the following is my attempt to example what I came across, this problem occured because _instance is set after the constructor e.t.c. of the bean has executed.
(this code probably wont compile as i am typeing it from my head)..

@EBean(scope="singleton")
class DatabaseHelper
{
}

@EBean(scope="singleton")
class Worker1
{
  @Bean
  DatabaseHelper database;
}

@EBean(scope="singleton")
class Worker2
{
  @Bean
  DatabaseHelper database;
  @Bean
  Worker1 worker1;
}

@Bean(activity/fragment/whatever)
class someotherclass
{
  @Bean
  Worker2 worker2;
}

In this case, worker2 creates a database helper and worker1
worker1 will also create a new databasehelper..

If _instance was set in the constructor to "this", then we would only get one instance of databasehelper.

I had a go at making the changes myself, but after making the change, i couldnt compile the source through some error unleated to where i had made changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup