Posts

Apache CXF and Spring

http://cxf.apache.org/docs/writing-a-service-with-spring.html http://cxf.apache.org/docs/jax-ws-configuration.html http://cxf.apache.org/docs/configuration.html And finally à http://stackoverflow.com/questions/689902/cxf-without-spring --> http://cxf.apache.org/docs/servlet-transport.html#ServletTransport-UsingtheservlettransportwithoutSpring   Follwing maven settings in   jroller http://www.jroller.com/gmazza/entry/web_service_tutorial Reading a little from Spring I understood that this is actually the applicationcontext.xml and cxf is somehow cooking its beans with Spring < bean id="cxf" class="org.apache.cxf.bus.spring.SpringBus" destroy-method="shutdown" / >             < bean id="org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor"                 class="org.apache.cxf.bus.spring.BusWiringBeanFactor...

JavaScript (Prototypal) Inheritance with new and Object.create

//--------------------------- //Inheritance in JavaScript //--------------------------- var Person = function (string){ this.name= string; //if ( !(this instanceof Person) ) //part soln to danger 1 // return new Person(name); }; Person.prototype.get_name = function(){ return this.name; }; //Danger 1 : No compile errors here if new is skipped //Also inside the function would now be the global this object, //not the new instance! The constructor would be overriding all sorts //of global variables inadvertently var manu = Person("Manu"); name; manu.get_name(); //Danger 1 :only run time error here;Crackford's reason var adi = new Person("Adi"); adi.get_name(); //Okay let us try Iheritance with new var Employee = function (name,company){ this.name = name; this.company=company; Person.call(this,name); }; Employee.prototype.get_company = function(){ return this.comany; }; //How to inherit from Person ? //Step 1 - Link the prototypes /...

Self Monitoring Processor Design for a State Machine Implementation

Self Monitoring Processor Design for a FSM Using the Runnable and Callable interface as well as the Java 6 ThreadPool classes to create a class design that not only executes a task, but can monitor the execution progress periodically Here is how the interface looks like. Note that each processor has an associated ‘State’ and each state has a status - like ex scheduled, started, awaiting_async, success , fail ,timeout etc. This is because the IProcessor class is also used to implement a state machine.I won't be going through this part in more detail here. public interface IProcessor extends Runnable, Callable { ProcessingStatus getCurrentStatus(); ProcessingState getCurrentState(); ProcessingStatus execute(); Future getTask(); void setScheduledFutureHandle(ScheduledFuture handle); Now we define an Abstract class that does the basic work public abstract class Processor implements IProcessor, Comparable { @Override //Method which does the actual work publi...

OpenLayers Advanced Clustering and Setting dynamic images for OpenLayer Styles via Ajax

Update: - Read the same at  Medium  for better readability; Blogger is not technology blogging friendly JSFiddle Source for this Tutorial Let us start with a simple OpenLayer map In the JSP or the HTML we have <head> <script src="http://openlayers.org/api/OpenLayers.js"></script> <script type="text/javascript" src="<%=request.getContextPath()%>/js/maplister.js"></script> <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.7.2.min.js"></script> <script src="http://maps.google.com/maps/api/js?v=3&amp;sensor=false"></script> </head> <body> <div id="map-id" style="height:100%;width=100%"></div> </body> And on document load AUI().ready(function(X) { resize("scMapListerportlet", "#map-id"); var iconpath ="<%=request.getContextPath()%>/...

Running Jstestdriver with PhantomJs in Windows

Image
Using JSTestDriver with PhantomJS Locally PahntomJS is command line web browser JSTestDriver can be integrated to Jenkins; it can also be used for unit testing JavaScritpt Code; Only that it needs a browser running to execute the test cases.Using PahntomJs as the browser will  remove the need for a GUI browser to be launched from the script driven CI evnironment. Steps First start JStestdriver D:\Coding\lib>java -jar JsTestDriver-1.3.5.jar  --port 9876 --captureConsole --runnerMode DEBUG Starting Phantomjs browser and using it to capture the JStestdriver Download Phantomjs Download and use the javascript that is used to capture the pahntom browser https://github.com/larrymyers/js-test-driver-phantomjs/blob/master/phantomjs-jstd.js d:\Program_Files\phantomjs-1.7.0-windows>phantomjs.exe phantomjs-jstd.js Wed Oct 31 2012 12:07:26 GMT+0530 (India Standard Time): Attempting (1) to load:   http://localhost:9876/capture Run your JStestdiver...

JAX-RS with GSON and Jersy

