Hi,
I'm *almost* sure that there's no equivalent in Guice as these mechanisms promote bad design: objects should rather be initialized in their constructors and regarding `BeanNameAware` even its javadoc says "Note that it is not usually recommended
that an object depends on its bean name, as this represents a potentially
brittle dependence on external configuration, as well as a possibly
unnecessary dependence on a Spring API".
For name injection, you could create a simple custom `Provider` for each binding, but as I understand this exactly what you are trying to avoid:
```
bind(SomeBean.class).annotatedWith(Names.named("beanName")).toProvider(() -> {
final var bean = new SomeBeanImpl(); // or whatever else way to create an instance
bean.setBeanName("beanName");
return bean;
});
```
Other than the above, you could try writing Guice extension using its SPI (Service Provider Interface) and check if the class of the implementation implements your interface and if so, retrieve `@Named` value from the key and call your `setBeanName(name)`. Have a look at
https://github.com/google/guice/wiki/ExtendingGuice and other subsections of `Extensions` section.
For `BeanFactoryAware` issue a), as you probably know, you can always inject `Injector` itself (just add as a constructor param or an injectable field: `@Inject Injector injector`), but this is also discouraged in most cases: dependencies of your objects should rather be explicitly enumerated, ideally as constructor params.
For providing initialization point, again: this should ideally be done in constructors. Other than that you can try these ways:
- manually create simple custom `Provider` that calls `initialize()` for each binding of a class that needs to be initialized ` post constructor (again, as I understand that's what you are trying to avoid).
- similarly like for name injection, you could try using SPI and check for yet another interface with some `initialize()` method.
- set all dependencies (including `Injector` if needed) of your bean with a single method (like `@Inject void setDependencies(Dep1 dep1, Dep2 dep2 /* and so on */)`) and perform initialization there.
Hope this helps in some way :)
Cheers!