<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Programming on Shaaf's blog</title><link>https://shaaf.dev/tags/programming/</link><description>Recent content in Programming on Shaaf's blog</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 11 Apr 2022 07:07:22 +0200</lastBuildDate><atom:link href="https://shaaf.dev/tags/programming/index.xml" rel="self" type="application/rss+xml"/><item><title>Processing images in Java with OpenCV and Quarkus</title><link>https://shaaf.dev/post/2022-04-11-processing-images-in-java-with-opencv-and-quarkus/</link><pubDate>Mon, 11 Apr 2022 07:07:22 +0200</pubDate><guid>https://shaaf.dev/post/2022-04-11-processing-images-in-java-with-opencv-and-quarkus/</guid><description>&lt;p>If you are into Computer vision, you probably are familiar with &lt;a href="https://opencv.org/">OpenCV&lt;/a>. Its an amazing library that has almost everything one needs to do 2D and 3D processing and much more. Gesture recognition, face detection, Motion tracking, think of anything related to image processing and OpenCV can be your goto. Its based on the BSD license, so you can just download it and start using it.&lt;/p>
&lt;p>OpenCV is written in C, and there are nice Java bindings for it too. If you are a Java developer like me and dont want to get into all the loading and building native bindings etc., then read on. In this article I will show how you can use OpenCV with the popular new framework Quarkus, without worrying about installing libraries or reloading the entire app.&lt;/p></description></item><item><title>SQL cache stores and more in Data Grid 8.3</title><link>https://shaaf.dev/post/2022-02-24-sql-cache-stores-and-more-data-grid-83/</link><pubDate>Thu, 24 Feb 2022 07:07:22 +0200</pubDate><guid>https://shaaf.dev/post/2022-02-24-sql-cache-stores-and-more-data-grid-83/</guid><description>&lt;blockquote>
&lt;p>&lt;em>Orignally posted at&lt;/em> &lt;a href="https://developers.redhat.com/articles/2022/02/24/sql-cache-stores-and-more-data-grid-83">Red Hat Developers&lt;/a>&lt;/p>&lt;/blockquote>
&lt;p>&lt;a href="https://developers.redhat.com/products/datagrid/overview">Red Hat Data Grid&lt;/a> is a distributed, cloud-based datastore offering very fast response times as an in-memory database. The latest version, Data Grid 8.3, features cross-site replication with more observability and two new types of SQL cache store for scaling applications with large datasets. This version also brings improved security, support for Helm charts, and a better command-line interface (CLI).&lt;/p>
&lt;p>This article is an overview of new features and enhancements in this latest version of Red Hat Data Grid.&lt;/p></description></item><item><title>What's new for developers in Java 18</title><link>https://shaaf.dev/post/2022-01-27-whats-new-for-developers-in-java-18/</link><pubDate>Thu, 27 Jan 2022 07:07:22 +0200</pubDate><guid>https://shaaf.dev/post/2022-01-27-whats-new-for-developers-in-java-18/</guid><description>&lt;blockquote>
&lt;p>&lt;em>Orignally posted at&lt;/em> &lt;a href="https://developers.redhat.com/articles/2022/01/27/whats-new-developers-java-18#">Red Hat Developers&lt;/a>&lt;/p>&lt;/blockquote>
&lt;p>In exciting news for &lt;a href="https://developers.redhat.com/topics/enterprise-java">Java&lt;/a> developers, Java 18 forked off from the main line &lt;a href="https://www.infoq.com/news/2021/12/java-news-roundup-dec06-2021/">at the end of last year&lt;/a> and has entered &lt;a href="https://openjdk.java.net/projects/jdk/18/">Rampdown Phase Two&lt;/a>. This article highlights some of the features that developers can look for in the upcoming Java 18 release, including the new simple web server module, a more sophisticated way to annotate your Javadocs, and the &lt;code>–finalization=disabled&lt;/code> option, which lets you test how a Java application will behave when finalization is removed in a future release. See the end of the article for where to download Java 18 in early access builds.&lt;/p></description></item><item><title>Deploy Quarkus everywhere with Red Hat Enterprise Linux (RHEL)</title><link>https://shaaf.dev/post/2021-05-17-deploy-quarkus-everywhere/</link><pubDate>Fri, 07 May 2021 07:07:22 +0200</pubDate><guid>https://shaaf.dev/post/2021-05-17-deploy-quarkus-everywhere/</guid><description>&lt;blockquote>
&lt;p>&lt;em>Orignally posted at&lt;/em> &lt;a href="https://developers.redhat.com/blog/2021/04/07/deploy-quarkus-everywhere-with-red-hat-enterprise-linux-rhel#">Red Hat Developers&lt;/a>&lt;/p>&lt;/blockquote>
&lt;p>Java is one of the most used languages out there and has been in the&lt;a href="https://www.tiobe.com/tiobe-index/?hid=B4E841AA3BF5CD6D546F03D321E49994&amp;amp;wordfence_lh=1"> top three&lt;/a> for the last two decades. Java powers millions of applications across verticals and platforms. Linux is widely deployed in data centers, Edge networks, and Cloud. Today we announce the availability of Quarkus for all our Red Hat Enterprise Linux (RHEL) customers. If you are running RHEL, you can now also run Red Hat Build of Quarkus (RHBQ). By doing this, we enable our customers, partners, and software vendors to use RHBQ in their applications with ease and furthermore enable them to deploy Quarkus for multiple use-cases for Java on Linux. If you are developing applications on a Kubernetes platform like Openshift, you can also use RHBQ with it, and this was&lt;a href="https://www.redhat.com/en/blog/introducing-quarkus-red-hat-openshift"> announced&lt;/a> last year. What is Quarkus and how can I develop and deploy it on RHEL? Learn more in this post.&lt;/p></description></item><item><title>Creating and deploying a Java 8 runtime container image</title><link>https://shaaf.dev/post/2019-02-26-create-java-8-runtime-container-image/</link><pubDate>Tue, 26 Feb 2019 07:07:22 +0200</pubDate><guid>https://shaaf.dev/post/2019-02-26-create-java-8-runtime-container-image/</guid><description>&lt;blockquote>
&lt;p>&lt;em>Orignally posted at&lt;/em> &lt;a href="https://developers.redhat.com/blog/2019/02/26/create-java-8-runtime-container-image">Red Hat Developers&lt;/a>&lt;/p>&lt;/blockquote>
&lt;p>A Java runtime environment should be able to run compiled source code, whereas a development kit, for example, OpenJDK, would include all the libraries/binaries to compile and run the source code. Essentially the latter is a superset of the runtime environment. More details on OpenJDK support and lifecycle can be found &lt;a href="https://access.redhat.com/articles/1299013">here&lt;/a>.&lt;/p>
&lt;p>Red Hat ships and supports container images with OpenJDK for both Java 8 and 11. More details are &lt;a href="https://access.redhat.com/containers/#/search/openjdk">here&lt;/a>. If you are using Red Hat Middleware, the s2i images shipped are also useful to deploy, for example, on Red Hat Openshift Container Platform.&lt;/p></description></item><item><title>number of lines of code in a directory</title><link>https://shaaf.dev/post/2010-10-29-number-of-lines-of-code-in-a-directory/</link><pubDate>Fri, 29 Oct 2010 15:25:39 +0200</pubDate><guid>https://shaaf.dev/post/2010-10-29-number-of-lines-of-code-in-a-directory/</guid><description>&lt;p>I just wanted to find the number of lines of java code in a directory i.e. recursively..&lt;/p>
&lt;pre>&lt;code>find . -type f -name '*java' -print0 | wc -l --files0-from=-

