0 Replies Latest reply: Jul 27, 2012 3:21 AM by 911534 RSS

    Using the {scheme-ref} parameter macro with the ExtensibleEnvironment

    911534
      I have just started trying to use the ExtensibleEnvironment inside the coherence-common project (2.2.0.32329) with Coherence version 3.7.1 (Build 27797) but am running into a problem when I try to load my existing cache-config. My cache-config configures a custom BinaryEntryStore implementation which accepts 4 initialisation parameters, two of which use the {scheme-ref} parameter macro to instantiate and inject class-scheme defined objects into the BinaryEntryStore.

      e.g.

      ...
      <init-param>
      <param-type>{scheme-ref}</param-type>
      <param-value>cachestore-logger</param-value>
      </init-param>
      ...
      <class-scheme>
      <scheme-name>cachestore-logger</scheme-name>
      <class-name>com.myco.cache.coherence.CoherenceLog</class-name>
      </class-scheme>
      ...

      My BinaryEntryStore implementation has a constructor which accepts an interface implemented by the CoherenceLog class.

      At runtime, I get a NoSuchMethodException complaining that no compatible constructor could be found:

      (Wrapped) java.lang.NoSuchMethodException: Unable to find a compatible constructor for com.man.cache.coherence.RemoteBinaryEntryStoreAdapter with the parameters SimpleParameterProvider{parameters={0x00000138C36750450ADC6D66EF1A74D51921F21692F9081BCBB0E26C90336CD6=Parameter{name=0x00000138C36750450ADC6D66EF1A74D51921F21692F9081BCBB0E26C90336CD6, type=com.tangosol.net.BackingMapManagerContext, expression=MacroParameterExpression{expression={manager-context}}}, 0x00000138C36750450ADC6D66D99B58139013F91CA4BB6822C41B290290336CD7=Parameter{name=0x00000138C36750450ADC6D66D99B58139013F91CA4BB6822C41B290290336CD7, type=java.lang.String, expression=MacroParameterExpression{expression={cache-name}}}, 0x00000138C36750450ADC6D66252F3E8F874086D5AFCE74C3CB2A378590336CD8=Parameter{name=0x00000138C36750450ADC6D66252F3E8F874086D5AFCE74C3CB2A378590336CD8, type={scheme-ref}, expression=MacroParameterExpression{expression=cachestore-repository-factory}}}}
           at com.tangosol.util.Base.ensureRuntimeException(Base.java:288)
           at com.tangosol.util.Base.ensureRuntimeException(Base.java:269)
           at com.oracle.coherence.common.builders.ClassSchemeBasedParameterizedBuilder.realize(ClassSchemeBasedParameterizedBuilder.java:313)
           at com.oracle.coherence.environment.extensible.ExtensibleEnvironment.instantiateAny(ExtensibleEnvironment.java:746)
           at com.tangosol.net.DefaultConfigurableCacheFactory.instantiateCacheStore(DefaultConfigurableCacheFactory.java:3324)
      ...

      Looking in the coherence-common source code I cannot see support for the {scheme-ref} macro. I think the fact that the <param-type> element has been specified in the cache-config causes the Parameter.isStronglyTyped() method to return true which in turn causes the ClassSchemeBasedParameterizedBuilder to try to load a class corresponding to the specified <param-type> value. This ultimately results in the exception above being thrown.

      Is there another way of injecting dependencies in this way (preferably without having to resort to Spring or external dependency injection configuration files)?

      Thanks in advance for your help.