View Javadoc
1 /* 2 * $Header: /cvsroot/ebxmlrr/ebxmlrr/src/share/com/sun/ebxml/registry/persistence/PersistenceManagerImpl.java,v 1.21 2003/01/01 15:39:20 farrukh_najmi Exp $ 3 */ 4 5 package com.sun.ebxml.registry.persistence; 6 7 import com.sun.ebxml.registry.*; 8 import com.sun.ebxml.registry.persistence.rdb.*; 9 10 import org.oasis.ebxml.registry.bindings.rs.RegistryErrorList; 11 import org.oasis.ebxml.registry.bindings.rim.*; 12 import org.oasis.ebxml.registry.bindings.rim.types.*; 13 import org.oasis.ebxml.registry.bindings.query.*; 14 import org.oasis.ebxml.registry.bindings.query.types.*; 15 16 17 import java.util.*; 18 import java.io.*; 19 20 /*** 21 * Class Declaration for Class1 22 * @see 23 * @author Farrukh S. Najmi 24 * @author Adrian Chong 25 */ 26 public class PersistenceManagerImpl implements PersistenceManager { 27 28 /*** 29 * 30 * @associates <{com.sun.ebxml.registry.persistence.rdb.SQLPersistenceManagerImpl}> 31 */ 32 SQLPersistenceManagerImpl sqlPM = SQLPersistenceManagerImpl.getInstance(); 33 34 protected PersistenceManagerImpl(){} 35 36 public static PersistenceManagerImpl getInstance(){ 37 if (instance == null) { 38 synchronized(PersistenceManagerImpl.class) { 39 if (instance == null) { 40 instance = new PersistenceManagerImpl(); 41 } 42 } 43 } 44 return instance; 45 } 46 47 /*** 48 * Does a bulk insert of a heterogeneous Collection of RegistrObjects. 49 * 50 */ 51 public void insert(User user, ArrayList registryObjects) throws RegistryException{ 52 sqlPM.insert(user, registryObjects); 53 } 54 55 /*** 56 * Does a bulk update of a heterogeneous Collection of RegistrObjects. 57 * 58 */ 59 public void update(User user, ArrayList registryObjects) throws RegistryException{ 60 sqlPM.update(user, registryObjects); 61 } 62 63 /*** 64 * Update the status of specified objects to the specified status. 65 * 66 */ 67 public void updateStatus(User user, ArrayList registryObjectsIds, StatusType status, RegistryErrorList el) throws RegistryException { 68 sqlPM.updateStatus(user, registryObjectsIds, status, el); 69 } 70 71 /*** 72 * Does a bulk delete of a heterogeneous Collection of RegistrObjects. 73 * If any RegistryObject cannot be found, it will make no change to the 74 * database and throw RegistryException 75 * 76 */ 77 public void delete(User user, ArrayList registryObjectIds) throws RegistryException{ 78 sqlPM.delete(user, registryObjectIds); 79 } 80 81 /*** 82 * Adds specified slots to specified object. 83 * 84 */ 85 public void addSlots(String objectId, ArrayList slots) throws RegistryException { 86 sqlPM.addSlots(objectId, slots); 87 } 88 89 /*** 90 * Removes specified slots from specified object. 91 * 92 */ 93 public void removeSlots(String objectId, ArrayList slots) throws RegistryException { 94 sqlPM.removeSlots(objectId, slots); 95 } 96 97 /*** 98 * Returns ArrayList of ids of non-existent RegistryObject 99 */ 100 public ArrayList registryObjectsExist(ArrayList ids) throws 101 RegistryException { 102 return sqlPM.registryObjectsExist(ids); 103 } 104 105 /*** 106 * Gets the specified object using specified id and className 107 * 108 */ 109 public RegistryObjectType getRegistryObject(String id, String className) throws RegistryException { 110 return sqlPM.getRegistryObject(id, className); 111 } 112 113 /*** 114 * Executes and SQL query using specified parameters. 115 * 116 * @return An ArrayList of RegistryObjectType instances 117 */ 118 public ArrayList executeSQLQuery(String sqlQuery, ResponseOption responseOption, String tableName, ArrayList objectRefs) throws RegistryException { 119 return sqlPM.executeSQLQuery(sqlQuery, responseOption, tableName, objectRefs); 120 } 121 122 /*** 123 Get a HashMap with registry object id as key and owner id as value 124 */ 125 public HashMap getOwnersMap(ArrayList ids) throws RegistryException { 126 return sqlPM.getOwnersMap(ids); 127 } 128 129 public String mapTableName(String name) { 130 return sqlPM.mapTableName(name); 131 } 132 133 public String mapColumnName(String name) { 134 return sqlPM.mapColumnName(name); 135 } 136 137 public static void main(String[] args) throws RegistryException { 138 PersistenceManagerImpl pm = PersistenceManagerImpl.getInstance(); 139 140 /* Test the updateStatus method impl. 141 ArrayList ids = new ArrayList(); 142 ids.add("urn:uuid:1cdbe4df-cb09-45b2-90bb-9730f4bf1193"); 143 144 pm.updateStatus(ids, StatusType.DEPRECATED); 145 */ 146 147 /* Test the removeSlots method impl 148 ArrayList slots = new ArrayList(); 149 Slot slot = new Slot(); 150 slot.setName("addedSlot1"); 151 slot.setSlotType("junkType"); 152 153 ValueList values = new ValueList(); 154 ValueListTypeItem item = new ValueListTypeItem(); 155 item.setValue("addedValue1"); 156 values.addValueListTypeItem(item); 157 158 slot.setValueList(values); 159 160 slots.add(slot); 161 162 pm.removeSlots("urn:uuid:1cdbe4df-cb09-45b2-90bb-9730f4bf1193", slots); 163 */ 164 165 /* Test the delete method impl 166 ArrayList ids = new ArrayList(); 167 ids.add("urn:uuid:1cdbe4df-cb09-45b2-90bb-9730f4bf1193"); 168 169 pm.delete(new User(), ids); 170 */ 171 172 /* Test the getRegistryObject method */ 173 RegistryObjectType ro = pm.getRegistryObject("urn:uuid:921284f0-bbed-4a4c-9342-ecaf0625f9d7", "User"); 174 175 176 StringWriter sw = new StringWriter(); 177 try { 178 ro.marshal(sw); 179 } 180 catch (Exception e) { 181 e.printStackTrace(); 182 } 183 System.err.println("object = " + sw); 184 } 185 186 187 188 /*** 189 * @link 190 * @shapeType PatternLink 191 * @pattern Singleton 192 * @supplierRole Singleton factory 193 */ 194 /*# private PersistenceManagerImpl _persistenceManagerImpl; */ 195 private static PersistenceManagerImpl instance = null; 196 }

This page was automatically generated by Maven