...
To write a custom window you have to create a class in the package "org.wso2.siddhi.core.query.processorstream.handler.window" with a name <Name>WindowProcessor<Name>WindowHandler, and it has to extend "org.wso2.siddhi.core.query.stream.processorhandler.window.WindowProcessorWindowHandler".
You need to compile that class and add the jar to the class path. (In WSO2 CEP add that to the CEP_HOME/repertory/components/lib)
E.g for creating firstUnique window you class name need to be FirstUniqueWindowProcessorWindowHandler.
You can use your class in the query as follows
...