use ctor::ctor;
use std::sync::Arc;
use crate::rudi::dicontainer::direg;
#[derive(Debug, Clone)]
pub struct Database {
id: u64,
}
impl Database {
pub fn new() -> Self {
println!(">>> Database::new() 被调用了2026!");
Self { id: rand::random() }
}
}
const SingleBeanName: &str = "*dbentity.DB-c4c86833-374b-4acb-8769-b5fa294cb7b3";
pub fn find_bean_database() -> Option<Arc<Database>> {
direg::get_bean::<Database>(SingleBeanName)
}
#[ctor(unsafe)]
pub fn register_bean_database() {
direg::register_singleton(SingleBeanName, Database::new);
}