Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Eol (#326)
* Reenable archival thunk code and rework setup. * Fixed EOL to LF.
- Loading branch information
Showing
167 changed files
with
18,811 additions
and
18,596 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
* test=auto | ||
|
||
# Specify lf for all source files | ||
*.py text eol=lf | ||
*.cpp text eol=lf | ||
*.c text eol=lf | ||
*.h text eol=lf | ||
|
||
*.xml text eol=lf | ||
*.txt text | ||
.gitignore text eol=lf | ||
.gitattributes text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -22,3 +22,4 @@ Huge thanks to these CONTRIBUTORS: | ||
* Martin K. Scherer | ||
* Dongwon Shin | ||
* rbprogrammer | ||
* Karl Einar Nelson |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
This example of using JPype and JMS contributed by David Morgenthaler | ||
Here is the message that accompanied it when he posted it on comp.lang.python : | ||
============================================================================= | ||
Your question intrigued me, so I gave it a try. And the anwer (at | ||
least for JMS Publish/Subscribe TextMessages) is YES. | ||
It includes: | ||
- Java classes for a publisher (src/messaging/JpypePublisher) and a | ||
subscriber (src/messaging/JpypeSubscriber). These Java classes, which | ||
do most of the dirty work of connecting to the JMS server, are used | ||
from python via jpype. | ||
- Java classes that test the publisher and subscriber | ||
(src/messaging/testJpepePublisher, src/messaging/testJpypeSubscriber) | ||
- A Java interface that is used by python for the JProxy | ||
- python scripts for publishing and subscribing | ||
- An build.xml for ant to build and run the Java classes | ||
The Java and python publishers and subscribers work in any reasonable | ||
combination (J pub/J sub, J pub/p sub, p pub/p sub, p pub/J sub, and | ||
even with multiple subscribers) | ||
Copy conveniently located folder. You'll find a build.xml for | ||
ant to build the Java. You'll have to edit (in the testers and in the | ||
python scripts) the naming and connection factory stuff for your | ||
situation. You'll also have to edit the python scripts to correctly | ||
locate your jvm and other classpath information. Once you're correctly | ||
configured, you can use ant to build and/or execute the Java (type | ||
"ant help"). And once the Java is built, you can try the python | ||
versions. | ||
I can't imagine that this approach wouldn't work for JMS Queues. And | ||
while I haven't tested it, I don't see anything preventing the use of | ||
other message types (BinaryMessage, ObjectMessage,...). | ||
BTW, I don't detect any noticable slowdown in the python versions from | ||
the Java versions (probably because of the strightforward conversion | ||
of python strings to Java Strings). | ||
This example of using JPype and JMS contributed by David Morgenthaler | ||
|
||
Here is the message that accompanied it when he posted it on comp.lang.python : | ||
============================================================================= | ||
Your question intrigued me, so I gave it a try. And the anwer (at | ||
least for JMS Publish/Subscribe TextMessages) is YES. | ||
|
||
It includes: | ||
- Java classes for a publisher (src/messaging/JpypePublisher) and a | ||
subscriber (src/messaging/JpypeSubscriber). These Java classes, which | ||
do most of the dirty work of connecting to the JMS server, are used | ||
from python via jpype. | ||
- Java classes that test the publisher and subscriber | ||
(src/messaging/testJpepePublisher, src/messaging/testJpypeSubscriber) | ||
- A Java interface that is used by python for the JProxy | ||
- python scripts for publishing and subscribing | ||
- An build.xml for ant to build and run the Java classes | ||
|
||
The Java and python publishers and subscribers work in any reasonable | ||
combination (J pub/J sub, J pub/p sub, p pub/p sub, p pub/J sub, and | ||
even with multiple subscribers) | ||
|
||
Copy conveniently located folder. You'll find a build.xml for | ||
ant to build the Java. You'll have to edit (in the testers and in the | ||
python scripts) the naming and connection factory stuff for your | ||
situation. You'll also have to edit the python scripts to correctly | ||
locate your jvm and other classpath information. Once you're correctly | ||
configured, you can use ant to build and/or execute the Java (type | ||
"ant help"). And once the Java is built, you can try the python | ||
versions. | ||
|
||
I can't imagine that this approach wouldn't work for JMS Queues. And | ||
while I haven't tested it, I don't see anything preventing the use of | ||
other message types (BinaryMessage, ObjectMessage,...). | ||
|
||
BTW, I don't detect any noticable slowdown in the python versions from | ||
the Java versions (probably because of the strightforward conversion | ||
of python strings to Java Strings). | ||
|
||
============================================================================= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
from jpype import * | ||
import time | ||
|
||
NUMMSGS = 10 | ||
|
||
def pyPublisher (javaNamingFactory="weblogic.jndi.WLInitialContextFactory", | ||
javaNamingProvider="t3://158.188.40.21:7001", | ||
connectionFactory="weblogic.jms.ConnectionFactory", | ||
topicName="defaultTopic"): | ||
return messaging.JpypePublisher(javaNamingFactory,javaNamingProvider, | ||
connectionFactory,topicName) | ||
|
||
## Startup Jpype and import the messaging java package | ||
startJVM("C:\\program files\\Java\\j2re1.4.2_02\\bin\\client\\jvm.dll", | ||
"-Djava.class.path=D:/jIRAD/JpypeJMS/src;D:/jIRAD/JpypeJMS/classes;C:/bea/weblogic81/server/lib/weblogic.jar") | ||
messaging = JPackage('messaging') | ||
|
||
# Get a publisher | ||
publisher = pyPublisher() | ||
|
||
## Timing test | ||
# The "Start" message signals the subscriber to start timing message receipts | ||
publisher.publish("Start") | ||
|
||
t0 = time.time() | ||
for i in range(NUMMSGS): | ||
publisher.publish("Hello World! %s"%i) | ||
print "MessageRate =",float(NUMMSGS)/(time.time()-t0) | ||
|
||
# The "Stop" message signals the subscriber to stop timing message receipts | ||
publisher.publish("Stop") | ||
|
||
# Close and quit | ||
publisher.close() | ||
shutdownJVM() | ||
from jpype import * | ||
import time | ||
|
||
NUMMSGS = 10 | ||
|
||
def pyPublisher (javaNamingFactory="weblogic.jndi.WLInitialContextFactory", | ||
javaNamingProvider="t3://158.188.40.21:7001", | ||
connectionFactory="weblogic.jms.ConnectionFactory", | ||
topicName="defaultTopic"): | ||
return messaging.JpypePublisher(javaNamingFactory,javaNamingProvider, | ||
connectionFactory,topicName) | ||
|
||
## Startup Jpype and import the messaging java package | ||
startJVM("C:\\program files\\Java\\j2re1.4.2_02\\bin\\client\\jvm.dll", | ||
"-Djava.class.path=D:/jIRAD/JpypeJMS/src;D:/jIRAD/JpypeJMS/classes;C:/bea/weblogic81/server/lib/weblogic.jar") | ||
messaging = JPackage('messaging') | ||
|
||
# Get a publisher | ||
publisher = pyPublisher() | ||
|
||
## Timing test | ||
# The "Start" message signals the subscriber to start timing message receipts | ||
publisher.publish("Start") | ||
|
||
t0 = time.time() | ||
for i in range(NUMMSGS): | ||
publisher.publish("Hello World! %s"%i) | ||
print "MessageRate =",float(NUMMSGS)/(time.time()-t0) | ||
|
||
# The "Stop" message signals the subscriber to stop timing message receipts | ||
publisher.publish("Stop") | ||
|
||
# Close and quit | ||
publisher.close() | ||
shutdownJVM() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
from jpype import * | ||
import time | ||
|
||
def pySubscriber (proxy, | ||
javaNamingFactory="weblogic.jndi.WLInitialContextFactory", | ||
javaNamingProvider="t3://158.188.40.21:7001", | ||
connectionFactory="weblogic.jms.ConnectionFactory", | ||
topicName="defaultTopic"): | ||
return messaging.JpypeSubscriber(proxy,javaNamingFactory,javaNamingProvider, | ||
connectionFactory,topicName) | ||
|
||
## Startup Jpype and import the messaging java package | ||
startJVM("C:\\program files\\Java\\j2re1.4.2_02\\bin\\client\\jvm.dll", | ||
"-Djava.class.path=D:/jIRAD/JpypeJMS/src;D:/jIRAD/JpypeJMS/classes;C:/bea/weblogic81/server/lib/weblogic.jar") | ||
messaging = JPackage('messaging') | ||
|
||
# Setup the JProxy for the messaging.JpypeSubscriberCallback interface | ||
class pyCallback: | ||
startTime = 0 | ||
count = 0 | ||
def onMessage (self,text): | ||
print text | ||
if text=='Start': | ||
pyCallback.startTime=time.time() | ||
pyCallback.count = 0 | ||
elif text=='Stop': | ||
print "Message Rate =",float(pyCallback.count)/(time.time()-pyCallback.startTime) | ||
else: | ||
pyCallback.count += 1 | ||
|
||
c = pyCallback() | ||
proxy = JProxy(messaging.JpypeSubscriberCallback,inst=c) | ||
|
||
# Get a subscriber | ||
sub = pySubscriber(proxy) | ||
print "Listening..." | ||
|
||
# Prevent this thread from exiting | ||
time.sleep(1000) | ||
|
||
# exit | ||
shutdownJVM() | ||
from jpype import * | ||
import time | ||
|
||
def pySubscriber (proxy, | ||
javaNamingFactory="weblogic.jndi.WLInitialContextFactory", | ||
javaNamingProvider="t3://158.188.40.21:7001", | ||
connectionFactory="weblogic.jms.ConnectionFactory", | ||
topicName="defaultTopic"): | ||
return messaging.JpypeSubscriber(proxy,javaNamingFactory,javaNamingProvider, | ||
connectionFactory,topicName) | ||
|
||
## Startup Jpype and import the messaging java package | ||
startJVM("C:\\program files\\Java\\j2re1.4.2_02\\bin\\client\\jvm.dll", | ||
"-Djava.class.path=D:/jIRAD/JpypeJMS/src;D:/jIRAD/JpypeJMS/classes;C:/bea/weblogic81/server/lib/weblogic.jar") | ||
messaging = JPackage('messaging') | ||
|
||
# Setup the JProxy for the messaging.JpypeSubscriberCallback interface | ||
class pyCallback: | ||
startTime = 0 | ||
count = 0 | ||
def onMessage (self,text): | ||
print text | ||
if text=='Start': | ||
pyCallback.startTime=time.time() | ||
pyCallback.count = 0 | ||
elif text=='Stop': | ||
print "Message Rate =",float(pyCallback.count)/(time.time()-pyCallback.startTime) | ||
else: | ||
pyCallback.count += 1 | ||
|
||
c = pyCallback() | ||
proxy = JProxy(messaging.JpypeSubscriberCallback,inst=c) | ||
|
||
# Get a subscriber | ||
sub = pySubscriber(proxy) | ||
print "Listening..." | ||
|
||
# Prevent this thread from exiting | ||
time.sleep(1000) | ||
|
||
# exit | ||
shutdownJVM() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
The 2 scripts in this derectory are here to resolve a weakness in the linux implementation. | ||
Since the JVM is loaded dynamically, the LD_LIBRARY_PATH may not contain the proper directories. | ||
Unfortunately, dlopen() will ignore any changes made to the LD_LIBRARY_PATH in the current process. | ||
The jpype.sh is meant as an example for people redistributing apps using jpype. Instead of having | ||
users launch python script.py directly, have then launch script.sh. The companion finjvm.py can be | ||
delivered along your app, but is also present in the ptyhon distribution of jpype. | ||
Developpers are encouraged to make their lives simpler by adding the correct directories to their | ||
LD_LIBRARY_PATH directly. | ||
To learn more about the dlopen problem, you can look at : | ||
http://forum.java.sun.com/thread.jsp?forum=52&thread=303583&message=1210441 | ||
and | ||
http://www.nathanr.net/diary/index.php?year=2004&month=05 | ||
The 2 scripts in this derectory are here to resolve a weakness in the linux implementation. | ||
|
||
Since the JVM is loaded dynamically, the LD_LIBRARY_PATH may not contain the proper directories. | ||
|
||
Unfortunately, dlopen() will ignore any changes made to the LD_LIBRARY_PATH in the current process. | ||
|
||
The jpype.sh is meant as an example for people redistributing apps using jpype. Instead of having | ||
users launch python script.py directly, have then launch script.sh. The companion finjvm.py can be | ||
delivered along your app, but is also present in the ptyhon distribution of jpype. | ||
|
||
Developpers are encouraged to make their lives simpler by adding the correct directories to their | ||
LD_LIBRARY_PATH directly. | ||
|
||
To learn more about the dlopen problem, you can look at : | ||
|
||
http://forum.java.sun.com/thread.jsp?forum=52&thread=303583&message=1210441 | ||
|
||
and | ||
|
||
http://www.nathanr.net/diary/index.php?year=2004&month=05 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
#***************************************************************************** | ||
# Copyright 2004-2008 Steve Menard | ||
# | ||
# 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. | ||
# | ||
#***************************************************************************** | ||
import jpype, os.path | ||
|
||
jvmlib = jpype.getDefaultJVMPath() | ||
print os.path.dirname(os.path.dirname(jvmlib)) | ||
#***************************************************************************** | ||
# Copyright 2004-2008 Steve Menard | ||
# | ||
# 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. | ||
# | ||
#***************************************************************************** | ||
import jpype, os.path | ||
|
||
jvmlib = jpype.getDefaultJVMPath() | ||
print os.path.dirname(os.path.dirname(jvmlib)) |
Oops, something went wrong.