Tutorials > Content management > Create a content-managed resource > Make the resource content managed

< Previous | Next >


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

  1. In the Enterprise Explorer view, navigate to Other Projects > WebSphereCommerceServerExtensionsLogic.

  2. Right-click src and select New > Class.

  3. In the Name field, type ExtendedCatalogDescriptionResourceManager.

  4. In the Package field, type com.mycompany.catalog.content.resources

  5. In the SuperClass field, click the browse button and enter AbstractEntityBeanResourceManagerImpl into the Superclass selection window.

  6. Click the Add button next to the Interface box.

  7. In the Implemented Interfaces Selection window, type ResourceManager in the Choose interfaces field.

  8. In the Matching types box, select ResourceManager and click OK.

  9. Ensure that Inherited Abstract Methods is not selected.

  10. Click Finish.

  11. 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;
    }
    

  12. 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);
    }
    

  13. 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);
    }
    

  14. Press CTRL+SHIFT+O to organize imports and save the file.

< Previous | Next >


+

Search Tips   |   Advanced Search