Output:
.
.
56 ./App.java
550 total
&lt;/code>&lt;/pre></description></item><item><title>Logging with log4J isDebugEnabled</title><link>https://shaaf.dev/post/2009-08-12-logging-with-log4j-isdebugenabled/</link><pubDate>Wed, 12 Aug 2009 14:39:52 +0200</pubDate><guid>https://shaaf.dev/post/2009-08-12-logging-with-log4j-isdebugenabled/</guid><description>&lt;p>Excerpt: Alot of times I have seen the questions popping up whether to use isDebugEnabled property or not. Arguably most of the times or rather always about performance. Some of the stuff that I feel important about using it follows.&lt;/p>
&lt;p>Alot of times I have seen the questions popping up whether to use isDebugEnabled property or not. Arguably most of the times or rather always about performance. Some of the stuff that I feel important about using it follows.&lt;/p></description></item><item><title>Calling wsadmin scripts from ant</title><link>https://shaaf.dev/post/2008-12-11-calling-wsadmin-scripts-from-ant/</link><pubDate>Thu, 11 Dec 2008 10:17:46 +0100</pubDate><guid>https://shaaf.dev/post/2008-12-11-calling-wsadmin-scripts-from-ant/</guid><description>&lt;p>You can simply add the following to a target.
For the following wsadmin should be in your PATH env.&lt;/p>
&lt;pre>&lt;code>&amp;lt; exec dir=&amp;quot;.&amp;quot; executable=&amp;quot;wsadmin.bat&amp;quot; logError=&amp;quot;true&amp;quot; failonerror=&amp;quot;true&amp;quot; output=&amp;quot;wsconfig.out&amp;quot; &amp;gt;
	&amp;lt; arg line=&amp;quot;-lang jython -f ../../createQFactory.py&amp;quot;/ &amp;gt;
