List of usage examples for org.apache.commons.collections.collection CompositeCollection addComposited
public void addComposited(Collection c)
From source file:com.btoddb.fastpersitentqueue.Fpq.java
/** * * @param batchSize//from ww w. j ava2 s. c om * @return */ public Collection<FpqEntry> pop(int batchSize) { checkInitializing(); checkShutdown(); // - move (up to) context.maxBatchSize events from globalMemoryQueue to context.queue // - do not wait for events // - return context.queue // assumptions // - can call 'pop' with same context over and over until context.queue has size context.maxBatchSize FpqContext context = contextThrowException(); if (batchSize > maxTransactionSize) { throw new FpqException( "size of " + batchSize + " exceeds maximum transaction size of " + maxTransactionSize); } CompositeCollection returnColl = new CompositeCollection(); Collection<FpqEntry> tmp; int numPopped = 0; do { tmp = memoryMgr.pop(batchSize); if (null != tmp) { numPopped += tmp.size(); // at this point, if system crashes, the entries are in the journal files // TODO:BTB - however this is not true if system has been previously shutdown and not all of the // entries have been pop'ed. on shutdown the journal files are drained into memory segments, // which are then serialized to disk (this is done to avoid dupes) context.addPoppedEntries(tmp); returnColl.addComposited(tmp); } } while (null != tmp && tmp.size() > 0 && numPopped < batchSize); return returnColl; }
From source file:org.apache.cayenne.map.MappingCache.java
public Collection<DbEntity> getDbEntities() { // TODO: LEGACY SUPPORT: // some downstream code (like Modeler and merge framework) expect // always fresh list here, so instead of doing the right thing of // refreshing the cache and returning cache.entries(), we are scanning // the list of DataMaps. if (maps.size() == 0) { return Collections.emptyList(); }//w w w.j a va 2 s . co m if (maps.size() == 1) { return maps.iterator().next().getDbEntities(); } CompositeCollection c = new CompositeCollection(); for (DataMap map : maps) { c.addComposited(map.getDbEntities()); } return c; }
From source file:org.apache.cayenne.map.MappingCache.java
public Collection<Procedure> getProcedures() { // TODO: LEGACY SUPPORT: // some downstream code (like Modeler and merge framework) expect // always fresh list here, so instead of doing the right thing of // refreshing the cache and returning cache.entries(), we are scanning // the list of DataMaps. if (maps.size() == 0) { return Collections.emptyList(); }/* ww w . j a va2 s .com*/ if (maps.size() == 1) { return maps.iterator().next().getProcedures(); } CompositeCollection c = new CompositeCollection(); for (DataMap map : maps) { c.addComposited(map.getProcedures()); } return c; }
From source file:org.apache.cayenne.map.MappingCache.java
public Collection<QueryDescriptor> getQueryDescriptors() { // TODO: LEGACY SUPPORT: // some downstream code (like Modeler and merge framework) expect // always fresh list here, so instead of doing the right thing of // refreshing the cache and returning cache.entries(), we are scanning // the list of DataMaps. if (maps.size() == 0) { return Collections.emptyList(); }/*from w w w .j a v a2 s . c o m*/ if (maps.size() == 1) { return maps.iterator().next().getQueryDescriptors(); } CompositeCollection c = new CompositeCollection(); for (DataMap map : maps) { c.addComposited(map.getQueryDescriptors()); } return c; }
From source file:org.apache.cayenne.map.MappingCache.java
public Collection<ObjEntity> getObjEntities() { // TODO: LEGACY SUPPORT: // some downstream code (like Modeler and merge framework) expect // always fresh list here, so instead of doing the right thing of // refreshing the cache and returning cache.entries(), we are scanning // the list of DataMaps. if (maps.size() == 0) { return Collections.emptyList(); }//from w w w .j a va 2s . c om if (maps.size() == 1) { return maps.iterator().next().getObjEntities(); } CompositeCollection c = new CompositeCollection(); for (DataMap map : maps) { c.addComposited(map.getObjEntities()); } return c; }
From source file:org.apache.cayenne.map.MappingCache.java
public Collection<Embeddable> getEmbeddables() { // TODO: LEGACY SUPPORT: // some downstream code (like Modeler and merge framework) expect // always fresh list here, so instead of doing the right thing of // refreshing the cache and returning cache.entries(), we are scanning // the list of DataMaps. if (maps.size() == 0) { return Collections.emptyList(); }// w w w . j av a 2 s. c o m if (maps.size() == 1) { return maps.iterator().next().getEmbeddables(); } CompositeCollection c = new CompositeCollection(); for (DataMap map : maps) { c.addComposited(map.getEmbeddables()); } return c; }
From source file:org.apache.cayenne.map.MappingCache.java
public Collection<SQLResult> getResults() { // TODO: LEGACY SUPPORT: // some downstream code (like Modeler and merge framework) expect // always fresh list here, so instead of doing the right thing of // refreshing the cache and returning cache.entries(), we are scanning // the list of DataMaps. if (maps.size() == 0) { return Collections.emptyList(); }/*from ww w .jav a 2 s.c o m*/ if (maps.size() == 1) { return maps.iterator().next().getResults(); } CompositeCollection c = new CompositeCollection(); for (DataMap map : maps) { c.addComposited(map.getResults()); } return c; }
From source file:org.archive.modules.fetcher.BdbCookieStore.java
/** * Returns a {@link LimitedCookieStoreFacade} whose * {@link LimitedCookieStoreFacade#getCookies()} method returns only cookies * from {@code host} and its parent domains, if applicable. *///from w w w .j a v a 2s .co m public CookieStore cookieStoreFor(String host) { CompositeCollection cookieCollection = new CompositeCollection(); if (InternetDomainName.isValid(host)) { InternetDomainName domain = InternetDomainName.from(host); while (domain != null) { Collection<Cookie> subset = hostSubset(domain.toString()); cookieCollection.addComposited(subset); if (domain.hasParent()) { domain = domain.parent(); } else { domain = null; } } } else { Collection<Cookie> subset = hostSubset(host.toString()); cookieCollection.addComposited(subset); } @SuppressWarnings("unchecked") List<Cookie> cookieList = new RestrictedCollectionWrappedList<Cookie>(cookieCollection); LimitedCookieStoreFacade store = new LimitedCookieStoreFacade(cookieList); return store; }
From source file:org.objectstyle.cayenne.map.EntityResolver.java
public Collection getDbEntities() { CompositeCollection c = new CompositeCollection(); Iterator it = getDataMaps().iterator(); while (it.hasNext()) { DataMap map = (DataMap) it.next(); c.addComposited(map.getDbEntities()); }// w w w .j a va 2s. co m return c; }
From source file:org.objectstyle.cayenne.map.EntityResolver.java
public Collection getObjEntities() { CompositeCollection c = new CompositeCollection(); Iterator it = getDataMaps().iterator(); while (it.hasNext()) { DataMap map = (DataMap) it.next(); c.addComposited(map.getObjEntities()); }/* w w w . j av a2s . com*/ return c; }