2 Replies Latest reply on Dec 14, 2010 6:48 AM by manik

    Getting the name of the cache in ReplicationQueueImpl

    cbo_

      Wonder if there is an easy way to  obtain the name of the cache associated with the replication queue in a class that will extend ReplicationQueueImpl?

       

      Mircea had previously suggested something like the following:


      MultipleRpcCommand multipleRpcCommand =  commandsFactory.buildReplicateCommand(toReplicate);
      multipleRpcCommand.getCacheName()
      
      

       

      The above may work in the ReplicationQueueImpl itself, but I will need to gain access to the cache name in a class that will extend the ReplicationQueueImpl.  commandsFactory has private access.

        • 1. Re: Getting the name of the cache in ReplicationQueueImpl
          mircea.markus

          You can have it inject it in your implementation by using @Inject annotation, e.g.:

             @Inject
             private void injectDependencies(@ComponentName(KnownComponentNames.ASYNC_REPLICATION_QUEUE_EXECUTOR) ScheduledExecutorService executor,
                                             RpcManager rpcManager, Configuration configuration, CommandsFactory commandsFactory) {

             @Inject

             private void injectDependencies(@ComponentName(KnownComponentNames.ASYNC_REPLICATION_QUEUE_EXECUTOR) ScheduledExecutorService executor,

                                             RpcManager rpcManager, Configuration configuration, CommandsFactory commandsFactory)

          This method will be called at startup, before anything gets queued. Just use as params whatever is relevant for you.

          • 2. Re: Getting the name of the cache in ReplicationQueueImpl
            manik

            You should be able to declare your own method, e.g.,

             

            @Inject

            private void injectCache(Cache c) { .. }

             

            and that will give you a reference to the Cache, after which you can call:

             

            c.getName()