Modified: river/jtsk/modules/modularize/apache-river/river-collections/pom.xml URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-collections/pom.xml?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-collections/pom.xml (original) +++ river/jtsk/modules/modularize/apache-river/river-collections/pom.xml Sun Jul 5 11:41:39 2020 @@ -1,187 +1,187 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -~ Copyright (C) 2014 the original author or authors. -~ -~ Licensed under the Apache License, Version 2.0 (the "License"); -~ you may not use this file except in compliance with the License. -~ You may obtain a copy of the License at -~ -~ http://www.apache.org/licenses/LICENSE-2.0 -~ -~ Unless required by applicable law or agreed to in writing, software -~ distributed under the License is distributed on an "AS IS" BASIS, -~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -~ See the License for the specific language governing permissions and -~ limitations under the License. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache</groupId> - <artifactId>river</artifactId> - <version>3.0-SNAPSHOT</version> - <relativePath>../pom.xml</relativePath> - </parent> - - <groupId>org.apache.river</groupId> - <artifactId>river-collections</artifactId> - <packaging>jar</packaging> - - <name>Module :: River Collection</name> - <description>Apache River Collection, Thread and Executor utilities - </description> - - <properties> - <high.scale.lib.version>1.0.6</high.scale.lib.version> - </properties> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.6</version> - <scope>test</scope> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>biz.aQute.bnd</groupId> - <artifactId>bnd-maven-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>bnd-process</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.owasp</groupId> - <artifactId>dependency-check-maven</artifactId> - <executions> - <execution> - <goals> - <goal>check</goal> - </goals> - </execution> - </executions> - </plugin> - <!--<plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <version>2.2</version> - <configuration> - <archive> - <manifestEntries> - <Implementation-Version>${project.version}</Implementation-Version> - <Class-Path>river-resources-${project.version}.jar high-scale-lib-${high.scale.lib.version}.jar</Class-Path> - </manifestEntries> - </archive> - </configuration> - </plugin> --> - - <!--<plugin> - <groupId>org.codehaus.gmaven</groupId> - <artifactId>gmaven-plugin</artifactId> - <configuration> - <providerSelection>${gmavenProviderSelection}</providerSelection> - <source/> - </configuration> - <executions> - <execution> - <goals> - <goal>generateStubs</goal> - <goal>compile</goal> - <goal>generateTestStubs</goal> - <goal>testCompile</goal> - </goals> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-all</artifactId> - <version>${groovy.version}</version> - </dependency> - </dependencies> - </plugin>--> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-source-plugin</artifactId> - <version>2.1.1</version> - <executions> - <execution> - <id>attach-sources</id> - <phase>verify</phase> - <goals> - <goal>jar-no-fork</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <version>2.3.2</version> - <configuration> - <source>1.5</source> - <profile>compact1</profile> - <target>1.5</target> - <debug>true</debug> - <optimize>true</optimize> - <encoding>UTF-8</encoding> - <meminitial>128m</meminitial> - <maxmem>1024m</maxmem> - </configuration> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>retrotranslator-maven-plugin</artifactId> - <version>1.0-alpha-4</version> - <executions> - <execution> - <goals> - <goal>translate-project</goal> - </goals> - <configuration> - <classifier>jdk14</classifier> - <attach>true</attach> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <reporting> - <plugins> - <plugin> - <artifactId>maven-javadoc-plugin</artifactId> - <configuration> - <!--<additionalDependencies> - <additionalDependency> - <groupId>org.apache.river</groupId> - <artifactId>river-lib</artifactId> - <version>${project.version}</version> - </additionalDependency> - <additionalDependency> - <groupId>org.apache.river</groupId> - <artifactId>river-lib-dl</artifactId> - <version>${project.version}</version> - </additionalDependency> - </additionalDependencies>--> - </configuration> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>findbugs-maven-plugin</artifactId> - <configuration> - <excludeFilterFile>findbugs-exclude.xml</excludeFilterFile> - </configuration> - </plugin> - </plugins> - </reporting> -</project> +<?xml version="1.0" encoding="UTF-8"?> +<!-- +~ Copyright (C) 2014 the original author or authors. +~ +~ Licensed under the Apache License, Version 2.0 (the "License"); +~ you may not use this file except in compliance with the License. +~ You may obtain a copy of the License at +~ +~ http://www.apache.org/licenses/LICENSE-2.0 +~ +~ Unless required by applicable law or agreed to in writing, software +~ distributed under the License is distributed on an "AS IS" BASIS, +~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +~ See the License for the specific language governing permissions and +~ limitations under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache</groupId> + <artifactId>river</artifactId> + <version>3.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <groupId>org.apache.river</groupId> + <artifactId>river-collections</artifactId> + <packaging>jar</packaging> + + <name>Module :: River Collection</name> + <description>Apache River Collection, Thread and Executor utilities + </description> + + <properties> + <high.scale.lib.version>1.0.6</high.scale.lib.version> + </properties> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.6</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>biz.aQute.bnd</groupId> + <artifactId>bnd-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>bnd-process</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.owasp</groupId> + <artifactId>dependency-check-maven</artifactId> + <executions> + <execution> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + </plugin> + <!--<plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.2</version> + <configuration> + <archive> + <manifestEntries> + <Implementation-Version>${project.version}</Implementation-Version> + <Class-Path>river-resources-${project.version}.jar high-scale-lib-${high.scale.lib.version}.jar</Class-Path> + </manifestEntries> + </archive> + </configuration> + </plugin> --> + + <!--<plugin> + <groupId>org.codehaus.gmaven</groupId> + <artifactId>gmaven-plugin</artifactId> + <configuration> + <providerSelection>${gmavenProviderSelection}</providerSelection> + <source/> + </configuration> + <executions> + <execution> + <goals> + <goal>generateStubs</goal> + <goal>compile</goal> + <goal>generateTestStubs</goal> + <goal>testCompile</goal> + </goals> + </execution> + </executions> + <dependencies> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-all</artifactId> + <version>${groovy.version}</version> + </dependency> + </dependencies> + </plugin>--> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <version>2.1.1</version> + <executions> + <execution> + <id>attach-sources</id> + <phase>verify</phase> + <goals> + <goal>jar-no-fork</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.3.2</version> + <configuration> + <source>1.8</source> + <profile>compact1</profile> + <target>1.8</target> + <debug>true</debug> + <optimize>true</optimize> + <encoding>UTF-8</encoding> + <meminitial>128m</meminitial> + <maxmem>1024m</maxmem> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>retrotranslator-maven-plugin</artifactId> + <version>1.0-alpha-4</version> + <executions> + <execution> + <goals> + <goal>translate-project</goal> + </goals> + <configuration> + <classifier>jdk14</classifier> + <attach>true</attach> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <reporting> + <plugins> + <plugin> + <artifactId>maven-javadoc-plugin</artifactId> + <configuration> + <!--<additionalDependencies> + <additionalDependency> + <groupId>org.apache.river</groupId> + <artifactId>river-lib</artifactId> + <version>${project.version}</version> + </additionalDependency> + <additionalDependency> + <groupId>org.apache.river</groupId> + <artifactId>river-lib-dl</artifactId> + <version>${project.version}</version> + </additionalDependency> + </additionalDependencies>--> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>findbugs-maven-plugin</artifactId> + <configuration> + <excludeFilterFile>findbugs-exclude.xml</excludeFilterFile> + </configuration> + </plugin> + </plugins> + </reporting> +</project>
Modified: river/jtsk/modules/modularize/apache-river/river-collections/src/main/java/org/apache/river/concurrent/ReadResolveFixCollectionCircularReferences.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-collections/src/main/java/org/apache/river/concurrent/ReadResolveFixCollectionCircularReferences.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-collections/src/main/java/org/apache/river/concurrent/ReadResolveFixCollectionCircularReferences.java (original) +++ river/jtsk/modules/modularize/apache-river/river-collections/src/main/java/org/apache/river/concurrent/ReadResolveFixCollectionCircularReferences.java Sun Jul 5 11:41:39 2020 @@ -1,607 +1,616 @@ -/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.river.concurrent; - -import java.io.IOException; -import java.io.InvalidClassException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.ObjectStreamException; -import java.util.Collection; -import java.util.Comparator; -import java.util.Deque; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.NavigableSet; -import java.util.Queue; -import java.util.Set; -import java.util.SortedSet; -import java.util.concurrent.BlockingDeque; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.TimeUnit; - -/** - * The purpose of this class is to implement all the possible interfaces - * that subclasses of ReferenceCollection may implement. This is designed - * to fix the readResolve issue that occurs in de-serialised object graphs - * containing circular references. - * - * @author Peter Firmstone. - */ -abstract class ReadResolveFixCollectionCircularReferences<T> extends SerializationOfReferenceCollection<T> -implements List<T>, Set<T>, SortedSet<T>, NavigableSet<T> , -Queue<T>, Deque<T>, BlockingQueue<T>, BlockingDeque<T>{ - - // This abstract class must not hold any serial data. - - // Builder created List on deserialization - private volatile Collection<T> serialBuilt = null; - private volatile boolean built = false; - - ReadResolveFixCollectionCircularReferences(){} - - @Override - Collection<T> build() throws InstantiationException, IllegalAccessException, - ObjectStreamException { - if (isBuilt()) return getSerialBuilt(); - setBuilt(); - /* Traverse Inheritance heirarchy in reverse order */ - if ( BlockingDeque.class.isAssignableFrom(getClazz())) - return RC.blockingDeque((BlockingDeque<Referrer<T>>) getCollection(), getType(), 10000L); - if ( BlockingQueue.class.isAssignableFrom(getClazz())) - return RC.blockingQueue((BlockingQueue<Referrer<T>>) getCollection(), getType(), 10000L); - if ( Deque.class.isAssignableFrom(getClazz())) - return RC.deque((Deque<Referrer<T>>) getCollection(), getType(), 10000L); - if ( Queue.class.isAssignableFrom(getClazz())) - return RC.queue((Queue<Referrer<T>>) getCollection(), getType(), 10000L); - if ( List.class.isAssignableFrom(getClazz()) ) - return RC.list((List<Referrer<T>> ) getCollection(), getType(), 10000L); - if ( NavigableSet.class.isAssignableFrom(getClazz()) ) - return RC.navigableSet((NavigableSet<Referrer<T>>) getCollection(), getType(), 10000L); - if ( SortedSet.class.isAssignableFrom(getClazz()) ) - return RC.sortedSet((SortedSet<Referrer<T>>) getCollection(), getType(), 10000L); - if ( Set.class.isAssignableFrom(getClazz())) - return RC.set((Set<Referrer<T>>) getCollection(), getType(), 10000L); - return RC.collection(getCollection(), getType(), 10000L); - } - - /** - * @serialData - * @return the type - */ - abstract Ref getType(); - - /** - * @serialData - * @return the collection - */ - abstract Collection<Referrer<T>> getCollection(); - - /** - * @serialData - * @return the class - */ - abstract Class getClazz(); - - /** - * @return the serialBuilt - */ - Collection<T> getSerialBuilt() { - return serialBuilt; - } - - /** - * @param serialBuilt the serialBuilt to set - */ - Collection<T> setSerialBuilt(Collection<T> serialBuilt) { - this.serialBuilt = serialBuilt; - return serialBuilt; - } - - /** - * @return the built - */ - boolean isBuilt() { - return built; - } - - /** - * - */ - void setBuilt() { - built = true; - } - - - @Override - public int hashCode() { - if ( getSerialBuilt() instanceof List || getSerialBuilt() instanceof Set ){ - return getSerialBuilt().hashCode(); - } - return System.identityHashCode(this); - } - - /** - * Because equals and hashCode are not defined for collections, we - * cannot guarantee consistent behaviour by implementing equals and - * hashCode. A collection could be a list, set, queue or deque. - * So a List != Queue and a Set != list. therefore equals for collections is - * not defined. - * - * However since two collections may both also be Lists, while abstracted - * from the client two lists may still be equal. - * - * Unfortunately this object, when behaving as a delegate, is not always - * equal to the object it is trying to represent. - * - * @see Collection#equals(java.lang.Object) - */ - - @Override - public boolean equals(Object o){ - if ( o == this ) return true; - if ( getSerialBuilt() instanceof List || getSerialBuilt() instanceof Set ){ - return getSerialBuilt().equals(o); - } - return false; - } - - @Override - public Iterator<T> iterator(){ - if (getSerialBuilt() != null) return getSerialBuilt().iterator(); - return new NullIterator<T>(); - } - - @Override - public int size() { - if (getSerialBuilt() != null) return getSerialBuilt().size(); - return 0; - } - - public boolean add(T t){ - if (getSerialBuilt() != null) return getSerialBuilt().add(t); - return false; - } - - private void readObject(ObjectInputStream in) - throws IOException, ClassNotFoundException { - in.defaultReadObject(); - } - - private void writeObject(ObjectOutputStream out) throws IOException { - out.defaultWriteObject(); - } - - // If deserialized state may have changed since, if another type of - // Map, apart from ImmutableMap, uses the same builder for example. - final Object writeReplace() { - if ( isBuilt()) return getSerialBuilt(); - return this; - } - - final Object readResolve() throws ObjectStreamException{ - try { - return setSerialBuilt(build()); - } catch (InstantiationException ex) { - throw new InvalidClassException(this.getClass().toString(), ex.fillInStackTrace().toString()); - } catch (IllegalAccessException ex) { - throw new InvalidClassException(this.getClass().toString(), ex.fillInStackTrace().toString()); - } - } - - - public boolean addAll(int index, Collection<? extends T> c) { - if (getSerialBuilt() instanceof List) return ((List<T>) getSerialBuilt()).addAll(index, c); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T get(int index) { - if (getSerialBuilt() instanceof List) return ((List<T>) getSerialBuilt()).get(index); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T set(int index, T element) { - if (getSerialBuilt() instanceof List) return ((List<T>) getSerialBuilt()).set(index, element); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public void add(int index, T element) { - if (getSerialBuilt() instanceof List)((List<T>) getSerialBuilt()).add(index, element); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T remove(int index) { - if (getSerialBuilt() instanceof List) return ((List<T>) getSerialBuilt()).remove(index); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public int indexOf(Object o) { - if (getSerialBuilt() instanceof List) return ((List<T>) getSerialBuilt()).indexOf(o); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public int lastIndexOf(Object o) { - if (getSerialBuilt() instanceof List) return ((List<T>) getSerialBuilt()).lastIndexOf(o); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public ListIterator<T> listIterator() { - if (getSerialBuilt() instanceof List) return ((List<T>) getSerialBuilt()).listIterator(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public ListIterator<T> listIterator(int index) { - if (getSerialBuilt() instanceof List) return ((List<T>) getSerialBuilt()).listIterator(index); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public List<T> subList(int fromIndex, int toIndex) { - if (getSerialBuilt() instanceof List) return ((List<T>) getSerialBuilt()).subList(fromIndex, toIndex); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public Comparator<? super T> comparator() { - if (getSerialBuilt() instanceof SortedSet) return ((SortedSet<T>) getSerialBuilt()).comparator(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public SortedSet<T> subSet(T fromElement, T toElement) { - if (getSerialBuilt() instanceof SortedSet) return ((SortedSet<T>) getSerialBuilt()).subSet(fromElement, toElement); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public SortedSet<T> headSet(T toElement) { - if (getSerialBuilt() instanceof SortedSet) return ((SortedSet<T>) getSerialBuilt()).headSet(toElement); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public SortedSet<T> tailSet(T fromElement) { - if (getSerialBuilt() instanceof SortedSet) return ((SortedSet<T>) getSerialBuilt()).tailSet(fromElement); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T first() { - if (getSerialBuilt() instanceof SortedSet) return ((SortedSet<T>) getSerialBuilt()).first(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T last() { - if (getSerialBuilt() instanceof SortedSet) - return ((SortedSet<T>) getSerialBuilt()).last(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T lower(T e) { - if (getSerialBuilt() instanceof NavigableSet) - return ((NavigableSet<T>) getSerialBuilt()).lower(e); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T floor(T e) { - if (getSerialBuilt() instanceof NavigableSet) - return ((NavigableSet<T>) getSerialBuilt()).floor(e); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T ceiling(T e) { - if (getSerialBuilt() instanceof NavigableSet) - return ((NavigableSet<T>) getSerialBuilt()).ceiling(e); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T higher(T e) { - if (getSerialBuilt() instanceof NavigableSet) - return ((NavigableSet<T>) getSerialBuilt()).higher(e); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T pollFirst() { - if (getSerialBuilt() instanceof NavigableSet) - return ((NavigableSet<T>) getSerialBuilt()).pollFirst(); - if (getSerialBuilt() instanceof Deque) - return ((Deque<T>) getSerialBuilt()).pollFirst(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T pollLast() { - if (getSerialBuilt() instanceof NavigableSet) - return ((NavigableSet<T>) getSerialBuilt()).pollLast(); - if (getSerialBuilt() instanceof Deque) - return ((Deque<T>) getSerialBuilt()).pollLast(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public NavigableSet<T> descendingSet() { - if (getSerialBuilt() instanceof NavigableSet) - return ((NavigableSet<T>) getSerialBuilt()).descendingSet(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public Iterator<T> descendingIterator() { - if (getSerialBuilt() instanceof NavigableSet) - return ((NavigableSet<T>) getSerialBuilt()).descendingIterator(); - if (getSerialBuilt() instanceof Deque) - return ((Deque<T>) getSerialBuilt()).descendingIterator(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public NavigableSet<T> subSet(T fromElement, boolean fromInclusive, T toElement, boolean toInclusive) { - if (getSerialBuilt() instanceof NavigableSet) - return ((NavigableSet<T>) getSerialBuilt()).subSet(fromElement, fromInclusive, toElement, toInclusive); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public NavigableSet<T> headSet(T toElement, boolean inclusive) { - if (getSerialBuilt() instanceof NavigableSet) - return ((NavigableSet<T>) getSerialBuilt()).headSet(toElement, inclusive); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public NavigableSet<T> tailSet(T fromElement, boolean inclusive) { - if (getSerialBuilt() instanceof NavigableSet) - return ((NavigableSet<T>) getSerialBuilt()).tailSet(fromElement, inclusive); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public boolean offer(T e) { - if (getSerialBuilt() instanceof Queue) return ((Queue<T>) getSerialBuilt()).offer(e); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T remove() { - if (getSerialBuilt() instanceof Queue) return ((Queue<T>) getSerialBuilt()).remove(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T poll() { - if (getSerialBuilt() instanceof Queue) return ((Queue<T>) getSerialBuilt()).poll(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T element() { - if (getSerialBuilt() instanceof Queue) return ((Queue<T>) getSerialBuilt()).element(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T peek() { - if (getSerialBuilt() instanceof Queue) return ((Queue<T>) getSerialBuilt()).peek(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public void addFirst(T e) { - if (getSerialBuilt() instanceof Deque) ((Deque<T>) getSerialBuilt()).addFirst(e); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public void addLast(T e) { - if (getSerialBuilt() instanceof Deque) ((Deque<T>) getSerialBuilt()).addLast(e); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public boolean offerFirst(T e) { - if (getSerialBuilt() instanceof Deque) return ((Deque<T>) getSerialBuilt()).offerFirst(e); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public boolean offerLast(T e) { - if (getSerialBuilt() instanceof Deque) return ((Deque<T>) getSerialBuilt()).offerLast(e); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T removeFirst() { - if (getSerialBuilt() instanceof Deque) return ((Deque<T>) getSerialBuilt()).removeFirst(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T removeLast() { - if (getSerialBuilt() instanceof Deque) return ((Deque<T>) getSerialBuilt()).removeLast(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T getFirst() { - if (getSerialBuilt() instanceof Deque) return ((Deque<T>) getSerialBuilt()).getFirst(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T getLast() { - if (getSerialBuilt() instanceof Deque) return ((Deque<T>) getSerialBuilt()).getLast(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T peekFirst() { - if (getSerialBuilt() instanceof Deque) return ((Deque<T>) getSerialBuilt()).peekFirst(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T peekLast() { - if (getSerialBuilt() instanceof Deque) return ((Deque<T>) getSerialBuilt()).peekLast(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public boolean removeFirstOccurrence(Object o) { - if (getSerialBuilt() instanceof Deque) - return ((Deque<T>) getSerialBuilt()).removeFirstOccurrence(o); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public boolean removeLastOccurrence(Object o) { - if (getSerialBuilt() instanceof Deque) - return ((Deque<T>) getSerialBuilt()).removeLastOccurrence(o); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public void push(T e) { - if (getSerialBuilt() instanceof Deque)((Deque<T>) getSerialBuilt()).push(e); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T pop() { - if (getSerialBuilt() instanceof Deque) return ((Deque<T>) getSerialBuilt()).pop(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public void put(T e) throws InterruptedException { - if (getSerialBuilt() instanceof BlockingQueue) ((BlockingQueue<T>) getSerialBuilt()).put(e); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public boolean offer(T e, long timeout, TimeUnit unit) throws InterruptedException { - if (getSerialBuilt() instanceof BlockingQueue) - return ((BlockingQueue<T>) getSerialBuilt()).offer(e, timeout, unit); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T take() throws InterruptedException { - if (getSerialBuilt() instanceof BlockingQueue) - return ((BlockingQueue<T>) getSerialBuilt()).take(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T poll(long timeout, TimeUnit unit) throws InterruptedException { - if (getSerialBuilt() instanceof BlockingQueue) - return ((BlockingQueue<T>) getSerialBuilt()).poll(timeout, unit); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public int remainingCapacity() { - if (getSerialBuilt() instanceof BlockingQueue) - return ((BlockingQueue<T>) getSerialBuilt()).remainingCapacity(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public int drainTo(Collection<? super T> c) { - if (getSerialBuilt() instanceof BlockingQueue) - return ((BlockingQueue<T>) getSerialBuilt()).drainTo(c); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public int drainTo(Collection<? super T> c, int maxElements) { - if (getSerialBuilt() instanceof BlockingQueue) - return ((BlockingQueue<T>) getSerialBuilt()).drainTo(c, maxElements); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public void putFirst(T e) throws InterruptedException { - if (getSerialBuilt() instanceof BlockingDeque) - ((BlockingDeque<T>) getSerialBuilt()).putFirst(e); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public void putLast(T e) throws InterruptedException { - if (getSerialBuilt() instanceof BlockingDeque) - ((BlockingDeque<T>) getSerialBuilt()).putLast(e); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public boolean offerFirst(T e, long timeout, TimeUnit unit) throws InterruptedException { - if (getSerialBuilt() instanceof BlockingDeque) - return ((BlockingDeque<T>) getSerialBuilt()).offerFirst(e, timeout, unit); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public boolean offerLast(T e, long timeout, TimeUnit unit) throws InterruptedException { - if (getSerialBuilt() instanceof BlockingDeque) - return ((BlockingDeque<T>) getSerialBuilt()).offerLast(e, timeout, unit); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T takeFirst() throws InterruptedException { - if (getSerialBuilt() instanceof BlockingDeque) - return ((BlockingDeque<T>) getSerialBuilt()).takeFirst(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T takeLast() throws InterruptedException { - if (getSerialBuilt() instanceof BlockingDeque) - return ((BlockingDeque<T>) getSerialBuilt()).takeLast(); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T pollFirst(long timeout, TimeUnit unit) throws InterruptedException { - if (getSerialBuilt() instanceof BlockingDeque) - return ((BlockingDeque<T>) getSerialBuilt()).pollFirst(timeout, unit); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - - public T pollLast(long timeout, TimeUnit unit) throws InterruptedException { - if (getSerialBuilt() instanceof BlockingDeque) - return ((BlockingDeque<T>) getSerialBuilt()).pollLast(timeout, unit); - throw new UnsupportedOperationException("Unsupported Interface Method."); - } - - -} +/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.river.concurrent; + +import java.io.IOException; +import java.io.InvalidClassException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.ObjectStreamException; +import java.util.Collection; +import java.util.Comparator; +import java.util.Deque; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NavigableSet; +import java.util.Queue; +import java.util.Set; +import java.util.SortedSet; +import java.util.Spliterator; +import java.util.concurrent.BlockingDeque; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.TimeUnit; + +/** + * The purpose of this class is to implement all the possible interfaces + * that subclasses of ReferenceCollection may implement. This is designed + * to fix the readResolve issue that occurs in de-serialised object graphs + * containing circular references. + * + * @author Peter Firmstone. + */ +public abstract class ReadResolveFixCollectionCircularReferences<T> extends SerializationOfReferenceCollection<T> +implements List<T>, Set<T>, SortedSet<T>, NavigableSet<T>, Queue<T>, Deque<T>, BlockingQueue<T>, BlockingDeque<T>{ + + // This abstract class must not hold any serial data. + + // a hacky workaround, for now, to deal with the "Java8 and above" error that you get when you + // try to implement BOTH List and SortedSet. See: + // https://stackoverflow.com/questions/22746948/class-inherits-unrelated-defaults-for-spliterator-from-types-java-util-set-and + @Override + public Spliterator<T> spliterator() { + return List.super.spliterator(); + } + + + // Builder created List on deserialization + private volatile Collection<T> serialBuilt = null; + private volatile boolean built = false; + + ReadResolveFixCollectionCircularReferences(){} + + @Override + Collection<T> build() throws InstantiationException, IllegalAccessException, + ObjectStreamException { + if (isBuilt()) return getSerialBuilt(); + setBuilt(); + /* Traverse Inheritance heirarchy in reverse order */ + if ( BlockingDeque.class.isAssignableFrom(getClazz())) + return RC.blockingDeque((BlockingDeque<Referrer<T>>) getCollection(), getType(), 10000L); + if ( BlockingQueue.class.isAssignableFrom(getClazz())) + return RC.blockingQueue((BlockingQueue<Referrer<T>>) getCollection(), getType(), 10000L); + if ( Deque.class.isAssignableFrom(getClazz())) + return RC.deque((Deque<Referrer<T>>) getCollection(), getType(), 10000L); + if ( Queue.class.isAssignableFrom(getClazz())) + return RC.queue((Queue<Referrer<T>>) getCollection(), getType(), 10000L); + if ( List.class.isAssignableFrom(getClazz()) ) + return RC.list((List<Referrer<T>> ) getCollection(), getType(), 10000L); + if ( NavigableSet.class.isAssignableFrom(getClazz()) ) + return RC.navigableSet((NavigableSet<Referrer<T>>) getCollection(), getType(), 10000L); + if ( SortedSet.class.isAssignableFrom(getClazz()) ) + return RC.sortedSet((SortedSet<Referrer<T>>) getCollection(), getType(), 10000L); + if ( Set.class.isAssignableFrom(getClazz())) + return RC.set((Set<Referrer<T>>) getCollection(), getType(), 10000L); + return RC.collection(getCollection(), getType(), 10000L); + } + + /** + * @serialData + * @return the type + */ + abstract Ref getType(); + + /** + * @serialData + * @return the collection + */ + abstract Collection<Referrer<T>> getCollection(); + + /** + * @serialData + * @return the class + */ + abstract Class getClazz(); + + /** + * @return the serialBuilt + */ + Collection<T> getSerialBuilt() { + return serialBuilt; + } + + /** + * @param serialBuilt the serialBuilt to set + */ + Collection<T> setSerialBuilt(Collection<T> serialBuilt) { + this.serialBuilt = serialBuilt; + return serialBuilt; + } + + /** + * @return the built + */ + boolean isBuilt() { + return built; + } + + /** + * + */ + void setBuilt() { + built = true; + } + + + @Override + public int hashCode() { + if ( getSerialBuilt() instanceof List || getSerialBuilt() instanceof Set ){ + return getSerialBuilt().hashCode(); + } + return System.identityHashCode(this); + } + + /** + * Because equals and hashCode are not defined for collections, we + * cannot guarantee consistent behaviour by implementing equals and + * hashCode. A collection could be a list, set, queue or deque. + * So a List != Queue and a Set != list. therefore equals for collections is + * not defined. + * + * However since two collections may both also be Lists, while abstracted + * from the client two lists may still be equal. + * + * Unfortunately this object, when behaving as a delegate, is not always + * equal to the object it is trying to represent. + * + * @see Collection#equals(java.lang.Object) + */ + + @Override + public boolean equals(Object o){ + if ( o == this ) return true; + if ( getSerialBuilt() instanceof List || getSerialBuilt() instanceof Set ){ + return getSerialBuilt().equals(o); + } + return false; + } + + @Override + public Iterator<T> iterator(){ + if (getSerialBuilt() != null) return getSerialBuilt().iterator(); + return new NullIterator<T>(); + } + + @Override + public int size() { + if (getSerialBuilt() != null) return getSerialBuilt().size(); + return 0; + } + + public boolean add(T t){ + if (getSerialBuilt() != null) return getSerialBuilt().add(t); + return false; + } + + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + } + + private void writeObject(ObjectOutputStream out) throws IOException { + out.defaultWriteObject(); + } + + // If deserialized state may have changed since, if another type of + // Map, apart from ImmutableMap, uses the same builder for example. + final Object writeReplace() { + if ( isBuilt()) return getSerialBuilt(); + return this; + } + + final Object readResolve() throws ObjectStreamException{ + try { + return setSerialBuilt(build()); + } catch (InstantiationException ex) { + throw new InvalidClassException(this.getClass().toString(), ex.fillInStackTrace().toString()); + } catch (IllegalAccessException ex) { + throw new InvalidClassException(this.getClass().toString(), ex.fillInStackTrace().toString()); + } + } + + + public boolean addAll(int index, Collection<? extends T> c) { + if (getSerialBuilt() instanceof List) return ((List<T>) getSerialBuilt()).addAll(index, c); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T get(int index) { + if (getSerialBuilt() instanceof List) return ((List<T>) getSerialBuilt()).get(index); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T set(int index, T element) { + if (getSerialBuilt() instanceof List) return ((List<T>) getSerialBuilt()).set(index, element); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public void add(int index, T element) { + if (getSerialBuilt() instanceof List)((List<T>) getSerialBuilt()).add(index, element); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T remove(int index) { + if (getSerialBuilt() instanceof List) return ((List<T>) getSerialBuilt()).remove(index); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public int indexOf(Object o) { + if (getSerialBuilt() instanceof List) return ((List<T>) getSerialBuilt()).indexOf(o); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public int lastIndexOf(Object o) { + if (getSerialBuilt() instanceof List) return ((List<T>) getSerialBuilt()).lastIndexOf(o); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public ListIterator<T> listIterator() { + if (getSerialBuilt() instanceof List) return ((List<T>) getSerialBuilt()).listIterator(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public ListIterator<T> listIterator(int index) { + if (getSerialBuilt() instanceof List) return ((List<T>) getSerialBuilt()).listIterator(index); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public List<T> subList(int fromIndex, int toIndex) { + if (getSerialBuilt() instanceof List) return ((List<T>) getSerialBuilt()).subList(fromIndex, toIndex); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public Comparator<? super T> comparator() { + if (getSerialBuilt() instanceof SortedSet) return ((SortedSet<T>) getSerialBuilt()).comparator(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public SortedSet<T> subSet(T fromElement, T toElement) { + if (getSerialBuilt() instanceof SortedSet) return ((SortedSet<T>) getSerialBuilt()).subSet(fromElement, toElement); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public SortedSet<T> headSet(T toElement) { + if (getSerialBuilt() instanceof SortedSet) return ((SortedSet<T>) getSerialBuilt()).headSet(toElement); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public SortedSet<T> tailSet(T fromElement) { + if (getSerialBuilt() instanceof SortedSet) return ((SortedSet<T>) getSerialBuilt()).tailSet(fromElement); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T first() { + if (getSerialBuilt() instanceof SortedSet) return ((SortedSet<T>) getSerialBuilt()).first(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T last() { + if (getSerialBuilt() instanceof SortedSet) + return ((SortedSet<T>) getSerialBuilt()).last(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T lower(T e) { + if (getSerialBuilt() instanceof NavigableSet) + return ((NavigableSet<T>) getSerialBuilt()).lower(e); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T floor(T e) { + if (getSerialBuilt() instanceof NavigableSet) + return ((NavigableSet<T>) getSerialBuilt()).floor(e); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T ceiling(T e) { + if (getSerialBuilt() instanceof NavigableSet) + return ((NavigableSet<T>) getSerialBuilt()).ceiling(e); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T higher(T e) { + if (getSerialBuilt() instanceof NavigableSet) + return ((NavigableSet<T>) getSerialBuilt()).higher(e); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T pollFirst() { + if (getSerialBuilt() instanceof NavigableSet) + return ((NavigableSet<T>) getSerialBuilt()).pollFirst(); + if (getSerialBuilt() instanceof Deque) + return ((Deque<T>) getSerialBuilt()).pollFirst(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T pollLast() { + if (getSerialBuilt() instanceof NavigableSet) + return ((NavigableSet<T>) getSerialBuilt()).pollLast(); + if (getSerialBuilt() instanceof Deque) + return ((Deque<T>) getSerialBuilt()).pollLast(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public NavigableSet<T> descendingSet() { + if (getSerialBuilt() instanceof NavigableSet) + return ((NavigableSet<T>) getSerialBuilt()).descendingSet(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public Iterator<T> descendingIterator() { + if (getSerialBuilt() instanceof NavigableSet) + return ((NavigableSet<T>) getSerialBuilt()).descendingIterator(); + if (getSerialBuilt() instanceof Deque) + return ((Deque<T>) getSerialBuilt()).descendingIterator(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public NavigableSet<T> subSet(T fromElement, boolean fromInclusive, T toElement, boolean toInclusive) { + if (getSerialBuilt() instanceof NavigableSet) + return ((NavigableSet<T>) getSerialBuilt()).subSet(fromElement, fromInclusive, toElement, toInclusive); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public NavigableSet<T> headSet(T toElement, boolean inclusive) { + if (getSerialBuilt() instanceof NavigableSet) + return ((NavigableSet<T>) getSerialBuilt()).headSet(toElement, inclusive); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public NavigableSet<T> tailSet(T fromElement, boolean inclusive) { + if (getSerialBuilt() instanceof NavigableSet) + return ((NavigableSet<T>) getSerialBuilt()).tailSet(fromElement, inclusive); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public boolean offer(T e) { + if (getSerialBuilt() instanceof Queue) return ((Queue<T>) getSerialBuilt()).offer(e); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T remove() { + if (getSerialBuilt() instanceof Queue) return ((Queue<T>) getSerialBuilt()).remove(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T poll() { + if (getSerialBuilt() instanceof Queue) return ((Queue<T>) getSerialBuilt()).poll(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T element() { + if (getSerialBuilt() instanceof Queue) return ((Queue<T>) getSerialBuilt()).element(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T peek() { + if (getSerialBuilt() instanceof Queue) return ((Queue<T>) getSerialBuilt()).peek(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public void addFirst(T e) { + if (getSerialBuilt() instanceof Deque) ((Deque<T>) getSerialBuilt()).addFirst(e); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public void addLast(T e) { + if (getSerialBuilt() instanceof Deque) ((Deque<T>) getSerialBuilt()).addLast(e); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public boolean offerFirst(T e) { + if (getSerialBuilt() instanceof Deque) return ((Deque<T>) getSerialBuilt()).offerFirst(e); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public boolean offerLast(T e) { + if (getSerialBuilt() instanceof Deque) return ((Deque<T>) getSerialBuilt()).offerLast(e); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T removeFirst() { + if (getSerialBuilt() instanceof Deque) return ((Deque<T>) getSerialBuilt()).removeFirst(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T removeLast() { + if (getSerialBuilt() instanceof Deque) return ((Deque<T>) getSerialBuilt()).removeLast(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T getFirst() { + if (getSerialBuilt() instanceof Deque) return ((Deque<T>) getSerialBuilt()).getFirst(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T getLast() { + if (getSerialBuilt() instanceof Deque) return ((Deque<T>) getSerialBuilt()).getLast(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T peekFirst() { + if (getSerialBuilt() instanceof Deque) return ((Deque<T>) getSerialBuilt()).peekFirst(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T peekLast() { + if (getSerialBuilt() instanceof Deque) return ((Deque<T>) getSerialBuilt()).peekLast(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public boolean removeFirstOccurrence(Object o) { + if (getSerialBuilt() instanceof Deque) + return ((Deque<T>) getSerialBuilt()).removeFirstOccurrence(o); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public boolean removeLastOccurrence(Object o) { + if (getSerialBuilt() instanceof Deque) + return ((Deque<T>) getSerialBuilt()).removeLastOccurrence(o); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public void push(T e) { + if (getSerialBuilt() instanceof Deque)((Deque<T>) getSerialBuilt()).push(e); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T pop() { + if (getSerialBuilt() instanceof Deque) return ((Deque<T>) getSerialBuilt()).pop(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public void put(T e) throws InterruptedException { + if (getSerialBuilt() instanceof BlockingQueue) ((BlockingQueue<T>) getSerialBuilt()).put(e); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public boolean offer(T e, long timeout, TimeUnit unit) throws InterruptedException { + if (getSerialBuilt() instanceof BlockingQueue) + return ((BlockingQueue<T>) getSerialBuilt()).offer(e, timeout, unit); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T take() throws InterruptedException { + if (getSerialBuilt() instanceof BlockingQueue) + return ((BlockingQueue<T>) getSerialBuilt()).take(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T poll(long timeout, TimeUnit unit) throws InterruptedException { + if (getSerialBuilt() instanceof BlockingQueue) + return ((BlockingQueue<T>) getSerialBuilt()).poll(timeout, unit); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public int remainingCapacity() { + if (getSerialBuilt() instanceof BlockingQueue) + return ((BlockingQueue<T>) getSerialBuilt()).remainingCapacity(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public int drainTo(Collection<? super T> c) { + if (getSerialBuilt() instanceof BlockingQueue) + return ((BlockingQueue<T>) getSerialBuilt()).drainTo(c); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public int drainTo(Collection<? super T> c, int maxElements) { + if (getSerialBuilt() instanceof BlockingQueue) + return ((BlockingQueue<T>) getSerialBuilt()).drainTo(c, maxElements); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public void putFirst(T e) throws InterruptedException { + if (getSerialBuilt() instanceof BlockingDeque) + ((BlockingDeque<T>) getSerialBuilt()).putFirst(e); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public void putLast(T e) throws InterruptedException { + if (getSerialBuilt() instanceof BlockingDeque) + ((BlockingDeque<T>) getSerialBuilt()).putLast(e); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public boolean offerFirst(T e, long timeout, TimeUnit unit) throws InterruptedException { + if (getSerialBuilt() instanceof BlockingDeque) + return ((BlockingDeque<T>) getSerialBuilt()).offerFirst(e, timeout, unit); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public boolean offerLast(T e, long timeout, TimeUnit unit) throws InterruptedException { + if (getSerialBuilt() instanceof BlockingDeque) + return ((BlockingDeque<T>) getSerialBuilt()).offerLast(e, timeout, unit); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T takeFirst() throws InterruptedException { + if (getSerialBuilt() instanceof BlockingDeque) + return ((BlockingDeque<T>) getSerialBuilt()).takeFirst(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T takeLast() throws InterruptedException { + if (getSerialBuilt() instanceof BlockingDeque) + return ((BlockingDeque<T>) getSerialBuilt()).takeLast(); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T pollFirst(long timeout, TimeUnit unit) throws InterruptedException { + if (getSerialBuilt() instanceof BlockingDeque) + return ((BlockingDeque<T>) getSerialBuilt()).pollFirst(timeout, unit); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + + public T pollLast(long timeout, TimeUnit unit) throws InterruptedException { + if (getSerialBuilt() instanceof BlockingDeque) + return ((BlockingDeque<T>) getSerialBuilt()).pollLast(timeout, unit); + throw new UnsupportedOperationException("Unsupported Interface Method."); + } + + +} Modified: river/jtsk/modules/modularize/apache-river/river-collections/src/main/java/org/apache/river/concurrent/ReferenceCollectionSerialData.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-collections/src/main/java/org/apache/river/concurrent/ReferenceCollectionSerialData.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-collections/src/main/java/org/apache/river/concurrent/ReferenceCollectionSerialData.java (original) +++ river/jtsk/modules/modularize/apache-river/river-collections/src/main/java/org/apache/river/concurrent/ReferenceCollectionSerialData.java Sun Jul 5 11:41:39 2020 @@ -1,88 +1,88 @@ -/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.river.concurrent; - -import java.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.util.Collection; - -/** - *This class is the serial form of ReferenceCollection and all it's subclasses. - * - * While the serial form of this class will remain compatible with itself, - * ReferenceCollection may replace this implementation with another - * at some point in the future. - * - * This class will still be able to de-serialise into a ReferenceCollection. - * - * @author peter - */ - class ReferenceCollectionSerialData<T> - extends ReferenceCollectionRefreshAfterSerialization<T> implements Serializable { - private static final long serialVersionUID = 1L; - - /** @serialField */ - private Ref type; - /** @serialField */ - private Collection<Referrer<T>> collection; - /** @serialField */ - private Class referenceCollectionClass; - - @SuppressWarnings("unchecked") - ReferenceCollectionSerialData( Class clazz, - Collection<Referrer<T>> underlyingCollection, Ref type) - throws InstantiationException, IllegalAccessException{ - // Create a new instance of the underlying collection and - // add all objects. - if ( clazz == null || underlyingCollection == null || type == null){ - throw new NullPointerException("null parameters prohibited"); - } - this.collection = underlyingCollection; - this.type = type; - this.referenceCollectionClass = clazz; - } - - @Override - public Ref getType() { - return type; - } - - @Override - public Collection<Referrer<T>> getCollection() { - return collection; - } - - @Override - public Class getClazz() { - return referenceCollectionClass; - } - - private void readObject(ObjectInputStream in) - throws IOException, ClassNotFoundException { - in.defaultReadObject(); - if ( referenceCollectionClass == null || collection == null || type == null){ - throw new InvalidObjectException("null fields found after deserialization"); - } - } - - private void writeObject(ObjectOutputStream out) throws IOException { - out.defaultWriteObject(); - } - -} +/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.river.concurrent; + +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.Collection; + +/** + *This class is the serial form of ReferenceCollection and all it's subclasses. + * + * While the serial form of this class will remain compatible with itself, + * ReferenceCollection may replace this implementation with another + * at some point in the future. + * + * This class will still be able to de-serialise into a ReferenceCollection. + * + * @author peter + */ + public class ReferenceCollectionSerialData<T> + extends ReferenceCollectionRefreshAfterSerialization<T> implements Serializable { + private static final long serialVersionUID = 1L; + + /** @serialField */ + private Ref type; + /** @serialField */ + private Collection<Referrer<T>> collection; + /** @serialField */ + private Class referenceCollectionClass; + + @SuppressWarnings("unchecked") + ReferenceCollectionSerialData( Class clazz, + Collection<Referrer<T>> underlyingCollection, Ref type) + throws InstantiationException, IllegalAccessException{ + // Create a new instance of the underlying collection and + // add all objects. + if ( clazz == null || underlyingCollection == null || type == null){ + throw new NullPointerException("null parameters prohibited"); + } + this.collection = underlyingCollection; + this.type = type; + this.referenceCollectionClass = clazz; + } + + @Override + public Ref getType() { + return type; + } + + @Override + public Collection<Referrer<T>> getCollection() { + return collection; + } + + @Override + public Class getClazz() { + return referenceCollectionClass; + } + + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + if ( referenceCollectionClass == null || collection == null || type == null){ + throw new InvalidObjectException("null fields found after deserialization"); + } + } + + private void writeObject(ObjectOutputStream out) throws IOException { + out.defaultWriteObject(); + } + +} Modified: river/jtsk/modules/modularize/apache-river/river-destroy/pom.xml URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-destroy/pom.xml?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-destroy/pom.xml (original) +++ river/jtsk/modules/modularize/apache-river/river-destroy/pom.xml Sun Jul 5 11:41:39 2020 @@ -1,105 +1,100 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -~ Copyright (C) 2014 the original author or authors. -~ -~ Licensed under the Apache License, Version 2.0 (the "License"); -~ you may not use this file except in compliance with the License. -~ You may obtain a copy of the License at -~ -~ http://www.apache.org/licenses/LICENSE-2.0 -~ -~ Unless required by applicable law or agreed to in writing, software -~ distributed under the License is distributed on an "AS IS" BASIS, -~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -~ See the License for the specific language governing permissions and -~ limitations under the License. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache</groupId> - <artifactId>river</artifactId> - <version>3.0-SNAPSHOT</version> - </parent> - - <groupId>org.apache.river</groupId> - <artifactId>river-destroy</artifactId> - <packaging>jar</packaging> - - <name>Module :: River SharedGroup Destroy</name> - <description>This executable JAR file is the primary entry point for the Service Starter. - It acts as both the class path for the container virtual machine (VM) for the Java platform - that executes non-activatable services, and as the setup VM for activatable services. - </description> - - <dependencies> - - <dependency> - <groupId>org.apache.river</groupId> - <artifactId>service-starter</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.river</groupId> - <artifactId>river-lib</artifactId> - <version>${project.version}</version> - </dependency> - - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>biz.aQute.bnd</groupId> - <artifactId>bnd-maven-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>bnd-process</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.owasp</groupId> - <artifactId>dependency-check-maven</artifactId> - <executions> - <execution> - <goals> - <goal>check</goal> - </goals> - </execution> - </executions> - </plugin> - <!--<plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <version>2.2</version> - <configuration> - <archive> - <manifestEntries> - <Main-Class>org.apache.river.start.ServiceStarter</Main-Class> - <Implementation-Version>${project.version}</Implementation-Version> - <Class-Path>river-url-integrity.jar</Class-Path> - </manifestEntries> - </archive> - </configuration> - </plugin>--> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-source-plugin</artifactId> - <version>2.1.1</version> - <executions> - <execution> - <id>attach-sources</id> - <phase>verify</phase> - <goals> - <goal>jar-no-fork</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project> +<?xml version="1.0" encoding="UTF-8"?> +<!-- ~ Copyright (C) 2014 the original author or authors. ~ ~ Licensed under + the Apache License, Version 2.0 (the "License"); ~ you may not use this file + except in compliance with the License. ~ You may obtain a copy of the License + at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by + applicable law or agreed to in writing, software ~ distributed under the + License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS + OF ANY KIND, either express or implied. ~ See the License for the specific + language governing permissions and ~ limitations under the License. --> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache</groupId> + <artifactId>river</artifactId> + <version>3.0-SNAPSHOT</version> + </parent> + + <groupId>org.apache.river</groupId> + <artifactId>river-destroy</artifactId> + <packaging>jar</packaging> + + <name>Module :: River SharedGroup Destroy</name> + <description>This executable JAR file is the primary entry point for the Service Starter. + It acts as both the class path for the container virtual machine (VM) for the Java platform + that executes non-activatable services, and as the setup VM for activatable services. + </description> + + <dependencies> + + <dependency> + <groupId>org.apache.river</groupId> + <artifactId>river-start</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.river</groupId> + <artifactId>river-lib</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.river</groupId> + <artifactId>river-logging</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.river</groupId> + <artifactId>river-logging</artifactId> + <version>${project.version}</version> + </dependency> + + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>biz.aQute.bnd</groupId> + <artifactId>bnd-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>bnd-process</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.owasp</groupId> + <artifactId>dependency-check-maven</artifactId> + <executions> + <execution> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + </plugin> + <!--<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> + <version>2.2</version> <configuration> <archive> <manifestEntries> <Main-Class>org.apache.river.start.ServiceStarter</Main-Class> + <Implementation-Version>${project.version}</Implementation-Version> <Class-Path>river-url-integrity.jar</Class-Path> + </manifestEntries> </archive> </configuration> </plugin> --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <version>2.1.1</version> + <executions> + <execution> + <id>attach-sources</id> + <phase>verify</phase> + <goals> + <goal>jar-no-fork</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project>
