Implementing a storage type
You can extend the Storage Layer by providing your own type of storage.
Procedure
- Extend the com.tridion.storage.DAOFactory class. The constructor must supply a storage ID to the parent class:
package com.tridion.storage.myCustomDAOFactories; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Scope; import org.springframework.context.stereotype.Component; import org.springframework.beans.factory.annotation.Autowired; import com.tridion.storage.DAOFactory; // If you use database-type storage, include the following two lines @Component("MyDAOFactoryImpl") @Scope("prototype") public class MyDAOFactoryImpl implements DAOFactory { // If you use database-type storage, include the following two lines. // This picks up the configuration of this storage type that you define // in the Storage Layer configuration file. @Autowired private ApplicationContext applicationContext; private String storageId; // constructor public MyDAOFactoryImpl(String storageId) { this.storageId = storageId; } // implementation of DAO Factory. }If your custom DAO factory provides JPA-type storage, you must provide
@Component,@Scopeand, if your factory has configurable parameters,@Autowired. - Define DAOs for the various item types (standard or custom) that you intend to store in this new custom storage repository. The best way to do this is to create your own
MyNewStorageTypeBaseDAOclass, equivalent to theJPABaseDAOandFSBaseDAOclasses.MyNewStorageTypeBaseDAOwould contain storage logic and properties common to all types of items that you store in your custom repository.You now have a base DAO class for storing items in your custom repository. - Extend this base class to create specific DAOs for the specific item types you intend to store. For example, you would make a
MyNewStorageTypePageDAOImplclass that extendsMyNewStorageTypeBaseDAOand implements thePageDAOinterface. Once you have created a specific DAO class, go through the steps described in Customizing storage of an existing item type to configure their storage.You now have set up storage in your custom repository for all relevant item types. - Open the Storage Layer configuration file, cd_storage_conf.xml, in a plain-text or XML editor and find the
<Storages>section. Inside this element, insert a newStorageelement that looks as follows:<Storage Type="myNewStorageType" Class="myCustomDAOFactories.MyDAOFactoryImpl" Id="myStorageId"> // configuration items required by your custom DAO Factory </Storage> - In the Storage Layer configuration file, you can specify storage of default item types in this custom storage repository, simply by setting the
storageIdattribute of the appropriateItemelement tomyStorageId. For example:<Item typeMapping="ComponentPresentation" storageId="myStorageId" />specifies that Component Presentations should be stored in your custom storage repository.