0

Can you please provide examples how to implement in Java a custom deployer extension to flush the application server cache when new content is published?

  • I'm tempted to ask you to do my "homework" in return ;o), but seriously without any details, I don't think you will get any usable answers. First you need to think about how are you expecting the application server cache to be flushed from an external process (in a secure way). So it would help if you edit your question and provide some more details around your question. – Bart Koopman Jun 1 '17 at 14:04
  • Why do you need to this, instead of using the OOTB cache solution (Cache Channel Service)? – Nuno Linhares Jun 1 '17 at 14:07
  • is it DD4T, DXA, traditional application. what cache you are referring here, give example? – Raj Kumar Jul 3 '17 at 6:24
1

The documentation contains a very nice (yet completely fictional) example of how to do this, which you can find here http://docs.sdl.com/LiveContent/content/en-US/SDL%20Web-v5/GUID-894AB0F0-313C-45A3-B8FC-8A02DA894C93

The example code will look like this:

package com.tridion.examples;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.tridion.transport.transportpackage.*;
import com.tridion.configuration.*;
import com.tridion.deployer.ProcessingException;
import com.tridion.deployer.Processor;
import com.tridion.deployer.Module;
import com.perfectsoftware.AppServer.*;

public class CacheFlusher extends Module {
    private static Logger log = LoggerFactory.getLogger(CacheFlusher.class);

    //imaginary appserver API
    AppManager server = CachingAppServer.getManagerInstance();

    public CacheFlusher(Configuration config, Processor processor) 
        throws ConfigurationException {
        super(config, processor);
    }

    // This method is called once for each TransportPackage that is deployed.
    public void process(TransportPackage data) throws ProcessingException {
        try {
            server.flush(config.getAttribute("AppInstance"));
        } catch (ConfigurationException e) {
            log.error("Could not get custom configuration", e);
        }
    }
}

Now all you need to do to suit it towards your needs is replace the line import com.perfectsoftware.AppServer.*; with an import to the application server you are actually using, and then accordingly change the example implementation (anything from the line //imaginary appserver API and below).

  • Thanks for your response #Bark Koopman, Already i have seen the above example, Here the below code they have customized to flush the cache but here my question is how to customize and from where we need to start the implementation. Kindly provide your inputs to proceed further //imaginary appserver API AppManager server = CachingAppServer.getManagerInstance(); ... ... server.flush(config.getAttribute("AppInstance")); – VijayaNaga Jun 2 '17 at 13:59
  • 2
    @VijayaNaga (the name is Bart, pleased to meet you), the implementation would depend on your application server, and my crystal ball doesn't show me what kind of app server you are using, so I wouldn't know what to answer ;o). Maybe you can edit your question and provide more details? – Bart Koopman Jun 2 '17 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.