Tutorials > Content management > Create a content-managed resource > Make the resource content managed
Create a resource manager
As mentioned, content managed resources are comprised of two parts. This second part is the resource manager which manages create, update and delete operations for a particular resource. Every resource container has at least one associated resource manager.
Procedure
- In the Enterprise Explorer view, navigate to Other Projects > WebSphereCommerceServerExtensionsLogic.
- Right-click src and select New > Class.
- In the Name field, type ExtendedCatalogDescriptionResourceManager.
- In the Package field, type com.mycompany.catalog.content.resources
- In the SuperClass field, click the browse button and enter AbstractEntityBeanResourceManagerImpl into the Superclass selection window.
- Click the Add button next to the Interface box.
- In the Implemented Interfaces Selection window, type ResourceManager in the Choose interfaces field.
- In the Matching types box, select ResourceManager and click OK.
- Ensure that Inherited Abstract Methods is not selected.
- Click Finish.
- Implement the getEntityBeanCreationData(Object businessObject) method by copying the following code:
public EntityBeanCreationData getEntityBeanCreationData(Object businessObject) throws Exception { ExtendedCatalogDescriptionEntityBeanCreationData entityData = new ExtendedCatalogDescriptionEntityBeanCreationData(); entityData.copyFromAccessBean((ExtendedCatalogDescriptionAccessBean)businessObject); return entityData; }
- Implement the getManagedResourceKey(Map arg0) method to incorporate the keys for the new resource:
public ManagedResourceKey getManagedResourceKey(Map arg0) throws Exception { Long key[] = new Long[2]; key[0] = new Long((String)arg0.get("CATALOG_ID")); key[1] = new Long((String)arg0.get("LANGUAGE_ID")); return new ManagedResourceKey(key); }
- Override the getManagedResourceKey method with two more implementations that take in EntityBeanCreationData and Objects as parameters.
public ManagedResourceKey getManagedResourceKey(EntityBeanCreationData ecd) throws Exception { ExtendedCatalogDescriptionEntityBeanCreationData targetECD = (ExtendedCatalogDescriptionEntityBeanCreationData) ecd; Long key[] = new Long[2]; key[0] = targetECD.getCatalog_id(); key[1] = new Long(targetECD.getLanguage_id().longValue()); return new ManagedResourceKey(key); } public ManagedResourceKey getManagedResourceKey(Object arg0) throws Exception { Long key[] = new Long[2]; ExtendedCatalogDescriptionAccessBean a = (ExtendedCatalogDescriptionAccessBean) arg0; key[0] = a.getCatalog_id(); key[1] = new Long(a.getLanguage_id().longValue()); return new ManagedResourceKey(key); }
- Press CTRL+SHIFT+O to organize imports and save the file.