Showing posts from 2011

Clojure and maven

I had started about learning clojure and though the REPL interpreter seems to be the standard way of starting learning, I wanted to do it in a more Test driven method using maven. So I created a source and test directory and went about writing a simple learn.clj and a simple testlearn.clj. Took some time to figure things out and make the tests work Here is the directory structure

 (Learn.clj dir structure \NetBeans2\ClojureLearn2\src\main\clojure\my\clojure\learn.clj)

(ns my.clojure.learn

(defn main  [args]
  (println  "A red apple tree" )
   (println (def x(str "Hello " args "!")) )

(defn add [x y]
    (+ x y)

( defn workingwithlist []
  (println "In the function workingwithlist")
  (def listx (list 1 (add 1 1) 3 4  ))
   (doseq [item listx]
   (println item))

 (TestLern.clj dir structure \NetBeans2\ClojureLearn2\src\test\clojure\my\clojure\Testlearn.clj)

(ns my.clojure.Testlearn
(:use my.clojure.learn)
(:use clojure.test)

Booting OS/Ubuntu from an external Hard disk uisng Virtual Box virtual harddrive feature

First you need to boot from the hard drive

For that put the harddrive in an hardrive enclosure and connect it via usb to your host OS

Then follow the steps in the Virtual box help guide

9.9.1. Access to entire physical hard disk
While this variant is the simplest to set up, you must be aware that this will give a guest operating system direct and full access to an entire physical disk. If your host operating system is also booted from this disk, please take special care to not access the partition from the guest at all. On the positive side, the physical disk can be repartitioned in arbitrary ways without having to recreate the image file that gives access to the raw disk.

To create an image that represents an entire physical hard disk (which will not contain any actual data, as this will all be stored on the physical disk), on a Linux host, use the command

VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk
-rawdisk /dev/sda
This creates the image /path/to/…

Connecting to JMX with username and password

Got the tip from
echo("\nCreate an RMI connector client and " +
"connect it to the RMI connector server");
JMXServiceURL url =
//new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi");
new JMXServiceURL("service:jmx:rmi:///jndi/rmi://");

String[] credentials = new String[2];
// The user will travel as clear text
credentials[0] = "user"; //user name
credentials[1] = "password"; //password

Map environment = new HashMap();

environment.put(JMXConnector.CREDENTIALS, credentials);

JMXConnector jmxc = JMXConnectorFactory.connect(url, environment);

Creating a Servicemix Binding Component and using it

Here are the steps I followed to do this
- A working knowledge of maven is a must - Some knowledge of using Xbean is good ( not a must)
Creating a BC
1. Follow steps in
mvn archetype:create -DarchetypeGroupId=org.apache.servicemix.tooling -DarchetypeArtifactId=servicemix-binding-component -DarchetypeVersion=3.3.2 -DgroupId=com.nsn.hiq -DartifactId=hello-world-bc
4. xmlns:hellobc="http://com.nsn.hiq/1.0"
Some tips
In MyProviderEndPoint class the Xbean annnotation marks the name of the provider endpoint (which we will need later to use this component)
/** * @org.apache.xbean.XBean element="provider" */ public class MyProviderEndpoint extends ProviderEn…