java (11)

در نمایش آنلاین پاورپوینت، ممکن است بعضی علائم، اعداد و حتی فونت‌ها به خوبی نمایش داده نشود. این مشکل در فایل اصلی پاورپوینت وجود ندارد.




  • جزئیات
  • امتیاز و نظرات
  • متن پاورپوینت

امتیاز

درحال ارسال
امتیاز کاربر [0 رای]

نقد و بررسی ها

هیچ نظری برای این پاورپوینت نوشته نشده است.

اولین کسی باشید که نظری می نویسد “Mixing Python and Java”

Mixing Python and Java

اسلاید 1: Folie 1EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Mixing Python and JavaHow Python and Java can communicate and work togetherEuroPython 2009 (June 30th 2009, Birmingham) Andreas Schreiber <Andreas.Schreiber@dlr.de> German Aerospace Center (DLR), Cologne, Germany http://www.dlr.de/sc

اسلاید 2: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Follow this presentation…twitter.com/python_demoLive! PowerPoint to Twitter!

اسلاید 3: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Final Version of this Slides is available on SlideSharehttp://tr.im/ep09java

اسلاید 4: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009DLR German Aerospace CenterResearch InstitutionSpace AgencyProject Management Agency

اسلاید 5: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009n Koelnn Lampoldshausenn Stuttgartn OberpfaffenhofenBraunschweig nn GoettingenBerlin- nn BonnTrauen nn Hamburgn NeustrelitzWeilheim nBremen- nLocations and employees6000 employees across 29 research institutes and facilities at13 sites.Offices in Brussels, Paris and Washington.

اسلاید 6: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Research AreasAeronauticsSpaceTransportEnergySpace AgencyProject Management Agency

اسلاید 7: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Mixing Python and Java? JythonIs it all about?

اسلاید 8: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Mixing Python and Java? OutlineAccessing Python from JavaJythonJEPPAccessing Java from PythonJPypeJCCInter-process communicationCORBASOAPOther remote object libraries

اسلاید 9: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Java Why People are Using Java?Widely used in many different application domainsindustry/business, research, academiaAvailable on many different platformsGood performancegood Garbage Collector (and no GIL)Many, many libraries E.g., for data base access, XML processing, PDF generation, security, or user interfacesAvailability of good documentation for all aspects of Java programmingVery good development toolsEclipse, NetBeans, IntelliJ IDEA, …

اسلاید 10: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Python Why People are Using Python?Python in Research and Industry Scientists and engineers don’t want to write software but just solve their problems If they have to write code, it must be as easy as possibleReasons for Python? Very easy to learn and easy to use ( = steep learning curve)Allows rapid development ( = short development time)Inherent great maintainability “I want to design planes, not software!”

اسلاید 11: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009“Python has the cleanest, most-scientist- or engineer friendly syntax and semantics.-Paul F. DuboisPaul F. Dubois. Ten good practices in scientific programming. Comp. In Sci. Eng., Jan/Feb 1999, pp.7-11

اسلاید 12: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Why Mixing Java and Python? Embedded scripting and more…Many mature Java applications and frameworks existsLots of commercial and Open Source software systems and librariesFor example, The Eclipse Universe, Apache-Software, Portal-Frameworks, Workflows systems, …Common use casesAdd embedded (Python) scripting to Java applicationsUse Java libraries from Python code

اسلاید 13: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Why Mixing Java and Python? Integration of Python code into Java applications…Existing code or libraries exist either for Java or Python onlyEffort to re-implement the functionalities could be very highIf the library is very well tested, it could be an enormous effort to reach a comparable level of qualityCommon use casesJust use an existing library from the “other” languageEspecially, use Python code (or C/Fortran/WHATEVER code with Python wrappers) from JavaIts harder to wrap C codes in Java than in Python (see CTypes)

اسلاید 14: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Example QF-Test – Automated GUI Testing

اسلاید 15: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Example TENT – Software Integration and Workflow Management

اسلاید 16: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Use Cases for Python Scripting (1)Steering and controlling the program by user defined scriptsApplications are complex parameter variations or steering multidisciplinary coupled simulationsAutomation of repeating tasksIn most cases, this is called “macro” recording and replayingExtending user interfacesFor example, with additional customized dialogs and other extensionsIn Java, this requires scripts which use the Java GUI libraries (AWT, Swing, or SWT)Integration of additional legacy toolsImportant and widely used for integration and workflow systems End users can integrate external codes without changing the Java program itself

اسلاید 17: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Use Cases for Python Scripting (2)Interactive experimentation and debugging of the Java programCan be easily done with an embedded interactive interpreter Allows end users and software developers to debug and analyze the Java program during runtimeCreating automated tests for quality assuranceRecording user actions during runtime of the Java program as a Python script (“Journaling)Editing and generalizing the recorded scriptReplaying the script manually or automatically

