Merging B-1_9_1 back to head

This commit is contained in:
clay_shooter
2005-10-24 22:59:25 +00:00
parent d61eac5a7a
commit 5f8e69d7e2
75 changed files with 3179 additions and 1163 deletions

View File

@@ -1,31 +1,21 @@
/*
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
* All rights reserved. Originator: Dan Adler (http://danadler.com).
* Get more information about JACOB at www.sourceforge.net/jacob-project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Redistributions in any form must be accompanied by information on
* how to obtain complete source code for the JACOB software.
* 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 SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* 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.activeX;
@@ -51,6 +41,11 @@ public class ActiveXComponent extends Dispatch {
* Normally used to create a new connection to a microsoft application.
* The passed in parameter is the name of the program as registred
* in the registry. It can also be the object name.
* <p>
* This constructor causes a new Windows object of the requested
* type to be created. The windows CoCreate() function gets called
* to create the underlying windows object.
*
* <pre>new ActiveXComponent("ScriptControl");</pre>
* @param programId
*/

View File

@@ -1,28 +1,21 @@
/*
* Copyright (c) 1999-2004 Sourceforge JACOB Project. All rights reserved.
* Originator: Dan Adler (http://danadler.com).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. 2. Redistributions in
* binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution. 3. Redistributions in any form must
* be accompanied by information on how to obtain complete source code for the
* JACOB software.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
* All rights reserved. Originator: Dan Adler (http://danadler.com).
* Get more information about JACOB at www.sourceforge.net/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;

View File

@@ -1,28 +1,21 @@
/*
* Copyright (c) 1999-2004 Sourceforge JACOB Project. All rights reserved.
* Originator: Dan Adler (http://danadler.com).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. 2. Redistributions in
* binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution. 3. Redistributions in any form must
* be accompanied by information on how to obtain complete source code for the
* JACOB software.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
* All rights reserved. Originator: Dan Adler (http://danadler.com).
* Get more information about JACOB at www.sourceforge.net/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;
@@ -31,14 +24,20 @@ package com.jacob.com;
*/
public class ComFailException extends ComException {
/**
* eclipse generated to get rid of a wanring
*/
private static final long serialVersionUID = -266047261992987700L;
/**
* Constructor
* @param hrNew
*/
// Constructors
public ComFailException(int hrNew) {
super(hrNew);
}
/**
* Constructor
* @param hrNew
* @param message
*/
@@ -58,6 +57,7 @@ public class ComFailException extends ComException {
}
/**
* Constructor
* @param hrNew
* @param description
* @param source
@@ -70,7 +70,7 @@ public class ComFailException extends ComException {
}
/**
*
* No argument Constructor
*/
public ComFailException() {
super();

View File

@@ -1,33 +1,28 @@
/*
* Copyright (c) 1999-2004 Sourceforge JACOB Project. All rights reserved.
* Originator: Dan Adler (http://danadler.com).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. 2. Redistributions in
* binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution. 3. Redistributions in any form must
* be accompanied by information on how to obtain complete source code for the
* JACOB software.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
* All rights reserved. Originator: Dan Adler (http://danadler.com).
* Get more information about JACOB at www.sourceforge.net/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;
/**
* represents a COM level thread
* Represents a COM level thread
* This is an abstract class because all the methods are static
* and no instances are ever created.
*/
public abstract class ComThread {
private static final int MTA = 0x0;
@@ -108,22 +103,22 @@ public abstract class ComThread {
// to avoid COM creating its own
startMainSTA();
}
//System.out.println("before Init: "+mode);
if (JacobObject.isDebugEnabled()){JacobObject.debug("ComThread: before Init: "+mode);}
doCoInitialize(mode);
//System.out.println("after Init");
if (JacobObject.isDebugEnabled()){JacobObject.debug("ComThread: after Init: "+mode);}
ROT.addThread();
//System.out.println("after ROT.addThread");
if (JacobObject.isDebugEnabled()){JacobObject.debug("ComThread: after ROT.addThread: "+mode); }
}
/**
* Call CoUninitialize to release this java thread from COM
*/
public static synchronized void Release() {
//System.out.println("before clearObjects");
if (JacobObject.isDebugEnabled()){JacobObject.debug("ComThread: before clearObjects"); }
ROT.clearObjects();
//System.out.println("before UnInit");
if (JacobObject.isDebugEnabled()){JacobObject.debug("ComThread: before UnInit"); }
doCoUninitialize();
//System.out.println("after UnInit");
if (JacobObject.isDebugEnabled()){JacobObject.debug("ComThread: after UnInit"); }
}
/**

View File

@@ -0,0 +1,103 @@
/*
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
* All rights reserved. Originator: Dan Adler (http://danadler.com).
* Get more information about JACOB at www.sourceforge.net/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.Calendar;
import java.util.Date;
/**
* java / windows date conversion utilities
* @author joe
*
*/
public class DateUtilities {
/**
* converts a windows time to a Java Date Object
* @param comTime
* @return Date object representing the windows time as specified in comTime
*/
static public Date convertWindowsTimeToDate(double comTime){
return new Date(convertWindowsTimeToMilliseconds (comTime));
}
/**
* Convert a COM time from functions Date(), Time(), Now() to a
* Java time (milliseconds). Visual Basic time values are based to
* 30.12.1899, Java time values are based to 1.1.1970 (= 0
* milliseconds). The difference is added to the Visual Basic value to
* get the corresponding Java value. The Visual Basic double value
* reads: <day count delta since 30.12.1899>.<1 day percentage
* fraction>, e.g. "38100.6453" means: 38100 days since 30.12.1899 plus
* (24 hours * 0.6453). Example usage:
* <code>Date javaDate = new Date(toMilliseconds (vbDate));</code>.
*
* @param comTime
* COM time.
* @return Java time.
*/
static public long convertWindowsTimeToMilliseconds(double comTime) {
long result = 0;
// code from jacobgen:
comTime = comTime - 25569D;
Calendar cal = Calendar.getInstance();
result = Math.round(86400000L * comTime)
- cal.get(Calendar.ZONE_OFFSET);
cal.setTime(new Date(result));
result -= cal.get(Calendar.DST_OFFSET);
return result;
}// convertWindowsTimeToMilliseconds()
/**
* converts a java date to a windows time object
* (is this timezone safe?)
*
* @param javaDate the java date to be converted to windows time
* @return the double representing the date in a form windows understands
*/
static public double convertDateToWindowsTime(Date javaDate){
if (javaDate == null){
throw new IllegalArgumentException("cannot convert null to windows time");
}
return convertMillisecondsToWindowsTime(javaDate.getTime());
}
/**
* Convert a Java time to a COM time.
*
* @param milliseconds
* Java time.
* @return COM time.
*/
static public double convertMillisecondsToWindowsTime(long milliseconds) {
double result = 0.0;
// code from jacobgen:
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(milliseconds);
milliseconds += (cal.get(Calendar.ZONE_OFFSET) + cal
.get(Calendar.DST_OFFSET)); // add GMT offset
result = (milliseconds / 86400000D) + 25569D;
return result;
}//convertMillisecondsToWindowsTime()
}

View File

@@ -1,31 +1,21 @@
/*
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
* All rights reserved. Originator: Dan Adler (http://danadler.com).
* Get more information about JACOB at www.sourceforge.net/jacob-project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Redistributions in any form must be accompanied by information on
* how to obtain complete source code for the JACOB software.
* 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 SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* 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;
@@ -152,9 +142,14 @@ public class Dispatch extends JacobObject
}
/**
* Constructor that calls createInstance with progid. This is the
* constructor used by the ActiveXComponent
*
* This constructor calls createInstance with progid. This is the
* constructor used by the ActiveXComponent or by programs that
* don't like the activeX interface but wish to create new connections
* to windows programs.
* <p>
* This constructor always creates a new windows/program object
* because it is based on the CoCreate() windows function.
* <p>
* @param requestedProgramId
*/
public Dispatch(String requestedProgramId) {
@@ -163,15 +158,29 @@ public class Dispatch extends JacobObject
}
/**
* native call createIstnace only used by the constructor with the same parm
* type could this be private?
* native call createInstance only used by the constructor with the same parm
* type. This probably should be private. It is the wrapper for the
* Windows CoCreate() call
* <P>
* This ends up calling CoCreate down in the JNI layer
*
* @param progid
*/
protected native void createInstance(String progid);
/**
* return a different interface by IID string
* Return a different interface by IID string.
* <p>
* Once you have a Dispatch object, you can navigate to the other
* interfaces of a COM object by calling QueryInterafce.
* The argument is an IID string in the format:
* "{9BF24410-B2E0-11D4-A695-00104BFF3241}". You typically get
* this string from the idl file (it's called uuid in there).
* Any interface you try to use must be derived from IDispatch. T
* The atl example uses this.
* <p>
* The Dispatch instance resulting from this query is instanciated in the
* JNI code.
*
* @param iid
* @return Dispatch a disptach that matches ??
@@ -180,7 +189,9 @@ public class Dispatch extends JacobObject
/**
* Constructor that only gets called from JNI
*
* QueryInterface calls JNI code that looks up the object
* for the key passed in. The JNI CODE then creates a new dispatch object
* using this constructor
* @param pDisp
*/
protected Dispatch(int pDisp) {

View File

@@ -1,31 +1,21 @@
/*
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
* All rights reserved. Originator: Dan Adler (http://danadler.com).
* Get more information about JACOB at www.sourceforge.net/jacob-project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Redistributions in any form must be accompanied by information on
* how to obtain complete source code for the JACOB software.
* 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 SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* 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;
@@ -45,17 +35,43 @@ package com.jacob.com;
public class DispatchEvents extends JacobObject {
/**
* ponter to an MS data struct.
* pointer to an MS data struct.
* The COM layer knows the name of this variable and puts the windows
* memory pointer here.
*/
int m_pConnPtProxy = 0;
/**
* create a permanent reference to this Variant so that
* it never gets garbage collected. The
* Dispatch proxies will keep a handle on this so
* we don't really want it released
* the wrapper for the event sink.
* This object is the one that will be sent a message when an event
* occurs in the MS layer. Normally, the InvocationProxy will forward
* the messages to a wrapped object that it contains.
*/
private static Variant prototypicalVariant = new VariantViaEvent();
InvocationProxy mInvocationProxy = null;
/**
* A constructor for those that want to supply their own InvocationProxy.
* or subclass (future implementations may take an interface).
* This lets someone distribute their events to other objects
* at the single method dispatch point.
* <p>
* Most users of this class will use the other constructors!
*
* @param sourceOfEvent the Dispatch object that will send events
* @param pInvocationProxy the proxy object that expects to receive the
* events for some other object
*/
public DispatchEvents(Dispatch sourceOfEvent, InvocationProxy pInvocationProxy){
mInvocationProxy = pInvocationProxy;
if (mInvocationProxy != null){
init(sourceOfEvent, mInvocationProxy);
} else {
if (JacobObject.isDebugEnabled()){
JacobObject.debug("Cannot register null invocation proxy for events");
}
throw new IllegalArgumentException("Cannot register null invocation proxy for events");
}
}
/**
* Creates the event callback linkage between the the
@@ -65,7 +81,19 @@ public class DispatchEvents extends JacobObject {
* @param eventSink Java object that wants to receive the events
*/
public DispatchEvents(Dispatch sourceOfEvent, Object eventSink) {
init(sourceOfEvent, eventSink, prototypicalVariant);
if (JacobObject.isDebugEnabled()){
System.out.println(
"DispatchEvents: Registering "+ eventSink + "for events ");
}
mInvocationProxy = new InvocationProxy(eventSink);
if (mInvocationProxy != null){
init(sourceOfEvent, mInvocationProxy);
} else {
if (JacobObject.isDebugEnabled()){
JacobObject.debug("Cannot register null event sink for events");
}
throw new IllegalArgumentException("Cannot register null event sink for events");
}
}
/**
@@ -74,34 +102,42 @@ public class DispatchEvents extends JacobObject {
* Java object that will receive the callback.
* @param sourceOfEvent Dispatch object who's MS app will generate callbacks
* @param eventSink Java object that wants to receive the events
* @param progId
* @param progId ???
*/
public DispatchEvents(Dispatch sourceOfEvent, Object eventSink, String progId) {
init2(sourceOfEvent, eventSink, prototypicalVariant, progId);
if (JacobObject.isDebugEnabled()){
System.out.println(
"DispatchEvents: Registering "+ eventSink + "for events ");
}
mInvocationProxy = new InvocationProxy(eventSink);
if (mInvocationProxy != null) {
init2(sourceOfEvent, mInvocationProxy, progId);
} else {
if (JacobObject.isDebugEnabled()){
JacobObject.debug("Cannot register null event sink for events");
}
throw new IllegalArgumentException("Cannot register null event sink for events");
}
}
/**
* hooks up a connection point proxy by progId
* event methods on the sink object will be called
* by name with a signature of <name>(Variant[] args)
* protoVariant is a sacrificial variant object so we don't have to do findClass in callbacks
* @param src
* @param sink
* @param protoVariant
*/
protected native void init(Dispatch src, Object sink, Object protoVariant);
protected native void init(Dispatch src, Object sink);
/**
* hooks up a connection point proxy by progId
* event methods on the sink object will be called
* by name with a signature of <name>(Variant[] args)
* protoVariant is a sacrificial variant object so we don't have to do findClass in callbacks
* @param src
* @param sink
* @param protoVariant
* @param progId
*/
protected native void init2(Dispatch src, Object sink, Object protoVariant, String progId);
protected native void init2(Dispatch src, Object sink, String progId);
/**
* now private so only this object can asccess
@@ -123,13 +159,17 @@ public class DispatchEvents extends JacobObject {
* @see com.jacob.com.JacobObject#safeRelease()
*/
public void safeRelease(){
if (mInvocationProxy!=null){
mInvocationProxy.clearTarget();
}
mInvocationProxy = null;
super.safeRelease();
if (m_pConnPtProxy != 0){
release();
m_pConnPtProxy = 0;
} else {
// looks like a double release
if (isDebugEnabled()){debug(this.getClass().getName()+":"+this.hashCode()+" double release");}
if (isDebugEnabled()){debug("DispatchEvents:"+this.hashCode()+" double release");}
}
}

View File

@@ -1,31 +1,21 @@
/*
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
* All rights reserved. Originator: Dan Adler (http://danadler.com).
* Get more information about JACOB at www.sourceforge.net/jacob-project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Redistributions in any form must be accompanied by information on
* how to obtain complete source code for the JACOB software.
* 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 SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* 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;

View File

@@ -1,31 +1,21 @@
/*
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
* All rights reserved. Originator: Dan Adler (http://danadler.com).
* Get more information about JACOB at www.sourceforge.net/jacob-project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Redistributions in any form must be accompanied by information on
* how to obtain complete source code for the JACOB software.
* 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 SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* 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;

View File

@@ -0,0 +1,140 @@
/*
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
* All rights reserved. Originator: Dan Adler (http://danadler.com).
* Get more information about JACOB at www.sourceforge.net/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.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* @version $Id$
* @author joe
*
* DispatchProxy wraps this class around any event handlers
* before making the JNI call that sets up the link with EventProxy.
* This means that EventProxy just calls invoke(String,Variant[])
* against the instance of this class. Then this class does
* reflection against the event listener to call the actual event methods.
* All Event methods have the signature
*
* <code> void eventMethodName(Variant[])</code>
*
*/
public class InvocationProxy {
/**
* the object we will try and forward to.
*/
Object mTargetObject = null;
/**
* constructs an invocation proxy that fronts for an event listener
* @param pTargetObject
*/
protected InvocationProxy(Object pTargetObject){
super();
if (JacobObject.isDebugEnabled()){
JacobObject.debug(
"InvocationProxy: created for object "+pTargetObject);
}
mTargetObject = pTargetObject;
if (mTargetObject == null){
throw new IllegalArgumentException("InvocationProxy requires a target");
}
// JNI code apparently bypasses this check and could operate against
// protected classes. This seems like a security issue...
// mayb eit was because JNI code isn't in a package?
if (!java.lang.reflect.Modifier.isPublic(
pTargetObject.getClass().getModifiers())){
throw new IllegalArgumentException(
"InvocationProxy only public classes can receive event notifications");
}
}
/**
* the method actually invoked by EventProxy.cpp
* @param methodName name of method in mTargetObject we will invoke
* @param targetParameter Variant[] that is the single parameter to the method
*/
public void invoke(String methodName, Variant targetParameter[]){
if (mTargetObject == null){
if (JacobObject.isDebugEnabled()){
JacobObject.debug(
"InvocationProxy: received notification with no target set");
}
return;
}
Class targetClass = mTargetObject.getClass();
if (methodName == null){
throw new IllegalArgumentException("InvocationProxy: missing method name");
}
if (targetParameter == null){
throw new IllegalArgumentException("InvocationProxy: missing Variant parameters");
}
try {
// should wrap in debug flag
if (JacobObject.isDebugEnabled()){
JacobObject.debug("InvocationProxy: trying to invoke "+methodName
+" on "+mTargetObject);
}
Method targetMethod = targetClass.getMethod(methodName,
new Class[] {Variant[].class});
if (targetMethod != null){
// protected classes can't be invoked against even if they
// let you grab the method. you could do targetMethod.setAccessible(true);
// but that should be stopped by the security manager
targetMethod.invoke(mTargetObject,new Object[] {targetParameter});
}
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
// this happens whenever the listener doesn't implement all the methods
if (JacobObject.isDebugEnabled()){
JacobObject.debug("InvocationProxy: listener doesn't implement "
+ methodName);
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
if (JacobObject.isDebugEnabled()){
JacobObject.debug("InvocationProxy: probably tried to access public method on non public class"
+ methodName);
}
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
/**
* used by EventProxy.cpp to create variant objects in the right thread
* @return Variant object that will be used by the COM layer
*/
public Variant getVariant(){
return new VariantViaEvent();
}
/**
* helper method used by DispatchEvents to help clean up and reduce references
*
*/
protected void clearTarget(){
mTargetObject = null;
}
}

View File

@@ -1,39 +1,27 @@
/*
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
* All rights reserved. Originator: Dan Adler (http://danadler.com).
* Get more information about JACOB at www.sourceforge.net/jacob-project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Redistributions in any form must be accompanied by information on
* how to obtain complete source code for the JACOB software.
* 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 SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* 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.io.IOException;
import java.io.InputStream;
import java.util.Locale;
import java.util.Properties;
import java.util.ResourceBundle;
/**
* The superclass of all Jacob objects. It is used to
@@ -46,7 +34,19 @@ import java.util.ResourceBundle;
* result in a segmentation violation.
*/
public class JacobObject {
/**
* holds the build version as retrieved from the version.properties
* file that exists in the JAR.
* This can be retrived by calling the static method getBuildVersion()
* @see getBuildVersion()
*/
private static String buildVersion = "";
/**
* holds the build date as retrieved from the version.properties
* file that exists in the JAR
* This can be retrived by calling the static method getBuildDate()
* @see getBuildDate()
*/
private static String buildDate = "";
/**
@@ -109,7 +109,8 @@ public class JacobObject {
public void safeRelease() {
// currently does nothing - subclasses may do something
if (isDebugEnabled()){
debug(this.getClass().getName()+":"+this.hashCode()+" release");
// this used to do a toString() but that is bad for SafeArray
debug("SafeRelease: "+this.getClass().getName());
}
}
@@ -132,7 +133,8 @@ public class JacobObject {
{
if(isDebugEnabled())
{
System.out.println(istrMessage);
System.out.println(istrMessage
+ " in thread "+ Thread.currentThread().getName());
}
}

View File

@@ -1,31 +1,21 @@
/*
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
* All rights reserved. Originator: Dan Adler (http://danadler.com).
* Get more information about JACOB at www.sourceforge.net/jacob-project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Redistributions in any form must be accompanied by information on
* how to obtain complete source code for the JACOB software.
* 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 SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* 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;

View File

@@ -1,31 +1,21 @@
/*
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
* All rights reserved. Originator: Dan Adler (http://danadler.com).
* Get more information about JACOB at www.sourceforge.net/jacob-project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Redistributions in any form must be accompanied by information on
* how to obtain complete source code for the JACOB software.
* 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 SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* 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;
@@ -75,7 +65,9 @@ public abstract class ROT {
// nothing to do
} else {
Map tab = null;
if (JacobObject.isDebugEnabled()){ JacobObject.debug("Automatic GC flag == "+USE_AUTOMATIC_GARBAGE_COLLECTION);}
if (JacobObject.isDebugEnabled()){
JacobObject.debug("ROT: Automatic GC flag == "+ USE_AUTOMATIC_GARBAGE_COLLECTION
);}
if (!USE_AUTOMATIC_GARBAGE_COLLECTION){
tab = new HashMap();
} else {
@@ -112,8 +104,13 @@ public abstract class ROT {
*/
protected static void clearObjects() {
Map tab = getThreadObjects(false);
if (JacobObject.isDebugEnabled()){ JacobObject.debug("starting clear objects");}
if (JacobObject.isDebugEnabled()){
JacobObject.debug("ROT: "+rot.keySet().size()+" thread tables exist");
}
if (tab != null){
if (JacobObject.isDebugEnabled()){
JacobObject.debug("ROT: "+tab.keySet().size()+ " objects to clear in this thread " );
}
// walk the values
Iterator it;
if (USE_AUTOMATIC_GARBAGE_COLLECTION){
@@ -128,7 +125,15 @@ public abstract class ROT {
// and we get an exceptin modifying the collection while iterating
// && o.toString() != null
){
if (JacobObject.isDebugEnabled()){ JacobObject.debug(" removing "+o.getClass().getName());}
if (JacobObject.isDebugEnabled()){
if (o instanceof SafeArray){
// SafeArray create more objects when calling toString()
// which causes a concurrent modification exception in HashMap
JacobObject.debug("ROT: removing "+o.getClass().getName());
} else {
JacobObject.debug("ROT: removing "+o+"->"+o.getClass().getName());
}
}
o.safeRelease();
}
// used to be an iterator.remove() but why bother when we're nuking them all anyway?
@@ -137,8 +142,11 @@ public abstract class ROT {
tab.clear();
// remove the collection from rot
rot.remove(Thread.currentThread().getName());
if (JacobObject.isDebugEnabled()){
JacobObject.debug("ROT: thread table cleared and removed");
}
} else {
if (JacobObject.isDebugEnabled()){ JacobObject.debug("nothing to clear!");}
if (JacobObject.isDebugEnabled()){ JacobObject.debug("ROT: nothing to clear!");}
}
}
@@ -192,8 +200,6 @@ public abstract class ROT {
* @param o
*/
protected static void addObject(JacobObject o) {
String t_name = Thread.currentThread().getName();
if (JacobObject.isDebugEnabled()){ JacobObject.debug(" add:"+o+"->"+o.getClass().getName());}
Map tab = getThreadObjects(false);
if (tab == null) {
// this thread has not been initialized as a COM thread
@@ -201,9 +207,12 @@ public abstract class ROT {
ComThread.InitMTA(false);
tab = getThreadObjects(true);
}
if (JacobObject.isDebugEnabled()){
JacobObject.debug(
"ROT: adding "+o+"->"+o.getClass().getName() +
" table size prior to addition:" +tab.size());}
if (tab != null) {
tab.put(getMapKey(tab,o),getMapValue(tab,o));
if (JacobObject.isDebugEnabled()){ JacobObject.debug(" ROT thread table size after addition is :"+tab.size());}
}
}

View File

@@ -36,7 +36,7 @@ package com.jacob.com;
*/
public class STA extends Thread {
/**
* TODO: no references exist to this. should it be dropped
* referenced by STA.cpp
*/
public int threadID;

View File

@@ -67,11 +67,19 @@ public class SafeArray extends JacobObject {
}
/**
* constructor
* @param vt
* @param lbounds
* @param celems
*/
* constructor (needs more java doc)
*
* With the addition of N-dimensional array support
*
* You create an N-D SafeArray by: SafeArray sa = new
* SafeArray(Variant.VariantVariant, new int[] {0,0,0,0}, new int[]
* {4,4,4,4}); Where the 1st array is lower bounds and 2nd has the lengths
* of each dimension *
*
* @param vt
* @param lbounds
* @param celems
*/
public SafeArray(int vt, int lbounds[], int celems[]) {
init(vt, lbounds, celems);
}
@@ -547,7 +555,7 @@ public class SafeArray extends JacobObject {
public native void setByte(int sa_idx1, int sa_idx2, byte c);
/**
* Fills byte array(?) from contents of this array
* Fills byte array from contents of this array
* @param sa_idx
* @param nelems
* @param ja
@@ -753,6 +761,127 @@ public class SafeArray extends JacobObject {
return s;
}
/*================================================================
* The beginning of N-dimensional array support
*================================================================*/
/**
* get Variant value from N-dimensional array
* @param indices - length must equal Dimension of SafeArray
*/
public native Variant getVariant(int indices[]);
/**
* set Variant value in N-dimensional array
* @param indices - length must equal Dimension of SafeArray
* @param v
*/
public native void setVariant(int indices[], Variant v);
/**
* get char value from N-dimensional array
* @param indices - length must equal Dimension of SafeArray
*/
public native char getChar(int indices[]);
/**
* set char value in N-dimensional array
* @param indices - length must equal Dimension of SafeArray
* @param c
*/
public native void setChar(int indices[], char c);
/**
* get int value from N-dimensional array
* @param indices - length must equal Dimension of SafeArray
*/
public native int getInt(int indices[]);
/**
* set int value in N-dimensional array
* @param indices - length must equal Dimension of SafeArray
* @param c
*/
public native void setInt(int indices[], int c);
/**
* get short value from N-dimensional array
* @param indices - length must equal Dimension of SafeArray
*/
public native short getShort(int indices[]);
/**
* set short value in N-dimensional array
* @param indices - length must equal Dimension of SafeArray
* @param c
*/
public native void setShort(int indices[], short c);
/**
* get double value from N-dimensional array
* @param indices - length must equal Dimension of SafeArray
*/
public native double getDouble(int indices[]);
/**
* set double value in N-dimensional array
* @param indices - length must equal Dimension of SafeArray
* @param c
*/
public native void setDouble(int indices[], double c);
/**
* get String value from N-dimensional array
* @param indices - length must equal Dimension of SafeArray
*/
public native String getString(int indices[]);
/**
* set Stringvalue in N-dimensional array
* @param indices - length must equal Dimension of SafeArray
* @param c
*/
public native void setString(int indices[], String c);
/**
* get byte value from N-dimensional array
* @param indices - length must equal Dimension of SafeArray
*/
public native byte getByte(int indices[]);
/**
* set byte value in N-dimensional array
* @param indices - length must equal Dimension of SafeArray
* @param c
*/
public native void setByte(int indices[], byte c);
/**
* get float value from N-dimensional array
* @param indices - length must equal Dimension of SafeArray
*/
public native float getFloat(int indices[]);
/**
* set float value in N-dimensional array
* @param indices - length must equal Dimension of SafeArray
* @param c
*/
public native void setFloat(int indices[], float c);
/**
* get boolean value from N-dimensional array
* @param indices - length must equal Dimension of SafeArray
*/
public native boolean getBoolean(int indices[]);
/**
* set boolean value in N-dimensional array
* @param indices - length must equal Dimension of SafeArray
* @param c
*/
public native void setBoolean(int indices[], boolean c);
static {
System.loadLibrary("jacob");
}

View File

@@ -29,6 +29,8 @@
*/
package com.jacob.com;
import java.util.Date;
/**
* The multi-format data type used for all call backs and most communications
* between Java and COM. It provides a single class that can handle all data
@@ -122,13 +124,21 @@ public class Variant extends JacobObject implements java.io.Serializable {
/** variant's type is a reference (to IDispatch?) */
public static final short VariantByref = 16384;
/** @return the value of this variant as an int */
/**
* @return the value of this variant as an int
* (after possible conversion)
*/
public native int toInt();
/** @return the value of this variant as a date */
/**
* @return the value of this variant as a date
* (after possible conversion)
*/
public native double toDate();
/** @return the value of this variant as boolean */
/**
* @return the value of this variant as boolean (after possible conversion)
*/
public native boolean toBoolean();
/** @return the value of this variant as an enumeration (java style) */
@@ -208,6 +218,21 @@ public class Variant extends JacobObject implements java.io.Serializable {
*/
public native void putDateRef(double in);
/**
* converts a java date to a windows time and calls putDateRef(double)
* SF 959382
* @throws IllegalArgumentException if inDate = null
* @param inDate a Java date to be converted
*/
public void putDateRef(Date inDate){
if (inDate == null){
throw new IllegalArgumentException("Cannot put null in as windows date");
// do nothing
} else {
putDateRef(DateUtilities.convertDateToWindowsTime(inDate));
}
}
/**
* set the content of this variant to a string (VT_BSTR|VT_BYREF)
* @param in
@@ -250,6 +275,21 @@ public class Variant extends JacobObject implements java.io.Serializable {
*/
public native double getDateRef();
/**
* returns the windows time contained in this Variant to a Java Date
* should return null if this is not a date reference Variant
* SF 959382
* @return java.util.Date
*/
public Date getJavaDateRef(){
double windowsDate = getDateRef();
if (windowsDate == 0){
return null;
} else {
return DateUtilities.convertWindowsTimeToDate(getDate());
}
}
/**
* get the content of this variant as a string
* @return String
@@ -300,6 +340,21 @@ public class Variant extends JacobObject implements java.io.Serializable {
*/
public native double getDate();
/**
* returns the windows time contained in this Variant to a Java Date
* should return null if this is not a date Variant
* SF 959382
* @return java.util.Date
*/
public Date getJavaDate(){
double windowsDate = getDate();
if (windowsDate == 0){
return null;
} else {
return DateUtilities.convertWindowsTimeToDate(getDate());
}
}
/**
* set the value of this variant
* @param in
@@ -312,8 +367,24 @@ public class Variant extends JacobObject implements java.io.Serializable {
*/
public native void putDate(double in);
/**
* converts a java date to a windows time and calls putDate(double)
* SF 959382
* @throws IllegalArgumentException if inDate = null
* @param inDate a Java date to be converted
*/
public void putDate(Date inDate){
if (inDate == null){
throw new IllegalArgumentException("Cannot put null in as windows date");
// do nothing
} else {
putDate(DateUtilities.convertDateToWindowsTime(inDate));
}
}
/**
* attempts to return the content of this variant as a double
* (after possible conversion)
* @return byte
*/
public native byte toByte();
@@ -334,8 +405,16 @@ public class Variant extends JacobObject implements java.io.Serializable {
putObject(in);
}
/**
*
* @return the value in this Variant as a boolean, null if not a boolean
*/
public native boolean getBoolean();
/**
*
* @return the value in this Variant as a byte, null if not a byte
*/
public native byte getByte();
public native void putBoolean(boolean in);
@@ -369,6 +448,10 @@ public class Variant extends JacobObject implements java.io.Serializable {
public native void putDouble(double in);
/**
*
* @return the value in this Variant as a long, null if not a long
*/
public native long getCurrency();
public native void putFloatRef(float in);
@@ -401,6 +484,11 @@ public class Variant extends JacobObject implements java.io.Serializable {
public native byte getByteRef();
/**
* attempts to return the contents of this variant as a float
* (after possible conversion)
* @return float
*/
public native float toFloat();
/**
@@ -472,8 +560,7 @@ public class Variant extends JacobObject implements java.io.Serializable {
init();
putEmpty();
if (isDebugEnabled()) {
debug("create " + getClass().getName() + " in thread "
+ Thread.currentThread().getName());
debug("Variant: " + "create " + this );
}
}
@@ -626,6 +713,11 @@ public class Variant extends JacobObject implements java.io.Serializable {
public native short getvt();
/**
* attempts tor return the contents of this Variant as a short
* (after possible conversion)
* @return short
*/
public native short toShort();
/**
@@ -662,7 +754,7 @@ public class Variant extends JacobObject implements java.io.Serializable {
// this should almost always happen due to gc
// after someone has called ComThread.Release
if (isDebugEnabled()) {
debug(this.getClass().getName() + ":" + this.hashCode()
debug("Variant: " + this.hashCode()
+ " double release");
//Throwable x = new Throwable();
//x.printStackTrace();

View File

@@ -1,3 +1,22 @@
/*
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
* All rights reserved. Originator: Dan Adler (http://danadler.com).
* Get more information about JACOB at www.sourceforge.net/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;
/**

View File

@@ -27,10 +27,15 @@
package com.jacob.com;
/**
* TODO: Exception thrown when? No references found
* thrown in util.cpp
*/
public class WrongThreadException extends RuntimeException {
/**
* identifier generated by Eclipse
*/
private static final long serialVersionUID = 6308780364980228692L;
/**
* standard 0 arg constructor with no message
*
*/