/*******************************************************************************
* 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.kato.tck.scenario142.javaruntime;
import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import org.apache.kato.tck.harness.scenario.ScenarioElement;
public class SetupJavaReferences extends ScenarioElement {
class StrongReferent {
public static final String TYPE = "Strong";
};
class WeakReferent {
public static final String TYPE = "Weak";
};
class SoftReferent {
public static final String TYPE = "Soft";
};
class PhantomReferent {
public static final String TYPE = "Phantom";
};
class ArrayElement {
public static final String TYPE = "ArrayElement";
}
private WeakReference weakReference = null;
private SoftReference softReference = null;
private PhantomReference phantomReference = null;
private StrongReferent strongReferent = new StrongReferent();
private WeakReferent weakReferent = new WeakReferent();
private SoftReferent softReferent = new SoftReferent();
private PhantomReferent phantomReferent = new PhantomReferent();
private ClassLoader classLoader = null;
private ArrayElement[] array = new ArrayElement[1];
public void configureReferences() {
weakReference = new WeakReference(weakReferent);
softReference = new SoftReference(softReferent);
phantomReference = new PhantomReference(phantomReferent, new ReferenceQueue());
array[0] = new ArrayElement();
classLoader = this.getClass().getClassLoader();
}
}