« March 2008 | Main | May 2008 »

April 2008 Archives

April 14, 2008

Recursively replacing a string in all files in a directory [Linux]

My colleague provided me an extremely useful script that will replace a source string with a target string in all files in the current directory and its subdirectories.

find . -type f | xargs perl -pi~ -e 's/oldtext/newtext/g;'

Replace "oldtext" with the source string, and "newtext" with the target string.


During the replacement, all original files are backed up with a  "~" suffix.

April 15, 2008

Dynamically updating bpel.xml properties within your BPEL Process

There are different properties that you could actually update in your process descriptor. They are a) The Configuration properties b) The preference properties c) The partnerlink properties. These properties are illustrated below.






  1. <BPELSuitcase>  
  2.   <BPELProcess id="UpdatePropertyProcess" src="UpdatePropertyProcess.bpel">  
  3.     <partnerLinkBindings>  
  4.       <partnerLinkBinding name="client">  
  5.         <property name="wsdlLocation">  
  6.           UpdatePropertyProcess.wsdl   
  7.         </property>  
  8.         <property name="partnerlinkProperty1">  
  9.           valueOfPartnerlinkProperty 1   
  10.         </property>  
  11.       </partnerLinkBinding>  
  12.     </partnerLinkBindings>  
  13.      <preferences>  
  14.        <property name="preferenceProperty1" encryption="plaintext">  
  15.          valueOfPreferenceProperty1   
  16.        </property>  
  17.      </preferences>  
  18.      <configurations>  
  19.       <property name="configProperty1" encryption="plaintext">  
  20.         valueOfConfigProperty1   
  21.       </property>  
  22.       </configurations>  
  23.    </BPELProcess>  
  24. </BPELSuitcase>  

To update these properties dynamically within the BPEL Process, you can use a Java embedding within the process, as shown below.






  1.   
  2. try {   
  3.   getLocator().lookupProcess ("UpdatePropertyProcess").   
  4.                  getDescriptor ().   
  5.                   getConfigurations().   
  6.                     setPropertyValue ("configProperty1",   
  7.                      "newValueOfConfigPropertyValue1");   
  8.   getLocator().lookupProcess ("UpdatePropertyProcess").   
  9.                   getDescriptor ().   
  10.                    getPreferences().   
  11.                     setPropertyValue ("preferenceProperty1",   
  12.                       "newValueOfPreferenceProperty1" );   
  13.   getLocator().lookupProcess ("UpdatePropertyProcess").   
  14.                   getDescriptor ().   
  15.                    getPartnerLinkBindings().   
  16.                      getPartnerLinkBinding ("client").   
  17.                        setPropertyValue ("partnerlinkProperty1",   
  18.                        "newValueOfPartnerlinkProperty 1");   
  19.  }   
  20.  catch(Throwable ex) {   
  21.  }   
  22.    

Click here to download the Sample BPEL Process project.

April 21, 2008

Obtaining the Execution Times of BPEL Processes over a period of time

Here is a simple BPEL Query that will get you the statistics of execution times of all BPEL Process instances over a period of time. The stats include the number of invocations, minimum, maximum and average time of execution.






  1. SELECT process_id,count(*) as num_invocations,   
  2.   max(((EXTRACT(HOUR FROM MODIFY_DATE) - extract(hour from creation_date)) *3600 +   
  3.       (EXTRACT(MINUTE FROM MODIFY_DATE) - extract(MINUTE from creation_date)) *60 +   
  4.       (EXTRACT(SECOND FROM MODIFY_DATE) - extract(SECOND from creation_date))) *1000)   
  5.   as Max_Time ,   
  6.   
  7.   min(((EXTRACT(HOUR FROM MODIFY_DATE) - extract(hour from creation_date)) *3600 +   
  8.      (EXTRACT(MINUTE FROM MODIFY_DATE) - extract(MINUTE from creation_date)) *60 +   
  9.      (EXTRACT(SECOND FROM MODIFY_DATE) - extract(SECOND from creation_date))) *1000)   
  10.   as Min_Time ,   
  11.   
  12.   avg(((EXTRACT(HOUR FROM MODIFY_DATE) - extract(hour from creation_date)) *3600 +   
  13.      (EXTRACT(MINUTE FROM MODIFY_DATE) - extract(MINUTE from creation_date)) *60 +   
  14.      (EXTRACT(SECOND FROM MODIFY_DATE) - extract(SECOND from creation_date))) *1000)   
  15.   as Avg_Time   
  16.   
  17.   FROM CUBE_INSTANCE   
  18.     WHERE  
  19.       state <> 9   
  20.         and  
  21.       creation_date > '09-APR-08 09.00.00.000000000 AM'  
  22.         and  
  23.       creation_date < '09-APR-08 01.00.00.000000000 PM'  
  24.   
  25.       group by process_id order by process_id asc  

In this query, you need to replace the sample date and time values with the values that you wish to use and report. Here is another query that gives the execution times of all BPEL instances over the given time period.






  1.   
  2. select bpel_process_name as process_id,   
  3.        instance_key as cikey,   
  4.        trunc(creation_date),   
  5.        eval_time as exec_time   
  6. from bpel_process_instances   
  7. where state <> 9 and  
  8.       creation_date > '11-APR-08 09.00.00.000000000 AM' and  
  9.       creation_date < '11-APR-08 05.00.00.420000000 PM'  
  10. order by process_id asc, exec_time desc  
  11.     

In this query, you need to replace the sample date and time values with the values that you wish to use and report. Note that the above query shall give you the execution times for a particular day. Take a look at the comments on this blog entry to see a modified example that uses the "day" as well to obtain stats that span across multiple days.

April 22, 2008

Reusing code snippets in JDeveloper

Here is one simple but useful thing that I've been too lazy to make use of, and had overlooked.


JDeveloper's component palette has a page named "Code Snippets". You could actually add frequently re-used code snippets and save them into the "code snippets" section.



Once you click on "Add component", you can give the snippet a name, for e.g. "Assign WS-Addressing Headers" and copy the snippet from your source code  to the given text area.


You can now re-use the code snippet by dragging and dropping the component from the code snippet palette onto the source view of any file that you open in JDeveloper.


Similarly, you can also add your own Pages to the Component palette, to capture Snippets for diferent cateogies of code [for instnace, BPEL,XML, XSD, XSLT etc].



Now you can specify the Page Name and specify the type  - "snippet", "java" etc.


 


 



 


Now you can add new code snippets to the new Palette Page that you created.


 

Viewing Audits for Stale instances

Wondering what to do if you wished to view the audit trail for stale instances?


Well, you could make use of the View Raw XML feature in the BPEL Console.


 


 

About April 2008

This page contains all entries posted to Ramkumar Menon's Blog in April 2008. They are listed from oldest to newest.

March 2008 is the previous archive.

May 2008 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle