Search code examples
javadependency-injectionintershop

How does Intershop object wiring work


Could someone explain what is the capi package used for? Is it for dependency injection?

Also what would be the proper way to connect two BOs (eg BasketBO and BucketBO to get access to their methods and create some new data) ?

Is it through the pipeline or through some new common object?


Solution

  • The capi (cartridge API) package is where you put the interfaces/classes to your public API of the cartridge. You might have noticed there is almost always an internal package too, this is where the implementation of the public API goes. So interface SomeObjectMgr will be in the com.example.capi package and the implementation class SomeObjectMgrImpl in the com.example.internal package. The capi package you can consider to be stable, while the internal packages can drastically change from version to version.

    As for your second question, BO's are group together in an aggregate if they belong together, but an aggregate can refence other aggregates. So you are not limited in the relations you need to build . Example the BasketBO can access the BucketBO objects using its access methods. You could write an extension with business logic that manipulate the two BO's and return whatever data you need. However keep in mind that transaction control is on pipeline/pipelet level. So take that into account when designing your methods if you need to do a rollback of a transaction.

    As for dependency injection, intershop uses google's guice framework. You can find more information on how to use it here.