<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5534616972635403710</id><updated>2013-05-14T08:08:41.384+01:00</updated><category term='PHP'/><category term='reflection'/><category term='fields'/><category term='UTF-8'/><category term='encoding'/><category term='bridge'/><category term='patterns'/><category term='magic'/><category term='static'/><category term='v7'/><category term='Message Broker'/><category term='application integration'/><category term='eclipse'/><category term='methods'/><category term='Java'/><category term='invoke'/><category term='subversion'/><title type='text'>Ant's Blog</title><subtitle type='html'>Healthcare, Java, PHP, Groovy, Security, Blah</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>24</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-5676192437773365010</id><published>2013-05-13T16:35:00.001+01:00</published><updated>2013-05-13T22:40:11.944+01:00</updated><title type='text'>Logging with Message Broker</title><content type='html'>Message Broker has several logging options all of which are valuable in different circumstances. First of all there is the new kid on the block: &lt;a href="http://www.ibm.com/developerworks/websphere/tutorials/1212_storey/"&gt;record and replay&lt;/a&gt;. This feature is designed to capture messages as they flow through Message Broker and store them in a database. Key fields can be selected and pulled out for searching and filtering. The Message Broker web application provides a nice easy to use UI for accessing the stored messages and replaying them if required. This is the ideal tool for auditing and long term storage.&lt;br /&gt;&lt;br /&gt;Activity log is another very useful facility. It provides a high level view of key&amp;nbsp;&lt;a href="http://publib.boulder.ibm.com/infocenter/wmbhelp/v8r0m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Fbj55170_.htm"&gt;activities&amp;nbsp;&lt;/a&gt;as they occur in Message Broker (file opened, message written, database updated etc). The key with activity log is that it is left on all the time. It consumes very little overhead and ensures there is always some diagnostics information available.&lt;br /&gt;&lt;br /&gt;User trace is text based and a much lower level view of what Message Broker is up to as it processes your messages. User trace supports several levels of verbosity. There is a trace node provided in Message Broker which adds your information to the Message Broker trace. Trace can be controlled with the &lt;span style="font-family: Courier New, Courier, monospace;"&gt;mqsichangetrace &lt;/span&gt;command and siblings (or equally through the Message Broker Java API and Message Broker Explorer). There is also service trace but that is really only intended for IBM to diagnose product issues.&lt;br /&gt;&lt;br /&gt;So there is something of a gap for a more flexible way to log output from message flows. With that in mind I've knocked up a logging node which you can use to instrument your message flows. The node is configurable and outputs its messages through the most excellent &lt;a href="http://logging.apache.org/log4j/2.x/"&gt;Log4J &lt;/a&gt;logging framework.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-AQd2P6sKdic/UZEIuvpzsWI/AAAAAAAAAIc/KUHNrxH2K1w/s1600/Log.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="102" src="http://4.bp.blogspot.com/-AQd2P6sKdic/UZEIuvpzsWI/AAAAAAAAAIc/KUHNrxH2K1w/s400/Log.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;You can read about what the node does in &lt;a href="https://sites.google.com/site/antblah/Logging.pdf"&gt;this&lt;/a&gt; PDF. The node works on Message Broker v8 Fix Pack 2 and later releases. Essentially the node writes messages to Log4J. The messages can contain anything including pieces of the actual message body being processing (for example, from an HL7 message). The output messages are collected into files according to their message flow, execution group and broker. You can switch logging on or off at any level at any time using a simple configuration file which is automatically reloaded. The node itself packaged as a JAR file &lt;a href="https://sites.google.com/site/antblah/LoggingNode.zip"&gt;here &lt;/a&gt;along with the source code &lt;a href="https://sites.google.com/site/antblah/LoggingSource.zip"&gt;here&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/5676192437773365010/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2013/05/healthcare-logging-with-message-broker.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/5676192437773365010'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/5676192437773365010'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2013/05/healthcare-logging-with-message-broker.html' title='Logging with Message Broker'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-AQd2P6sKdic/UZEIuvpzsWI/AAAAAAAAAIc/KUHNrxH2K1w/s72-c/Log.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-7010278210513555362</id><published>2013-04-07T17:18:00.001+01:00</published><updated>2013-05-06T11:34:06.185+01:00</updated><title type='text'>Healthcare Analytics with Message Broker</title><content type='html'>One feature I would like to call out in the new version of the &lt;a href="http://www.slideshare.net/AntPhillips/message-broker-healthcare-connectivity-pack"&gt;Healthcare Connectivity Pack&lt;/a&gt; is our healthcare analytics capability. This feature makes it incredibly easy to find, search and extract meaningful data from a range of healthcare data sources (HL7 v2, DICOM and CDA). The tooling can do this because it &lt;i&gt;understands&lt;/i&gt;&amp;nbsp;these healthcare formats, not just at a syntactic level but the semantics as well. This knowledge of a standard is encapsulated in what we call a Data Analysis Profile (DAP).&lt;br /&gt;&lt;br /&gt;For example, in the case of clinical documents, the CDA DAP understands the HL7 v3 RIM and structural attributes (such as &lt;span style="font-family: Courier New, Courier, monospace;"&gt;templateID&lt;/span&gt; and &lt;span style="font-family: Courier New, Courier, monospace;"&gt;root&lt;/span&gt;). With this understanding the tooling can pick apart clinical documents and show you the meaning of different sections (medications, procedures etc). This is just the tip of the iceberg, the tooling makes it a breeze to do really complex work with clinical documents.&lt;br /&gt;&lt;br /&gt;Another example are HL7 v2 observation results, the HL7 DAP understands where the coding system is stored in the OBX segment. Armed with this information the tooling deciphers LOINC codes to present user friendly display names when you are working with your data. In fact you can plug in your own bespoke coding systems as well (a common requirement in providers).&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-Iou9-JvialI/UWGaIUb93rI/AAAAAAAAAHc/1-Vsaaj-UpM/s1600/Analytics.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="211" src="http://3.bp.blogspot.com/-Iou9-JvialI/UWGaIUb93rI/AAAAAAAAAHc/1-Vsaaj-UpM/s400/Analytics.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Understanding and working with these healthcare standards is one big step forward, but the tooling goes way further. The tooling builds for you the Message Broker solution to validate inbound messages and extract the data you want. The data can be extracted into a simpler XML message format. This is the ideal approach if you want to send some extract of the healthcare data to a downstream application. Alternatively, the tooling can extract the data directly into database tables. In fact, the tooling will even design you the database table layout, key selection and everything else!&lt;br /&gt;&lt;br /&gt;If you are interested to learn more, take a look through &lt;a href="http://www.slideshare.net/AntPhillips/healthcare-analytics"&gt;these&lt;/a&gt; slides I have posted.</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/7010278210513555362/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2013/04/healthcare-analytics-with-message-broker.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/7010278210513555362'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/7010278210513555362'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2013/04/healthcare-analytics-with-message-broker.html' title='Healthcare Analytics with Message Broker'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-Iou9-JvialI/UWGaIUb93rI/AAAAAAAAAHc/1-Vsaaj-UpM/s72-c/Analytics.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-5896250670193986376</id><published>2013-04-07T16:47:00.000+01:00</published><updated>2013-04-07T21:03:06.950+01:00</updated><title type='text'>Medical Imaging (DICOM) with Message Broker</title><content type='html'>One of the key things we focus on with the &lt;a href="http://www.slideshare.net/AntPhillips/healthcare-overview-18356221"&gt;Healthcare Connectivity Pack&lt;/a&gt; is to have a single healthcare ESB which can work with a wide range of protocols, standards, transports and formats. This focus is becoming ever more important as healthcare organisations seek to join up more sources of data whether they be clinical, financial or anything else for that matter.&lt;br /&gt;&lt;br /&gt;In many healthcare organisations I talk to DICOM has traditionally been kept separate from the main line integration of clinical applications (often using HL7). This legacy is quickly disappearing though accelerated by many factors not least of which is work being done by IHE (for example, the&amp;nbsp;&lt;a href="http://wiki.ihe.net/index.php?title=Scheduled_Workflow"&gt;scheduled workflow profile&lt;/a&gt;&amp;nbsp;which requires integration between HL7 &lt;i&gt;and &lt;/i&gt;DICOM modalities).&lt;br /&gt;&lt;br /&gt;The latest version of the Healthcare Connectivity Pack includes support for medical imaging (DICOM). This enables a wide range of high value use cases. The diagram below shows an example walk through of how the Healthcare Connectivity Pack can route DICOM instances to external experts for a second opinion. This scenario comes in various flavours. For example, perhaps you have several radiologists and you want to work load balance between them. Alternatively, radiologists with specialist skills might be geographically dispersed and so DICOM images can be routed to the correct location.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-ppSZe5cRHoQ/UWGSGCU8opI/AAAAAAAAAHM/8lecBA6yWZQ/s1600/ExpertOpinion.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="263" src="http://1.bp.blogspot.com/-ppSZe5cRHoQ/UWGSGCU8opI/AAAAAAAAAHM/8lecBA6yWZQ/s400/ExpertOpinion.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Another use case is to pre-fetch DICOM instances when a patient is admitted to a hospital:&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-mxQjLywHN9A/UWGTaSX3DWI/AAAAAAAAAHU/_triDpZ8zTc/s1600/PreFetchOnAdmission.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="226" src="http://4.bp.blogspot.com/-mxQjLywHN9A/UWGTaSX3DWI/AAAAAAAAAHU/_triDpZ8zTc/s400/PreFetchOnAdmission.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;This scenario uses the Healthcare Connectivity Pack to pull down DICOM images to the local PACS so that the right information is in the right place for a patient's effective treatment. These scenarios uses a range of DICOM capabilities including C-FIND, C-STORE and C-MOVE.&lt;br /&gt;&lt;br /&gt;I've posted some slides &lt;a href="http://www.slideshare.net/AntPhillips/dicom-18356827"&gt;here &lt;/a&gt;which walk through all the technical details of the DICOM integration.</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/5896250670193986376/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2013/04/medical-imaging-dicom-and-message-broker.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/5896250670193986376'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/5896250670193986376'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2013/04/medical-imaging-dicom-and-message-broker.html' title='Medical Imaging (DICOM) with Message Broker'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-ppSZe5cRHoQ/UWGSGCU8opI/AAAAAAAAAHM/8lecBA6yWZQ/s72-c/ExpertOpinion.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-6844816440466310857</id><published>2013-04-07T16:17:00.006+01:00</published><updated>2013-04-07T16:20:10.326+01:00</updated><title type='text'>Healthcare Integration with Message Broker</title><content type='html'>&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;We have just &lt;a href="http://www-01.ibm.com/common/ssi/cgi-bin/ssialias?infotype=AN&amp;amp;subtype=CA&amp;amp;htmlfid=897/ENUS213-077&amp;amp;appname=USN"&gt;released&lt;/a&gt;&amp;nbsp;our latest and greatest healthcare integration product, the Message Broker Healthcare Connectivity Pack&lt;/span&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;. In the last three years we have made huge steps forward in the healthcare integration space, indeed we have had four product releases in the last two years alone.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;This new release comes packed with a host of new features:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul class="ibm-bullet-list ibm-no-links" style="background-color: white; font-family: Arial, sans-serif; margin-bottom: 2px; margin-top: 2px; padding-bottom: 2px; padding-top: 2px;"&gt;&lt;li&gt;&lt;b&gt;DICOM&lt;/b&gt;, the digital medical imaging standard, is now natively supported. It enables the integration of image archive systems (PACS) and imaging applications and also enables a broad range of high-value integration use cases such as &amp;nbsp;pre-fetch on admission.&lt;/li&gt;&lt;/ul&gt;&lt;ul class="ibm-bullet-list ibm-no-links" style="background-color: white; font-family: Arial, sans-serif; margin-bottom: 2px; margin-top: 2px; padding-bottom: 2px; padding-top: 2px;"&gt;&lt;li style="margin-bottom: 0px;"&gt;&lt;b&gt;Analytics&lt;/b&gt;, the ability to glean clinical insight, is now made easy with integrated tooling that quickly and easily extracts meaningful information from a range of medical sources. These sources include clinical documents (C-CDA/CDA/CCD/HITSP), DICOM images, and HL7 v2 messages. Meaningful data from these sources can be filtered, captured and fed directly into downstream applications and data warehouses for healthcare intelligence applications.&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;ul class="ibm-bullet-list ibm-no-links" style="background-color: white; font-family: Arial, sans-serif; margin-bottom: 2px; margin-top: 2px; padding-bottom: 2px; padding-top: 2px;"&gt;&lt;li style="margin-bottom: 0px;"&gt;&lt;b&gt;HL7 &lt;/b&gt;data models that use the industry standard Data Format Description Language (&lt;b&gt;DFDL&lt;/b&gt;), are included in support of the HL7 messaging standard. HL7 v2.3 through to the most recently approved HL7 v2.7 are provided in the pack. The graphical modeling tools bring a modern feel to HL7 data processing, provide excellent performance characteristics, and allow healthcare integrators to customize and develop healthcare integrations quickly and easily.&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;ul class="ibm-bullet-list ibm-no-links" style="background-color: white; font-family: Arial, sans-serif; margin-bottom: 2px; margin-top: 2px; padding-bottom: 2px; padding-top: 2px;"&gt;&lt;li style="margin-bottom: 0px;"&gt;The ability to send &lt;b&gt;IHE &lt;/b&gt;compatible Audit Trail and Node Authentication (&lt;b&gt;ATNA&lt;/b&gt;) messages to an audit repository enables logging events across a healthcare network.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style="background-color: white; font-family: Arial, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="background-color: white; font-family: Arial, sans-serif;"&gt;The new capabilities augment the existing capabilities of the Healthcare Connectivity Pack:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="background-color: white; font-family: Arial, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul class="ibm-bullet-list ibm-no-links" style="background-color: white; font-family: Arial, sans-serif; margin-bottom: 2px; margin-top: 2px; padding-bottom: 2px; padding-top: 2px;"&gt;&lt;li style="margin-bottom: 0px;"&gt;Ready-to-use connectivity and time saving patterns for healthcare providers who seek to integrate &lt;b&gt;clinical applications&lt;/b&gt; based on HL7 v2.x.&lt;/li&gt;&lt;/ul&gt;&lt;ul class="ibm-bullet-list ibm-no-links" style="background-color: white; font-family: Arial, sans-serif; margin-bottom: 2px; margin-top: 2px; padding-bottom: 2px; padding-top: 2px;"&gt;&lt;li style="margin-bottom: 0px;"&gt;Direct connectivity to bedside &lt;b&gt;medical devices&lt;/b&gt; that includes &lt;b&gt;patient monitors&lt;/b&gt;, &lt;b&gt;infusion pumps&lt;/b&gt;, and more (the full list of medical devices is &lt;a href="http://www-01.ibm.com/software/integration/wbimessagebroker/requirements/acute-medical-devices.html"&gt;here&lt;/a&gt;).&lt;/li&gt;&lt;/ul&gt;&lt;ul class="ibm-bullet-list ibm-no-links" style="background-color: white; font-family: Arial, sans-serif; margin-bottom: 2px; margin-top: 2px; padding-bottom: 2px; padding-top: 2px;"&gt;&lt;li style="margin-bottom: 0px;"&gt;&lt;b&gt;Pattern-based&lt;/b&gt; healthcare focused development tooling - rapid integration without detailed knowledge of integration engines or enterprise service bus (ESB) technologies.&lt;/li&gt;&lt;/ul&gt;&lt;ul class="ibm-bullet-list ibm-no-links" style="background-color: white; font-family: Arial, sans-serif; margin-bottom: 2px; margin-top: 2px; padding-bottom: 2px; padding-top: 2px;"&gt;&lt;li style="margin-bottom: 0px;"&gt;Healthcare-oriented, &lt;b&gt;operational monitoring&lt;/b&gt; for connected clinical applications and devices.&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family: Arial, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: Arial, sans-serif;"&gt;I've posted some slides &lt;a href="http://www.slideshare.net/AntPhillips/healthcare-overview-18356221"&gt;here&lt;/a&gt; which walk through the high level features now available.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/6844816440466310857/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2013/04/healthcare-integration-with-message.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/6844816440466310857'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/6844816440466310857'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2013/04/healthcare-integration-with-message.html' title='Healthcare Integration with Message Broker'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-4867815019658925343</id><published>2012-09-26T16:23:00.000+01:00</published><updated>2012-09-26T19:07:41.337+01:00</updated><title type='text'>Message Broker Goes Mobile!</title><content type='html'>Message Broker v8 FP1 shipped just a few weeks ago. One of the many new features in this release is close integration with mobile applications. The background to this work is an acquisition we made at the start of the year with &lt;a href="http://www-01.ibm.com/software/mobile-solutions/worklight/"&gt;Worklight&lt;/a&gt;. IBM Worklight is a mobile application development product that enables you to quickly and easily develop mobile applications for many devices (iOS, Android, Windows Phone, RIM Blackberry and more). Furthermore, mobile applications are written using well established web development skills (HTML, CSS and JavaScript).&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-j5Gs1P7J40c/UGMYFCcZPpI/AAAAAAAAAGw/5S962WpaghI/s1600/Mobile.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="118" src="http://2.bp.blogspot.com/-j5Gs1P7J40c/UGMYFCcZPpI/AAAAAAAAAGw/5S962WpaghI/s320/Mobile.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Message Broker now has a host of patterns that address key integration challenges in the mobile space:&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;&lt;/h3&gt;&lt;h3&gt;Mobile enablement for Microsoft .NET applications&lt;/h3&gt;&lt;div&gt;In just a few easy clicks, convert any Microsoft .NET class (C#, VB.NET, F#) into a web service running in Message Broker. The pattern generates the integration logic for Worklight and a complete mobile application that can exercise the .NET service.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;h3&gt;Mobile service enablement&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;Take any Message Broker web service and mobile enable it. The pattern adds an HTTP/JSON binding to the service so that mobile applications through Worklight can integrate with back-end systems. The pattern also does a really great job of documenting (in HTML) the JSON format that the mobile developer should send to Worklight.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;Push notifications to mobile devices&lt;/h3&gt;&lt;div&gt;There are a whole host of use cases where pushing data out to mobile devices is incredibly useful. For example, perhaps you might want to send a meeting reminder to a client. This pattern creates all the integration logic for pushing notifications out to users on their mobile devices. The notifications themselves are sent out through Worklight using vendor specific push notification servers (for example, Apple APNS and Google C2DM).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;Resource handler&lt;/h3&gt;&lt;div&gt;This pattern brings a fresh look at the world of CRUD (Create, Read, Update and Delete). The pattern builds a Message Broker application that supports the CRUD operations as well as adding caching and security to complete the picture. Caching uses the WebSphere Extreme Scale (WXS) cache now available in Message Broker. Security supports authorisation and authentication against an LDAP server (such as Microsoft ActiveDirectory).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The source code for all these patterns is available so you are free to take these patterns and extend them in any way that makes sense to you!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;More information on all these patterns is available &lt;a href="http://www.slideshare.net/AntPhillips/worklight-patterns"&gt;here &lt;/a&gt;on my SlideShare account. If you are new to Message Broker, you might find the following &lt;a href="http://www.slideshare.net/AntPhillips/introduction-to-websphere-message-broker"&gt;introduction &lt;/a&gt;slides helpful. And finally, if you are looking for some guidance on how to build integrations with Message Broker, &lt;a href="http://www.slideshare.net/AntPhillips/effective-application-development-with-websphere-message-broker"&gt;these &lt;/a&gt;slides provide lots of information.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/4867815019658925343/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2012/09/message-broker-goes-mobile.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/4867815019658925343'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/4867815019658925343'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2012/09/message-broker-goes-mobile.html' title='Message Broker Goes Mobile!'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-j5Gs1P7J40c/UGMYFCcZPpI/AAAAAAAAAGw/5S962WpaghI/s72-c/Mobile.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-6357546424265884762</id><published>2010-12-17T09:40:00.003Z</published><updated>2010-12-17T09:59:53.033Z</updated><title type='text'>Pattern Communities</title><content type='html'>&lt;div style="text-align: left;"&gt;Message Broker patterns are all about creating production ready connectivity solutions. The value of a pattern multiples hugely the more it is shared, and consequently the more it is used. In Message Broker fix pack 2 we added a significant capability to enable pattern communities. You can see some slides that walk through some of this work &lt;a href="http://www.slideshare.net/AntPhillips/pattern-communities-in-websphere-message-broker"&gt;here&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now it is worth saying that a community means different things to different people. For some organisations, a community might be private where patterns are created and shared within a development team. In this scenario, patterns offer consistency and time-to-value.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://1.bp.blogspot.com/_PvsuDEcKVb8/TQs0hHqLc1I/AAAAAAAAAFI/6v5PoDNBDRQ/s1600/Reindeer.png"&gt;&lt;img src="http://1.bp.blogspot.com/_PvsuDEcKVb8/TQs0hHqLc1I/AAAAAAAAAFI/6v5PoDNBDRQ/s400/Reindeer.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5551588709260555090" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 276px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For other organisations, patterns are a way to deliver capability to the market in an easily consumable form. For example, you might want to develop a suite of patterns for a particular industry or technology area. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;With this in mind you might be interested in a new global pattern community - &lt;a href="http://www.mqseries.net/phpBB2/viewforum.php?f=39"&gt;mqseries.net&lt;/a&gt; has added a pattern community where you can find, download and share patterns. We will be putting some very cool example patterns up over the next few weeks to help get it started. Why mqseries.net? Well communities are all about people, and mqseries.net is where the Broker community go to find answers.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;One particular thought to leave you with. We are very motivated to make your business succeed. So you might consider uploading a free starter version of your pattern to mqseries.net. In your pattern you can very easily include your own branding and links to your web site where the professional and enterprise versions can be purchased. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/6357546424265884762/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2010/12/pattern-communities.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/6357546424265884762'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/6357546424265884762'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2010/12/pattern-communities.html' title='Pattern Communities'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_PvsuDEcKVb8/TQs0hHqLc1I/AAAAAAAAAFI/6v5PoDNBDRQ/s72-c/Reindeer.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-7910622535385978683</id><published>2010-12-17T08:33:00.007Z</published><updated>2010-12-17T18:27:57.305Z</updated><title type='text'>Pattern Authoring in Message Broker</title><content type='html'>&lt;div style="text-align: left;"&gt;Almost a year to the day, Message Broker v7 was released. Well it has been a busy year in the development team. One area I particularly wanted to highlight was the work the team has done around patterns.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Broker v7 introduced the first generation of &lt;a href="http://www.slideshare.net/AntPhillips/patterns-4271745"&gt;patterns technology&lt;/a&gt; to the connectivity world. The v7 release shipped with an extensive set of built-in connectivity patterns. For example putting a web service front end on an existing application is a problem that comes up again and again in the field. Adding a production-ready pattern to the product made perfect sense. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Back in July we shipped Broker fix pack 1. Along with many new features, pattern authoring made its debut. Pattern authoring allows anyone to design, test, debug, package and distribute their own patterns. The patterns are presented in the Pattern Explorer alongside the built-in patterns provided by the product. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This capability has proved to be a big hit with our customers. We have talked to many customers this year who are now using patterns to simplify their development process, get more consistent solutions and to reduce costs.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Yesterday, Broker &lt;a href="http://www-01.ibm.com/support/docview.wss?uid=swg27006041"&gt;fix pack 2&lt;/a&gt; was released. Fix packs are the way we release new functionality between our biennial major product releases. In fix pack 2 we have released the third generation of patterns technology. This includes major enhancements to pattern authoring. You can read about the pattern authoring capabilities in &lt;a href="http://www.slideshare.net/AntPhillips/pattern-authoring-in-websphere-message-broker"&gt;this&lt;/a&gt; slide show. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://4.bp.blogspot.com/_PvsuDEcKVb8/TQsuBLfGFYI/AAAAAAAAAFA/qMcmzJVM3cQ/s1600/Snow.png"&gt;&lt;img src="http://4.bp.blogspot.com/_PvsuDEcKVb8/TQsuBLfGFYI/AAAAAAAAAFA/qMcmzJVM3cQ/s400/Snow.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5551581563462227330" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 321px; height: 213px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Pattern authors can now plug in their own Java and PHP code to their patterns which is called whenever pattern instances are created. Included in this is a major new Java API to programmatically manipulate message flows. You can browse the infocenter &lt;a href="http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/index.jsp"&gt;here&lt;/a&gt; and the new Java and PHP additions are documented &lt;a href="http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/topic/com.ibm.etools.mft.doc/bc68240_.htm"&gt;here&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;A couple of other links to mention. First there is an introductory article on developerWorks for &lt;a href="http://www.ibm.com/developerworks/websphere/library/techarticles/1010_stewart/1010_stewart.html?ca=drs-"&gt;pattern authoring&lt;/a&gt;. We also have a web site called the &lt;a href="http://publib.boulder.ibm.com/infocenter/ieduasst/v1r1m0/topic/com.ibm.iea.wmb_v7/plugin_coverpage.html"&gt;IBM Education Assistant&lt;/a&gt;, here you will find lots of short videos showing you how to use many of the features in the product.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/7910622535385978683/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2010/12/pattern-authoring-in-message-broker.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/7910622535385978683'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/7910622535385978683'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2010/12/pattern-authoring-in-message-broker.html' title='Pattern Authoring in Message Broker'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_PvsuDEcKVb8/TQsuBLfGFYI/AAAAAAAAAFA/qMcmzJVM3cQ/s72-c/Snow.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-2757988219944377331</id><published>2009-10-08T14:41:00.016+01:00</published><updated>2009-10-09T14:29:21.023+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='v7'/><category scheme='http://www.blogger.com/atom/ns#' term='patterns'/><category scheme='http://www.blogger.com/atom/ns#' term='Message Broker'/><category scheme='http://www.blogger.com/atom/ns#' term='application integration'/><title type='text'>Patterns and Message Broker</title><content type='html'>&lt;div style="text-align: left;"&gt;I see WebSphere Message Broker has just &lt;a href="http://www-01.ibm.com/common/ssi/ShowDoc.jsp?docURL=/common/ssi/rep_ca/1/897/ENUS209-291/index.html&amp;amp;breadCrum=DET001PT022&amp;amp;url=buttonpressed=DET002PT005&amp;amp;specific_index=DET001PEF502&amp;amp;DET015PGL002=DET001PEF011&amp;amp;submit.x=7&amp;amp;submit.y=8&amp;amp;lang=en_GB"&gt;announced v7&lt;/a&gt;. The product has been brewing for considerably longer than my involvement and we are all working flat out to finish it off. I've been working on Broker for a little over six months now. My bit of the jigsaw is in a new feature called patterns.&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Patterns solves a conundrum familiar to developers - it goes like this:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Broker is a product that can do, well, just about anything. It's purpose in life is to connect everything to everything. More than that, it routes, transforms, filters, and validates messages and data along the way. But this flexibility can easily be an Achilles heal. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;How, as an inexperienced user of the technology, do I learn to use the product? How do I solve common problems? I don't want to make mistakes, so how do I avoid them? And of course how can I find out what best practices exist?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;img src="http://1.bp.blogspot.com/_PvsuDEcKVb8/Ss86hWTWwKI/AAAAAAAAAEo/gUIF4dV1XZc/s400/BlankPage.png" style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 234px; height: 154px;" border="0" alt="" id="BLOGGER_PHOTO_ID_5390591623582630050" /&gt;&lt;/div&gt;&lt;div&gt;Samples is one important answer of course! Samples typically demonstrate a particular feature of a product. Very rarely are samples intended for production use. Indeed, many samples remove production requirements like error handling altogether! Another important answer is documentation. This includes concept, task and reference material.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img src="http://1.bp.blogspot.com/_PvsuDEcKVb8/Ss850Tvi3zI/AAAAAAAAAEg/tH46e3qlBPM/s400/Patterns.png" style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 131px; height: 114px;" border="0" alt="" id="BLOGGER_PHOTO_ID_5390590849801445170" /&gt;&lt;/div&gt;&lt;div&gt;Patterns is different. Patterns creates production ready solutions to problems. For example, perhaps I want to create a Web service front end to a WebSphere MQ application (a frequently asked about problem). No problem, simply create an instance of the&lt;b&gt; Service Facade to WebSphere MQ: one-way&lt;/b&gt; pattern. Provide some configuration details, like the queue name, and click &lt;b&gt;Generate&lt;/b&gt;. Lo and behold out pops a Message Broker project that implements the pattern! Need advanced logging and error handling? No problem, just enable those options in the pattern parameters. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In v7 we are providing a set of patterns that cover a surprisingly wide set of problems. Need to process messages stored in files? No problem, try the &lt;b&gt;File Processing&lt;/b&gt; pattern. Need to put a proxy between a Web service client and server? Try the &lt;b&gt;Service Proxy&lt;/b&gt; pattern. And so on.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you would like to read more, try the &lt;a href="http://www.ibm.com/developerworks/websphere/library/techarticles/0910_philliips/0910_phillips.html"&gt;Introduction to Patterns&lt;/a&gt; developerWorks article.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/2757988219944377331/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2009/10/patterns-and-developerworks.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/2757988219944377331'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/2757988219944377331'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2009/10/patterns-and-developerworks.html' title='Patterns and Message Broker'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_PvsuDEcKVb8/Ss86hWTWwKI/AAAAAAAAAEo/gUIF4dV1XZc/s72-c/BlankPage.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-1807433496625538919</id><published>2009-09-14T19:09:00.016+01:00</published><updated>2009-09-14T19:49:20.666+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='UTF-8'/><category scheme='http://www.blogger.com/atom/ns#' term='encoding'/><category scheme='http://www.blogger.com/atom/ns#' term='eclipse'/><category scheme='http://www.blogger.com/atom/ns#' term='subversion'/><title type='text'>UTF-8 Problems and Subversion</title><content type='html'>I was writing some unit tests recently and needed to store files containing UTF-8 text in Subversion. The file &lt;strong&gt;names&lt;/strong&gt; also contained UTF-8 characters (see below). I was using Eclipse for the development work and ran into problems sharing the files between Linux and Windows.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;The problem was that a file created and committed by a Windows machine, was not synchronising correctly to the Linux machine (and vica versa). The character encodings in the file names were being changed somewhere along the commit and synchronise path. &lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://4.bp.blogspot.com/_PvsuDEcKVb8/Sq6JpewORgI/AAAAAAAAAEA/gib9yMpSE0w/s1600-h/Files.png"&gt;&lt;img id="BLOGGER_PHOTO_ID_5381389950477288962" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 348px; CURSOR: hand; HEIGHT: 325px; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_PvsuDEcKVb8/Sq6JpewORgI/AAAAAAAAAEA/gib9yMpSE0w/s400/Files.png" border="0" /&gt;&lt;/a&gt; So here is what I needed to do to make it work. First I needed to make sure Eclipse marked the contents of the file as UTF-8. This is straightforward, simply right click the file name, select &lt;strong&gt;Properties&lt;/strong&gt; and change the text encoding to UTF-8 (on Windows the default is Cp1252):&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://3.bp.blogspot.com/_PvsuDEcKVb8/Sq6JBnskJtI/AAAAAAAAAD4/QHZcsQKE7wU/s1600-h/Contents.png"&gt;&lt;img id="BLOGGER_PHOTO_ID_5381389265683097298" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 255px; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_PvsuDEcKVb8/Sq6JBnskJtI/AAAAAAAAAD4/QHZcsQKE7wU/s400/Contents.png" border="0" /&gt;&lt;/a&gt;The next step involves configuring the CVS repository. Change to the CVS perspective, right click the repository and select &lt;strong&gt;Properties:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;img id="BLOGGER_PHOTO_ID_5381390753300393266" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 191px; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_PvsuDEcKVb8/Sq6KYNgKrTI/AAAAAAAAAEI/nQB8Hq2CAbM/s400/Repositories.png" border="0" /&gt; Change the &lt;strong&gt;Server Encoding&lt;/strong&gt; to UTF-8 (on Linux the default &lt;strong&gt;Server Encoding &lt;/strong&gt;is UTF-8, hence the problem sharing files):&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;img id="BLOGGER_PHOTO_ID_5381391241812117922" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 229px; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_PvsuDEcKVb8/Sq6K0pWcCaI/AAAAAAAAAEY/Rtuxi0l7G7c/s400/ServerEncoding.png" border="0" /&gt;&lt;/div&gt;&lt;div&gt;The files should now commit and synchronise with the correct contents &lt;strong&gt;and &lt;/strong&gt;names. When you commit the files you should probably also commit the &lt;strong&gt;org.eclipse.core.resources.prefs&lt;/strong&gt; file that Eclipse generates in your project. This file stores the character encodings for the file contents.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/1807433496625538919/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2009/09/utf-8-problems-and-subversion.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/1807433496625538919'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/1807433496625538919'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2009/09/utf-8-problems-and-subversion.html' title='UTF-8 Problems and Subversion'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_PvsuDEcKVb8/Sq6JpewORgI/AAAAAAAAAEA/gib9yMpSE0w/s72-c/Files.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-3966905018461526453</id><published>2009-03-16T14:13:00.012Z</published><updated>2009-03-16T15:27:49.659Z</updated><title type='text'>Integrating SAP NetWeaver in Zero PHP</title><content type='html'>&lt;div style="text-align: left;"&gt;I've been playing with the &lt;a href="http://en.wikipedia.org/wiki/Shirley_Crabtree"&gt;Big Daddy&lt;/a&gt; of enterprise systems, &lt;a href="http://www.sap.com/index.epx"&gt;SAP&lt;/a&gt;. &lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;I thought it would be interesting to hook up a Zero PHP application with a SAP NetWeaver system. So last weekend I summoned up the courage and, armed with a bottle of red wine, set about the task. Surprisingly enough it wasn't too difficult (setting aside finding &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;20GB&lt;/span&gt; of disk space needed by the installer).&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_PvsuDEcKVb8/Sb5iw29HzTI/AAAAAAAAADg/mneCnetVa3w/s1600-h/BigDaddy.png"&gt;&lt;img src="http://3.bp.blogspot.com/_PvsuDEcKVb8/Sb5iw29HzTI/AAAAAAAAADg/mneCnetVa3w/s400/BigDaddy.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5313793201868885298" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 248px; height: 189px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;The bit I was interested in was the SAP Java connector. SAP Java Connector (SAP &lt;a href="http://help.sap.com/saphelp_nw04/helpdata/en/6f/1bd5c6a85b11d6b28500508b5d5211/content.htm"&gt;JCo&lt;/a&gt;) is a middleware component that enables the development of SAP-compatible components and applications in Java. Since we have a &lt;a href="http://www.projectzero.org/zero/sebring/latest/docs/zero.devguide.doc/zero.php/ZeroAdvancedPHPJavaBridge.html"&gt;PHP/Java Bridge&lt;/a&gt; in Zero I thought it should be possible to wire them up.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here is an example that invokes a SAP remote function call (&lt;a href="http://help.sap.com/saphelp_nw04/helpdata/en/6f/1bd5b6a85b11d6b28500508b5d5211/content.htm"&gt;RFC&lt;/a&gt;):&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&amp;lt;?php&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;try {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;    &lt;/span&gt;java_import("com.sap.mw.jco.JCO", NULL, FALSE, NULL, FALSE);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;// Establish the client connection to SAP&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;span class="Apple-style-span" style="white-space: normal; "&gt;$connection = JCO::createClient("000", "bcuser", &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;        &lt;span class="Apple-style-span" style="white-space: normal; "&gt;"minisap", null, "localhost", "00");&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$connection-&gt;connect();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$repository = JCO::createRepository("ZeroRepository", $connection);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;span class="Apple-style-span" style="white-space: normal; "&gt;$template = $repository-&gt;getFunctionTemplate("RFC_SYSTEM_INFO");&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;span class="Apple-style-span" style="white-space: normal; "&gt;$function = new Java("com.sap.mw.jco.JCO.Function", $template);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$connection-&gt;execute($function);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$list = $function-&gt;getExportParameterList();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;span class="Apple-style-span" style="white-space: normal; "&gt;$structure = $list-&gt;getStructure("RFCSI_EXPORT");&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$iterator = $structure-&gt;fields();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;span class="Apple-style-span" style="white-space: normal; "&gt;while ($iterator-&gt;hasMoreElements()) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;       &lt;span class="Apple-style-span" style="white-space: normal; "&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$field = $iterator-&gt;nextField();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;        &lt;span class="Apple-style-span" style="white-space: normal; "&gt;echo $field-&gt;getName()." : ".$field-&gt;getString()."\n";&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style=" ;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=" ;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$connection-&gt;disconnect();&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style=" ;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;   &lt;/span&gt;} catch (Exception $exception) {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;       echo&lt;/span&gt; $exception-&gt;getMessage();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;?&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;The code turns out to be pretty straightforward. In a production environment it would be better to use some of the connection pooling options to avoid the repetitive connect/disconnect overhead. The function &lt;span class="Apple-style-span"  style="font-size:small;"&gt;RFC_SYSTEM_INFO&lt;/span&gt; doesn't require any arguments but those can be passed as well if required.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If anyone is interested in SAP there is an un-conference event being organised by &lt;a href="http://nigeljames.wordpress.com/"&gt;Nigel James &lt;/a&gt;and &lt;a href="http://zoomsplatter.blogspot.com/"&gt;Zoe Slattery&lt;/a&gt; on Saturday 4th April. More details &lt;a href="https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/5237"&gt;here&lt;/a&gt; (beware the SAP/SDN sites do not work in Google Chrome). I am planning to be there to chat about Zero/Java/PHP with SAP NetWeaver.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/3966905018461526453/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2009/03/integrating-sap-netweaver-in-zero-php.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/3966905018461526453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/3966905018461526453'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2009/03/integrating-sap-netweaver-in-zero-php.html' title='Integrating SAP NetWeaver in Zero PHP'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_PvsuDEcKVb8/Sb5iw29HzTI/AAAAAAAAADg/mneCnetVa3w/s72-c/BigDaddy.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-2462399361288590094</id><published>2009-03-06T13:14:00.026Z</published><updated>2009-03-07T15:55:54.158Z</updated><title type='text'>developerWorks Article: Business Intelligence</title><content type='html'>&lt;div style="text-align: left;"&gt;The developerWorks article on business intelligence I mentioned a while back has been &lt;a href="http://www.ibm.com/developerworks/websphere/techjournal/0903_phillips/0903_phillips.html"&gt;published&lt;/a&gt;. It covers several use cases for integrating BIRT reports into a &lt;a href="https://www.projectzero.org/php/"&gt;Zero PHP&lt;/a&gt; application. It uses the &lt;a href="http://www.eclipse.org/birt/phoenix/db/"&gt;sample database&lt;/a&gt; and reports provided by BIRT and runs against a MySQL database.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;From my perspective the most interesting example is the last one: scripted data sources. In this use case the report doesn't get its data from a database query. Instead the PHP script creates the data and pushes it into the BIRT runtime ready for the report to render. Here is the sample code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&amp;lt;?php&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;require_once 'startup.php';&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$engine = startup();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$root_directory = zget("/config/root");&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$report_engine = $root_directory."/ReportEngine";&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$design_file = $root_directory.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    "/samples/data_source.rptdesign";&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$images_directory = $root_directory.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    "/public/images/logos";&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;java_import(&lt;/span&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;span class="Apple-style-span" style=" ;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style=" ;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    "org.eclipse.birt.report.engine.api.HTMLRenderOption"&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;java_import(&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    "org.eclipse.birt.report.engine.api.HTMLServerImageHandler"&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$design = $engine-&gt;openReportDesign($design_file);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$task = $engine-&gt;createRunAndRenderTask($design);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$task-&gt;validateParameters();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$generated_report_file = &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    tempnam(sys_get_temp_dir(), 'report');&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$models[] = array("ANG Resellers", &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;"1952 Alpine Renault 1300", "Red");&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$models[] = array("AV Stores, Co.", &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;"1969 Harley Davidson Ultimate Chopper", "Blue");&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$models[] = array("Alpha Cognac", &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;"1969 Ford Falcon", "Blue");&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$models[] = array("Asian Shopping Network, Co", &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;"1969 Dodge Charger", "Plum Crazy Purple");&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$models[] = array("Asian Treasures, Inc.", &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;"1969 Corvair Monza", "Red");&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;zput("/request/report", $models);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$options = new HTMLRenderOption();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$options-&gt;setOutputFileName(&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    $generated_report_file);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$options-&gt;setOutputFormat("html");&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$options-&gt;setImageDirectory($images_directory);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$options-&gt;setBaseImageURL("/images/logos/");&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$options-&gt;setImageHandler(new HTMLServerImageHandler());&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$task-&gt;setRenderOption($options);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$task-&gt;run();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$task-&gt;close();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;echo file_get_contents($generated_report_file);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;unlink($generated_report_file);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;?&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;bold section&lt;/span&gt; hard codes some data for the report. A more realistic example might query an external system like a web service to build the data set. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The magic that makes this possible is the JavaScript engine that BIRT embeds. When BIRT renders the report it executes JavaScript embedded in the report with the &lt;a href="http://www.mozilla.org/rhino/"&gt;Rhino&lt;/a&gt; scripting engine. Because the BIRT runtime and the PHP application are all running on the same JVM they can share data very easily and efficiently. In this case the PHP code puts the data collection into the &lt;a href="http://www.projectzero.org/zero/sebring/latest/docs/zero.devguide.doc/zero.core/GlobalContext.html"&gt;Global Context&lt;/a&gt;, and the JavaScript in the report pulls it out.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_PvsuDEcKVb8/SbEkzyRIgZI/AAAAAAAAADY/sBEvHI2Woqo/s1600-h/Report.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_PvsuDEcKVb8/SbEkzyRIgZI/AAAAAAAAADY/sBEvHI2Woqo/s400/Report.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5310065907732087186" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 181px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/2462399361288590094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2009/03/developerworks-article-business.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/2462399361288590094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/2462399361288590094'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2009/03/developerworks-article-business.html' title='developerWorks Article: Business Intelligence'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_PvsuDEcKVb8/SbEkzyRIgZI/AAAAAAAAADY/sBEvHI2Woqo/s72-c/Report.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-7800303864250652420</id><published>2009-03-03T16:32:00.007Z</published><updated>2009-03-07T15:46:04.697Z</updated><title type='text'>Business Intelligence - The Code</title><content type='html'>A little later than intended - here is the code we were using on the &lt;a href="https://www.projectzero.org/php/"&gt;Zero&lt;/a&gt; stand at the (most excellent) &lt;a href="http://www.phpconference.co.uk/"&gt;PHP London&lt;/a&gt; conference last Friday. I had it running as a blog in Drupal but this will run just as well standalone. More detailed destructions for getting this running are up on YouTube &lt;a href="http://www.youtube.com/watch?v=s-BnKA7e2Bc"&gt;here&lt;/a&gt; (the video is six minutes long).&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&amp;lt;?php&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" ;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;require_once 'startup.php';&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$engine = startup();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$root_directory = zget("/config/root");&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$design_file = $root_directory."/samples/hello_world.rptdesign";&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$design = $engine-&gt;openReportDesign($design_file);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$task = $engine-&gt;createRunAndRenderTask($design);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$task-&gt;validateParameters();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;java_import("org.eclipse.birt.report.engine.api.HTMLRenderOption");&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$generated_report_file = tempnam(sys_get_temp_dir(), 'report');&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$options = new HTMLRenderOption();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$options-&gt;setOutputFileName($generated_report_file);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$options-&gt;setOutputFormat("html");&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$task-&gt;setRenderOption($options);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$task-&gt;run();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$task-&gt;close();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;echo file_get_contents($generated_report_file);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;unlink($generated_report_file);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;?&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;And the include file that configures the BIRT runtime is as follows:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&amp;lt;?php&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;function startup() {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" ;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;    &lt;/span&gt;zpost("/app#lock", "/engine"); &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;    &lt;/span&gt;$engine = zget("/tmp/factory");&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;    &lt;/span&gt;if ($engine != NULL) {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" ;"&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span" style=" ;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=" ;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;zpost("/app#unlock", "/engine"); &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;return $engine; // Did someone else get in first?&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;    &lt;/span&gt;$root_directory = zget("/config/root");&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$report_directory = $root_directory."/birt-runtime-2_3_1/ReportEngine";&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;span class="Apple-style-span" style="white-space: normal; "&gt;$log_directory = zget("/config/appLogDir");&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;java_import("org.eclipse.birt.core.framework.Platform");&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;span class="Apple-style-span" style="white-space: normal; "&gt;java_import("java.util.logging.Level");&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;span class="Apple-style-span" style="white-space: normal; "&gt;java_import("org.eclipse.birt.report.engine.api.EngineConfig");&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;span class="Apple-style-span" style="white-space: normal; "&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;java_import(&lt;/span&gt;&lt;span class="Apple-style-span" style=" ;"&gt;&lt;span class="Apple-style-span" style=" ;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;"org.eclipse.birt.report.engine.api.IReportEngineFactory");&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;span class="Apple-style-span" style="white-space: normal; "&gt;$config = new EngineConfig();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;span class="Apple-style-span" style="white-space: normal; "&gt;$config-&gt;setBIRTHome($report_directory);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;span class="Apple-style-span" style="white-space: normal; "&gt;$config-&gt;setLogConfig($log_directory, Level::$SEVERE);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;span class="Apple-style-span" style="white-space: normal; "&gt;Platform::startup($config);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$factory = Platform::createFactoryObject(&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;        &lt;span class="Apple-style-span" style="white-space: normal; "&gt;IReportEngineFactory::$EXTENSION_REPORT_ENGINE_FACTORY);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;span class="Apple-style-span" style="white-space: normal; "&gt;// Store in process wide non persistent zone&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$engine = $factory-&gt;createReportEngine($config);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;span class="Apple-style-span" style="white-space: normal; "&gt;zput("/tmp/factory", $engine);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;span class="Apple-style-span" style="white-space: normal; "&gt;// Unlock when we are finished!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;span class="Apple-style-span" style="white-space: normal; "&gt;zpost("/app#unlock", "/engine"); &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;return $engine;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" ;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;?&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/7800303864250652420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2009/03/business-intelligence-code.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/7800303864250652420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/7800303864250652420'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2009/03/business-intelligence-code.html' title='Business Intelligence - The Code'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-8049026289562057422</id><published>2009-02-23T22:18:00.034Z</published><updated>2009-03-07T15:41:47.654Z</updated><title type='text'>PHP London Conference</title><content type='html'>Just a few more days until this year's &lt;a href="http://www.phpconference.co.uk/"&gt;PHP London&lt;/a&gt; Conference. I think it is going to be a brilliant event given the outstanding &lt;a href="http://www.phpconference.co.uk/speakers"&gt;speaker&lt;/a&gt; line up. The &lt;a href="http://www.phplondon.org/"&gt;PHP London User Group&lt;/a&gt; is also hosting a &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;free &lt;/span&gt;pre-conference &lt;a href="http://www.phpconference.co.uk/socials"&gt;social &lt;/a&gt;on Thursday night with guest speaker and PHP contributor &lt;a href="http://derickrethans.nl/who.php"&gt;Derick Rethans&lt;/a&gt;.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I know little about the new features in PHP 5.3 (shame on me) so the talks by &lt;a href="http://www.phpconference.co.uk/speakers#ScottMacVicar"&gt;Scott MacVicar&lt;/a&gt; and &lt;a href="http://www.phpconference.co.uk/speakers#SebastianBergmann"&gt;Sebastian Bergmann&lt;/a&gt; should be well worth taking in. &lt;a href="http://www.phpconference.co.uk/speakers#StuartHerbert"&gt;Stuart Herbert&lt;/a&gt;'s talk on PHP frameworks is sure to be interesting and no doubt will create plenty of audience discussion. There is lots more with talks about security, cloud computing and a term I had never heard before, database &lt;a href="http://highscalability.com/unorthodox-approach-database-design-coming-shard"&gt;sharding&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;My small contribution to the event is to put together a couple of demo applications for the &lt;a href="https://www.projectzero.org/php/"&gt;Zero&lt;/a&gt; stand. Given my main thing is language interop I thought to start with some PHP/Java Bridge examples. The &lt;a href="http://www.eclipse.org/birt"&gt;BIRT&lt;/a&gt; stuff I &lt;a href="http://antblah.blogspot.com/2009/02/singletons-and-php.html"&gt;rambled&lt;/a&gt; about the other day fits nicely and produces some glossy charts just perfect for a demo [:o)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Thanks to &lt;a href="http://nicholsr.blogspot.com/"&gt;Rob&lt;/a&gt; we also have a demo using Apache &lt;a href="http://en.wikipedia.org/wiki/Apache_POI"&gt;POI&lt;/a&gt; (the project name is a story in itself). POI is interesting because it provides a cross platform library for reading and writing Microsoft Office file formats. POI is really easy to use, just grab the download from the POI web site and extract the three JAR files. In Zero they need to go into the &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;lib &lt;/span&gt;directory.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;lt;?php&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;java_import("org.apache.poi.hslf.HSLFSlideShow");&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;java_import("org.apache.poi.hslf.usermodel.SlideShow");&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new'; font-size: 10px; "&gt;$fs = new Java("java.io.FileInputStream", "/test.ppt");&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;$hsss = new HSLFSlideShow($fs);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;$ss = new SlideShow($hsss);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;foreach ($ss-&gt;getSlides() as $slide) {    &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;    echo $slide-&gt;getTitle();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;?&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The code simply iterates through the titles of each PowerPoint slide. All very straightforward and just the tip of the iceberg for what POI can do.&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/8049026289562057422/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2009/02/php-london-conference.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/8049026289562057422'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/8049026289562057422'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2009/02/php-london-conference.html' title='PHP London Conference'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-2836708970318844221</id><published>2009-02-17T21:13:00.026Z</published><updated>2009-03-07T15:43:43.312Z</updated><title type='text'>Singletons, BIRT, Threads and PHP</title><content type='html'>&lt;div style="text-align: left;"&gt;&lt;div style="text-align: left;"&gt;PHP is designed to run in multithreaded web servers (such as Apache and IIS). What this means in practice is that a single PHP process concurrently processes multiple browser requests. It does this by having multiple threads, each of which handles one HTTP request at a time.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;PHP can also be built for non multithreaded web servers. In this deployment model life is somewhat different because the web server spawns multiple PHP processes. When requests arrive in the web server it farms them out among its pool of PHP worker processes. Each worker process handles just one request at a time. &lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;The pool of worker processes can grow and shrink over time to allow for busy periods. &lt;a href="http://www.projectzero.org/php/"&gt;Zero&lt;/a&gt; is multithreaded so it handles multiple web requests concurrently in the same process.&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_PvsuDEcKVb8/SZsqAUaQMQI/AAAAAAAAAC4/hd8fm1ZG4fc/s1600-h/RoadBlock.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 200px; height: 149px;" src="http://3.bp.blogspot.com/_PvsuDEcKVb8/SZsqAUaQMQI/AAAAAAAAAC4/hd8fm1ZG4fc/s200/RoadBlock.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5303879171126079746" /&gt;&lt;/a&gt;&lt;div&gt;&lt;div&gt;I’ve been playing with the &lt;a href="http://www.eclipse.org/birt"&gt;Eclipse Business Intelligence and Reporting Tools&lt;/a&gt; project (BIRT). BIRT is an open source Eclipse project that provides a whole bunch of stuff around designing and deploying reports and charts. It has a Java API and so I thought it would make a nice demonstration of the &lt;a href="http://www.projectzero.org/zero/sebring/latest/docs/zero.devguide.doc/zero.php/ZeroAdvancedPHPJavaBridge.html"&gt;PHP/Java Bridge&lt;/a&gt; in Zero.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The problem is that BIRT needs to be started once, and only once, in any given process. Once it has been started up, then it is plain sailing to load reports and render them to HTML. The BIRT runtime should be kept around until the process shuts down. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_PvsuDEcKVb8/SZsp8wxnMmI/AAAAAAAAACw/jIbIcJo6EEI/s1600-h/OneTon.jpg" style="text-decoration: none;"&gt;&lt;img style="text-decoration: underline;display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 116px; height: 200px; " src="http://4.bp.blogspot.com/_PvsuDEcKVb8/SZsp8wxnMmI/AAAAAAAAACw/jIbIcJo6EEI/s200/OneTon.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5303879110020772450" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;div&gt;This sounds suspiciously like a &lt;a href="http://en.wikipedia.org/wiki/Singleton_pattern"&gt;singleton&lt;/a&gt; pattern (or &lt;a href="http://en.wikipedia.org/wiki/Anti-pattern"&gt;anti-pattern&lt;/a&gt; if you prefer). The trouble is that process wide singletons are hard to implement correctly in PHP. You might think the following snippet would work:&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;class Singleton {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;    p&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;rivate static $birt = NULL;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;    static function getInstance() {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="white-space: normal; "&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;if (self::$birt == NULL) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="white-space: normal; "&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;self::$birt = new BIRT(...);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="white-space: normal; "&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="white-space: normal; "&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="white-space: normal; "&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;return self::$birt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span" style="white-space: normal; "&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;div style="text-align: left;"&gt;There are two problems with this. First, at the end of the current request, all statics are cleared away so &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;$birt&lt;/span&gt; is reset to &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;NULL&lt;/span&gt;. What we want is the BIRT runtime to be kept around forever (or at least until the process shuts down). &lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;The second problem is that on a multithreaded PHP runtime each PHP request gets an independent set of static and global variables. If two requests are being processed, and each calls &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;getInstance&lt;/span&gt;, then they will both create an instance of the BIRT class. &lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_PvsuDEcKVb8/SZsqD_pd0UI/AAAAAAAAADA/cuqBjbiRc7Q/s1600-h/Spaghetti.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_PvsuDEcKVb8/SZsqD_pd0UI/AAAAAAAAADA/cuqBjbiRc7Q/s200/Spaghetti.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5303879234272219458" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 200px; height: 160px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;div style="text-align: left; "&gt;The design intent in PHP is that each request looks like it is running in a single threaded PHP process, even though it is actually running in a multithreaded PHP process. But what I want is one (yes really one!) object in a process which can be shared amongst all the threads. The reason this works is that the BIRT runtime is thread safe, meaning that it can be safely used by multiple threads at the same time.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;The solution for me turned out to be the Zero &lt;a href="http://www.projectzero.org/zero/sebring/latest/docs/zero.devguide.doc/zero.core/GlobalContext.html"&gt;Global Context&lt;/a&gt;. The Global Context is a storage area in Zero where just about anything can be put. Different bits of the Global Context have different life times. For example, the &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;/request&lt;/span&gt; zone is only kept around for the current request. I opted to put the BIRT runtime in the &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;/tmp&lt;/span&gt; zone so that it is kept around for the life time of the process. It is also available to all threads running in the same process.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The final piece of the jigsaw was to ensure only one thread actually created the BIRT runtime. Dealing with multiple threads can be something of a headache as race conditions are easily created.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The Global Context provides a solution (albeit slightly crufty) with locking commands. Each thread does a lock, checks to see if the BIRT runtime has already been created (if not then it creates it and puts it in the &lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;/tmp&lt;/span&gt; zone) and then unlocks.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;With a bit of luck I'll get this written up in an &lt;a href="http://www.ibm.com/developerworks/websphere/zones/smash/"&gt;developerWorks &lt;/a&gt;article soon as the reports look really sweet (cross tabs, charts, compound reports and so).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/2836708970318844221/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2009/02/singletons-and-php.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/2836708970318844221'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/2836708970318844221'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2009/02/singletons-and-php.html' title='Singletons, BIRT, Threads and PHP'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_PvsuDEcKVb8/SZsqAUaQMQI/AAAAAAAAAC4/hd8fm1ZG4fc/s72-c/RoadBlock.jpg' height='72' width='72'/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-1390815322586667673</id><published>2009-01-29T19:12:00.010Z</published><updated>2009-01-29T19:30:26.918Z</updated><title type='text'>Charles Darwin and PHP</title><content type='html'>&lt;div style="text-align: left;"&gt;This year is the 150th anniversary of the publication of &lt;a href="http://www.literature.org/authors/darwin-charles/the-origin-of-species/index.html"&gt;On the Origin of Species&lt;/a&gt; (24 November 1859) and the 200th anniversary of Darwin's birth (12 February 1809). The BBC recently screened an absolutely fascinating program called "What Darwin Didn't Know". It is on iPlayer &lt;a href="http://www.bbc.co.uk/programmes/b00h6sbt"&gt;here&lt;/a&gt; although I'm not sure it is available outside of the UK - sorry if not!&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;What really struck me was not only his insight, but also how Darwin devoted an entire &lt;a href="http://www.literature.org/authors/darwin-charles/the-origin-of-species/chapter-06.html"&gt;chapter&lt;/a&gt; to describe the difficulties of the theory! Remarkable as well how he accepted the theory was incomplete and asked for future generations to fill in the gaps.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;All this got me thinking about applying the idea of natural selection to open source software. I was sure there must be an analogy for how open source projects grow and die that mimics the world of evolutionary biology. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;I also think natural selection provides a great explanation for why PHP is so hugely successful. I don't often hear people describe PHP as a pure and elegant programming language. A criticism that purists in the OOP world sometimes direct at us. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But that is rather missing the point I think! PHP succeeds because it has evolved over a relatively long period of time to do things quickly, easily, and well.&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); text-decoration: underline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); text-decoration: underline;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); "&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_PvsuDEcKVb8/SYICEh5EsxI/AAAAAAAAACQ/4ihEl6wcutM/s1600-h/Butterfly.png"&gt;&lt;img src="http://3.bp.blogspot.com/_PvsuDEcKVb8/SYICEh5EsxI/AAAAAAAAACQ/4ihEl6wcutM/s200/Butterfly.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5296798388581610258" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 200px; height: 163px; " /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Anyway, I set to task to find some prior art on this but my Googling didn't find any great matches. So my next thought was to ferret around and find some obsolete programming skills to show what has actually died out. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Alas, as before, nothing quite hit the mark. I did however dig up &lt;a href="http://www.obsoleteskills.com/"&gt;this&lt;/a&gt; web site where people are documenting obsolete skills. The problem is that most of the obsolete skills listed turn out to either still be used, or staging comebacks in one form or another (such as &lt;a href="http://www.obsoleteskills.com/skills/puttinganeedleonavinylrecord"&gt;putting a needle on a vinyl record&lt;/a&gt;)!&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So if you do know of somewhere that talks about natural selection and open source software, please let me know.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/1390815322586667673/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2009/01/charles-darwin-and-php.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/1390815322586667673'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/1390815322586667673'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2009/01/charles-darwin-and-php.html' title='Charles Darwin and PHP'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_PvsuDEcKVb8/SYICEh5EsxI/AAAAAAAAACQ/4ihEl6wcutM/s72-c/Butterfly.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-6513923350994553225</id><published>2009-01-29T14:47:00.030Z</published><updated>2009-01-29T18:20:54.023Z</updated><title type='text'>COM/.NET Interop in Zero PHP</title><content type='html'>&lt;div style="text-align: left;"&gt;Zero doesn't currently support the COM/.NET extension in PHP. &lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;No matter though, there is a handy open source project called &lt;a href="http://sourceforge.net/projects/jacob-project/"&gt;JACOB &lt;/a&gt;that bridges between Java and COM/.NET. In fact, there is an easier way to do this using a Groovy library called &lt;a href="http://groovy.codehaus.org/COM+Scripting"&gt;Scriptom&lt;/a&gt;. This is really just a friendly wrapper around JACOB to provide a better syntax for calling methods and accessing properties. &lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;The aim in this example is to list the processes on a Windows machine - here are the steps to do it in PHP. I'm using the latest Zero &lt;a href="http://www.projectzero.org/download/latest.php"&gt;download &lt;/a&gt;of Sebring and Eclipse PDT as the IDE.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1. Download Scriptom and put the JAR and DLL in the Zero lib directory:&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_PvsuDEcKVb8/SYHDGutPKlI/AAAAAAAAAB4/cVlgMHd_XnI/s1600-h/Project.png"&gt;&lt;img src="http://1.bp.blogspot.com/_PvsuDEcKVb8/SYHDGutPKlI/AAAAAAAAAB4/cVlgMHd_XnI/s320/Project.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5296729157148813906" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 208px; height: 257px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;2. Run a resolve step in Eclipse so that the JAR file is added to the class path.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;3. Add the following extension to php.ini (if not already there):&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;extension=com.ibm.p8.engine.xapi.groovy.GroovyExtensionLibrary&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;4. Copy and paste this code into a PHP script in the public folder:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&amp;lt;?php&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;define("wbemFlagForwardOnly", 32);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;java_import("com.jacob.com.ComThread");&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;ComThread::InitMTA(true);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;groovy_import("org.codehaus.groovy.scriptom.Scriptom");&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$locator = new ActiveXObject("WbemScripting.SWbemLocator");&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$services = $locator-&gt;ConnectServer('.');&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$processes = $services-&gt;ExecQuery(&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;  'SELECT * FROM Win32_Process',&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;  'WQL', wbemFlagForwardOnly);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$total = 0;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;// Iterate through the COM collection&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;foreach ($processes as $current) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;if (Scriptom::isNull($current-&gt;CreationDate) == FALSE) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$date = new ActiveXObject("WbemScripting.SWbemDateTime");&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$date-&gt;Value = $current-&gt;CreationDate;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$creation = $date-&gt;GetVarDate(TRUE);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$command = $current-&gt;CommandLine;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;$command = (Scriptom::isNull($command) ? "None" : $command);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;echo "Process found [".$current-&gt;Name.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;        " - ".$command."]"; $total++;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;ComThread::Release();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;echo "Found $total processes in all";&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;?&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Before you say it, yes I agree, the code is really yuck but that's COM for you. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;5. Run the application and point a browser at your script:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_PvsuDEcKVb8/SYHFG9EBnhI/AAAAAAAAACA/nbY1JUswQ_o/s1600-h/Results.png"&gt;&lt;img src="http://4.bp.blogspot.com/_PvsuDEcKVb8/SYHFG9EBnhI/AAAAAAAAACA/nbY1JUswQ_o/s320/Results.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5296731360025746962" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 320px; height: 160px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;If you are curious about what all these crazy objects are, there is lots more information on the &lt;a href="http://msdn.microsoft.com/en-us/library/aa394599(VS.85).aspx"&gt;Microsoft&lt;/a&gt; web site. The example is using Windows Management Instrumentation (WMI) to enumerate the processes.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The calls to &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;ComThread::InitMTA()&lt;/span&gt; and &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Release()&lt;/span&gt; are important to make sure Zero doesn't hang. COM has some weird stuff in it to do with apartments and threading.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/6513923350994553225/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2009/01/comnet-interop-in-zero-php.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/6513923350994553225'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/6513923350994553225'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2009/01/comnet-interop-in-zero-php.html' title='COM/.NET Interop in Zero PHP'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_PvsuDEcKVb8/SYHDGutPKlI/AAAAAAAAAB4/cVlgMHd_XnI/s72-c/Project.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-8142893149923133848</id><published>2009-01-27T16:23:00.013Z</published><updated>2009-01-28T11:02:25.190Z</updated><title type='text'>The Long Road to 64 Bits</title><content type='html'>&lt;div style="text-align: left;"&gt;There is an interesting story in January's Communications of the ACM called The Long Road to 64 Bits. The magazine is free online &lt;a href="http://portal.acm.org/citation.cfm?id=1435417.1435431&amp;amp;coll=ACM&amp;amp;dl=ACM&amp;amp;idx=J79&amp;amp;part=magazine&amp;amp;WantType=Magazines&amp;amp;title=Communications"&gt;here&lt;/a&gt;. It charts the long and often twisted road from 32 to 64 bit architectures. &lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;From a software perspective the challenge is around writing C code that compiles and runs cleanly on 32 &lt;span class="Apple-style-span" style=""&gt;and &lt;/span&gt;64 bit platforms. The issue being that compilers on different hardware architectures adopt different sized data types for integers, longs and pointers. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So for example, on Windows 32 bit (and many Unix's from the 1990's) all three were 32 bits wide, hence the tag ILP32. On 64 bit Windows, integers and longs remained 32 bits wide while pointers necessarily increased to 64 bits - so that goes by the tag IL32P64, or just P64 for short. Meanwhile many 64 bit Unix systems adopted I32LP64 - meaning integers remained 32 bits while longs and pointers widened to 64 bits. &lt;/div&gt;&lt;div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); text-decoration: underline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;PHP has to deal with this issue since it is written in C and is &lt;a href="http://wiki.php.net/platforms"&gt;ported&lt;/a&gt; to many platforms. This issue also comes up when mixing Java and C code because Java has a different approach. Java set out to &lt;a href="http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html"&gt;simplify &lt;/a&gt;the programming model by fixing the sizes of all data types. An integer in Java is 32 bits, always 32 bits and never anything apart from 32 bits. Java also has a long data type which is always 64 bits and has no unsigned data types at all.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_PvsuDEcKVb8/SX9CxVXPi-I/AAAAAAAAABg/Szx1E2gvqLE/s1600-h/SnowRoad.png" style="text-decoration: none;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;img src="http://2.bp.blogspot.com/_PvsuDEcKVb8/SX9CxVXPi-I/AAAAAAAAABg/Szx1E2gvqLE/s200/SnowRoad.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5296025102126648290" style="text-decoration: underline;display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 200px; height: 121px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Problems arise when Java code (with a fixed size data type) interacts with C code (that varies the data type size depending on the platform). Java has no pre-processor like C so it's not easy to write Java code that would, for example, use a Java integer on 32 bit machines, and magically use a Java long on 64 bit machines (and could therefore match the C code). So instead we generally use the wider data type (a Java long) on both 32 and 64 bit machines (and down cast where necessary).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;At this point I should also mention &lt;a href="http://www.wikipedia.org/wiki/Z/OS"&gt;z/OS&lt;/a&gt; which for it's own honourable reasons supported 24, 31 and 64 bit architectures...!&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/8142893149923133848/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2009/01/long-road-to-64-bits.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/8142893149923133848'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/8142893149923133848'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2009/01/long-road-to-64-bits.html' title='The Long Road to 64 Bits'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_PvsuDEcKVb8/SX9CxVXPi-I/AAAAAAAAABg/Szx1E2gvqLE/s72-c/SnowRoad.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-498164545183263653</id><published>2009-01-21T13:26:00.022Z</published><updated>2009-01-21T14:28:48.572Z</updated><title type='text'>Extending PHP in Project Zero</title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;The de facto open source implementation of &lt;/span&gt;&lt;a href="http://www.php.net/"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;PHP&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; is written almost entirely in C. Looking under the hood shows that it is really two fairly distinct parts. First there is the &lt;/span&gt;&lt;a href="http://en.wikipedia.org/wiki/Zend_Engine"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Zend Engine&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;. This is the core language engine that parses PHP scripts and interprets the resulting opcodes. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;The Zend Engine also contains the implementation of PHP types like variables (&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;zval&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;) and arrays (&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;HashTable&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;). &lt;span class="Apple-style-span"  style="font-size:small;"&gt;So where are all the PHP &lt;/span&gt;&lt;a href="http://www.php.net/quickref.php"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;functions and classes&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; implemented then?&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;The answer is that the Zend Engine provides an extension API. This allows anyone to write classes, functions, constants and much more that plug in to the php.net runtime. Taking a peek at the php.net source code in &lt;/span&gt;&lt;a href="http://cvs.php.net/viewvc.cgi/php-src/ext/"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;CVS&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; reveals just how many extensions there are. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;This C API is well documented in Sara Goleman's &lt;/span&gt;&lt;a href="http://www.amazon.com/Extending-Embedding-PHP-Developers-Library/dp/067232704X"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;book&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;. It talks in detail about how to extend PHP and indeed how to embed PHP in your own applications.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_PvsuDEcKVb8/SXcr5xGQNqI/AAAAAAAAAA4/HcYbBukWIz4/s1600-h/Skiing.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 138px;" src="http://1.bp.blogspot.com/_PvsuDEcKVb8/SXcr5xGQNqI/AAAAAAAAAA4/HcYbBukWIz4/s320/Skiing.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5293748158429410978" /&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;div style="text-align: left;"&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);"&gt;Zero has a very similar architecture that separates engine and extension. The main difference is that the core PHP language engine is written in Java. Zero also has a comprehensive API called XAPI-J that allows Java extensions to be written for the Zero PHP runtime. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);"&gt;We use XAPI-J to implement virtually all the PHP extension functions supported in Zero (listed &lt;a href="http://www.projectzero.org/zero/sebring/latest/docs/zero.devguide.doc/zero.php/CoreFunctions.html"&gt;here&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);"&gt;). But there is a bit more to this story than meets the eye. The slides Rob Nicholson &lt;a href="http://www.slideshare.net/nicholsr/project-zero-php-quebec"&gt;presented &lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);"&gt;at last year's PHP &lt;a href="http://conf.phpquebec.com/en/conf2008/"&gt;Quebec &lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);"&gt;cast some light on this. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Zero actually ships a pretty large number of the php.net C extensions. We do this by re-compiling the php.net source code against a different implementation of the php.net C API. The Zero implementation of the C API (called XAPI-C) knows how to talk to the Zero PHP runtime through &lt;/span&gt;&lt;a href="http://en.wikipedia.org/wiki/Java_Native_Interface"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;JNI&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;. &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;There are several benefits to this solution. First and foremost we maintain compatibility with the open source PHP. It is really important to PHP developers on Zero that we are as close to 100% compatible with php.net as possible, and using the php.net code certainly helps! &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Secondly, we avoid re-implementing all those extension functions from scratch. Why bother re-writing everything in Java when there is a perfectly good implementation already available! There are in fact a few performance critical functions that we do implement in Java, the &lt;/span&gt;&lt;a href="http://www.php.net/array"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; functions are one good example.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);"&gt;If you are interested in writing extensions for Zero you will find the documentation and examples for XAPI-J on the Zero &lt;a href="http://www.projectzero.org/zero/sebring/latest/docs/zero.devguide.doc/zero.php/ExtendingPHP.html"&gt;web site&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/498164545183263653/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2009/01/extending-php-in-project-zero.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/498164545183263653'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/498164545183263653'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2009/01/extending-php-in-project-zero.html' title='Extending PHP in Project Zero'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_PvsuDEcKVb8/SXcr5xGQNqI/AAAAAAAAAA4/HcYbBukWIz4/s72-c/Skiing.png' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-8581072875369465237</id><published>2009-01-21T11:32:00.029Z</published><updated>2009-01-26T09:45:08.312Z</updated><title type='text'>PHP and Java Collections: More PHP, Less Java</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_PvsuDEcKVb8/SX2E9sjR6FI/AAAAAAAAABQ/zpCmjvUuw5I/s1600-h/Watch.png"&gt;&lt;/a&gt;We've added some nice integration with the Java collection classes in &lt;a href="https://www.projectzero.org/php"&gt;Zero&lt;/a&gt;.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Java has a rich set of &lt;a href="http://java.sun.com/docs/books/tutorial/collections/index.html"&gt;collection &lt;/a&gt;classes. The three really important ones are &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Set&lt;/span&gt;, &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Map&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;and &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;List&lt;/span&gt;. We use the Java collections quite a bit when integrating Java libraries in PHP applications. So it got us thinking whether we could provide some good PHP syntax for these classes. It turns out there are quite a few things we could do to improve working with these classes in PHP.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); "&gt;&lt;img src="http://3.bp.blogspot.com/_PvsuDEcKVb8/SX2E9sjR6FI/AAAAAAAAABQ/zpCmjvUuw5I/s200/Watch.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5295534932323592274" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 200px; height: 150px; " /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;For example, Java lists now support the following:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&amp;lt;?php&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;java_import("java.util.ArrayList");&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$list = new ArrayList();&lt;span class="Apple-style-span"  style=" ;font-family:Georgia;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;$list-&gt;add("Hello World!");&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style=" ;font-family:Georgia;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$list[0] = "Hello Again!"; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$value = $list[0];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$array = (array) $list;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$check = isset($list[0]);&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;unset($list[0]);&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;// Append some items to list&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$list[] = "Hello Again!";&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$list[] = TRUE;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$list[] = "Updated!";&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;?&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Java maps and sets also get the full treatment. The reason why I like this is that it avoids lots of Java API calls. Some example code for hacking around with a &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Map&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;using the Java APIs is shown below. Notice all the method calls, just so much more long winded than PHP's nice expressive syntax!&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_PvsuDEcKVb8/SX2EdALuzrI/AAAAAAAAABI/XJ8rI7Px5F4/s1600-h/Watch.png"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&amp;lt;?php&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$map = new Java("java.util.HashMap");&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$map-&gt;put("title", "Java Bridge!");&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$value = $map-&gt;get("title");&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$check = $map-&gt;containsKey("title");&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$map-&gt;remove("stuff");&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;?&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;More information is on the Project Zero PHP/Java Bridge reference page &lt;a href="http://www.projectzero.org/zero/sebring/latest/docs/zero.devguide.doc/zero.php/ZeroAdvancedPHPJavaBridge.html"&gt;here&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Creative Commons picture attribute to &lt;a href="http://www.flickr.com/photos/bluenowhere/"&gt;MicMac&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/8581072875369465237/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2009/01/php-and-java-collections-more-php-less.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/8581072875369465237'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/8581072875369465237'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2009/01/php-and-java-collections-more-php-less.html' title='PHP and Java Collections: More PHP, Less Java'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_PvsuDEcKVb8/SX2E9sjR6FI/AAAAAAAAABQ/zpCmjvUuw5I/s72-c/Watch.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-990123486554652329</id><published>2009-01-12T08:53:00.001Z</published><updated>2009-01-22T14:53:02.837Z</updated><title type='text'>PHP/Groovy Bridge</title><content type='html'>&lt;div&gt;Ah, something new and shiny in Project Zero to talk about.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Zero supports three languages: Java, PHP and Groovy. It also supports a workflow runtime called Assemble and since that stores its flows as XML, and workflows are kind of like code, I suppose it could be considered an unofficial fourth language. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Anyway I digress. Up until recently the PHP runtime was treating Groovy code just the same as Java. Anyone could compile a Groovy class to Java class files using the Groovy compiler. Those class files could then be dropped into a Zero application and used in PHP through the PHP/Java Bridge.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The problem is that Groovy isn’t the same as Java. Groovy adds lots of scripting features over and above Java’s current capabilities. Closures being one obvious highlight. This shines through if Groovy classes are used through a PHP/Java Bridge, it all just looks like Java. Take for example the following Groovy class that makes use of Groovy’s &lt;a href="http://groovy.codehaus.org/Using+invokeMethod+and+getProperty"&gt;interceptors&lt;/a&gt;:&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;class Dynamic {&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;    def storage = [:]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;    &lt;/span&gt;def invokeMethod(String name, args) {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;        &lt;/span&gt;return "Hello World!";&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;    &lt;/span&gt;def getProperty(String name) { &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;storage[name] &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;    &lt;/span&gt;void setProperty(String name, value) { &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;storage[name] = value &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Another piece of Groovy can use this as follows:&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;foo = new Dynamic();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;foo.bar();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;foo.guff = "Hello World!";&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;print foo.guff;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now see how this looks from a Java client:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;public class Test {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;public static void main(String[] args) {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Dynamic foo = new Dynamic();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;String result = (String) &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;foo.invokeMethod("sayHello", null);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;        foo.setProperty("guff", "Hello World!");&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;        result = (String) foo.getProperty("guff");&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Yuck! And the same applies if we use this class in PHP through the Java Bridge. Well the PHP/Groovy Bridge solves this problem by integrating PHP and Groovy as  first class citizens - see how it looks with the Groovy Bridge:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&amp;lt;?php&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;groovy_import("dynamic.groovy");&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;$foo = new Dynamic();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;$foo-&gt;bar();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;$foo-&gt;guff = "Hello World!";&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;echo $foo-&gt;guff;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;?&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;That’s better! Intuitive use of the Groovy class as intended. The  &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;groovy_import&lt;/span&gt; function is just one aspect of the PHP/Groovy Bridge. It also supports a range of other nice Groovy interop features including closures,  currying and range objects. With this in mind I’ve put a slide cast up &lt;a href="http://www.slideshare.net/AntPhillips/groovy-bridge-presentation/"&gt;here &lt;/a&gt; where I ramble my way through an explanation of the PHP/Groovy Bridge.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The product documentation for the PHP/Groovy Bridge is also available &lt;a href="http://www.projectzero.org/zero/sebring/latest/docs/zero.devguide.doc/zero.php/ZeroAdvancedPHPGroovyBridge.html"&gt;here&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/990123486554652329/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2009/01/phpgroovy-bridge.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/990123486554652329'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/990123486554652329'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2009/01/phpgroovy-bridge.html' title='PHP/Groovy Bridge'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-2019810910688159562</id><published>2009-01-07T15:23:00.001Z</published><updated>2009-01-12T12:56:24.650Z</updated><title type='text'></title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;I've put some slides up &lt;a href="http://www.slideshare.net/AntPhillips/"&gt;here &lt;/a&gt;that &lt;a href="http://www.ibm.com/developerworks/websphere/library/techarticles/0805_coleman/0805_coleman.html"&gt;Andy Coleman&lt;/a&gt; presented at the WebSphere Technical Conference in November last. They discuss how sMash PHP fits into Message Broker and some of the really sweet integration points with the PHP language. Our inspiration for this was the &lt;a href="http://www.php.net/simplexml"&gt;SimpleXML &lt;/a&gt;extension which provides a fantastically easy way to navigate XML documents. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Message Broker has an existing Java API which we made heavy use of for this work. Much of the work involved was to catch method and field accesses in the PHP script and turn them into Java API calls on Message Broker. For example, take a look at the following message tree:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_PvsuDEcKVb8/SWTK4m5ScyI/AAAAAAAAAAo/xLx0fg9dlSQ/s1600-h/MessageTree.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_PvsuDEcKVb8/SWTK4m5ScyI/AAAAAAAAAAo/xLx0fg9dlSQ/s320/MessageTree.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5288574936302121762" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 320px; height: 208px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;Here's a first attempt at navigating through this message tree to the &lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;title&lt;/span&gt;&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p:colorscheme colors="#FFFFFF,#000000,#808080,#7889FB,#7889FB,#2DB6B3,#0000FF,#D18213"&gt;  &lt;div shape="_x0000_s3074" class="O"&gt;  &lt;div style="mso-line-spacing:&amp;quot;70 50 0&amp;quot;;mso-char-wrap:1;mso-kinsoku-overflow: 1"&gt;&lt;span style=""&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;$xml = $input-&gt;getLastChild(); &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div style="mso-line-spacing:&amp;quot;70 50 0&amp;quot;;mso-char-wrap:1;mso-kinsoku-overflow: 1"&gt;&lt;span style=""&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;$doc = $xml-&gt;getFirstChild(); &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div style="mso-line-spacing:&amp;quot;70 50 0&amp;quot;;mso-char-wrap:1;mso-kinsoku-overflow: 1"&gt;&lt;span style=""&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;$ch1 = $doc-&gt;getFirstChild(); &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div style="mso-line-spacing:&amp;quot;70 50 0&amp;quot;;mso-char-wrap:1;mso-kinsoku-overflow: 1"&gt;&lt;span style=""&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;$ch2 = $ch1-&gt;getNextSibling() &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div style="mso-line-spacing:&amp;quot;70 50 0&amp;quot;;mso-char-wrap:1;mso-kinsoku-overflow: 1"&gt;&lt;span style=""&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;$title = $ch2-&gt;getFirstChild();&lt;span class="Apple-style-span" style="font-family: Georgia; "&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="mso-line-spacing:&amp;quot;70 50 0&amp;quot;;mso-char-wrap:1;mso-kinsoku-overflow: 1"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="mso-line-spacing:&amp;quot;70 50 0&amp;quot;;mso-char-wrap:1;mso-kinsoku-overflow: 1"&gt;&lt;span style=""&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia; "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Yuck! This is really horrible, lots of method calls and very little &lt;/span&gt;&lt;a href="http://www.martinfowler.com/bliki/FluentInterface.html"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;fluency&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;. Ok we can do better, let's try again:&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new'; "&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="mso-line-spacing:&amp;quot;70 50 0&amp;quot;;mso-char-wrap:1;mso-kinsoku-overflow: 1"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="mso-line-spacing:&amp;quot;70 50 0&amp;quot;;mso-char-wrap:1;mso-kinsoku-overflow: 1"&gt;&lt;span style=""&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia; "&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new'; "&gt;$xml = $input-&gt;getChild(‘XMLNSC’);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/p:colorscheme&gt;&lt;/div&gt;&lt;div&gt;&lt;p:colorscheme colors="#FFFFFF,#000000,#808080,#7889FB,#7889FB,#2DB6B3,#0000FF,#D18213"&gt;&lt;div shape="_x0000_s3074" class="O"&gt;  &lt;div style="mso-line-spacing:&amp;quot;70 50 0&amp;quot;;mso-char-wrap:1;mso-kinsoku-overflow: 1"&gt;&lt;span style=""&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;$doc = $xml-&gt;getChild(‘document’); &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div style="mso-line-spacing:&amp;quot;70 50 0&amp;quot;;mso-char-wrap:1;mso-kinsoku-overflow: 1"&gt;&lt;span style=""&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;$ch2 = $doc-&gt;getChild(‘chapter’, 1); &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div style="mso-line-spacing:&amp;quot;70 50 0&amp;quot;;mso-char-wrap:1;mso-kinsoku-overflow: 1"&gt;&lt;span style=""&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;$title = $ch2-&gt;getAttribute(‘title’);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="display: none; "&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="mso-line-spacing:&amp;quot;70 50 0&amp;quot;;mso-char-wrap:1;mso-kinsoku-overflow: 1"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="mso-line-spacing:&amp;quot;70 50 0&amp;quot;;mso-char-wrap:1;mso-kinsoku-overflow: 1"&gt;Well it's a bit better but still far too much like hard work.&lt;/div&gt;&lt;div style="mso-line-spacing:&amp;quot;70 50 0&amp;quot;;mso-char-wrap:1;mso-kinsoku-overflow: 1"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="mso-line-spacing:&amp;quot;70 50 0&amp;quot;;mso-char-wrap:1;mso-kinsoku-overflow: 1"&gt;&lt;div style="mso-line-spacing:&amp;quot;70 50 0&amp;quot;;mso-char-wrap:1;mso-kinsoku-overflow: 1"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;$title = &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="mso-line-spacing:&amp;quot;70 50 0&amp;quot;;mso-char-wrap:1;mso-kinsoku-overflow: 1"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    $input-&gt;XMLNSC-&gt;document-&gt;chapter[1][‘title’]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;That's better! A really expressive way of navigating through messages. This is only scratching the surface of the PHP integration and the &lt;a href="http://www.slideshare.net/AntPhillips/"&gt;slides &lt;/a&gt;cover many other examples such as array integration, message shredding and content based routing.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/p:colorscheme&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/2019810910688159562/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2009/01/ive-put-some-slides-up-here-that-andy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/2019810910688159562'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/2019810910688159562'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2009/01/ive-put-some-slides-up-here-that-andy.html' title=''/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_PvsuDEcKVb8/SWTK4m5ScyI/AAAAAAAAAAo/xLx0fg9dlSQ/s72-c/MessageTree.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-1422559531124944808</id><published>2009-01-06T10:36:00.000Z</published><updated>2009-01-06T17:50:41.959Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='bridge'/><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='static'/><category scheme='http://www.blogger.com/atom/ns#' term='methods'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='fields'/><category scheme='http://www.blogger.com/atom/ns#' term='magic'/><title type='text'>Static Fields and Methods</title><content type='html'>One nice feature of PHP is its support for &lt;a href="http://www.php.net/oop5.magic"&gt;magic methods&lt;/a&gt;. These allow a class or object to catch a range of events such as method calls and property accesses. This kind of interception is really powerful and allows classes to implement all sorts of dynamic behaviour. For example, a database wrapper could intercept property access to get a property value from a database row. Many scripting languages offer something similar, for example Groovy has its own set of &lt;a href="http://groovy.codehaus.org/Dynamic+Groovy"&gt;interceptors&lt;/a&gt;.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;php.net is implemented in C and under the covers it implements magic methods by attaching a table of function pointers to each object (called the object handlers). In most cases the default implementation of an object handler is to simply call the appropriate PHP method on the class. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For example, there is a &lt;span class="Apple-style-span"  style="font-size:small;"&gt;__call &lt;/span&gt;object handler which calls the &lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;__call &lt;/span&gt;PHP &lt;/span&gt;magic method if it exists. Built in classes like &lt;a href="http://www.php.net/simplexml"&gt;SimpleXML&lt;/a&gt; and &lt;a href="http://www.php.net/mysqli"&gt;MySQLi&lt;/a&gt; use object handlers to implement whatever logic they need. All of this and a lot more besides is documented in Sara Golemans &lt;a href="http://www.amazon.com/Extending-Embedding-PHP-Developers-Library/dp/067232704X"&gt;book&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In Project Zero we added magic methods like &lt;span class="Apple-style-span"  style="font-size:small;"&gt;__call&lt;/span&gt;, &lt;span class="Apple-style-span"  style="font-size:small;"&gt;__get &lt;/span&gt;and &lt;span class="Apple-style-span"  style="font-size:small;"&gt;__set &lt;/span&gt;a long time ago. Over the Christmas break we finally got round to adding their static equivalents: &lt;span class="Apple-style-span"  style="font-size:small;"&gt;__callStatic&lt;/span&gt;,&lt;span class="Apple-style-span"  style="font-size:small;"&gt; __getStatic&lt;/span&gt;, &lt;span class="Apple-style-span"  style="font-size:small;"&gt;__setStatic &lt;/span&gt;and &lt;span class="Apple-style-span"  style="font-size:small;"&gt;__issetStatic&lt;/span&gt;. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here's an example of how &lt;span class="Apple-style-span"  style="font-size:small;"&gt;__callStatic &lt;/span&gt;can be used:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;lt;?php&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;class Foo {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;static public function __callStatic($a, $b) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;print "__callStatic [$a]\n";&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;foo::Test();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;?&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We have also surfaced this feature into the Java Bridge:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;lt;?php&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;java_import("java.lang.Integer", NULL, FALSE);&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;var_dump(Integer::$MIN_VALUE);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;var_dump(Integer::$MAX_VALUE);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;var_dump(Integer::toHexString("1234567890"));&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;var_dump(Integer::toOctalString("1234567890"));&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;// Signatures also work as normal!&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$signature = new JavaSignature(JAVA_STRING);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;var_dump(Integer::parseInt($signature, "1234567890"));&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;?&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This makes for a much cleaner syntax than using &lt;a href="http://www.projectzero.org/sMash/1.1.x/docs/zero.devguide.doc/zero.php/ZeroAdvancedPHPJavaBridge.html"&gt;JavaClass&lt;/a&gt;. &lt;span class="Apple-style-span"  style="font-size:small;"&gt;JavaClass &lt;/span&gt;was always something of an anomaly (er, hack) as it required the script to create an instance of an object just to access static class methods and properties. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;More information about this feature will be available just as soon as the Project Zero documentation has rebuilt tonight [:o)&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/1422559531124944808/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2009/01/static-fields-and-methods.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/1422559531124944808'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/1422559531124944808'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2009/01/static-fields-and-methods.html' title='Static Fields and Methods'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-3405997927408498942</id><published>2009-01-01T09:49:00.000Z</published><updated>2009-01-01T18:24:29.319Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='bridge'/><category scheme='http://www.blogger.com/atom/ns#' term='reflection'/><category scheme='http://www.blogger.com/atom/ns#' term='invoke'/><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>Thoughts on Bridging PHP and Java</title><content type='html'>I thought it might be interesting to talk a little about how we bridge between Java and PHP in Project Zero. So to start with I'm going to explain some background to the problem and then in a follow up post talk more about how the Java Bridge works in practice.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Java and PHP&lt;/span&gt;&lt;/div&gt;&lt;div&gt;I'm not going to enumerate every difference between the languages but I will talk a little about the main issues that effect the Java Bridge. First of all I should say that Java and PHP share much common ground in their object oriented design: objects, interfaces, classes, methods, fields, static members, exceptions, visibility (public, private etc) and so on. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;They also have some differences and this is where the problems often arise when integrating the two languages. For example, PHP methods, classes and function names are case insensitive, while in Java they are case sensitive. So it is possible, although unlikely, that a PHP script could invoke a method &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;foo()&lt;/span&gt; which has several possible target methods on a Java object (&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Foo&lt;/span&gt;, &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;FOO&lt;/span&gt;, &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;foo &lt;/span&gt;etc).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold; "&gt;Overloaded Methods&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;PHP does not support overloading of constructors nor methods. Java does support overloaded methods and constructors. Overloading in Java means two or more methods or constructors on the same class that have the same name but different argument types. Overloading on the return type alone is not allowed. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The most difficult issue with overloading is selecting the right overload. This &lt;span class="Apple-style-span" style="font-style: italic;"&gt;has &lt;/span&gt;to be done at runtime for reasons explained later.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Static and Instance Methods&lt;/span&gt;&lt;/div&gt;&lt;div&gt;PHP also allows instance methods on an object to be called statically, consider the following code:&lt;/div&gt;&lt;code&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; class Foo {&lt;br /&gt;    function bar() { }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Foo::bar();&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;div&gt;This runs fine albeit with the following &lt;a href="http://www.php.net/manual/en/book.errorfunc.php"&gt;strict coding notice&lt;/a&gt; to highlight the potential problem:&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Strict Standards: Non-static method Foo::bar() should not be called statically in foo.php on line 7&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In case you are wondering, if the method trys to access an instance field as follows:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;class Foo {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;function bar() { &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;$this-&gt;a = "Hello World!";&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" white-space: pre; font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Foo::bar();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Then a fatal error terminates the script with this output:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Fatal error: Using $this when not in object context in foo.php on line 4&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the context of the Java Bridge, we cannot call an instance method on a Java object in a static way because this is simply not possible in Java. We can however do the reverse, which is to allow a PHP script to call a static method through an instance of the object. As the Java API documentation for a dynamic invoke &lt;a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/Method.html#invoke(java.lang.Object, java.lang.Object[])"&gt;shows&lt;/a&gt;, the &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;obj&lt;/span&gt; argument is ignored if the method is static.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Dynamic Typing (&lt;a href="http://en.wikipedia.org/wiki/Duck_typing"&gt;Duck Typing&lt;/a&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;From my experience, the biggest difficulty by far is with data typing. In PHP, variables have no declared data type. One minute a variable might be an integer and the next a string. In Java all variables have a fixed type, albeit with some latitude granted by polymorphism. Furthermore PHP does an amazing job of coercing types to match the circumstances:&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;echo strlen(array(1,2,3));&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In this snippet I'm passing an array to a function clearly expecting a string. PHP politely informs me via a notice that it had to do something strange:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Notice: Array to string conversion in foo.php on line 3&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;And outputs 5 (why 5? Because it converted the array to the string &lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Array&lt;/span&gt;&lt;/span&gt;).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here is another simple example of type coercion:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;echo abs("123456789");&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In this snippet the &lt;span class="Apple-style-span"  style="font-size:small;"&gt;abs &lt;/span&gt;function converts the string to an integer. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;So what does this mean? &lt;/span&gt;&lt;/div&gt;&lt;div&gt;It means selecting the Java method to invoke is often the most difficult (and time consuming) part of the Java Bridge. This is especially true for overloaded constructors and methods. Perhaps the data type of an argument is a string and there is no candidate Java method that accepts a string argument. But instead, what if the string can be coerced to an integer like the &lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;abs&lt;/span&gt;&lt;/span&gt; snippet above? The permutations are many and varied and that's what makes bridging languages such an interesting problem.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The key thing is that we always follow PHP's example of being incredibly tolerant and wherever possible do the best thing we can. In some cases we simply cannot be absolutely sure we have chosen the right method or constructor. In which case we pick what we think is best and output a message saying the script needs to give us a better clue (for example, by using the &lt;a href="http://www.projectzero.org/sMash/1.1.x/docs/zero.devguide.doc/zero.php/ZeroAdvancedPHPJavaBridge.html"&gt;JavaSignature &lt;/a&gt;class).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In many regards the Java Bridge acts much like a compiler does in selecting methods and fields. The big difference is that the Java Bridge does the selection at &lt;span class="Apple-style-span" style="font-style: italic;"&gt;runtime &lt;/span&gt;based on the data types of arguments. A compiler does the selection at &lt;span class="Apple-style-span" style="font-style: italic;"&gt;compile time&lt;/span&gt; based on the &lt;span class="Apple-style-span" style="font-style: italic;"&gt;declared &lt;/span&gt;data types of arguments. And of course the Java Bridge has to be quick, &lt;span class="Apple-style-span" style="font-style: italic;"&gt;really &lt;/span&gt;quick. Java's reflection API is much faster than it used to be but it is still relatively slow to lookup classes, methods and parameter types.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/3405997927408498942/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2009/01/bridging-php-and-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/3405997927408498942'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/3405997927408498942'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2009/01/bridging-php-and-java.html' title='Thoughts on Bridging PHP and Java'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5534616972635403710.post-2787918987459929748</id><published>2008-12-31T13:07:00.001Z</published><updated>2008-12-31T15:43:31.018Z</updated><title type='text'>Java Bridge</title><content type='html'>I work in the team developing the PHP runtime for WebSphere sMash (&lt;a href="http://www.projectzero.org/"&gt;Project Zero&lt;/a&gt;). The PHP engine is implemented in Java. One very powerful feature of the PHP runtime is its &lt;a href="http://www.projectzero.org/sMash/1.1.x/docs/zero.devguide.doc/zero.php/ZeroAdvancedPHPJavaBridge.html"&gt;Java Bridge&lt;/a&gt;. The aim is to allow completely seemless integration between Java, PHP and Groovy. We released WebSphere sMash 1.1 just a few weeks ago and are hard at work on the next version already. With this in mind I've posted some slides that show what the Java Bridge can do &lt;a href="http://www.slideshare.net/AntPhillips"&gt;here&lt;/a&gt;.  &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;There is also a developerWorks article &lt;a href="http://www.ibm.com/developerworks/websphere/library/techarticles/0809_phillips/0809_phillips.html"&gt;here &lt;/a&gt;which shows how to use the &lt;a href="http://lucene.apache.org/java/docs/"&gt;Apache Lucene&lt;/a&gt; libraries in sMash.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Because we compile PHP scripts down to Java byte code, the Java Bridge is also extremely fast. This has made it possible to do some interesting integration with sMash PHP into products other than web server technology. For example, we shipped a new feature in WebSphere Message Broker at the end of November so that custom transformation and routing logic can be written in PHP. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Message Broker is the brains behind many seriously high traffic systems (from various stock exchanges to the Wimbledon Tennis Championships). This kind of business logic is performance sensitive and the fast PHP/Java interop really helps. There is more information about the new PHP Compute Node &lt;a href="http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/index.jsp?topic=/com.ibm.etools.mft.doc/ab67750_.htm"&gt;here&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you are interested in PHP you might also be interested in Zoe's &lt;a href="http://zoomsplatter.blogspot.com/"&gt;blog &lt;/a&gt;- she recently posted about some related work we have been doing to integrate sMash into &lt;a href="http://www.projectzero.org/blog/index.php/2008/12/15/cics-gets-smashed/"&gt;CICS&lt;/a&gt;. All of this goes to show how PHP's flexibility makes it a really good general purpose programming language beyond just the web application space.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antblah.blogspot.com/feeds/2787918987459929748/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antblah.blogspot.com/2008/12/i-work-in-team-developing-php-runtime.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/2787918987459929748'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5534616972635403710/posts/default/2787918987459929748'/><link rel='alternate' type='text/html' href='http://antblah.blogspot.com/2008/12/i-work-in-team-developing-php-runtime.html' title='Java Bridge'/><author><name>Ant Phillips</name><uri>http://www.blogger.com/profile/12340239827880191034</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://1.bp.blogspot.com/_PvsuDEcKVb8/SVttr6MsBVI/AAAAAAAAAAM/oo9nO1JRXjw/S220/Thumbnail.jpg'/></author><thr:total>0</thr:total></entry></feed>