I have an Enum :
public enum MyEnum {
INSTANCE;
@Autowired
Regroupements regroupements;
@PostConstruct
public void initi()
{
System.out.println("---------- i am not called!");
}
private MyEnum() {
System.out.println("---------- i am called!");
}
}
And a Spring-Factory
@Component
public class MyEnumFactory implements FactoryBean<MyEnum>{
@Override
public MyEnum getObject() throws Exception {
return MyEnum.INSTANCE;
}
@Override
public Class<?> getObjectType() {
return MyEnum.class;
}
@Override
public boolean isSingleton() {
return true;
}
}
The problem is : when in call the method of the factory to give me the unique INSTANCE, the init() method is never called! you'll notice that, as it is an Enum, the class don't have @Component annotation. it's why I use a factory.
what I want is to launch a post-construct, it doesn't matter the way.