1 19 package org.netbeans.mdr.storagemodel; 20 21 import org.netbeans.mdr.NBMDRepositoryImpl; 22 import org.netbeans.mdr.handlers.BaseObjectHandler; 23 import org.netbeans.mdr.persistence.*; 24 import org.netbeans.mdr.util.*; 25 import javax.jmi.model.ModelElement; 26 import javax.jmi.model.ModelPackage; 27 import javax.jmi.model.NameNotFoundException; 28 import javax.jmi.model.Namespace; 29 import javax.jmi.reflect.*; 30 import java.io.IOException ; 31 import java.lang.ref.ReferenceQueue ; 32 import java.lang.ref.WeakReference ; 33 import java.lang.ref.Reference ; 34 import java.lang.reflect.Constructor ; 35 import java.util.*; 36 37 51 52 public class MdrStorage implements MOFConstants, ObjectResolver { 53 54 55 56 57 58 private static final int STORAGE_VERSION = 26; 59 60 static final String IDX_OBJECTS_BY_CLASSES = "ObjectsByClasses"; 62 private static final String IDX_MDR_STORAGE_PROPERTIES = "Properties"; 63 private static final String IDX_CONTEXTS = "Contexts"; 64 65 private static final String PREFIX_ATTR_INDEX = "ai:"; 67 private static final String PREFIX_ATTR_INDEXES_BY_NAME = "aibn:"; 68 private static final String PREFIX_ATTR_INDEXES_CLASS_PROXY = "aicp:"; 69 private static final String PREFIX_ASSOC_END = "ae:"; 70 71 73 public static final String MOF_TOP_PACKAGE = "TOPMOST_PACKAGE"; 74 75 public static final String VALUES_ID = "VALUES_ID"; 76 77 78 private static final Hashtable instances = new Hashtable(); 79 80 private InstanceMap externalObjects = null; 81 82 85 86 87 88 89 93 public static MdrStorage getInstance(Storage storage) { 94 MdrStorage result = (MdrStorage) instances.get(storage); 95 return result; 97 } 98 99 public void registerExternal(StorableBaseObject storable) { 100 if (externalObjects == null) { 101 externalObjects = new InstanceMap(); 102 } 103 externalObjects.put(storable.getMofId(), storable); 104 } 105 106 public void removeExternal(StorableBaseObject storable) { 107 if (externalObjects != null) { 108 externalObjects.remove(storable.getMofId()); 109 } 110 } 111 112 private StorableBaseObject getExternal(MOFID mofId) { 113 StorableBaseObject result = null; 114 if (externalObjects != null) { 115 result = (StorableBaseObject) externalObjects.get(mofId); 116 } 117 return result; 118 } 119 120 121 122 123 124 125 128 private Storage bootStorage; 129 private org.netbeans.mdr.persistence.MOFID bootNullMofId; 130 131 134 private HashMap storages; 135 136 137 private HashMap nullMofId; 139 140 148 private HashMap objects; 149 150 153 private HashMap objByCls; 154 155 159 private HashMap contexts; 160 161 164 private HashMap properties; 165 166 171 175 private HashMap valuesObjects; 176 178 181 private final NBMDRepositoryImpl repository; 182 183 184 private final TransactionMutex repositoryMutex; 185 186 private final EventNotifier eventNotifier; 187 188 189 private org.netbeans.mdr.storagemodel.transientimpl.TransientStorage transientStorage; 190 191 192 193 196 private boolean booting; 197 198 private Collection bootClasses = null; 199 200 private Collection bootObjects = null; 201 202 private Collection bootAssociations = null; 203 204 private volatile boolean silent = false; 205 206 207 208 209 210 public TransactionMutex getRepositoryMutex() { 211 return repositoryMutex; 212 } 213 214 public EventNotifier getEventNotifier() { 215 return eventNotifier; 216 } 217 218 public NBMDRepositoryImpl getRepository() { 219 return repository; 220 } 221 222 226 public void setBooting(boolean flag) { 227 this.booting = flag; 228 } 229 230 public boolean isBooting() { 231 return this.booting; 232 } 233 234 public void enableEvents() { 235 silent = false; 236 } 237 238 public void disableEvents() { 239 silent = true; 240 } 241 242 public boolean eventsEnabled() { 243 return !silent; 244 } 245 246 247 248 249 250 261 public MdrStorage(NBMDRepositoryImpl repository, String storageClass, Map properties) { 262 this.storages = new HashMap(); 263 this.nullMofId = new HashMap(); 264 this.objects = new HashMap(); 265 this.objByCls = new HashMap(); 266 this.contexts = new HashMap(); 267 this.properties = new HashMap(); 268 this.valuesObjects = new HashMap(); 269 270 this.repository = repository; 271 StorageFactory storageFactory = null; 272 try { 273 Class storageFactoryClass = Class.forName(storageClass); 275 if (StorageFactory.class.isAssignableFrom(storageFactoryClass)) { 277 storageFactory = (StorageFactory) storageFactoryClass.newInstance(); 279 } else { 280 throw new Exception ("class "+storageClass+" does not implement StorageFactory"); 283 } 284 } catch (Exception e) { 285 Logger.getDefault().notify(Logger.INFORMATIONAL, e); 288 Logger.getDefault().log("using: org.netbeans.mdr.persistence.memoryimpl.StorageFactoryImpl"); 289 storageFactory = new org.netbeans.mdr.persistence.memoryimpl.StorageFactoryImpl(); 290 } 291 292 try { 293 this.bootStorage = storageFactory.createStorage(properties); 295 this.bootNullMofId = storageFactory.createNullMOFID(); 297 } catch (StorageException e) { 298 throw (DebugException) Logger.getDefault().annotate(new DebugException("Failed accessing storage factory."), e); 299 } 300 301 eventNotifier = new EventNotifier(); 303 304 String mutexClass = (String ) properties.get("mutexClass"); 305 TransactionMutex mutex = null; 306 307 if (mutexClass != null) { 308 try { 309 Constructor mutexConstructor = BaseObjectHandler.resolveImplementation(mutexClass).getConstructor(new Class [] {Object .class, Object .class, Object .class}); 310 mutex = (TransactionMutex) mutexConstructor.newInstance(new Object [] {this, eventNotifier, repository}); 311 } catch (Exception e) { 312 Logger.getDefault().notify(Logger.INFORMATIONAL, e); 313 } 314 } 315 316 if (mutex == null) { 317 mutex = new MultipleReadersMutex(this, eventNotifier, repository); 318 } 319 320 repositoryMutex = mutex; 321 } 322 323 324 325 326 327 342 public String mountStorage(String storageFactoryClass, Map properties) throws StorageException, InstantiationException , ClassNotFoundException , IllegalAccessException { 343 return this.mountStorage(Class.forName(storageFactoryClass), properties); 344 } 345 346 359 public String mountStorage(Class storageFactoryClass, Map properties) throws StorageException, InstantiationException , IllegalAccessException { 360 if (StorageFactory.class.isAssignableFrom(storageFactoryClass)) { 361 StorageFactory storageFactory = (StorageFactory) storageFactoryClass.newInstance(); 362 Storage st = storageFactory.createStorage(properties); 363 org.netbeans.mdr.persistence.MOFID nullMofId = storageFactory.createNullMOFID(); 364 this.init(st,nullMofId, false); 365 return st.getStorageId(); 366 } 367 return null; 368 } 369 370 377 public void unmountStorage(String storageId) throws StorageException { 378 Storage selStorage = (Storage) this.storages.get(storageId); 379 if (selStorage == null) 380 return; 381 selStorage.shutDown(); 382 this.instances.remove(selStorage); 383 this.nullMofId.remove(storageId); 384 this.objects.remove(storageId); 385 this.objByCls.remove(storageId); 386 this.contexts.remove(storageId); 387 this.storages.remove(storageId); 388 this.properties.remove(storageId); 389 this.valuesObjects.remove(storageId); 390 } 391 392 393 394 395 396 397 406 public boolean init() throws StorageException { 407 return this.init(this.bootStorage, this.bootNullMofId, true); 408 } 409 410 440 public boolean init(Storage storage, org.netbeans.mdr.persistence.MOFID nullMofId, boolean defaultStorage) throws StorageException { 441 boolean result; 446 String storageId = null; 447 try { 448 storage.open(false, this); 452 storageId = storage.getStorageId(); 455 initializeIndexes(storage, defaultStorage, false); 457 result = true; 459 } catch (Exception e) { 460 Logger.getDefault().log("Rebooting storage. Reason: " + e); 461 try { 463 storage.close(); 465 } catch (StorageException ex) { 466 } 467 468 storage.create(true, this); 470 storageId = storage.getStorageId(); 471 SinglevaluedIndex objectsIndex = storage.getPrimaryIndex(); 473 objects.put(storageId, objectsIndex); 474 contexts.put(storageId, storage.createSinglevaluedIndex(IDX_CONTEXTS + STORAGE_VERSION, Storage.EntryType.STRING, Storage.EntryType.MOFID)); 476 objByCls.put(storageId, storage.createMultivaluedIndex(IDX_OBJECTS_BY_CLASSES, Storage.EntryType.MOFID, Storage.EntryType.MOFID, false)); SinglevaluedIndex propertiesIndex = storage.createSinglevaluedIndex(IDX_MDR_STORAGE_PROPERTIES, Storage.EntryType.STRING, Storage.EntryType.MOFID); 478 propertiesIndex.put(MODEL_ASSOCIATION_END, nullMofId); 479 propertiesIndex.put(MODEL_ATTRIBUTE, nullMofId); 480 propertiesIndex.put(MODEL_REFERENCE, nullMofId); 481 propertiesIndex.put(MODEL_OPERATION, nullMofId); 482 MOFID valuesID = new MOFID (storage); 483 propertiesIndex.put(VALUES_ID, valuesID); 484 this.properties.put(storageId, propertiesIndex); 485 ValuesObject valuesObject = new ValuesObject(storage, valuesID); 486 this.valuesObjects.put(storageId, valuesObject); 487 objectsIndex.add(valuesID, valuesObject); 488 storage.objectStateChanged(valuesID); 489 result = ! defaultStorage; 491 } 492 instances.put(storage, this); 494 this.nullMofId.put(storageId, nullMofId); 495 this.storages.put(storageId, storage); 496 return result; 497 } 498 499 505 private void initializeIndexes(Storage storage, boolean defaultStorage, boolean rollBack) { 506 try { 507 String storageId = storage.getStorageId(); 509 SinglevaluedIndex objectsIndex = storage.getPrimaryIndex(); 510 MultivaluedIndex objByClsIndex = storage.getMultivaluedIndex(IDX_OBJECTS_BY_CLASSES); 511 SinglevaluedIndex contextsIndex = storage.getSinglevaluedIndex(IDX_CONTEXTS + STORAGE_VERSION); 512 if (objByClsIndex==null || objectsIndex==null || contextsIndex==null) { 513 throw new DebugException("Missing storage files or different storage version."); 514 } 515 if (!defaultStorage && !rollBack && !silent) { 516 for (Iterator it = contextsIndex.keySet().iterator(); it.hasNext();) { 518 String extentName = (String ) it.next(); 519 org.netbeans.api.mdr.events.ExtentEvent event = new org.netbeans.api.mdr.events.ExtentEvent(this.repository, 520 org.netbeans.api.mdr.events.ExtentEvent.EVENT_EXTENT_CREATE, extentName, 521 null, null,false); 522 this.getEventNotifier().REPOSITORY.firePlannedChange(this, event); 523 } 524 } 525 this.objects.put(storageId, objectsIndex); 526 this.contexts.put(storageId, contextsIndex); 527 this.objByCls.put(storageId, objByClsIndex); 528 SinglevaluedIndex props = storage.getSinglevaluedIndex(IDX_MDR_STORAGE_PROPERTIES); 529 if (props == null) { 530 throw new DebugException("Different storage version."); 531 } 532 this.properties.put(storageId, props); 533 this.valuesObjects.put(storageId, objectsIndex.get(props.get(VALUES_ID))); 534 } catch (StorageException e) { 535 throw new DebugException("Missing storage files or different storage version."); 536 } 537 } 538 539 540 541 542 543 546 public void commit() throws StorageException { 547 save(); 548 } 549 550 553 public synchronized void rollback() throws StorageException { 554 for (Iterator it = this.storages.values().iterator(); it.hasNext();) { 555 Storage storage = (Storage) it.next(); 556 storage.rollBackChanges(); 558 if (storage != transientStorage) 560 initializeIndexes(storage, storage == this.bootStorage, true); 561 } 562 } 563 564 567 public synchronized void save() throws StorageException { 568 573 for (Iterator it = this.storages.values().iterator(); it.hasNext();) { 574 Storage storage = (Storage) it.next(); 575 storage.commitChanges(); 577 } 578 } 579 580 584 public void shutDown() throws StorageException { 585 try { 586 for (Iterator it = this.storages.values().iterator(); it.hasNext();) { 587 Storage s = (Storage)it.next(); 588 s.shutDown(); 589 repository.notifyShutdownStep(); 590 } 591 } finally { 592 eventNotifier.shutdown(); 593 repository.notifyShutdownStep(); 594 } 595 } 596 597 public int getShutdownSteps() { 598 return storages.size() + 1; 599 } 600 601 602 603 604 605 609 org.netbeans.mdr.persistence.MOFID getProperty(String key) { 610 return this.getProperty(this.bootStorage.getStorageId(),key); 611 } 612 613 621 org.netbeans.mdr.persistence.MOFID getProperty(String storageId, String key) { 622 try { 623 SinglevaluedIndex propertiesIndex = this.getPropertiesIndexByStorageId(storageId); 624 if (propertiesIndex == null) 625 throw new DebugException("No such storage"); 626 return (org.netbeans.mdr.persistence.MOFID) propertiesIndex.get(key); 627 } catch (StorageException e) { 628 throw (DebugException) Logger.getDefault().annotate(new DebugException(), e); 629 } 630 } 631 632 636 void setProperty(String key, org.netbeans.mdr.persistence.MOFID value) { 637 this.setProperty(this.bootStorage.getStorageId(), key, value); 638 } 639 640 648 void setProperty(String storageId, String key, org.netbeans.mdr.persistence.MOFID value) { 649 try { 650 SinglevaluedIndex propertiesIndex = this.getPropertiesIndexByStorageId(storageId); 651 if (propertiesIndex == null) 652 throw new DebugException("No such storage"); 653 propertiesIndex.put(key, value); 654 } catch (StorageException e) { 655 throw (DebugException) Logger.getDefault().annotate(new DebugException(), e); 656 } 657 } 658 659 661 666 667 668 669 670 671 public ValuesObject values(org.netbeans.mdr.persistence.MOFID mofId) { 672 String storageId = getStorageIdFromMofId(mofId); 673 return this.storageValues(storageId); 674 } 675 676 public ValuesObject storageValues(String storageId) { 677 if (storageId == null) { 678 storageId = this.bootStorage.getStorageId(); 679 } 680 return (ValuesObject) valuesObjects.get(storageId); 681 } 682 683 684 685 686 687 693 public StorableBaseObject getObject(org.netbeans.mdr.persistence.MOFID mofid) throws StorageException { 694 if (mofid == null) 695 return null; 696 StorableBaseObject result = getExternal(mofid); 697 if (result == null) { 698 SinglevaluedIndex objectsIndex = getObjectsIndexByMofId(mofid); 699 if (objectsIndex == null) 700 return null; synchronized (getStorageById(mofid.getStorageID())) { 702 result = (StorableBaseObject) objectsIndex.getIfExists(mofid); 703 } 704 } 705 return result; 706 } 707 708 714 public StorableBaseObject getObjectFromIndexIfExists(SinglevaluedIndex index, Object key) throws StorageException { 715 Object mofId = index.getIfExists(key); 716 if (!(mofId instanceof org.netbeans.mdr.persistence.MOFID)) 717 return null; 718 else 719 return getObject((org.netbeans.mdr.persistence.MOFID) mofId); 720 } 721 722 728 public Collection getObjectsFromIndex(MultivaluedIndex index, Object key) throws StorageException { 729 SinglevaluedIndex objectsIndex = this.getObjectsIndexByMofId((org.netbeans.mdr.persistence.MOFID)key); 730 if (objectsIndex == null) 731 throw new DebugException("Invalid key"); 732 synchronized (getStorageById(((org.netbeans.mdr.persistence.MOFID) key).getStorageID())) { 733 if (index instanceof MultivaluedOrderedIndex) { 734 return ((MultivaluedOrderedIndex) index).getObjectsOrdered(key, objectsIndex); 735 } 736 else { 737 return index.getObjects(key, objectsIndex); 738 } 739 } 740 } 741 742 746 void addObject (StorableBaseObject object) throws StorageException { 747 org.netbeans.mdr.persistence.MOFID mofId = object.getMofId(); 748 SinglevaluedIndex objectsIndex = getObjectsIndexByMofId(mofId); 749 if (objectsIndex == null) { 750 throw new DebugException("Storage not found"); 751 } 752 objectsIndex.add(mofId, object); 753 } 754 755 759 void removeObject(StorableBaseObject object) throws StorageException { 760 org.netbeans.mdr.persistence.MOFID mofId = object.getMofId(); 761 this.removeObject (mofId); 762 } 763 764 765 void removeObject (org.netbeans.mdr.persistence.MOFID mofId) throws StorageException { 766 SinglevaluedIndex objectsIndex = (SinglevaluedIndex) this.getObjectsIndexByMofId(mofId); 767 if (objectsIndex == null) { 768 throw new DebugException("Storage not found"); 769 } 770 objectsIndex.remove(mofId); 771 } 772 773 778 void addInstance(StorableObject object) throws StorageException { 779 addObject(object); 780 org.netbeans.mdr.persistence.MOFID mofId = object.getMofId(); 781 String storageId = getStorageIdFromMofId(mofId); 782 if (storageId == null) { 783 throw new DebugException("Invalid MOF ID"); 784 } 785 MultivaluedIndex objByClsIndex = (MultivaluedIndex) objByCls.get(storageId); 786 if (objByClsIndex == null) { 787 throw new DebugException("Storage not found"); 788 } 789 objByClsIndex.add(object.getClassProxyId(), mofId); 790 } 791 792 797 void removeInstance(StorableObject object) throws StorageException { 798 org.netbeans.mdr.persistence.MOFID mofId = object.getMofId(); 799 org.netbeans.mdr.persistence.MOFID classProxyMofId = object.getClassProxyId(); 800 this.removeInstance (mofId, classProxyMofId); 801 } 802 803 void removeInstance (org.netbeans.mdr.persistence.MOFID mofId, org.netbeans.mdr.persistence.MOFID classProxyMofId) throws StorageException { 804 removeObject(mofId); 805 MultivaluedIndex objByClsIndex = this.getObjectsByClassesByMofId (mofId); 806 if (objByClsIndex == null) { 807 throw new DebugException("Storage not found"); 808 } 809 objByClsIndex.remove( classProxyMofId, mofId); 810 } 811 812 818 public MultivaluedIndex getInstancesIndex(StorableClass classProxy) { 819 return this.getInstancesIndex(classProxy.getMofId()); 820 } 821 822 828 public MultivaluedIndex getInstancesIndex(org.netbeans.mdr.persistence.MOFID classProxyId) { 829 String storageId = getStorageIdFromMofId(classProxyId); 830 if (storageId == null) { 831 throw new DebugException("Invalid MOF ID"); 832 } 833 MultivaluedIndex objByClsIndex = (MultivaluedIndex) objByCls.get(storageId); 834 if (objByClsIndex == null) { 835 throw new DebugException("Storage not found"); 836 } 837 return objByClsIndex; 838 } 839 840 845 public Collection getInstancesIds(org.netbeans.mdr.persistence.MOFID classProxyId) throws StorageException { 846 String storageId = getStorageIdFromMofId(classProxyId); 847 if (storageId == null) { 848 throw new DebugException("Invalid MOF ID"); 849 } 850 MultivaluedIndex objByClsIndex = (MultivaluedIndex) objByCls.get(storageId); 851 if (objByClsIndex == null) { 852 throw new DebugException("Storage not found"); 853 } 854 return objByClsIndex.getItems(classProxyId); 855 } 856 857 859 865 void createContext(String name, org.netbeans.mdr.persistence.MOFID mofId) throws StorageException { 866 867 String storageId = getStorageIdFromMofId(mofId); 868 if (storageId == null) { 869 throw new DebugException("Invalid MOF ID"); 870 } 871 Storage storage = (Storage) this.storages.get(storageId); 872 if (storage == null) { 873 throw new DebugException("Storage not found"); 874 } 875 storage.createSinglevaluedIndex(PREFIX_ATTR_INDEXES_BY_NAME + mofId.getSerialNumber(), Storage.EntryType.STRING, Storage.EntryType.STRING); 877 storage.createSinglevaluedIndex(PREFIX_ATTR_INDEXES_CLASS_PROXY + mofId.getSerialNumber(), Storage.EntryType.STRING, Storage.EntryType.MOFID); 878 879 if (name != null) { 881 SinglevaluedIndex contextsIndex = (SinglevaluedIndex) this.contexts.get(storageId); 882 if (contextsIndex == null) { 883 throw new DebugException("Storage not found"); 884 } 885 contextsIndex.put(name, mofId); 886 } 887 } 888 889 894 void dropContext(String name, org.netbeans.mdr.persistence.MOFID mofId) throws StorageException { 895 String storageId = getStorageIdFromMofId(mofId); 897 if (storageId == null) { 898 throw new DebugException("Invalid MOF ID"); 899 } 900 Storage storage = (Storage) this.storages.get(storageId); 901 if (storage == null) { 902 throw new DebugException("Storage not found"); 903 } 904 for (Iterator it = storage.getSinglevaluedIndex(PREFIX_ATTR_INDEXES_BY_NAME + mofId.getSerialNumber()).values().iterator(); it.hasNext();) { 905 storage.dropIndex(getAdditionalIndexName(mofId, (String ) it.next())); 906 } 907 908 storage.dropIndex(PREFIX_ATTR_INDEXES_BY_NAME + mofId.getSerialNumber()); 910 storage.dropIndex(PREFIX_ATTR_INDEXES_CLASS_PROXY + mofId.getSerialNumber()); 911 912 if (name != null) { 914 SinglevaluedIndex contextsIndex = (SinglevaluedIndex) this.contexts.get(storageId); 915 if (contextsIndex == null) { 916 throw new DebugException("Storage not found"); 917 } 918 contextsIndex.remove(name); 919 } 920 } 921 922 927 public Collection getContexts() throws StorageException { 928 HashSet result = new HashSet(); 929 for (Iterator it = contexts.values().iterator(); it.hasNext();) { 930 SinglevaluedIndex sv = (SinglevaluedIndex) it.next(); 931 result.addAll(sv.keySet()); 932 } 933 return result; 934 } 935 936 943 public Collection getContexts(String storageId) throws StorageException { 944 SinglevaluedIndex context = (SinglevaluedIndex) this.contexts.get(storageId); 945 if (context == null) 946 throw new IllegalArgumentException (); 947 HashSet result = new HashSet(); 948 result.addAll(context.keySet()); 949 return result; 950 } 951 952 public boolean renameContext(MOFID mofId, String newName) throws StorageException { 953 SinglevaluedIndex context = (SinglevaluedIndex) this.contexts.get(mofId.getStorageID()); 954 if (context == null) throw new IllegalArgumentException (); 955 for (Iterator it = context.keySet().iterator(); it.hasNext();) { 956 String oldName = (String ) it.next(); 957 if (context.get(oldName).equals(mofId)) { 958 context.remove(oldName); 959 context.add(newName, mofId); 960 return true; 961 } 962 } 963 return false; 964 } 965 966 973 public StorablePackage getContextOutermostPackage(String context) throws StorageException { 974 Object id = null; 975 for (Iterator it = this.contexts.values().iterator(); it.hasNext();) { 976 SinglevaluedIndex contextsIndex = (SinglevaluedIndex) it.next(); 977 id = contextsIndex.getIfExists(context); 978 if (id != null) { 979 return (StorablePackage) getObject((org.netbeans.mdr.persistence.MOFID) id); 980 } 981 } 982 return null; 983 } 984 985 987 995 public void createAdditionalIndex(org.netbeans.mdr.persistence.MOFID context, String indexName, org.netbeans.mdr.persistence.MOFID proxyId) throws StorageException { 996 Storage storage = getStorageByMofId(context); 997 if (storage == null) { 998 throw new DebugException("Storage not found"); 999 } 1000 storage.getSinglevaluedIndex(PREFIX_ATTR_INDEXES_BY_NAME + context.getSerialNumber()).put(indexName, indexName); 1002 storage.getSinglevaluedIndex(PREFIX_ATTR_INDEXES_CLASS_PROXY + context.getSerialNumber()).put(indexName, proxyId); 1003 storage.createMultivaluedIndex(getAdditionalIndexName(context, indexName), Storage.EntryType.STRING, Storage.EntryType.MOFID, false); 1004 } 1005 1006 1013 private MultivaluedIndex getAdditionalIndex(org.netbeans.mdr.persistence.MOFID context, String indexName) { 1014 try { 1015 Storage storage = getStorageByMofId(context); 1016 if (storage == null) { 1017 throw new DebugException("Storage not found"); 1018 } 1019 return storage.getMultivaluedIndex(getAdditionalIndexName(context, indexName)); 1020 } catch (StorageException e) { 1021 return null; 1022 } 1023 } 1024 1025 private StorableClass getIndexClassProxy (org.netbeans.mdr.persistence.MOFID context, String indexName) { 1026 try { 1027 Storage storage = getStorageByMofId(context); 1028 if (storage == null) { 1029 throw new DebugException("Storage not found"); 1030 } 1031 return (StorableClass) getObject((org.netbeans.mdr.persistence.MOFID)storage.getSinglevaluedIndex(PREFIX_ATTR_INDEXES_CLASS_PROXY + context.getSerialNumber()).get(indexName)); 1032 } catch (StorageException e) { 1033 return null; 1034 } 1035 } 1036 1037 1042 MultivaluedIndex acquireAdditionalIndex(org.netbeans.mdr.persistence.MOFID context, String indexName) { 1043 MultivaluedIndex result = getAdditionalIndex(context, indexName); 1044 return result; 1045 } 1046 1047 1050 void releaseAdditionalIndex() { 1051 } 1052 1053 1056 public Collection objectsFromAdditionalIndex(org.netbeans.mdr.persistence.MOFID context, String indexName, String value) { 1057 try { 1058 SinglevaluedIndex objectsIndex = getObjectsIndexByMofId (context); 1059 return getAdditionalIndex (context, resolveAttrMofId(context, indexName)).getObjects (value, objectsIndex); 1060 } catch (StorageException e) { 1061 return null; 1062 } 1063 } 1064 1065 1071 public Collection getItemsFromAdditionalIndex(org.netbeans.mdr.persistence.MOFID context, String indexName, Object value) { 1072 try { 1073 StorableClass sc = getIndexClassProxy (context, indexName); 1074 if (sc == null) { 1075 throw new DebugException ("Index " + indexName + " does not exist in the specified context."); 1076 } 1077 StorableClass.IndexDescriptor desc = sc.getAdditionalIndex (indexName); 1078 String valueToString = StorableObject.valueToKey (value, desc.getFields()); 1079 return getAdditionalIndex(context, resolveAttrMofId(context, indexName)).getItems(valueToString); 1080 } catch (StorageException e) { 1081 return null; 1082 } 1083 } 1084 1085 1091 public Collection getObjectsFromAdditionalIndex(org.netbeans.mdr.persistence.MOFID context, String indexName, Object value) { 1092 try { 1093 StorableClass sc = getIndexClassProxy (context, indexName); 1094 if (sc == null) { 1095 throw new DebugException ("Index " + indexName + " does not exist in the specified context."); 1096 } 1097 StorableClass.IndexDescriptor desc = sc.getAdditionalIndex (indexName); 1098 String valueToString = StorableObject.valueToKey (value, desc.getFields()); 1099 SinglevaluedIndex objectsIndex = getObjectsIndexByMofId (context); 1100 return getAdditionalIndex (context, resolveAttrMofId(context, indexName)).getObjects (valueToString, objectsIndex); 1101 } catch (StorageException e) { 1102 return null; 1103 } 1104 } 1105 1106 1112 public Collection getObjectsFromAIByPrefix(org.netbeans.mdr.persistence.MOFID context, String indexName, String prefix) { 1113 try { 1114 StorableClass sc = getIndexClassProxy (context, indexName); 1115 if (sc == null) { 1116 throw new DebugException ("Index " + indexName + " does not exist in the specified context."); 1117 } 1118 StorableClass.IndexDescriptor desc = sc.getAdditionalIndex (indexName); 1119 SinglevaluedIndex objectsIndex = getObjectsIndexByMofId (context); 1120 return getAdditionalIndex (context, resolveAttrMofId(context, indexName)).queryByKeyPrefix(prefix, objectsIndex); 1121 } catch (StorageException e) { 1122 return null; 1123 } 1124 } 1125 1126 1132 public Collection queryAdditionalIndex(org.netbeans.mdr.persistence.MOFID context, String indexName, Map map) { 1133 try { 1134 StorableClass sc = getIndexClassProxy (context, indexName); 1135 if (sc == null) { 1136 throw new DebugException ("Index " + indexName + " does not exist in the specified context."); 1137 } 1138 StorableClass.IndexDescriptor desc = sc.getAdditionalIndex (indexName); 1139 String valueToString = StorableObject.valuesToKey (map, desc.getFields()); 1140 SinglevaluedIndex objectsIndex = getObjectsIndexByMofId (context); 1141 return getAdditionalIndex (context, resolveAttrMofId(context, indexName)).getObjects (valueToString, objectsIndex); 1142 } catch (StorageException e) { 1143 return null; 1144 } 1145 } 1146 1147 1153 private String resolveAttrMofId(org.netbeans.mdr.persistence.MOFID context, String indexName) throws StorageException { 1154 Storage storage = this.getStorageByMofId(context); 1155 return (String ) storage.getSinglevaluedIndex(PREFIX_ATTR_INDEXES_BY_NAME + context.getSerialNumber()).get(indexName); 1156 } 1157 1158 1163 private String getAdditionalIndexName(org.netbeans.mdr.persistence.MOFID context, String indexName) { 1164 return PREFIX_ATTR_INDEX + context.getSerialNumber() + ":" + indexName; 1165 } 1166 1167 1169 1171 1174 void addBootObject(org.netbeans.mdr.persistence.MOFID mofId) { 1175 if (bootObjects == null) { 1176 bootObjects = new ArrayList(); 1177 } 1178 bootObjects.add(mofId); 1179 } 1180 1181 1184 void addBootClass(org.netbeans.mdr.persistence.MOFID mofId) { 1185 addBootObject(mofId); 1186 if (bootClasses == null) { 1187 bootClasses = new ArrayList(); 1188 } 1189 bootClasses.add(mofId); 1190 } 1191 1192 1195 void addBootAssociation(org.netbeans.mdr.persistence.MOFID mofId) { 1196 addBootObject(mofId); 1197 if (bootAssociations == null) { 1198 bootAssociations = new ArrayList(); 1199 } 1200 bootAssociations.add(mofId); 1201 } 1202 1203 1206 void dropBoot() throws StorageException { 1207 String name = NBMDRepositoryImpl.BOOT_MOF; 1208 org.netbeans.mdr.persistence.MOFID extent = getContextOutermostPackage(name).getMofId(); 1209 org.netbeans.mdr.persistence.MOFID mofId; 1210 1211 String storageId = getStorageIdFromMofId(extent); 1212 MultivaluedIndex objByClsIndex = (MultivaluedIndex) this.objByCls.get(storageId); 1213 SinglevaluedIndex objectsIndex = (SinglevaluedIndex) this.objects.get(storageId); 1214 SinglevaluedIndex contextsIndex = (SinglevaluedIndex) this.contexts.get(storageId); 1215 Storage storage = (Storage) this.storages.get(storageId); 1216 if (objByClsIndex == null || objectsIndex == null || contextsIndex == null || storage == null) 1217 throw new DebugException("Illegal MdrStorage state"); 1218 1219 for (Iterator it = bootClasses.iterator(); it.hasNext();) { 1220 objByClsIndex.remove((org.netbeans.mdr.persistence.MOFID) it.next()); 1221 } 1222 1223 for (Iterator it = bootObjects.iterator(); it.hasNext();) { 1224 objectsIndex.remove(it.next ()); 1225 } 1226 1227 for (Iterator it = bootAssociations.iterator(); it.hasNext();) { 1228 mofId = (org.netbeans.mdr.persistence.MOFID) it.next(); 1229 storage.dropIndex(getContextAssocEndIndexName(extent, mofId, 1)); 1230 storage.dropIndex(getContextAssocEndIndexName(extent, mofId, 2)); 1231 } 1232 1233 storage.dropIndex(PREFIX_ATTR_INDEXES_BY_NAME + extent.getSerialNumber()); 1234 storage.dropIndex(PREFIX_ATTR_INDEXES_CLASS_PROXY + extent.getSerialNumber()); 1235 contextsIndex.remove(name); 1236 1237 bootObjects = null; 1238 bootClasses = null; 1239 1240 getRepository().freeCache(); 1241 } 1242 1243 1248 void replaceMeta(Hashtable table, RefBaseObject object) throws StorageException { 1249 StorableBaseObject sObject = this.getObject(((BaseObjectHandler)object)._getDelegate().getMofId()); 1250 sObject.replaceValues(table); 1251 } 1252 1253 1257 private RefObject qnToObject(RefPackage pkg, List qualifiedName) { 1258 ModelPackage mofPackage = (ModelPackage) pkg; 1259 RefClass pc = mofPackage.getMofPackage(); 1260 Iterator it = qualifiedName.iterator(); 1261 ModelElement object = getPackageElement(pc, (String )it.next() ); 1262 try { 1263 while (it.hasNext()) { 1264 object = ((Namespace) object).lookupElement((String ) it.next()); 1265 } 1266 } catch (NameNotFoundException e) { 1267 object = null; 1268 } 1269 return object; 1270 } 1271 1272 1276 private ModelElement getPackageElement(RefClass pc, String name) { 1277 ModelElement object = null; 1278 ModelElement result = null; 1279 Iterator it = pc.refAllOfClass().iterator(); 1280 result = (ModelElement) it.next(); 1281 for (;it.hasNext();){ 1282 object = (ModelElement)it.next(); 1283 if (name.equals( object.getName() ) ) { 1284 result = object; 1285 break; 1286 } 1287 } 1288 return result; 1289 } 1290 1291 1294 private List objectToQN(RefObject object) { 1295 return ((ModelElement) object).getQualifiedName(); 1296 } 1297 1298 public void rebuildMofContext() { 1299 try { 1300 RefPackage bootMOF = (RefPackage) getRepository().getHandler(getContextOutermostPackage(NBMDRepositoryImpl.BOOT_MOF)); 1301 RefPackage pureMOF = (RefPackage) getRepository().getHandler(getContextOutermostPackage(NBMDRepositoryImpl.PURE_MOF)); 1302 RefClass classProxy; 1303 RefObject pureObject; 1304 RefObject bootObject; 1305 Hashtable fromTo = new Hashtable(); 1306 1307 fromTo.put(((BaseObjectHandler)bootMOF)._getDelegate().getMofId(), ((BaseObjectHandler)pureMOF)._getDelegate().getMofId()); 1308 1309 for (Iterator classes = pureMOF.refAllClasses().iterator(); classes.hasNext();) { 1311 classProxy = (RefClass) classes.next(); 1312 for (Iterator instances = classProxy.refAllOfClass().iterator(); instances.hasNext();) { 1313 pureObject = (RefObject) instances.next(); 1314 bootObject = qnToObject(bootMOF, objectToQN(pureObject)); 1315 if (bootObject != null) { 1316 fromTo.put(((BaseObjectHandler)bootObject)._getDelegate().getMofId(), ((BaseObjectHandler)pureObject)._getDelegate().getMofId()); 1317 } 1318 } 1319 } 1320 replaceMeta(fromTo, pureMOF); 1322 1323 for (Iterator classes = pureMOF.refAllClasses().iterator(); classes.hasNext();) { 1325 classProxy = (RefClass) classes.next(); 1326 replaceMeta(fromTo, classProxy); 1327 for (Iterator instances = classProxy.refAllOfClass().iterator(); instances.hasNext();) { 1329 pureObject = (RefObject) instances.next(); 1330 replaceMeta(fromTo, pureObject); 1331 } 1332 } 1333 1334 for (Iterator associations = pureMOF.refAllAssociations().iterator(); associations.hasNext();) { 1335 replaceMeta(fromTo, (RefAssociation) associations.next()); 1336 } 1337 1338 rebuildMetas(NBMDRepositoryImpl.PURE_MOF, fromTo); 1339 dropBoot(); 1340 } catch (Exception e) { 1341 throw (DebugException) Logger.getDefault().annotate(new DebugException(), e); 1342 } 1343 } 1344 1345 1349 void rebuildMetas(String mofContext, Map table) throws StorageException { 1350 1376 1377 Object key; 1378 org.netbeans.mdr.persistence.MOFID newValue; 1379 org.netbeans.mdr.persistence.MOFID value; 1380 1381 for (Iterator it = new HashSet(((SinglevaluedIndex)properties.get(this.bootStorage.getStorageId())).keySet()).iterator(); it.hasNext();) { 1382 key = it.next(); 1383 value = getProperty((String ) key); 1384 if (this.bootNullMofId.equals(value)) { 1385 newValue = (org.netbeans.mdr.persistence.MOFID) table.get(key); 1386 } 1387 else { 1388 newValue = (org.netbeans.mdr.persistence.MOFID) table.get(value); 1389 } 1390 if (newValue != null) { 1391 setProperty((String ) key, newValue); 1392 } 1393 } 1394 } 1395 1396 1480 1482 1483 1484 1485 1486 public MOFID generateMOFID (MOFID immediatePackageId) throws StorageException { 1487 if (immediatePackageId == null) { 1488 return this.generateMOFID(this.bootStorage); 1489 } 1490 else { 1491 return this.generateMOFID(getStorageByMofId(immediatePackageId)); 1492 } 1493 } 1494 1495 public MOFID generateMOFID (String storageId) throws StorageException { 1496 Storage st = (Storage) this.storages.get(storageId); 1497 if (st == null && org.netbeans.mdr.storagemodel.transientimpl.TransientStorage.STORAGE_ID.equals(storageId)) { 1498 st = this.getTransientStorage (); 1499 } 1500 return this.generateMOFID (st); 1501 } 1502 1503 private org.netbeans.mdr.persistence.MOFID generateMOFID(Storage storage) throws StorageException { 1504 if (storage == null) { 1505 throw new IllegalArgumentException ("Wrong storage id"); } 1507 return new org.netbeans.mdr.persistence.MOFID (storage); 1508 } 1509 1510 public void objectStateWillChange(org.netbeans.mdr.persistence.MOFID mofId) throws StorageException { 1511 Storage storage = this.getStorageByMofId(mofId); 1512 if (storage == null) { 1513 throw new DebugException("Storage not found"); 1514 } 1515 storage.objectStateWillChange(mofId); 1516 } 1517 1518 public void objectStateChanged(org.netbeans.mdr.persistence.MOFID mofId) throws StorageException { 1519 Storage storage = this.getStorageByMofId(mofId); 1520 if (storage == null) { 1521 throw new DebugException("Storage not found"); 1522 } 1523 storage.objectStateChanged(mofId); 1524 } 1525 1526 1527 public Index getIndex(org.netbeans.mdr.persistence.MOFID context, org.netbeans.mdr.persistence.MOFID assocMofId, int end ) throws StorageException { 1528 Storage storage = getStorageByMofId(context); 1529 if (storage == null) { 1530 throw new DebugException("Storage not found"); 1531 } 1532 String indexName = getContextAssocEndIndexName(context, assocMofId, end); 1533 return storage.getIndex(indexName); 1534 } 1535 1536 1542 SinglevaluedIndex createSinglevaluedIndex(org.netbeans.mdr.persistence.MOFID context, org.netbeans.mdr.persistence.MOFID assocMofId, int end, Storage.EntryType keyType, Storage.EntryType valueType) throws StorageException { 1543 Storage storage = getStorageByMofId(context); 1544 if (storage == null) { 1545 throw new DebugException("Storage not found"); 1546 } 1547 String indexName = getContextAssocEndIndexName(context, assocMofId, end); 1548 return storage.createSinglevaluedIndex(indexName, keyType, valueType); 1549 } 1550 1551 1558 MultivaluedOrderedIndex createMultivaluedOrderedIndex(org.netbeans.mdr.persistence.MOFID context, org.netbeans.mdr.persistence.MOFID assoccMofId, int end, Storage.EntryType keyType, Storage.EntryType valueType, boolean unique) throws StorageException { 1559 Storage storage = getStorageByMofId(context); 1560 if (storage == null) { 1561 throw new DebugException("Storage not found"); 1562 } 1563 String indexName = getContextAssocEndIndexName(context, assoccMofId, end); 1564 return storage.createMultivaluedOrderedIndex(indexName, keyType, valueType, unique); 1565 } 1566 1567 1575 MultivaluedIndex createMultivaluedIndex(org.netbeans.mdr.persistence.MOFID context, org.netbeans.mdr.persistence.MOFID assoccMofId, int end, Storage.EntryType keyType, Storage.EntryType valueType, boolean unique) throws StorageException { 1576 Storage storage = getStorageByMofId(context); 1577 if (storage == null) { 1578 throw new DebugException("Storage not found"); 1579 } 1580 String indexName = getContextAssocEndIndexName(context, assoccMofId, end); 1581 return storage.createMultivaluedIndex(indexName, keyType, valueType, unique); 1582 } 1583 1584 void dropIndex(org.netbeans.mdr.persistence.MOFID context, org.netbeans.mdr.persistence.MOFID assoccMofId, int end) throws StorageException { 1585 Storage storage = getStorageByMofId (context); 1586 if (storage == null) { 1587 throw new DebugException("Storage not found"); 1588 } 1589 String indexName = getContextAssocEndIndexName(context, assoccMofId, end); 1590 storage.dropIndex(indexName); 1591 } 1592 1593 1594 1595 1596 1597 1603 private String getContextAssocEndIndexName (org.netbeans.mdr.persistence.MOFID context, org.netbeans.mdr.persistence.MOFID assocMofId, int end) { 1604 return PREFIX_ASSOC_END + context.getSerialNumber() + ":" + assocMofId.getSerialNumber() + ":" + end; 1605 } 1606 1607 public Storage getStorageByMofId (org.netbeans.mdr.persistence.MOFID mofId) { 1608 String storageId = getStorageIdFromMofId (mofId); 1609 return getStorageById(storageId); 1610 } 1611 1612 public Storage getStorageById(String storageId) { 1613 if (storageId == null) { 1614 return null; 1615 } 1616 Storage result = (Storage) this.storages.get(storageId); 1617 return result; 1619 } 1620 1621 private SinglevaluedIndex getObjectsIndexByMofId (org.netbeans.mdr.persistence.MOFID mofId) { 1622 String storageId = getStorageIdFromMofId(mofId); 1623 if (storageId == null) { 1624 return null; 1625 } 1626 SinglevaluedIndex result = (SinglevaluedIndex) this.objects.get(storageId); 1627 return result; 1636 } 1637 1638 private MultivaluedIndex getObjectsByClassesByMofId (org.netbeans.mdr.persistence.MOFID mofId) { 1639 String storageId = getStorageIdFromMofId (mofId); 1640 if (storageId == null) { 1641 return null; 1642 } 1643 return (MultivaluedIndex) this.objByCls.get (storageId); 1644 } 1645 1646 private SinglevaluedIndex getPropertiesIndexByStorageId (String storageId) { 1647 return (SinglevaluedIndex) this.properties.get(storageId); 1648 } 1649 1650 public static String getStorageIdFromMofId(org.netbeans.mdr.persistence.MOFID mofId) { 1651 return mofId.getStorageID (); 1652 } 1653 1654 1655 1656 1657 1658 1663 public Object resolve(String storageID, Object key) throws StorageException { 1664 SinglevaluedIndex objectsIndex = (SinglevaluedIndex) this.objects.get(storageID); 1665 if (objectsIndex == null) 1666 return null; 1667 synchronized (getStorageById(storageID)) { 1668 return objectsIndex.get(key); 1669 } 1670 } 1671 1672 public synchronized Storage getTransientStorage () throws StorageException { 1673 if (this.transientStorage == null) { 1674 this.transientStorage = new org.netbeans.mdr.storagemodel.transientimpl.TransientStorage ("TransientStorage"); 1675 this.transientStorage.create(false, this); 1676 this.objects.put (org.netbeans.mdr.storagemodel.transientimpl.TransientStorage.STORAGE_ID, transientStorage.getPrimaryIndex ()); 1677 this.objByCls.put (org.netbeans.mdr.storagemodel.transientimpl.TransientStorage.STORAGE_ID, transientStorage.createMultivaluedIndex (IDX_OBJECTS_BY_CLASSES, Storage.EntryType.MOFID, Storage.EntryType.MOFID, false)); 1678 this.transientStorage.commitChanges (); this.storages.put (org.netbeans.mdr.storagemodel.transientimpl.TransientStorage.STORAGE_ID, transientStorage); 1680 } 1681 return this.transientStorage; 1682 } 1683 1684 public static boolean isTransientMofId(org.netbeans.mdr.persistence.MOFID mofId) { 1685 String storageID = getStorageIdFromMofId(mofId); 1686 return org.netbeans.mdr.storagemodel.transientimpl.TransientStorage.STORAGE_ID.equals(storageID); 1687 } 1688 1689 1690 1691 1692 1693 1696 public static class ValuesObject implements Streamable, StorageClient { 1697 private Storage storage; 1698 private org.netbeans.mdr.persistence.MOFID id; 1699 1700 1701 private List list = new ArrayList(); 1702 1703 1705 private final transient Map map = new HashMap(); 1706 1707 1710 public ValuesObject() { 1711 } 1712 1713 1719 private ValuesObject(Storage storage, org.netbeans.mdr.persistence.MOFID id) { 1720 this.storage = storage; 1721 this.id = id; 1722 } 1723 1724 1725 1729 public void setStorage(Storage storage) { 1730 this.storage = storage; 1731 } 1732 1733 1743 public int store(Object value) { 1744 if (value == null) return 0; 1745 try { 1746 storage.objectStateWillChange(id); 1747 Object index = new Integer (map.size()); 1748 Object old = map.put(value, index); 1749 if (old != null) { 1750 map.put(value, old); 1751 index = old; 1752 } else { 1753 list.add(value); 1754 storage.objectStateChanged(id); 1755 } 1756 return ((Integer ) index).intValue() + 1; 1757 } catch (StorageException e) { 1758 throw (DebugException) Logger.getDefault().annotate(new DebugException(), e); 1759 } 1760 } 1761 1762 1772 public Object resolve(int index) { 1773 if (index == 0) return null; 1774 return list.get(index - 1); 1775 } 1776 1777 1787 public int indexOf(Object value) { 1788 if (value == null) return 0; 1789 Integer result = (Integer ) map.get(value); 1790 if (result == null) { 1791 throw new DebugException("Value not found: " + value); 1792 } 1793 return result.intValue() + 1; 1794 } 1795 1796 1801 public void read(java.io.InputStream inputStream) throws StorageException { 1802 try { 1803 id = IOUtils.readMOFID (inputStream, this.storage); 1804 list = (List) IOUtils.read(inputStream); 1805 for (int i = 0; i < list.size(); i++) { 1806 map.put(list.get(i), new Integer (i)); 1807 } 1808 } catch (IOException e) { 1809 throw (DebugException) Logger.getDefault().annotate(new DebugException(), e); 1810 } 1811 } 1812 1813 1820 public void write(java.io.OutputStream outputStream) throws StorageException { 1821 try { 1822 IOUtils.writeMOFID (outputStream, id, this.storage); 1823 IOUtils.write(outputStream, list); 1824 } catch (IOException e) { 1825 throw (DebugException) Logger.getDefault().annotate(new DebugException(), e); 1826 } 1827 } 1828 } 1829 1830 private class InstanceMap extends HashMap { 1831 private final ReferenceQueue queue = new ReferenceQueue (); 1832 1833 private class InstanceReference extends WeakReference { 1834 private Object key; 1835 1836 public InstanceReference(Object key, Object instance) { 1837 super(instance, queue); 1838 this.key = key; 1839 } 1840 1841 public Object getKey() { 1842 return key; 1843 } 1844 } 1845 1846 private void cleanUp() { 1847 InstanceMap.InstanceReference reference; 1848 1849 while ((reference = (InstanceMap.InstanceReference) queue.poll()) != null) { 1850 Object key = reference.getKey(); 1852 Reference currentRef = (Reference ) super.remove(key); 1853 if (currentRef != null && currentRef != reference && currentRef.get() != null) { 1854 super.put(key, currentRef); 1855 } 1856 } 1857 } 1858 1859 public Object put(Object key, Object value) { 1860 cleanUp(); 1861 Object result = super.put(key, new InstanceMap.InstanceReference(key, value)); 1862 if (result != null) { 1863 return ((InstanceMap.InstanceReference) result).get(); 1864 } else { 1865 return result; 1866 } 1867 } 1868 1869 public Object get(Object key) { 1870 cleanUp(); 1871 Object result = super.get(key); 1872 if (result != null) { 1873 return ((InstanceMap.InstanceReference) result).get(); 1874 } else { 1875 return result; 1876 } 1877 } 1878 1879 public Collection values() { 1880 ArrayList result = new ArrayList(); 1881 cleanUp(); 1882 for (Iterator it = super.values().iterator(); it.hasNext();) { 1883 result.add(((InstanceMap.InstanceReference) it.next()).get()); 1884 } 1885 return result; 1886 } 1887 } 1888} 1889 | Popular Tags |