اسلاید 18: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Example: Codes with Python Interfaces Numerical Simulation Software in C++ or Fortran Examples for high-definition CFD-Solver with Python interfacesDLR TAU-Code (http://www.dlr.de/as)ONERA elsA-Code (http://elsa.onera.fr)Integration into Java workflow systems with the following techniques… EurofighterX-31

اسلاید 19: Folie 19EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Tools for Python-Java-IntegrationPython InterpreterPython InterpreterJava Virtual Machine (JVM)Java Code (Anwendung)JEPPJNIPython CodeJPypeJythonPython CodeInterface/ProtokollPython CodePython Code

اسلاید 20: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Accessing Python from JavaUse casesThe application should have embedded scripting functionality.The application should use an external code written in Python.The application should use an external code written in Python or other languages such as C, C++, Fortran.ToolsJythonJEPP

اسلاید 21: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Java Virtual MachineJythonComplete re-implementation of the Python interpreter in JavaPython code runs in the Java VMWebsite: http://www.jython.orgLatest version: Jython 2.5For details & questions, catchTobias Ivarsson Frank Wierzbicki and others here at EuroPython  JythonPython CodeJava ApplicationCode

اسلاید 22: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Jython Code Example 1: Java codeExecute Python codeimport org.python.util.PythonInterpreter ;import org.python.core.*;class TestClass { public static void main(String[] args) { try { org.python.util.PythonInterpreter python = new org.python.util.PythonInterpreter (); python.execfile(python_script.py); } catch (Exception e) { System.out.println(“Some error!); }}

اسلاید 23: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Jython Code Example 2: Python codeUse Swingfrom javax.swing import *frame = JFrame(Hello Jython)label = JLabel(Hello Jython!, JLabel.CENTER)frame.add(label)frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE)frame.setSize(200, 100)frame.show()

اسلاید 24: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009JEPP Java Embedded PythonEmbeds CPython interpreter via Java Native Interface (JNI) in JavaPython code runs in CPythonWebsite: http://jepp.sourceforge.net/Python InterpreterJava Virtual MachineJava Application CodePython CodeJNIJEPP

اسلاید 25: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009JEPP Code ExampleExecute (“evaluate”) Python statementsExecute a Python script fileJep jep = new Jep(false, SCRIPT_PATH, cl);jep.eval(print hello);jep.close();Jep jep = new Jep(false, SCRIPT_PATH, cl);jep.runScript(SCRIPT_PATH + file);jep.close();

اسلاید 26: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Accessing Java from PythonUse casesThe application should use an external Java application.The application should use a Java library.ToolsJPypeJCC

اسلاید 27: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Python InterpreterJNIJPypePython Application CodeJava Virtual MachineJava ApplicationCodeJPype Java to Python IntegrationInterface on native level of both (Java & Python) Virtual Machines/InterpretersStarts a Java Virtual MachineWebsite: http://jpype.sourceforge.net

اسلاید 28: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009JPype Code Example (1)Hello Worldfrom jpype import *# Start JVMstartJVM (path to jvm.dll, -ea)# Print Hello Worldjava.lang.System.out.println(Hello World)# Shutdown JVMshutdownJVM()

اسلاید 29: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009JPype Code Example (2)Call Java methods from Pythonimport jpype# Start JVMjpype.startJVM(path to jvm.dll, -ea)# Create reference to java packagejavaPackage = jpype.JPackage(JavaPackageName)# Create reference to java classjavaClass = javaPackage.JavaClassName# Create instance of java classjavaObject = javaClass()# Call java methodsjavaObject.JavaMethodName()# Shutdown JVMjpype.shutdownJVM()

اسلاید 30: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009JCC PyLucenes Code GeneratorC++ code generator for calling Java from C++/PythonC++ object interface for wrapping a Java library via JNIGenerates complete CPython extensionSupported on Mac OS X, Linux, Solaris and Windows, requires C++ compilerWebsite: http://lucene.apache.org/pylucene/jcc Part of PyLucenePython InterpreterJNIPython CodeJava Virtual MachineJava ApplicationCode pythonExtension()Generated C++ Wrapper CodeJCC Code Generator

اسلاید 31: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009JCC Code ExampleRequirement: VM initializationimport jcc# Start JVMjcc.initVM(maxheap=‘2000m’, …)

اسلاید 32: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009JCC Code Example Using PyLucene: Search Lucene IndexSearch for „Query“ in directory „index“from lucene import QueryParser, IndexSearcher, StandardAnalyzer, FSDirectory, Hit, VERSION, initVM, CLASSPATHinitVM(CLASSPATH)directory = FSDirectory.getDirectory(“index”, False)searcher = IndexSearcher(directory)analyzer = StandardAnalyzer()command = raw_input(Query:)query = QueryParser(contents, analyzer).parse(command)hits = searcher.search(query)for hit in hits: doc = Hit.cast_(hit).getDocument() print path:, doc.get(path), name:, doc.get(name)searcher.close()

اسلاید 33: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Inter-Process CommunicationInter-process communication (IPC) is data exchange between different processes on one or more computers connected by a network Typical IPC techniques are remote procedure calls (RPC)message passing.The most common APIs areObject Request Broker (ORB) or Web Services protocols based on XML.A drawback is the need for additional services, such as a directory service for registration and location of remote objectsNaming Service for CORBAUniversal Description, Discovery and Integration (UDDI) for Web Services

اسلاید 34: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Java Virtual MachineGeneratedJava Code(Stub)Python InterpreterObject Request Broker (ORBs) CORBAORBPython ApplicationCode (Server)Generated Python Code (Skeleton)JavaApplicationCode (Client)IDL CompilerIDL

اسلاید 35: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009CORBA Implementations for PythonFnorb Pure Python implementation that works with CPython and Jython. It is a light-weight CORBA implementation and interoperable with the standard Java ORB. The development of Fnorb has ended.omniORB An ORB implementation for C++ and Python that can be used from CPython. The Python ORB (omniORBpy) uses the C++ implementation of omniORB. omniORB is actively developed with regular releases.Website: http://omniorb.sourceforge.net

اسلاید 36: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009CORBA Example InterfaceHello World interface in Interface Definition Language (IDL)module HelloWorld { const string Message = Hello CORBA World!; interface Hello {string hello_world(); };};

اسلاید 37: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009CORBA Example Python Server (Fnorb): Implementation of Interface# Standard/built-in modules.import sys# Fnorb modules.from Fnorb.orb import BOA, CORBA# Stubs and skeletons generated by fnidl.import HelloWorld, HelloWorld_skelclass HelloWorldServer(HelloWorld_skel.Hello_skel): Implementation of the Hello interface. def hello_world(self): print HelloWorld.Message return HelloWorld.Message

اسلاید 38: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009CORBA Example Python Server (Fnorb): Main Functiondef main(argv): # Initialise ORB and BOA orb = CORBA.ORB_init(argv, CORBA.ORB_ID) boa = BOA.BOA_init(argv, BOA.BOA_ID) # Create object reference obj = boa.create(fred, HelloWorldServer._FNORB_ID) # Create an instance of the implementation class. impl = HelloWorldServer() # Activate the implementation boa.obj_is_ready(obj, impl) # Write the stringified object reference to a file open(Server.ref, w).write(orb.object_to_string(obj)) boa._fnorb_mainloop() # Start the event loop return 0

اسلاید 39: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009CORBA Example Java Clientpublic class Client { public static void main ( String args[] ) { java.util.Properties props = System.getProperties(); try { org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,props); org.omg.CORBA.Object obj = null; java.io.BufferedReader in = new java.io.BufferedReader( new java.io.FileReader(“Server.ref)); String ref = in.readLine(); obj = orb.string_to_object(ref); Hello hello = HelloHelper.narrow(obj); hello.hello_world(); orb.destroy(); } catch (Exception e) { e.printStackTrace(); }}

اسلاید 40: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Web Services: SOAPJava Virtual MachineServlet ContainerJavaApplicationCode (Server)Python InterpreterGenerated Python Code (Stub)Python ApplicationCode (Client)GeneratedJava Code(Skeleton)WSDL CompilerWSDL

اسلاید 41: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Web Services for PythonZolera SOAP Infrastructure (ZSI)For Python the only remaining SOAP toolkit of considerable quality is the Zolera SOAP Infrastructure (ZSI)

اسلاید 42: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Other Remote Object LibrariesPython Remote Objects (Pyro) Pyro is similar to Javas Remote Method Invocation (RMI). It is simple, very portable, and works with Jython. Brings its own Naming Service for locating remote objects. Pyro is actively developed with regular new releases.Simple Python Interface to Remote Objects (SPIRO)SPIRO implements an ORB and is developed as a bridge between CPython and Jython. The development has ended.

اسلاید 43: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Conclusions… but there are alternatives which makes sense for certain use cases!I Jython

اسلاید 44: EuroPython 2009 > Andreas Schreiber > Mixing Python and Java > 01.07.2009Questions?Contacthttp://tr.im/schreibertwitter.com/onyamepython@dlr.de

34,000 تومان

خرید پاورپوینت توسط کلیه کارت‌های شتاب امکان‌پذیر است و بلافاصله پس از خرید، لینک دانلود پاورپوینت در اختیار شما قرار خواهد گرفت.

در صورت عدم رضایت سفارش برگشت و وجه به حساب شما برگشت داده خواهد شد.

در صورت بروز هر گونه مشکل به شماره 09353405883 در ایتا پیام دهید یا با ای دی poshtibani_ppt_ir در تلگرام ارتباط بگیرید.

افزودن به سبد خرید