&amp;lt; /exec &amp;gt;
&lt;/code>&lt;/pre>
&lt;p>All output will be logged to wsconfig.out&lt;/p></description></item><item><title>Generate XML - DBMS_XMLGEN</title><link>https://shaaf.dev/post/2008-12-10-generate-xml-dbms_xmlgen/</link><pubDate>Wed, 10 Dec 2008 16:58:04 +0100</pubDate><guid>https://shaaf.dev/post/2008-12-10-generate-xml-dbms_xmlgen/</guid><description>&lt;p>On my way to my solution store just found this nice to use, old and easy feature.
Possibilities endless, usage typically very easy.&lt;/p>
&lt;p>I used the following to generate XML from sqlplus:&lt;/p>
&lt;pre>&lt;code>select dbms_xmlgen.getxml('select * from user') from dual;
&lt;/code>&lt;/pre>
&lt;p>Output:
&amp;lt; ROWSET &amp;gt;
&amp;lt; ROW &amp;gt;
&amp;lt; TNAME &amp;gt;Employee&amp;lt; / TNAME &amp;gt;
&amp;lt; TABTYPE &amp;gt; TABLE &amp;lt; / TABTYPE &amp;gt;
&amp;lt; / ROW &amp;gt;
&amp;lt; / ROWSET &amp;gt;&lt;/p></description></item><item><title>Command, Singleton, JMenuItem, JButton, AbstractButton - One Listener for the app</title><link>https://shaaf.dev/post/2008-11-17-command-singleton-jmenuitem-jbutton-abstractbutton-one-listener-for-the-app/</link><pubDate>Mon, 17 Nov 2008 21:17:24 +0100</pubDate><guid>https://shaaf.dev/post/2008-11-17-command-singleton-jmenuitem-jbutton-abstractbutton-one-listener-for-the-app/</guid><description>&lt;p>Here I would like to demonstrate a simple use of JMenuItems being used with Single Listener for the entire system.
A simple sample of use would probably be SingleInstance Desktop Application.&lt;/p>
&lt;p>Lets see how that is done here.&lt;/p>
&lt;ol>
&lt;li>First lets create a OneListener class that should be able to listen to ActionEvents and also be able to add Commands to itself. Please refer to my previous post on Command,Singleton if you would like to see more about this patterns and there usage.&lt;/li>
&lt;/ol>
&lt;pre tabindex="0">&lt;code>	package com.shaafshah.jmenus;

	import java.awt.event.ActionEvent;
	import java.awt.event.ActionListener;
	import java.util.ArrayList;
	import javax.swing.AbstractButton;

	// Implements the ActionListener and is a Singleton also.

	public class OneListener implements ActionListener{

		private static OneListener oneListener = null;

		// Holds the list of all commands registered to this listener
		private ArrayList&amp;lt;Command&amp;gt; commandList = null;

		// A private constructor
		private OneListener(){
			commandList = new ArrayList&amp;lt;Command&amp;gt;();
		}

		// Ensuring one instance.
		public static OneListener getInstance(){
			if(oneListener != null)
				return oneListener;
			else return oneListener = new OneListener();
		}

		// Add the command and add myself as the listener
		public void addCommand(Command command){
			commandList.add(command);
		 ((AbstractButton)command).addActionListener(this);
		}


		// All Events hit here.
		@Override
		public void actionPerformed(ActionEvent e) {
			((Command)e.getSource()).execute();
		}

	}&lt;/code>&lt;/pre>&lt;p>In the above code, the addCommand method adds the command Object and adds a listener to it.
