首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Intershop7中通过ObjectGraph绑定管理器

在Intershop7中通过ObjectGraph绑定管理器
EN

Stack Overflow用户
提问于 2018-07-04 21:25:50
回答 1查看 71关注 0票数 2

我们已经创建了一个自定义对象管理器,我们希望将它绑定到实现上,这样我们就可以将用于自定义对象处理的管理器注入到我们的cartridge pipelets中。

我们已经创建了Mgr接口和实现,并遵循Intershop cookbook中的说明将实现绑定到接口:

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

以下是objectgraph.properties的内容:

代码语言:javascript
复制
global.modules = hr.a1.core.internal.modules.AppCoreA1NamingModule

这是AppCoreA1NamingModule.java的内容:

代码语言:javascript
复制
/*
 * 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);

    }

}

这是项目的结构:

但是,当我们启动服务器或尝试使用管理器时,我们会得到以下异常:

代码语言:javascript
复制
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来源:

代码语言:javascript
复制
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'


}

为了能够在我们的插件中注入和使用管理器,我们还需要做什么吗?

EN

回答 1

Stack Overflow用户

发布于 2018-07-04 22:15:44

我找到了一个解决方案。指向objectgraph.properties的路径应为src/main/resources/resources/cartridgeName/objectgraph/objectgraph.properties

一旦我更改了路径,管理器就可以正确绑定了。项目结构现在如下所示:

问题现在解决了,但是在文件夹结构中有两个同名的文件夹真的很令人困惑,所以也许这是应该从Intershop方面进行查看的事情。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51174832

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档