Following from the excellent tutorial from Vogella ( http://www.vogella.com/articles/REST/article.html  ), extending with some extra details.  Using GSON in this as my  class had  a custom class wrapped in Java collection, GSON makes it very easy to marshall JSON, same also with JAXB using Jersy; But with GSON unmarshalling to Java is also pretty easy.  Also multiple parmeter support is shown So let us start with the interface first. Kindly read Roy Thomas Fielding's 2000 Dissertation, where he described his architecture style for the web This is a must read for , especially 'architects'. Enough Talk, Let us show some code Yes read about JAX-RS annotations, otherwise it is a simple Java Class (packaged as a servlet - WAR, see Vogellas article first. Okay here goes the interface (in rest everything is HTTP,GET,SET, POST etc package com.test.prog; import java.util.ArrayList; import java.util.List; import javax.ws.rs.GET; import javax.ws.rs.Path...

Ubuntu 11.10 on my Dell Inspirion M101Z (dual core)

From the time I had this  laptop   Dell Inspiron M101z (AMD Athlon II Neo K325 Processor 1.3GHz, 2GB RAM)   ( http://asia.cnet.com/product/dell-inspiron-m101z-amd-athlon-ii-neo-k325-processor-1-3ghz-4gb-ram-45287123.htm ), I had used the excellent wubi installer to dual boot Ubuntu  10.10 to my system. This was okay, however the Windows 7 starter OS I have in this is also pretty light and fast and most often I was using it. I guess with Windows Ubuntu half lost the battle. Since Ubuntu has lot of releases, one day I tried upgrading Ubuntu in place. I guess upgrade is one area where Ubuntu is not that strong as earlier also upgrade has not been smooth.However this time, it managed to corrupt the Windows booting also. Since mine is a kind of high power Netbook, there is no CD tray. My hear skipped a beat when I saw this. However Windows 7 asked if it should go ahead and repair. Usually this sort of dialog from windows results in nothing much wort...

Clojure and maven

Image
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  (:gen-class)) (defn main  [args]   (println  "A red apple tree" )    (println (def x(str "Hello " args "!")) )    x  ) (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))      listx   )  (TestLern.clj dir s...

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 ima...

Connecting to JMX with username and password

Got the tip from http://mx4j.sourceforge.net/docs/api/mx4j/tools/remote/PasswordAuthenticator.html ----------------------------------------- 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://11.11.11.11:711/jmxrmi"); 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 Prerequisite - 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 http://servicemix.apache.org/hello-world-bc.html mvn archetype:create -DarchetypeGroupId=org.apache.servicemix.tooling -DarchetypeArtifactId=servicemix-binding-component -DarchetypeVersion=3.3.2 -DgroupId=com.nsn.hiq -DartifactId=hello-world-bc 2. http://markmail.org/message/gfxipkxic73fq2rg#query:+page:1+mid:keescdr6cm6g3hhc+state:results 3. http://servicemix.396122.n5.nabble.com/Exception-on-hello-world-BC-sample-td415697.html 4. http://www.mail-archive.com/users@servicemix.apache.org/msg02389.html 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 MyProvid...

Service mix error compiling SA - "does not have a dependency which is packaged as a jbi-component or a project property 'componentName'"

This error used to come especially when you have two or more service units that is dependent on the same component (ex a file sender and a file poller , both being dependent on servicemix-file component) Googling found me that this was an error - https://issues.apache.org/activemq/browse/SM-694 but putting the componentName property was not working. In the end updated the verison of the jbi-maven-plugin to verison 4.0 in the pom.xml of the Service Assembly - SA org.apache.servicemix.tooling jbi-maven-plugin 4.0 true service-assembly (Note this error was comming only when you compile the SA and the individual compilation of the SU was going fine; Also this can come if you have for example not put the depedencies, or say the correct verison of the dependencies in the pom.xml of the SU)

Tomcat and servlets

Sevlet Package Strucutre package proto.inmc.fm.servlet; Web Xml Structure    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"    version="2.5">          inmcservlet      proto.inmc.fm.servlet.inmcservlet            inmcservlet      /servlet/inmcservlet2      Deploy dir in Tomcat D:\Program Files\Apache Group\apache-tomcat-6.0.16\apache-tomcat-6.0.16\webapps\inmc\WEB-INF\classes\proto\inmc\fm\servlet Html depl0y place in Tomcat D:\Program Files\Apache Group\apache-tomcat-6.0.16\apache-tomcat-6.0.16\webapps\docs\inmc.html Html invocation of servlet form name="myForm" method="GET" action="../inmc/servlet/inmcjnlp" input type="submit" value="Get Logged in User"  form Paths  http://localhost:8090/docs/inmc.html  http://localhost:8090/docs/inmcjnlp.html http://localhost:8090...

Jacorb Publish a Corba Servant on well know port without Naming Service

Thanks to the posts from - [jacorb-developer] ' Publish a Servant on well know port ' I was able to do the same. Below are the server and client snippet. This is using Jacorb ORB. Server code String[] args3=  { "-DOAPort=4013" };         java.util.Properties argProps = ObjectUtil.argsToProps( args3 );                         Properties props = System.getProperties();         props.put("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");//JACORB         props.put("org.omg.CORBA.ORBSingletonClass", "org.jacorb.orb.ORBSingleton");         props.put("org.omg.PortableInterceptor.ORBInitializerClass.bidir_init",           "org.jacorb.orb.giop.BiDirConnectionInitializer");         props.put("jacorb.implname","StandardImplName");         props.putAll( argProps );         System.setProperties(props); orb = org.omg.CORBA.ORB.init(args, props); root_poa = org.omg.PortableServer.POAHelper.narrow( ...

Configuring PHP in Apache 2 in Windows

1. Install php and crate a dir in c:\php and copy the unzipped file there Copy all the dll's under php to c:\windows\system32 reanme php.ini-dist to php.ini and put it in path c:\windows for example Also in php.ini add support to mysql "As with enabling any PHP extension (such as php_mysql.dll), the PHP directive extension_dir should be set to the directory where the PHP extensions are located. See also the Manual Windows Installation Instructions. An example extension_dir value for PHP 5 is c:\php\ext" 2. In the Apache httpd.conf After #ExtendedStatus On Add LoadModule rewrite_module modules/mod_rewrite.so LoadModule php5_module "c:/php/php5apache2.dll" AddType application/x-httpd-php .php AddType application/x-httpd-php .php3 AddType application/x-httpd-php .php4 Then set permission to # # This should be changed to whatever you set DocumentRoot to. # Options Indexes Includes FollowSymLinks MultiViews ExecCGI AllowOverride All Note - check the security risk...

Periodic refresh with AJAX

Hint use - timerID = window.setInterval("ajaxFunction()",5000); Below is the AJAX script And in the HTML body

Deploying under tomcat

Deploying under tomcat 1 Class inmcservlet.class is under the package proto.inmc.fm.servlet. 2 Directory strcture of tomcat depolyment D:\Program Files\Apache Group\apache-tomcat-6.0.16\apache-tomcat-6.0.16\webapps\inmc\WEB-INF\classes\proto\inmc\fm\servlet Under servlet inmcservlet.class 3. The web Xml Web.xml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> inmcservlet proto.inmc.fm.servlet.inmcservlet inmcservlet /servlet/inmcservlet2 4 . The url string http://localhost:8080/inmc/servlet/inmcservlet2

Java Log4j

Code snippet log4j.properties ### direct log messages to stdout ### #log4j.appender.stdout=org.apache.log4j.ConsoleAppender #log4j.appender.stdout.Target=System.out #log4j.appender.stdout.layout=org.apache.log4j.PatternLayout #log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n #log4j.rootLogger=debug, stdout ### direct log messages to a file ### log4j.appender.file=org.apache.log4j.FileAppender log4j.appender.file.File = mylog.txt log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n log4j.rootLogger=debug,file

Checking Memory Corruption using Gflags and NTSD debugger

>gflags /p /enable mmladc.exe path: SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options mmladc.exe: page heap enabled >gflags /p path: SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options mmladc.exe: page heap enabled with flags (traces ) >ntsd -g -x -pn mmladc.exe If there is a heap corruption you will see something like this =========================================================== VERIFIER STOP 00000006: pid 0x3634: corrupted heap pointer or using wrong heap 01421000 : Heap used in the call 0152C100 : Heap block 00000000 : Block size 70F0F0F0 : Heap owning the block =========================================================== >.lines Line number information will be loaded >kb

Porting fron VC6 to VC7 compiler errors

------------------------------------------------------------------------ Code which compiles in VC6 typedef priority_queue *,//value type deque *>,//container type Command ::Compare > REQUESTQUEUE; //comapritor typedef map ::iterator REQUESTQUEUEITR; std::map RequestQueue; std::map ::iterator CurrentItr; Changes to be done to compile in VC7 ------------------------------------------------------------------------ typedef priority_queue *,//value type deque *>,//container type typename Command ::Compare > REQUESTQUEUE; //comapritor typedef typename map ::iterator REQUESTQUEUEITR; //todo make this a priority queue - priority_queue std::map RequestQueue; typename std::map ::iterator CurrentItr; ------------------------------------------------------------------------ tags vc7 nested class template cannot access private class declared in class vc7 dependent name is not a type