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

    Getting the name of the cache in ReplicationQueueImpl

    craig bomba Novice

      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 Master

          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 Surtani Master

            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()