com.jacob.com.ROT Maven / Gradle / Ivy
Show all versions of jacob-jdk15 Show documentation
/*
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
* All rights reserved. Originator: Dan Adler (http://danadler.com).
* Get more information about JACOB at http://sourceforge.net/projects/jacob-project
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
package com.jacob.com;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.WeakHashMap;
/**
* The Running Object Table (ROT) maps each thread to a collection of all the
* JacobObjects that were created in that thread. It always operates on the
* current thread so all the methods are static and they implicitly get the
* current thread.
*
* The clearObjects method is used to release all the COM objects created by
* Jacob in the current thread prior to uninitializing COM for that thread.
*
* Prior to 1.9, manual garbage collection was the only option in Jacob, but
* from 1.9 onward, setting the com.jacob.autogc system property allows the
* objects referenced by the ROT to be automatically GCed. Automatic GC may be
* preferable in systems with heavy event callbacks.
*
* Is [ 1116101 ] jacob-msg 0284 relevant???
*/
public abstract class ROT {
/**
* Manual garbage collection was the only option pre 1.9 Can staticly cache
* the results because only one value and we don't let it change during a
* run
*/
protected static final boolean USE_AUTOMATIC_GARBAGE_COLLECTION = "true"
.equalsIgnoreCase(System.getProperty("com.jacob.autogc"));
/**
* If the code is ran from an applet that is called from javascript the Java
* Plugin does not give full permissions to the code and thus System
* properties cannot be accessed. They can be accessed at class
* initialization time.
*
* The default behavior is to include all classes in the ROT, setting a
* boolean here to indicate this prevents a call to System.getProperty as
* part of the general call flow.
*/
protected static final Boolean INCLUDE_ALL_CLASSES_IN_ROT = Boolean
.valueOf(System.getProperty("com.jacob.includeAllClassesInROT",
"true"));
/**
* Suffix added to class name to make up property name that determines if
* this object should be stored in the ROT. This 1.13 "feature" makes it
* possible to cause VariantViaEvent objects to not be added to the ROT in
* event callbacks.
*
* We don't have a static for the actual property because there is a
* different property for each class that may make use of this feature.
*/
protected static String PUT_IN_ROT_SUFFIX = ".PutInROT";
/**
* ThreadLocal with the com objects created in that thread
*/
private static ThreadLocal