In this blog, We are going to extend the Storage layer in SDL WEB 8.5 but first, we need to set up the project and will make sure that the custom code interacts with the default process.
Pre-Requisites
Step 1. Create a JAVA class file and add the following Namespaces.
Step 3. Create a storage DAO bundle config file.
Step 4. Copy this config file in the Deployer config folder and open the cd_storage config file in your favorite editor and add the following element.
Step 5. Copy the Custom JAR file in the deployer and restart the deployer.
Step 6. We are done with code and configuration, now we need to publish the DCP and check the logs.
In the log file, we can see the custom log is available and it's returning the Component ID which means the code is interacting with the default process.
In the next blog, we will see the difference between other Methods, how our code will change on Publishing, Unpublishing and re-publishing and how to read DCP content, Until then.
Happy Coding and Keep Sharing !!!
Pre-Requisites
- Eclipse or you can use your favorite JAVA IDE. You can also follow my previous blog on how to set up the Project in Eclipse and generate custom JAR. [here]
- JAVA 8
- Default SDL JARs
Step 1. Create a JAVA class file and add the following Namespaces.
import com.tridion.broker.StorageException;Step 2. Extends the class JPAComponentPresentationDAO and implement ComponentPresentationDAO. We also need to insert a @Component and a @scope("prototype") statement between import statements and class definition and the following line of code.
import com.tridion.storage.ComponentPresentation;
import com.tridion.storage.dao.ComponentPresentationDAO;
import com.tridion.storage.persistence.JPAComponentPresentationDAO;
import com.tridion.storage.util.ComponentPresentationTypeEnum;
import java.io.UnsupportedEncodingException;
import java.util.Collection;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Custom Storage Extension |
Step 3. Create a storage DAO bundle config file.
Step 4. Copy this config file in the Deployer config folder and open the cd_storage config file in your favorite editor and add the following element.
Edit storage config file. |
Step 5. Copy the Custom JAR file in the deployer and restart the deployer.
Custom JAR. |
Step 6. We are done with code and configuration, now we need to publish the DCP and check the logs.
Logs |
In the log file, we can see the custom log is available and it's returning the Component ID which means the code is interacting with the default process.
In the next blog, we will see the difference between other Methods, how our code will change on Publishing, Unpublishing and re-publishing and how to read DCP content, Until then.
Happy Coding and Keep Sharing !!!
No comments:
Post a Comment