2

We have created a custom object manager and we would like to bind it to the implementation so we can inject the manager for our custom object handling into our cartridge pipelets.

We have created the Mgr interface and implementation and followed the instructions in Intershop cookbook for binding the implementation to interface:

https://support.intershop.com/kb/index.php/Display/2S4413#Cookbook-DependencyInjectionandObjectGraphs-Recipe:AddaNewManager/Provider/ServiceNewManagerProviderService

This is the content of objectgraph.properties:

global.modules = hr.a1.core.internal.modules.AppCoreA1NamingModule

And this is the content of AppCoreA1NamingModule.java:

/*
 * AppCoreA1NamingModule AppCoreA1NamingModule.java.
 *
 * Copyright (c) 2018 OptimIT d.o.o.. All rights reserved.
 */
package hr.a1.core.internal.modules;

import javax.inject.Singleton;

import com.intershop.beehive.core.capi.naming.AbstractNamingModule;

import hr.a1.core.postpaid.capi.A1PostpaidPriceMgr;
import hr.a1.core.postpaid.internal.A1PostpaidPriceMgrImpl;

/**
 * The Class AppCoreA1NamingModule.
 */
public class AppCoreA1NamingModule extends AbstractNamingModule {

    /**
     * Configure.
     */
    @Override
    protected void configure() {

        bindManager(A1PostpaidPriceMgr.class).to(A1PostpaidPriceMgrImpl.class).in(Singleton.class);

    }

}

And this is the project structure:

enter image description here

However, when we start the server or try to use the manager, we get the following exception:

1) No implementation for hr.a1.core.postpaid.capi.A1PostpaidPriceMgr was bound.
  while locating hr.a1.core.postpaid.capi.A1PostpaidPriceMgr
    for field at hr.a1.service.product.pipelet.ESBCreatePrices.a1PostpaidPriceMgr(ESBCreatePrices.java:34)
  while locating hr.a1.service.product.pipelet.ESBCreatePrices

build.gradle source:

apply plugin: 'java-cartridge'
apply plugin: 'static-cartridge'
apply plugin: 'com.intershop.gradle.cartridge-resourcelist'

intershop {
    displayName = 'Core - Core cartridge for A1 Organization'
    description = 'Core cartridge for A1 Organization'
}


dependencies {
   compile group: 'com.intershop.platform', name: 'bc_mail'
   compile group: 'com.intershop.platform', name: 'bc_service'
   compile group: 'com.intershop.platform', name: 'orm'
   compile group: 'com.intershop.business', name: 'bc_product'
   compile group: 'com.intershop.business', name: 'bc_image'   
   compile group: 'com.intershop.business', name: 'xcs'
   compile group: 'com.intershop.platform', name: 'cache'
   compile group: 'com.intershop.platform', name: 'core'
   compile group: 'com.intershop.platform', name: 'businessobject'
   compile group: 'com.intershop.platform', name: 'bc_repository'
   compile group: 'com.intershop.platform', name: 'bc_application'
   compile group: 'com.intershop.platform', name: 'pf_property'
   compile group: 'com.intershop.platform', name: 'app'

   compile ('com.intershop.platform:pf_axis2')
   {
       exclude module: 'axiom-api'
       exclude module: 'axiom-impl'
       exclude module: 'axis2-kernel'
       exclude module: 'axis2-transport-http'
       exclude module: 'axis2-transport-local'
       exclude module: 'geronimo-jta_1.1_spec'
       exclude module: 'servlet-api'
       exclude module: 'geronimo-activation_1.1_spec'
   }

   compile ('org.apache.axis2:axis2-kernel')
   {
       exclude module: 'axiom-api'
       exclude module: 'axiom-impl'
       exclude module: 'geronimo-activation_1.1_spec'
       exclude module: 'geronimo-jta_1.1_spec'
       exclude module: 'geronimo-ws-metadata_2.0_spec'
       exclude module: 'geronimo-stax-api_1.0_spec'
       exclude module: 'jsr311-api'
       exclude module: 'neethi'
       exclude module: 'servlet-api'
   }
   compile ('org.apache.axis2:axis2-transport-local')
   {
       exclude module: 'axis2-kernel'
       exclude module: 'axiom-api'
       exclude module: 'axiom-impl'
       exclude module: 'jsr311-api'
       exclude module: 'geronimo-jta_1.1_spec'
       exclude module: 'servlet-api'
       exclude module: 'geronimo-activation_1.1_spec'
   }
   compile ('org.apache.axis2:axis2-transport-http')
   {
       exclude module: 'axis2-kernel'
       exclude module: 'axiom-api'
       exclude module: 'axiom-impl'
       exclude module: 'jsr311-api'
       exclude module: 'geronimo-jta_1.1_spec'
       exclude module: 'servlet-api'
       exclude module: 'geronimo-activation_1.1_spec'
   }

   compile ('org.apache.ws.commons.axiom:axiom-api')
   {
       exclude module: 'geronimo-activation_1.1_spec'
       exclude module: 'geronimo-stax-api_1.0_spec'
       exclude module: 'jaxen'
       exclude module: 'stax-api'
   }

   compile ('org.apache.axis2:axis2-adb')
   {
       exclude module: 'axiom-dom'
       exclude module: 'axis2-kernel'
       exclude module: 'geronimo-ws-metadata_2.0_spec'
       exclude module: 'geronimo-activation_1.1_spec'
       exclude module: 'geronimo-stax-api_1.0_spec'
   }


      compile ('commons-logging:commons-logging')

      // https://mvnrepository.com/artifact/com.google.code.gson/gson
      compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'


}

Is there anything else we need to do to be able to inject and use the manager in our cartridges?

1 Answers1

4

I have found a solution. Path to the objectgraph.properties should be src/main/resources/resources/[cartridgeName]/objectgraph/objectgraph.properties

Once I changed the path, manager is binding correctly. The project structure looks like this now:

enter image description here

Problem is solved now, but it is really confusing to have 2 folders with the same name in the folder structure so maybe it's something that should be looked into from the Intershop side.

  • oh wow, i would have never guessed. Agree intershop should look at this. At least update the cookbook. – Willem Evertse Jul 04 '18 at 14:18
  • 1
    Thanks for posting it. Even if I'll receive a shit storm now, I want to explain the reason why this is necessary. In old releases of Intershop, cartridges never had the maven like source folder structure. Everything was in one java-source folder. That's why the additional resource package prefix was needed. – Johannes Metzner Jul 04 '18 at 14:59
  • 2
    Anyways, sorry for the trouble. I'll file an issue for the responsible team in regards to update the cookbook documentation. – Johannes Metzner Jul 04 '18 at 15:03