<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shoaib Anwar on Medium]]></title>
        <description><![CDATA[Stories by Shoaib Anwar on Medium]]></description>
        <link>https://medium.com/@shoaib4330?source=rss-6b7917d395ad------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*SMJeraOQRdKuv7oMOVFaYg.jpeg</url>
            <title>Stories by Shoaib Anwar on Medium</title>
            <link>https://medium.com/@shoaib4330?source=rss-6b7917d395ad------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 02:48:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shoaib4330/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Learning Norwegian Made Me Build My Own Practice Tool]]></title>
            <link>https://medium.com/@shoaib4330/learning-norwegian-made-me-build-my-own-practice-tool-c04fc694d1e7?source=rss-6b7917d395ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/c04fc694d1e7</guid>
            <category><![CDATA[language]]></category>
            <category><![CDATA[norwegian]]></category>
            <category><![CDATA[norsk]]></category>
            <category><![CDATA[norway]]></category>
            <dc:creator><![CDATA[Shoaib Anwar]]></dc:creator>
            <pubDate>Tue, 10 Mar 2026 22:11:55 GMT</pubDate>
            <atom:updated>2026-03-10T22:16:32.705Z</atom:updated>
            <content:encoded><![CDATA[<h4>Most apps helped me recognize Norwegian. I wanted something that forced me to actually produce sentences.</h4><p>After using the same approach to learn English years ago, I ended up building a small app to practice Norwegian the same way.</p><blockquote>Try it here <a href="https://setning.com/?utm_source=mediumblog&amp;utm_medium=mediumrral&amp;utm_campaign=launch"><strong>Setning</strong></a></blockquote><p>When I moved to Norway, I knew learning the language would take time. I’d been through that process before when I was learning English.</p><p>Back then I didn’t use apps. I mostly practiced sentences from a grammar book — different tenses, affirmative and negative forms, questions, over and over again. It wasn’t glamorous, but after a while something clicked. I stopped translating everything in my head and started forming sentences more naturally.</p><p>So when I started learning Norwegian, I looked for tools that would let me practise the same way.</p><p>Most apps I tried were good for vocabulary and recognition, but I kept feeling the same gap: I could recognise Norwegian, but producing sentences myself was still hard.</p><p>One thing that kept tripping me up was Norwegian word order. For example:</p><p><em>I dag jobber jeg.</em><br> (Today I work.)</p><p>The verb has to come second. It’s simple once you know it, but it takes repetition before it feels natural.</p><p>So I started collecting sentence drills for myself. Short patterns I could practice whenever I had a few minutes.</p><p>Eventually I turned that into a small web app so I could use it easily on my phone. That app became <a href="https://setning.com/?utm_source=mediumblog&amp;utm_medium=mediumrral&amp;utm_campaign=launch"><strong>Setning.com</strong></a></p><p>The idea is simple: you see an English sentence and type the Norwegian translation. No multiple choice, no streak counters, just practising full sentences.</p><p>Right now it focuses on a few common patterns you see all the time in everyday Norwegian — present tense, past tense, modal verbs, and word order.</p><p>It’s not meant to replace courses or textbooks. It’s more like a practice tool. A good one at that, so Norwegian Grammar becomes natural for learners (expats, immigrants, students)</p><p>I built it mainly for myself, but I thought it might help other people in Norway who are trying to get more comfortable actually forming sentences in Norwegian.</p><p>If you’re curious, you can try it here: <a href="https://setning.com/?utm_source=mediumblog&amp;utm_medium=mediumrral&amp;utm_campaign=launch"><strong>Setning.com</strong></a></p><p>It’s free, and I’m still improving it as I go.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c04fc694d1e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Keep EJB Container from wrapping your exceptions]]></title>
            <link>https://medium.com/@shoaib4330/keep-ejb-container-from-wrapping-your-exceptions-4ce1106a4491?source=rss-6b7917d395ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ce1106a4491</guid>
            <category><![CDATA[rest-easy]]></category>
            <category><![CDATA[jax-rs]]></category>
            <category><![CDATA[exception]]></category>
            <category><![CDATA[ejb]]></category>
            <category><![CDATA[java8]]></category>
            <dc:creator><![CDATA[Shoaib Anwar]]></dc:creator>
            <pubDate>Sat, 16 Mar 2019 12:10:43 GMT</pubDate>
            <atom:updated>2019-03-16T12:10:43.023Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Problem Statement: </strong>Exceptions thrown from inside <em>EJB’s</em> are dealt as System Exceptions and hence caught by <em>EJB Container</em> and wrapped inside <strong><em>EjbException </em></strong>unless it is annotated as <strong><em>@ApplicationException</em></strong>. In which case <em>EJB container</em> considers it an application exception and leaves it up-to you to handle them. However:<br>You cannot annotate a third-party exception or some Java(EE) exception as @<em>ApplicationException</em>.</p><p><strong>Solution: <br></strong>Java(EE) has to offer JAX-RS 2.1 spec that includes <strong><em>Providers </em></strong>to get the job done, that is catching and handling exception.</p><p>Here’s a sample <em>JAX-RS</em> <strong><em>Provider</em></strong> (extending <strong><em>ExceptionMapper</em></strong><em> </em>interface from <em>JAX-RS </em>spec) that catches and handles <strong><em>ContraintViolationException </em></strong><em>(An exception thrown by Bean Validation API of Java, that we cannot annotate as ApplicationException).</em></p><pre>@Provider<br><strong>public class </strong>ValidationExceptionHandler <strong>implements </strong>ExceptionMapper&lt;ConstraintViolationException&gt; {<br><br>    <strong>private </strong>Logger <strong>logger </strong>= LoggerFactory.<em>getLogger</em>(ValidationExceptionHandler.<strong>class</strong>);<br><br>    @Override<br>    <strong>public </strong>Response toResponse(ConstraintViolationException exception) {<br>        <strong>logger</strong>.info(<strong>&quot;handling validation errors ...&quot;</strong>);<br>        JsonArrayBuilder constraints = Json.<em>createArrayBuilder</em>();<br>        StringBuilder message = <strong>new </strong>StringBuilder(<strong>&quot;&quot;</strong>);<br><br>        <strong>for </strong>(ConstraintViolation&lt;?&gt; c : exception.getConstraintViolations()) {<br>            constraints.add(c.getPropertyPath() + <strong>&quot; &quot; </strong>+ c.getMessage());<br>            message.append(<strong>&quot;invalid value: &quot;</strong>).append(c.getInvalidValue()).append(<strong>&quot; message: &quot;</strong>).append(c.getMessage()).append(<strong>&quot;, &quot;</strong>);<br>        }<br><br>        <strong>logger</strong>.info(<strong>&quot;Validation error messages: {}&quot;</strong>, message.toString());<br>        ErrorResponse errorResponse = ErrorResponse.<em>builder</em>()<br>                .errorCode(GeneralErrorType.<strong><em>INVALID_INPUT</em></strong>.getErrorCode())<br>                .message(message.toString())<br>                .httpStatus(Response.Status.<strong><em>BAD_REQUEST</em></strong>)<br>                .build();<br><br>        <strong>return </strong>Response.<em>status</em>(Response.Status.<strong><em>BAD_REQUEST</em></strong>).entity(errorResponse).build();<br><br>    }<br>}</pre><p>The solution is to put an <strong>ejb-jar.xml</strong> configuration file and placing it inside <strong>WEB-INF</strong> directory, inside your maven project. Here’s how.</p><pre><em>&lt;?</em><strong>xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;</strong><em>?&gt;<br></em>&lt;<strong>ejb-jar xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot; version=&quot;3.1&quot;<br>         xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;<br>         xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd&quot;</strong>&gt;<br><br>    &lt;<strong>assembly-descriptor</strong>&gt;<br>        &lt;<strong>application-exception</strong>&gt;<br>            &lt;<strong>exception-class</strong>&gt;javax.validation.ConstraintViolationException&lt;/<strong>exception-class</strong>&gt;<br>            &lt;<strong>rollback</strong>&gt;true&lt;/<strong>rollback</strong>&gt;<br>        &lt;/<strong>application-exception</strong>&gt;<br>    &lt;/<strong>assembly-descriptor</strong>&gt;<br><br>&lt;/<strong>ejb-jar</strong>&gt;</pre><p>EJB container sees this <em>ejb-jar.xml</em> file and hence no longer deals with <em>ConstraintViolationException</em>, letting your provider handle it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ce1106a4491" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get ActiveMQ Artemis running & no dazzling between Artemis/ActiveMQ]]></title>
            <link>https://medium.com/@shoaib4330/get-activemq-artemis-running-no-dazzling-between-artemis-activemq-cd252f74ca5b?source=rss-6b7917d395ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd252f74ca5b</guid>
            <category><![CDATA[artemis]]></category>
            <category><![CDATA[apache-active-mq]]></category>
            <category><![CDATA[activemq]]></category>
            <category><![CDATA[jms]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Shoaib Anwar]]></dc:creator>
            <pubDate>Thu, 14 Mar 2019 20:15:41 GMT</pubDate>
            <atom:updated>2019-03-14T20:16:47.305Z</atom:updated>
            <content:encoded><![CDATA[<p>This post discusses:<br>- Getting <strong>ActiveMQ Artemis</strong> up and running on linux as a service<br>- And a few points regarding <strong>ActiveMQ </strong>vs <strong>ActiveMQ Artemis</strong></p><p>Let me start with the 2nd point first and waive the confusion between <em>ActiveMQ </em>and <em>ActiveMQ Artemis</em>. When I started reading about these queues, what I understood was that, <em>Artemis</em> was a successor of <em>ActiveMQ</em>. However, <em>Apache</em> lists <em>Artemis</em> as a sub-project of <em>ActiveMQ</em>. Plus, the versioning is entirely different. One goes with version 5.x.x and other with 2.x.</p><p><strong>To clarify the picture, here’s the answer:<br></strong>HornetQ when received by Apache, was re-titled as Artemis. The <em>Artemis</em> and <em>ActiveMQ </em>are two different products, based on different source codes. Artemis already implements <strong>JMS 2.0 API</strong>. And<em> </em>therefore<em>, Artemis </em>is not a successor of <em>ActiveMQ </em>(as of yet. There are features of <em>ActiveMQ </em>to be added to <em>Artemis</em>, then it might be declared as successor, if its mature enough).</p><h4><strong>Getting Artemis running</strong></h4><p>We’re to setup standalone Artemis on Linux as a service. The process is pretty straight forward and made easy by Artemis distribution.</p><pre>- <strong>Download Apache Artemis distribution:</strong></pre><pre>wget https://www-eu.apache.org/dist/activemq/activemq-artemis/2.6.4/apache-artemis-2.6.4-bin.tar.gz</pre><pre>- <strong>Rename the downloaded tar ball</strong><br>sudo mv apache-artemis-2.6.4-bin.tar.gz artemis</pre><pre>- <strong>unpack the tar<br></strong>sudo tar -xvf artemis</pre><pre>- <strong>Go to bin directory<br></strong>cd artemis/bin</pre><p>Now is the time to configure an instance of Artemis. Lets say, you are in a folder <strong><em>FOO </em></strong>and want your configured instance to reside here. For that, do as following.</p><pre>// Configure new instance as follows (our current directory is /Foo)<br>// ARTEMIS_HOME = directory pointing to artemis distribution</pre><pre><strong>${ARTEMIS_HOME}/bin/artemis create mybroker</strong></pre><pre>Creating ActiveMQ Artemis instance at: /user/server</pre><pre>    <strong>--user: is mandatory with this configuration:<br>    Please provide the default username:</strong><br>    admin<br><br>    <strong>--password: is mandatory with this configuration:<br>    Please provide the default password:</strong><br>    admin<br><br>    <strong>--allow-anonymous: is mandatory with this configuration:<br>    Allow anonymous access? (Y/N):</strong><br>    y</pre><pre>// Now inside directory Foo/mybroker your instance will be created<strong><br></strong>// Foo/mybroker has following directories inside it.<strong><br>      </strong>- bin (artemis exectuion file)<br>      - data <br>      - etc (configuration files e.g. broker.xml, jolokia-acces.xml)<br>      - lib<br>      - lock<br>      - log<br>      - tmp<br><strong>$ pwd<br>/Foo</strong></pre><pre>// run the instance &quot;mybroker&quot; as service<br><strong>$ cd mybroker/bin<br>$ sudo artemis-service run<br>service artemis started</strong></pre><p>Now you should be able to access Artemis web console at:</p><pre>localhost:8161/console/login</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*APFyjSOORaByHz6-Q9hB9Q.png" /></figure><p>Enter your login details (the ones that we provided during setup “admin”, “admin”). Once you’re logged in, you’ll see this. And Done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q-rwGeUzvPetooRCoBji7Q.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd252f74ca5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[EC2-Linux, Running  WildFly as a Service/Daemon.]]></title>
            <link>https://medium.com/@shoaib4330/ec2-linux-running-wildfly-as-a-service-daemon-b7d8a7672d89?source=rss-6b7917d395ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7d8a7672d89</guid>
            <category><![CDATA[wildfly]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[daemon]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[jboss]]></category>
            <dc:creator><![CDATA[Shoaib Anwar]]></dc:creator>
            <pubDate>Sun, 27 Jan 2019 20:31:19 GMT</pubDate>
            <atom:updated>2019-01-27T20:31:19.476Z</atom:updated>
            <content:encoded><![CDATA[<h3>EC2-Linux, Running WildFly as a Service/Daemon.</h3><p>Life is much easier with Tomcat as you web-container on top of an EBS instance. But every now and then, you’ll be facing yourself setting up your own instances from scratch. Setting up your preferred application server on them. Therefore, in this post I’ll be detailing:</p><p><strong>Getting WildFly up and running on an EC2-instance (Linux, x64-AMI) as a Background Service.</strong></p><p>Sit tight, Its easy, but really boring.</p><p>I assume:<br>You have already create and ec2-instace(Linux, x64-AMI). Downloaded the <strong><em>key-pair.pem </em></strong><em>to access </em>the instance via ssh. Lets start.</p><ul><li>Connect to AWS EC2 instance using SSH. (using <strong><em>GitBash</em></strong>)<br>On your local machine, open terminal and do as follows (assuming you have your <em>ec2-keypair</em> in current directory):<br> ssh –i [your-instance-key-pair].pem ec2-user@hostname <br>Host-name being public ip-address of your instance.<br> It will prompt for a yes/no, enter yes.</li><li>Install OpenJDK 8 JDK using command:<br> sudo yum install java-1.8.0-openjdk-devel</li><li>Check and make sure java version is correct using command:<br> java –version</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*pbpuPPOcTs9RZCIvDKbTzA.png" /></figure><ul><li>Navigate to <strong><em>opt</em></strong> directory and download and extract Wildfly 14.0.1-Final distribution using following commands:<br>- cd /opt<br>- sudo wget <a href="http://download.jboss.org/wildfly/14.0.1.Final/wildfly-14.0.1.Final.tar.gz">http://download.jboss.org/wildfly/14.0.1.Final/wildfly-14.0.1.Final.tar.gz</a><br>- sudo tar –xvf wildfly-14.0.1.Final.tar.gz</li><li>A process can run in foreground or background (as a service). It is standard practice to run application servers as service on Linux/Windows instances (for many reasons, one being, one can carry on other tasks while connected via console to your instance, while application-server runs in background as a service).<br>- Now we need to configure WildFly as a system service that we can start or stop in background:<br> - Rename WildFly directory from <strong><em>wildfly-14.0.1.Final</em></strong> to <strong><em>wildfly</em></strong> using command:<br>- sudo mv /opt/wildfly-14.0.1.Final /opt/wildfly</li><li>Copy <strong><em>wildfly.conf</em></strong> file to <strong><em>/etc/default/</em></strong> directory<br>- sudo cp /opt/wildfly/docs/contrib/scripts/init.d/wildfly.conf /etc/default/</li><li>Edit <strong><em>wildfly.conf</em></strong> as shown below:<br>- (.conf) file contains all configuration parameters e.g. JBOSS_HOME and etc, we have to assign them values specific to our case<br>- sudo nano /etc/default/wildfly.conf</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*sENt2Rli1zSvRY3Lbd8atg.png" /><figcaption>In the screen-shot above, JBOSS_USER is being set to “root”, that is by mistake, change it to JBOSS_USER=wildlfy.</figcaption></figure><ul><li>Whenever we want to run something as a service, we perform precisely following steps:<br>- Get/create and initialization script, that is responsible for initializing that process as a service.<br>- Place that script at the path <strong><em>/etc/init.d/<br>- </em></strong>We then register that initialization script to <strong><em>chkconfig </em></strong>that is responsible for managing services.<br>- Following is the step to register the service.</li><li>Now copy <strong><em>wildfly-init-redhat.s</em></strong>’ to <strong><em>/etc/init.d/</em></strong> and make configurations add WildFly as a system service:<br>- sudo cp /opt/wildfly/docs/contrib/scripts/init.d/wildfly-init-redhat.sh /etc/init.d/<br>- sudo mv wildfly-init-redhat.sh wildfly<br>- sudo chkconfig — add wildfly<br>- sudo chkconfig wildfly on<br>- sudo mkdir -p /var/log/wildfly</li><li>Update <strong><em>standalone.xml</em></strong> to allow access from everywhere.<br>- sudo nano /opt/wildfly/standalone/configurati on/standalone.xml</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*QDia2WnS3ubTsFyr1U-hVw.png" /></figure><ul><li>Add user <strong><em>wildfly</em></strong> and grant rights to <strong>/opt/wildfly/</strong> directory<br>- sudo adduser -r wildfly<br>- sudo chown -R wildfly:wildfly /opt/wildfly/</li><li>Start WildFly service<br>- sudo service wildfly start</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*XtbhDg8iVhOHGAG1xQqDww.png" /></figure><ul><li>Enable admin user to access admin console:<br>- sudo /opt/wildfly/bin/add-user.sh</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*LZx-zw6YcwVNF30hnTPBPg.png" /></figure><ul><li>Access WildFly admin console now (via Browser):<br>- <em>&lt;your-ec2-public-address&gt;:8080/</em></li></ul><p>These are the precise step you need to run Wildfly Application server as Linux Background Service Process. Plenty of steps are similar if you want to run any process as a Daemon/Service in linux.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7d8a7672d89" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why @Alternative exists as a Qualifier?]]></title>
            <link>https://medium.com/@shoaib4330/why-alternative-exists-as-a-qualifier-bf61539520b3?source=rss-6b7917d395ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf61539520b3</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[beans]]></category>
            <category><![CDATA[java-ee-8]]></category>
            <category><![CDATA[cdi]]></category>
            <dc:creator><![CDATA[Shoaib Anwar]]></dc:creator>
            <pubDate>Sun, 27 Jan 2019 19:51:29 GMT</pubDate>
            <atom:updated>2019-01-27T19:51:29.347Z</atom:updated>
            <content:encoded><![CDATA[<p>Not very long, since I have been wondering, what is the point of having @Alternative in <strong><em>CDI’s</em></strong> offered set of qualifiers? We know what it does right?</p><p><strong>Answer: -&gt;</strong> It allows us to have <strong>two</strong> or <strong>more</strong> <em>implementations</em> of the same <em>bean </em>with same qualifiers in an archive (which otherwise one cannot). We know that the beans marked with @Alternative cannot be injected.</p><p>Let’s say we have:</p><pre>@Alternative<br>public class <strong>a</strong>ChargeableImpl implements Chargeable {<br>// <strong>Here we have ONE implementation</strong><br>}</pre><p>And…</p><pre>@Alternative<br>public class <strong>b</strong>ChargeableImpl implements Chargeable {<br>// <strong>Here we have SECOND implementation</strong><br>}</pre><p>Both these beans are disabled for injection. Hence the following code on deployment will raise an <strong><em>unresolved dependency exception</em></strong>:</p><pre>@Inject Chargeable chargeable;</pre><p>This exception can be resolved explicitly, by stating which implementation to enable for injection in <strong><em>beans.xml.</em></strong></p><pre>&lt;beans<br>     xmlns=&quot;http://xmlns.jcp.org/xml/ns/javaee&quot;<br>     xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;<br>     xsi:schemaLocation=&quot;http://xmlns.jcp.org/xml/ns/javaee&quot;<br>     bean-discovery-mode=&quot;annotated&quot;&gt;<br>     &lt;alternatives&gt;<br>          &lt;class&gt;<strong>com.example.bChargeable</strong>&lt;/class&gt;<br>     &lt;/alternatives&gt;<br>&lt;/beans&gt;</pre><p><strong><em>@Alternative</em></strong> allows us to package multiple implementations of a bean with the same qualifiers in the .war file and selectively enable them by changing the deployment descriptor based upon the environment. For example, this can allow you to target separate beans for injection in <em>development</em>, <em>testing</em>, and <em>production</em> environments by enabling the classes in <strong><em>beans.xml</em></strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf61539520b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CDI (1.1) Excluding some or all beans from Injection]]></title>
            <link>https://medium.com/@shoaib4330/cdi-1-1-excluding-some-or-all-beans-from-injection-e16e3497046a?source=rss-6b7917d395ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/e16e3497046a</guid>
            <category><![CDATA[java-annotations]]></category>
            <category><![CDATA[java-ee]]></category>
            <category><![CDATA[beans]]></category>
            <category><![CDATA[cdi]]></category>
            <category><![CDATA[xml]]></category>
            <dc:creator><![CDATA[Shoaib Anwar]]></dc:creator>
            <pubDate>Sun, 27 Jan 2019 17:29:33 GMT</pubDate>
            <atom:updated>2019-01-27T18:25:45.432Z</atom:updated>
            <content:encoded><![CDATA[<p>I have always preferred annotations over xml configuration. For me, it was good to know that since version <strong>1.1 CDI</strong> (<em>JavaEE</em>) introduces @Vetoed annotation to exclude <em>beans/classes</em> from injection (using <em>@inject </em>).</p><p>Previously, we used beans.xml to declare beans.</p><pre><em>&lt;?</em>xml version=”1.0&quot; encoding=”UTF-8&quot;<em>?&gt;<br></em>&lt;beans xmlns=”http://xmlns.jcp.org/xml/ns/javaee&quot;<br>       xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&quot;<br>       xsi:schemaLocation=”http://xmlns.jcp.org/xml/ns/javaee<br>       http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd&quot;<br>       version=”2.0&quot; <br>       bean-discovery-mode=”all”&gt;<br>&lt;/beans&gt;</pre><p>This declares all beans for discovery, that is, all the classes in a given will be @inject able. We could exclude a specific class, package or sub-packages from <strong><em>injection</em></strong> as follows:</p><pre><em>&lt;?</em><strong>xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;</strong><em>?&gt;<br></em>&lt;<strong>beans xmlns=&quot;http://xmlns.jcp.org/xml/ns/javaee&quot;<br>       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;<br>       xsi:schemaLocation=&quot;http://xmlns.jcp.org/xml/ns/javaee<br>       version=&quot;2.0&quot; bean-discovery-mode=&quot;all&quot;</strong>&gt;<br>    &lt;<strong>scan</strong>&gt;<br>        &lt;<strong>exclude name=&quot;com.helloworld.package.subpackA.subpackB.*&quot;</strong>&gt;<br>            ...<br>        &lt;/<strong>exclude</strong>&gt;<br>    &lt;/<strong>scan</strong>&gt;<br>&lt;/<strong>beans</strong>&gt;</pre><p>The above snippet excludes all the beans inside <strong>subpackB. </strong>These will not be managed by CDI for injection.</p><p>However, since CDI 1.1, there’s a new approach (my preferred one). That is using @Vetoed.</p><pre>@Vetoed<br><strong>public class MyBeanImpl implements </strong>IMyBean{}</pre><p>In the above code snippet, MyBeanImpl is not considered for injection.</p><pre>@Vetoed<br>package com.example.helloworld;</pre><pre>import javax.enterprise.inject.Vetoed;</pre><pre>public class IgnoreBeanForInjection{}</pre><p>Now this code snippet, does the same job as &lt;exclude&gt; in the beans.xml does. Using this, the whole package com.example.helloworld is not considered for injection.</p><p>One might prefer one approach over the other, however, in my personal opinions, using annotations for providing <em>metadata</em> is a much better way of dealing with stuff. Since it saves you the hassle of placing <strong><em>beans.xml</em></strong> file in one directory if <strong>archive type</strong> is <strong><em>X</em></strong> and in other if <strong>archive type</strong> is <strong><em>Y</em></strong>, and the placement of these files based on build profiles.</p><p>Moreover, Java EE components such as Stateless EJB’s and JAX-RS resource endpoints, can be marked with @vetoed to prevent them from being considered beans.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e16e3497046a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Least to know about Unicode & Character Encodings]]></title>
            <link>https://medium.com/@shoaib4330/knowing-least-about-unicode-character-encodings-fd89d8b3981b?source=rss-6b7917d395ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd89d8b3981b</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ascii]]></category>
            <category><![CDATA[unicode]]></category>
            <category><![CDATA[character-encoding]]></category>
            <dc:creator><![CDATA[Shoaib Anwar]]></dc:creator>
            <pubDate>Thu, 21 Sep 2017 20:43:39 GMT</pubDate>
            <atom:updated>2018-02-11T20:03:49.640Z</atom:updated>
            <content:encoded><![CDATA[<h4>This will be a post telling you the least to know about Unicode and Character encodings. I will be as brief as possible. I don’t necessarily do what I say, so lets see if I can keep it brief.</h4><p>Have you seen the content-type header in a request/response header? or have you ever set a “enctype” attribute in an html form? It is okay if you haven’t.</p><p>But I suppose you all have seen that “?” or “????” thing with black background instead of some text you received from your Arabic friend, at some point in your lives. Yes, that’s the catch. Lets begin.</p><p><strong>What is Encoding?</strong></p><p>In simple terms, Encoding is conversion of data into some coded form/format for a number of information processing requirements.</p><p>In Computer Science specifically, Encoding is: The process of application of some numerics, symbols or characters to data, that is, applying some specific code to convert data into an equivalent cipher.</p><p><strong>Why Know about Unicode?</strong></p><p>Unicode is a character encoding standard. It has a wide acceptance now. Everyone is surely using Unicode already. You are using Unicode already whether aware of it or not. You might have seen “charset UTF-8” thing while writing some web/mobile application. That stands for Unicode UTF-8 standard. So this is pretty much it I suppose to Why you should be knowing about Unicode? Lets begin.</p><p><strong>Why use Unicode/ Why Unicode exists?</strong></p><p>If you are related to computer science, that I assume you do, you probably know that “computers deal with numbers. They store Letters, numbers and some special characters by associating some unique number with them.”</p><p>Before the introduction of Unicode, there existed roughly hundreds of different encoding systems for associating these numbers to characters. None of them was a standard within the industry worldwide. Furthermore, everyone of these encoding systems supported limited number of characters. All these varying encoding systems constrained the representation of one file on multiple systems with varying encoding systems (also called script system). Okay, this was a huge limitation, means, one could not send e.g a text file to a Chinese system and expect it open the same way. So what do we do? We get a little technical.</p><p><strong>Let’s get into some detail:</strong></p><p><strong>Character encoding</strong> is the organization of the set of numeric codes that represent all the meaningful characters of a script system in memory. So far we know that each character is stored as a number in the memory. When a key is pressed, character codes are forwarded to system, the character codes are associated to glyphs of a font and those glyphs are displayed on the screen.</p><p>Let us start with 1byte character encoding system. 1byte means that there can be 128 unique codes and hence 128 different characters, one for each of these codes. What is important is the fact that each character code is unique within its encoding system. Same character code will carry some different character in a different script system (encoding system). Therefore, a text file that you create would not have same meaning/form on another system with its differing script system.</p><p>Okay, so far we know what is the issue with multiple encoding/script systems.</p><p><strong>What is Unicode finally?</strong></p><p>Okay so, you have a beloved relative somewhere else (faraway) using maybe a system with Roman script system or maybe Japanese, Korean or Chinese script system (by the way, these latter three are 2-byte script systems). You want to send him/her a text. He/she might not understand a word you sent to him/her. Obviously its gonna happen. Your system’s character codes don’t represent same characters as his/her systems do. So we must have a standard character encoding, shouldn’t we? As long as we want that our texts start making meaning to other people somewhere at a distant place, we should.</p><p>Therefore:</p><p><strong>Unicode</strong> is an ISO standard for 16-bit universal worldwide character encoding. It is replacing individual script systems’ character encodings that exist worldwide. Therefore, a single 2-Byte character encoding applicable worldwide to all the characters existing in all languages.</p><p>Having such a universal encoding system, that is, Unicode, the character encodings of individual script systems do not conflict. In fact, there is absolutely no need to even define a script system, since every character encoding itself tells which writing system it belongs to. And yes, like 1-byte encoding systems Unicode is not constrained to limited number number of characters. 2-Byte encoding provides huge, huge space.</p><p>So, what is made possible using Unicode? its up to you, send English, Arabic, Roman or Urdu text to whatever person you desire, he/she will see the same thing as you do as long as he/she is using Unicode system (which most probably he/she will be).</p><p>For the sake of simplicity, at the moment I have said that Unicode uses 2 Bytes for storing a character. This is a common misconception actually conveyed by UCS-2 Unicode encoding. The space for storing a character varies in Unicode. It may use 1-byte, 2-bytes or up to 6-bytes for storing a character. Unicode utilizes the concept of “CodePoints” in its UTF-8 standard developed by Unicode Consortium.</p><p><strong>I intend to write a post in near future about how Unicode works. You might want to read that also.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd89d8b3981b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>