Now how is that possible.
Basically because I am categorizing my UI objects as Commands with in the system having some UI. And I am also assuming that these commands are Currently AbstractButton i.e. JMenuItem, JButton. Lets have a look at the Command Interface and its Implementation.&lt;/p></description></item><item><title>Doing the Locale - Danmark</title><link>https://shaaf.dev/post/2008-11-12-doing-the-locale-danmark/</link><pubDate>Wed, 12 Nov 2008 14:52:08 +0100</pubDate><guid>https://shaaf.dev/post/2008-11-12-doing-the-locale-danmark/</guid><description>&lt;p>The following illustrates how to get the Number format working with a danish locale.&lt;/p>
&lt;pre tabindex="0">&lt;code>	import java.text.NumberFormat;
	import java.util.Currency;
	import java.util.Locale;


	public class TestLocale {

	public static void main(String args[]){
		// Create a Locale for Danmark
		Locale DANMARK = new Locale(&amp;#34;da&amp;#34;,&amp;#34;DK&amp;#34;);

 		// get the currency instance for this locale.
 		Currency krone = Currency.getInstance(DANMARK);

 		// Get a Number format for the locale.
 		NumberFormat krFormat = NumberFormat.getCurrencyInstance(DANMARK);
 		// A symbol for the currency
 		String symbol = krFormat.getCurrency().getSymbol();
 		// A double amount
 		double amount = 10000.25;
		// print it out after formatting.
 		System.out.println(krFormat.format(amount));
 		}
	}&lt;/code>&lt;/pre></description></item><item><title>How to read a file from the JAR?</title><link>https://shaaf.dev/post/2008-10-31-how-to-read-a-file-from-the-jar/</link><pubDate>Fri, 31 Oct 2008 20:57:54 +0100</pubDate><guid>https://shaaf.dev/post/2008-10-31-how-to-read-a-file-from-the-jar/</guid><description>&lt;p>Someone just asked me this question today. And I thought might as well put it down for info.&lt;/p>
&lt;pre tabindex="0">&lt;code> 	public TestReadFileFromJar() throws FileNotFoundException, IOException {
 	InputStream is = getClass().getResource(&amp;#34;txtData/states.properties&amp;#34;);
 	read(is);
	}&lt;/code>&lt;/pre>&lt;p>In the case above txtData is placed in the jar on the root. Remmember to add the path with the &amp;ldquo;/&amp;rdquo;&lt;/p></description></item><item><title>Command</title><link>https://shaaf.dev/post/2008-10-31-command/</link><pubDate>Fri, 31 Oct 2008 20:45:04 +0100</pubDate><guid>https://shaaf.dev/post/2008-10-31-command/</guid><description>&lt;p>By using the command pattern you are seperating the operation from the invoking object. And just because of that it becomes easier to change the command without chagning the caller/s.
This means that you could use Command pattern when you might have the following situation&lt;/p>
&lt;p>You want to parameterize objects to perform an action
You want to specify, execute and queue requests at different times.&lt;/p>
&lt;p>Just to quickly start you need a command object, An interface will keep it easy going in this case, thus providing you with the option of extending other classes e.g. Swing MenuItem or Button.
Below the execute Method is the one invoked to do something when this command is called or asked to do its stuff.
Where as the getCommandName is assumed as a unique name how ever I am sure we can always come up with a better implementation for uniqueness.&lt;/p></description></item><item><title>Implementing the adapter</title><link>https://shaaf.dev/post/2008-10-29-implementing-the-adapter/</link><pubDate>Wed, 29 Oct 2008 20:47:56 +0100</pubDate><guid>https://shaaf.dev/post/2008-10-29-implementing-the-adapter/</guid><description>&lt;p>Typically when implementing an interface you would have to implement all the methods that exist in that interface. A very good example is the MouseListener in the java Swing. When you need to implement more then one method where as typically you might be catching only one of them. Saying that you would also find a Mouse Adapter provided as well. Some of us use that often. And that is part of the Adapter pattern. It makes life easier for me sometimes.&lt;/p></description></item><item><title>wasprofile -create -delete</title><link>https://shaaf.dev/post/2008-10-24-wasprofile-create-delete/</link><pubDate>Fri, 24 Oct 2008 13:38:00 +0200</pubDate><guid>https://shaaf.dev/post/2008-10-24-wasprofile-create-delete/</guid><description>&lt;p>Sometimes you require to do things silently, without any questions asked and &amp;ldquo;Just Do It&amp;rdquo; attitude is required.&lt;/p>
&lt;p>I often find my self with this problem.&lt;/p>
&lt;p>If you want to delete or create a Websphere profile from your command line try the following. (I have tried on RSA only)&lt;/p>
&lt;pre>&lt;code># deleteing a profile
wasprofile -delete -profileName MyProfile
&lt;/code>&lt;/pre>
&lt;p>You should get the following message on deletion&lt;/p>
&lt;pre>&lt;code>INSTCONFSUCCESS: Success: The profile no longer exists.
&lt;/code>&lt;/pre>
&lt;p>Creating a websphere profile&lt;/p></description></item><item><title>Abstract Factory pattern</title><link>https://shaaf.dev/post/2008-10-10-abstract-factory-pattern/</link><pubDate>Fri, 10 Oct 2008 10:20:10 +0200</pubDate><guid>https://shaaf.dev/post/2008-10-10-abstract-factory-pattern/</guid><description>&lt;p>Factories have been a key pattern in building applications, its fascinatingly simple, effective and to the point. When starting to learn a design oriented approach to applications or API, I would always recommend a factory pattern as one of the key starting notes of highlight in your design.&lt;/p>
&lt;p>So today I am talking about the Abstract Factory pattern. Its not an &amp;ldquo;abstract&amp;rdquo; class or object that you call a pattern. But its a Factory of facotries and that is what exactly makes it so much wordingly abstract. Having &amp;ldquo;abstract&amp;rdquo; classes is there but just some other side of the coin.&lt;/p></description></item><item><title>Crocus - CSV Reader</title><link>https://shaaf.dev/post/2008-10-03-crocus-csv-reader/</link><pubDate>Fri, 03 Oct 2008 23:38:42 +0200</pubDate><guid>https://shaaf.dev/post/2008-10-03-crocus-csv-reader/</guid><description>&lt;p>Easy to use ready to go CSV File Reading utility. Read One or Multiple files into a RecordManager, quick access to the file with segmentation into Fields and Records. Merge Multiple CSV files in one. Listener to CSV Files.&lt;/p>
&lt;p>&lt;a href="https://sourceforge.net/project/platformdownload.php?group_id=172152">Download Here&lt;/a>&lt;/p>
&lt;p>Organization:
A CSV file is broken up as follows
A CSVField has a group of characters
A CSVRecord has a group of CSVFields
A CSVFile has a group of record&lt;/p></description></item><item><title>HowTo create a JDBC provider with wsadmin scripting - Jython</title><link>https://shaaf.dev/post/2008-07-01-howto-create-a-jdbc-provider-with-wsadmin-scripting-jython/</link><pubDate>Tue, 01 Jul 2008 14:21:48 +0200</pubDate><guid>https://shaaf.dev/post/2008-07-01-howto-create-a-jdbc-provider-with-wsadmin-scripting-jython/</guid><description>&lt;p>Last week I wrote a post about creating MQQueues with jacl. However today I am moving to Jython. This is the new scripting languauge supported by the wsadmin. The following write-up helps you create a JDBC provider using Jython in 6 easy steps on the wsadmin console.&lt;/p>
&lt;p>*Pre requirements:
*Following should be known to start using this tutorial.&lt;/p>
&lt;ol>
&lt;li>How to launch the wsadmin with Jython enabled.&lt;/li>
&lt;/ol>
&lt;p>*Where will I find the wsadmin?
*It is typically placed in the bin directory of your server.
In my case its lying in my RAD installation directory as
../Rational/SDP/6.0/runtimes/base_v6/bin&lt;/p></description></item><item><title>Creating an SVN wrap for your build using Ant</title><link>https://shaaf.dev/post/2008-06-30-creating-an-svn-wrap-for-your-build-using-ant/</link><pubDate>Mon, 30 Jun 2008 14:45:32 +0200</pubDate><guid>https://shaaf.dev/post/2008-06-30-creating-an-svn-wrap-for-your-build-using-ant/</guid><description>&lt;p>Today after along break I would jump right on to one of the interesting topics in my den these days.&lt;/p>
&lt;p>One of my friends was lately troubled with doing some SVN stuff like merging etc. And a lot of people will agree with me on their first experiences. :) I think.&lt;/p>
&lt;p>While Automated builds take a lot of our time I thought I could plug in with some automated merging and a few other tasks. Its hard to go over all of that in one post but I will try putting in some basic stuff to get us started.&lt;/p></description></item><item><title>Creating the MQQueues with wsadmin scripting - JACL Part 2</title><link>https://shaaf.dev/post/2008-06-25-creating-the-mqqueues-with-wsadmin-scripting-jacl-part-2/</link><pubDate>Wed, 25 Jun 2008 14:40:47 +0200</pubDate><guid>https://shaaf.dev/post/2008-06-25-creating-the-mqqueues-with-wsadmin-scripting-jacl-part-2/</guid><description>&lt;p>Yesterday I wrote an article about creating and configuring the MQQueueConnectionFactory with the JACL on the wsadmin console. The other half of the article that was left out was to create the queues also.&lt;/p>
&lt;p>The world looks pretty much the same today and my /etc/profile doesnt seemed to have been sourced again. Good we dont need a restart.&lt;/p>
&lt;p>You would find some of the steps to be similar and that is because we are running on the same configs.&lt;/p></description></item><item><title>Creating the MQQueueConnectionFactory with wsadmin scripting - JACL Part 1.</title><link>https://shaaf.dev/post/2008-06-24-websphere-admin-scripting-jacl-part-1/</link><pubDate>Tue, 24 Jun 2008 15:44:31 +0200</pubDate><guid>https://shaaf.dev/post/2008-06-24-websphere-admin-scripting-jacl-part-1/</guid><description>&lt;p>While working my way in some piece of long java code I came across this huge pile of sand that just shattered me off every bit of patience I was left with. The dilemma all of us face every second day. &lt;em>CONFIGURATIONS!!&lt;/em>&lt;/p>
&lt;p>While my sarcastic mind was just saying Congratulations to me instead. And just how the - would you expect me to start configuring now.&lt;/p>
&lt;p>So what exactly is my problem? I have a list of MQs, Factories, datasource, providers etc.. that I need to configure. And every time I create a new profile on my RAD (Rational Application Developer) I have to manually goto the Admin console and configure them.&lt;/p></description></item><item><title>Quick start Singleton - Walk through</title><link>https://shaaf.dev/post/2008-06-23-quick-start-singleton-walk-through/</link><pubDate>Mon, 23 Jun 2008 03:56:37 +0200</pubDate><guid>https://shaaf.dev/post/2008-06-23-quick-start-singleton-walk-through/</guid><description>&lt;p>This being my first existence on the network and I just want to make sure that I would come back to this blog page again sometime and keep on writing. For now this is a quick 5 min walk through of getting your hands dirty on the Singleton Pattern. As any ones first pattern Singleton always seems to be the easiest to adapt and ironically always the mistress of your pains; when you realize the act wasn&amp;rsquo;t right in the first place.
More details on that later.&lt;/p></description></item></channel></rss>