I have structure where presenter/components can only access business object and business object is working with different services/repositories etc… I have few services like db connection, queue that should be available in every business object so they're in BaseLogic object from which every other business object is inherited. Is there some way to autowire those services there? I really don't want that presenter has any access to to those services and I don't want to have it in constructor and require them in every business layer. There's few possibilities that I see
- using inject* method and set for every business object inject: yes in neon files (would be cool if there's some setting for all services, but there's not)
- get those in presenters in inject* method and setting then to business layer object without setting them to any property in presenter.
I would have to make sure business object is created before all inject methods are runned.
@inject annotation is not option since property has to be public and that's a no.
Last edited by dkorpar (2017-01-17 11:55)
- David Matějka
- Moderator | 6427
would be cool if there's some setting for all services, but there's not
actually, there is :) it's called “decorator”, just add to your config.neon sth like this:
decorator: MyBaseClass: inject: true
and it will enable inject for all services which