Can we customize Deployer using .NET? [closed]

[亡魂溺海] 提交于 2019-12-10 23:18:23

问题


I need to customize my deployer for some reasons, I can only see some articles which are using java for customizing deployer.

Can we customize deployer using .NET project, please share your thought and if possible some solution.


回答1:


The Deployer is only extendable using Java as you have found. Your best bet if you want to do something completely custom using .NET is to publish files with FTP (or HTTP without an in process Deployer) and create a .NET application with a file system watch to process the files.

Perhaps you can share more about what you are trying to achieve and your version of SDL Tridion for someone to offer more suggestions.




回答2:


The obvious answer is NO. The Deployer is a rather low-level part of Content Delivery, and its extensibility points are only available to Java.

However, there's many ways to skin this cat, it all depends on what you're trying to achieve.

You could, for instance, create a webservice with .NET that does all the meat of your extension, and write a simple Deployer Module (with Java) that calls this webservice, passing all the required parameters to it.

You could pre-process the Transport package by publishing to a location where your .NET method would be called before passing the package to the real location where the deployer is listening.

In case you prefer post-processing, you could configure your deployer to keep successful transactions and monitor the location where the deployer stores these ("incoming folder" + "\Success").

It really all depends on what you want to achieve. The recommended way is to use Java, but if you're not comfortable with that language, you can be creative and achieve the same end results with minimal Java coding. Here's an example of an "empty" module that loops through the items being published and logs information about the objects:

import java.util.Iterator;

import com.tridion.configuration.Configuration;
import com.tridion.configuration.ConfigurationException;
import com.tridion.deployer.Module;
import com.tridion.deployer.ProcessingException;
import com.tridion.deployer.Processor;

import com.tridion.transport.transportpackage.Binary;
import com.tridion.transport.transportpackage.BinaryKey;
import com.tridion.transport.transportpackage.Component;
import com.tridion.transport.transportpackage.ComponentKey;
import com.tridion.transport.transportpackage.MetaData;
import com.tridion.transport.transportpackage.MetaDataFile;
import com.tridion.transport.transportpackage.Page;
import com.tridion.transport.transportpackage.PageKey;
import com.tridion.transport.transportpackage.ProcessorInstructions;
import com.tridion.transport.transportpackage.Section;
import com.tridion.transport.transportpackage.TransportPackage;

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


public class CustomCacheNotificationDeploy extends Module {

    String action = null;
    Logger log = null;
    MetaDataFile pageMeta = null;
    MetaDataFile componentMeta = null;
    MetaDataFile binaryMeta = null;
    public CustomCacheNotificationDeploy(Configuration config, Processor processor)
            throws ConfigurationException {
        super(config, processor);
        log = LoggerFactory.getLogger(getClass());
        // TODO Auto-generated constructor stub
    }

    @SuppressWarnings("deprecation")
    public void process(TransportPackage data) throws ProcessingException{
        ProcessorInstructions instructions = data.getProcessorInstructions();
        action = instructions.getAction();
        MetaData pageMetaInfo = instructions.getMetaData("Pages");
        MetaData componentMetaInfo = instructions.getMetaData("Components");
        MetaData binaryMetaInfo = instructions.getMetaData("Binaries");
        pageMeta = data.getMetaData("Pages", pageMetaInfo.getName());
        componentMeta = data.getMetaData("Components", componentMetaInfo.getName());
        binaryMeta = data.getMetaData("Binaries", binaryMetaInfo.getName());

        log.debug("Action " + action + " started for publication " + instructions.getPublicationId());

        Section section = null;
        Iterator<Section> Sections = instructions.getSections();
        for(; Sections.hasNext(); processSection(section))
        {
            section = Sections.next();
        }

    }

    protected void processSection(Section section)
    {
        log.debug("Processing Section " + section.getName());
        Iterator iterator = section.getFileItems();
        Object item;
        for(; iterator.hasNext(); processItem(item, section))
        {
            item = iterator.next();
        }
        Section subSection;
        for(Iterator i$ = section.getSubSections().iterator(); i$.hasNext(); processSection(subSection))
            subSection = (Section)i$.next();
    }

    protected void processItem(Object obj, Section section)
    {
        if(obj instanceof PageKey)
        {
            log.debug("Object is Page");
            PageKey key = (PageKey) obj;
            Page page = (Page)pageMeta.getMetaData(key);
            log.debug("Page being deployed is " + page.getId() + " with URL " + page.getURLPath());
        }
        if(obj instanceof ComponentKey)
        {
            log.debug("Object is Component");
            ComponentKey key = (ComponentKey) obj;
            Component component = (Component)componentMeta.getMetaData(key);
            log.debug("Component being deployed is " + component.getId());
        }
        if(obj instanceof BinaryKey)
        {
            log.debug("Object is Binary");
            BinaryKey key = (BinaryKey) obj;
            Binary binary = (Binary)binaryMeta.getMetaData(key);
            log.debug("Binary being deployed is " + binary.getId() + " with URL " + binary.getURLPath());
        }
    }
}


来源:https://stackoverflow.com/questions/10672582/can-we-customize-deployer-using-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!