public class SignIn extends SeleneseTestCase {
public void setUp() throws Exception {
setUp("https://localhost:9443/carbon/", "*chrome");
}
public void testSignInValdation() throws Exception {
BufferedReader in = null;
InputStreamReader inputStream = null;
inputStream = new InputStreamReader(new FileInputStream("C:" + File.separator + "signin.txt"));
in = new BufferedReader(inputStream);
String line = null;
while ((line = in.readLine()) != null) {
System.out.println("password: " + line);
selenium.open("/carbon/admin/login.jsp");
selenium.waitForPageToLoad("30000");
selenium.type("txtUserName", "yumani");
selenium.type("txtPassword", line);
selenium.click("//input[@value='Sign-in']");
selenium.waitForPageToLoad("30000");
}
}
}

The February 8th issue of the Newsweek (International) magazine has an absolutely great article titled “End of the Rogue”. The article is about how the concept of a “rogue state” (apparently created the cold war days) is no longer valid and how the US needs to get past it.
Not surprisingly many comments on the online edition don’t agree that the US approach needs to change. Living in Sri Lanka, however, and having observed the wrath of the US (and UK and EU) for the way the anti-LTTE war was conducted and ended, I can see what must be going on in “rogue” countries!
The most interesting quote I found in the article is this:
We don’t have the right to think other people should think like us.
If we all could live by that the entire world would be a better place!

"The reason people are giving so much money to Haiti is simple: They are hearing about it. They are seeing and reading about the catastrophe over and over again on the front page, in prime time, and in viral web appeals 24 hours a day, seven days a week. This is not a singular occurrence: Every so often, for brief moments, disasters trigger the deluge of media for humanity as is enjoyed every day by the likes of Budweiser, BMW, and the iPod. If it had to be paid for, the media that is currently publicizing Haiti would cost many tens, if not hundreds, of millions of dollars. But alas, we would never let humanitarian organizations spend that kind of money on advertising, despite the fact that it might bring in many times more dollars than it costs."


function brakeColumns(query) {
var columnList = new Array();
var patten1 = /^[\w\$][\w]*/i;
var patten2 = /^[\w\$][\w]*\.[\w\$][\w]*$/i;
var numEnd = query.search(/\sfrom\s/i);
var elems = (query.substring(6, numEnd)).split(",");
for (var i = 0; i < elems.length; i++) {
var elem = elems[i].toString();
elem = trim(elem);
var stPoint = "";
var wanted = "";
if (elem.search(/\sas\s/i) != -1) {
stPoint = elem.search(/\sas\s/i);
wanted = elem.substring(stPoint + 4);
wanted = trim(wanted);
if (patten1.test(wanted)) {
columnList.push(wanted);
}
} else if (patten2.test(elem)) { //check for tablename.column name pattern
stPoint = elem.search(/\./);
wanted = elem.substring(stPoint + 1);
wanted = trim(wanted);
if (patten1.test(wanted)) {
columnList.push(wanted);
}
} else { //check for straight column name like username,passsword etc
if (patten1.test(elem)) {
columnList.push(elem);
}
}
}
return(columnList);
}
function trim(stringToTrim) {
return stringToTrim.replace(/^\s+|\s+$/g, "");
}

alert(/^[a-zA-Z\$_][a-zA-Z0-9]*/.test("testVar"));
Samisa Abeysinghe, the directory of engineering at WSO2 will present a webinar on Building an Agile Enterprise With Business Activity Monitoring today (3rd February 2010).
There he will provide an overview of WSO2 Business Activity Monitor (WSO2 BAM), the latest product from the WSO2 Carbon platform, including its built-in dashboard to view analytics , reports of past and present activities of the enterprise SOA infrastructure and how these information can be used in tactical and strategic decision making.
function putInsidePre(txt,toPre){
var preText = document.createTextNode(txt);
document.getElementById(toPre).appendChild(preText);
}.codeStyle {
background-color:#EAEFF1;
border:1px solid #88BFCE;
color:#325669;
display:block;
font-size:11px;
height:200px;
line-height:1.5em;
overflow:auto;
}tag and give it a id and call "putInsidePre" method to populate it.
Here is a full working example.
<html>
<head>
<style>
.codeStyle {
background-color:#EAEFF1;
border:1px solid #88BFCE;
color:#325669;
display:block;
font-size:11px;
height:200px;
line-height:1.5em;
overflow:auto;
}
</style>
<script>
function putInsidePre(txt,toPre){
var preText = document.createTextNode(txt);
document.getElementById(toPre).appendChild(preText);
}
</script>
</head>
<body>
<pre class="codeStyle" id="codeBlock"></pre>
<script>
putInsidePre('<html><head></head><body>Content</body></html>',"codeBlock");
</script>
</body>
</html>
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
keyPairGenerator.initialize(1024);
KeyPair KPair = keyPairGenerator.generateKeyPair();
X509V3CertificateGenerator v3CertGen = new X509V3CertificateGenerator();
v3CertGen.setSerialNumber(BigInteger.valueOf(new SecureRandom().nextInt()));
v3CertGen.setIssuerDN(new X509Principal("CN=" + domainName + ", OU=None, O=None L=None, C=None"));
v3CertGen.setNotBefore(new Date(System.currentTimeMillis() - 1000L * 60 * 60 * 24 * 30));
v3CertGen.setNotAfter(new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 365*10)));
v3CertGen.setSubjectDN(new X509Principal("CN=" + domainName + ", OU=None, O=None L=None, C=None"));
v3CertGen.setPublicKey(KPair.getPublic());
v3CertGen.setSignatureAlgorithm("MD5WithRSAEncryption");
X509Certificate PKCertificate = v3CertGen.generateX509Certificate(KPair.getPrivate());
FileOutputStream fos = new FileOutputStream("/path/to/testCert.cert");
fos.write(PKCertificate.getEncoded());
fos.close();
keytool -printcert -file /path/to/cert
KeyStore privateKS = KeyStore.getInstance("JKS");
FileInputStream fis = new FileInputStream("/path/to/sample-key-store.jks");
privateKS.load(fis, "keyStorePass".toCharArray());
privateKS.setKeyEntry("sample.alias", KPair.getPrivate(),
new char[]{'e', 'n', 't', 'r', 'y', 'p', 'a', 's', 's'},
new java.security.cert.Certificate[]{PKCertificate});
privateKS.store( new FileOutputStream(keystoreFile), "keyStorePass".toCharArray());


This is a very interesting marketing strategy. A guy walks into an into an interview and highlights his negatives.
As I look over my copy of Thompson's application, I mentally reduce his chances from minuscule to nonexistent. I glance at my watch. I've got an early flight. I wonder how long it will take my compatriots to blow poor Thompson off.
"So why should we hire you, Mr. Thompson?" the area manager asks, starting with the question she usually finishes with.
Thompson smiles.
"I'm 53 years old," he says without hesitation. "I'm not pretty. I've been unemployed for almost five months—ever since my last company went belly-up. I've got no experience in your industry. If you take a look at my application you'll see that there's a checkmark next to the yes on that question about whether or not I've ever been convicted of a felony. I've applied for any number of other jobs and no one else will hire me." He looks at us each in turn while he's slowly ticking off these points on his fingers, as confidently as if he were explaining his Harvard MBA, his Olympic gold medals and his seven years as CEO of General Motors. "So let me tell you why I'm the best possible candidate you're ever going to find for this position."
And that's exactly what he proceeds to do—demonstrating the poise and assurance and experience he'd gained in those 53 years.
"If you hire me, I can't afford not to succeed!" he tells us with passion and conviction. "I don't have the option of being able to move on to greener pastures—or even brown pastures—when the job gets too grueling. I'm 100 percent committed. As locked into this position as I was locked into that jail cell 35 years ago. And if you'll notice that's where I earned the most of the credits for my college degree. I never wanted a Master's, so I've made sure I've never had to go back. But what I learned in that place—the formal and the informal training—has a lot to do with why I've been so successful at every job I've had since then."
Read the full article here.
http://www.evancarmichael.com/Sales/372/Making-the-Skeleton-Dance-Bragging-about-the-Negatives.html
U.S. troops pulled a man alive from the rubble of a collapsed building in Haiti's destroyed capital on Tuesday, two weeks after a massive earthquake rattled the country.
The 35-year-old man, covered in dust and dressed only in underpants, was carried out from the ruins of a building in downtown Port-au-Prince and was driven off for medical treatment. He did not appear to have any serious injuries.
The rescue, exactly 14 days after the magnitude-7.0 earthquake killed as many as 200,000 people, came as the U.S.-led relief effort was focused on getting help to hundreds of thousands of survivors left homeless, hungry and injured.
“Agility” is more than just a buzz word. The ability to be agile ensures enterprises to gain a competitive advantage. The right decisions made at the right time by the right people is the key to success. And both IT as well as business domain experts understand the need to respond to the latest trends in a proactive manner.
WSO2's new Business Activity Monitor - WSO2 BAM, is the ideal tool that is not only useful for business users but also IT personal to monitor key performance indicators that govern the success of their enterprise. The built in dashboards and reports along with analytical capabilities of historical data, empower users to make the right tactical and strategic decisions.
This webinar, will enlighten you on how to exercise business activity monitoring with your SOA deployments to implement a complete feedback life-cycle in your SOA.
I’ve started a series of articles on JAX-WS development with WSAS. The first one here, talks about the basics and fundamentals of JAX-WS development. I’ve written some areas of this topic in my previous posts in this blog. But this article brings all together and provides a very easy to follow approach to develop JAX-WS services with WSAS. There will be few more articles coming out on JAX-WS client side development, MTOM support, WS-Security etc. So stay tuned. I’ll post everything on this blog once those articles will be published.

“Code First or Contract First?”. This has been a hot topic in the Web services world for many years among the Web service developers. In one of my latest articles on WSO2 Oxygen Tank, I’ve discussed this topic in the context of WSO2 WSAS. In this article, you’ll find out how to select the most appropreate approach to be followed when developing your Web Service with WSAS.


In this webinar, Paul Fremantle, CTO of WSO2, will be explaining the benefits of the Gadget approach to portals, and also showing how you can get started with building effective portals fast. Tune in to find out about the best portal for the next decade.
Starts: Thursday, January 21, 2010 at 09:00 AM; Ends: 10:00 AM (PST)
Presenter: Paul Fremantle
Register Now it's free!
If you are new to JAX-WS service development with Axis2, please read this first. In this post, you will find out how to use MTOM functionality in Axis2 JAX-WS services. Here I’m using Axis2 1.5.1.
First of all, you have to use the BindingType annotation to set the SOAP11 MTOM binding as follows.
@BindingType(SOAPBinding.SOAP11HTTP_MTOM_BINDING)
After that, you can use javax.activation.DataHandler to represent your binary data in your parameters or return types. A simple MTOM enabled JAX-WS service class can be written as follows.
@WebService(serviceName = “MTOMSampleService”,
targetNamespace = “http://mtom.jaxws.wso2.org”
)
@BindingType(SOAPBinding.SOAP11HTTP_MTOM_BINDING)
public class MTOMService {
@WebMethod(action = “urn:uploadFile”)
public String uploadFile(DataHandler data) {
try {
InputStream is = data.getInputStream();
….
String msg = “File ” + data.getName() + ” of type ” + data.getContentType() +
” successfully received”;
return msg;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@WebMethod(action = “urn:getTestData”)
public DataHandler getBinaryTestData(String stmtId) {
byte[] testData = new byte[10240];
for (int i = 0; i < testData.length; i++) {
testData[i] = 0×7f;
}
ByteArrayDataSource bds = new ByteArrayDataSource(
testData, “application/octet-stream”);
return new DataHandler(bds);
}
}
DataHandler objects can be used inside wrapped classes as well.

When you have to go beyond the supported interface of a ServiceSkeleton when implementing a service, you can use a custom message receiver to achieve that functionality. For example, recently we encountered such scenario where the unparsed soap enveloped body has to be accessed for some custom logic. But when implementing a service using ServiceSkeleton interface, you would always ended up getting the first child of the soap body as an argument.
In that kind of a situation, the best option would be to implement a custom message receiver. WSF/CPP now provides a very convenient API for implementing a message receiver.
For implementing a custom message receiver, WSF/CPP provides a class named MessageReceiver. What a user has to do is to extend from this and implement the abstract method invokeBusinessLogicSync which will receive inflow message context and outflow message context as arguments. Then you have the full control over the processing of the message received by the message receiver.
Next add the macro WSF_MESSAGE_RECEIVER_INIT and pass the message receiver class name as the argument.
Next compile the written code as a shared library and place it in <WSFCPP_REPO>\lib directory. When implementing a service which would be invoked using this custom message receiver, set the name of the shared library as the “messageReceiver” parameter for each operation. For example, if the shared library name is “CustomMsgRecv”
<operation name=”Op1”><messageReceiver class=”CustomMsgRecv”/></operation>
Here is the example message receiver code.
/* CustomMsgRecv.h */
#include <MessageReceiver.h>
class CustomMsgRecv : public wso2wsf::MessageReceiver
{
public:
WSF_EXTERN bool WSF_CALL
invokeBusinessLogicSync(wso2wsf::MessageContext *inMsgCtx,
wso2wsf::MessageContext* outMsgCtx);
CustomMsgRecv(void);
~CustomMsgRecv(void);
};
/** CustomMsgRecv.cpp */
#include "CustomMsgRecv.h"
#include <MessageReceiver.h>
using namespace wso2wsf;
WSF_MESSAGE_RECEIVER_INIT(CustomMsgRecv)
CustomMsgRecv::CustomMsgRecv(void)
{
}
CustomMsgRecv::~CustomMsgRecv(void)
{
}
WSF_EXTERN bool WSF_CALL
CustomMsgRecv::invokeBusinessLogicSync(wso2wsf::MessageContext *inMsgCtx,
wso2wsf::MessageContext *outMsgCtx)
{
/** Add Your Logic Here */
}
So what's in your best interest? How can you avoid making Conan's mistake?
Stay in your role because you are gaining experiences that will help you achieve your long-term career objectives, or because you think it is the job you can get at the moment, or because it's fun — but you don't stay in your job because of some potential future rewards that may or may not materialize.
No organization can make reasonable promises of future placement — you're setting yourself up for disappointment trusting an organization to honor that agreement. In fact, that's essentially today's career deal.
The other day someone sent me an IM and thanked me for my open source contributions. They then said something about wishing they had my gem/code creation talents. I didn’t miss a beat and informed them that I have no talent.
I am sick of hearing people say, “Oh, I love your code, I wish I could do that.” You can. The only reason you can’t is because you don’t practice enough. I used to think that I wasn’t smart enough. I was jealous of those that did crazy code stuff that I couldn’t even comprehend. Then, one day, I ran into something I did not understand and instead of giving up, I pushed through. I sat there in front of my computer for hours and wrestled with class and class instance variables.
Even though the title mentions about WSO2 Carbon, the steps that I've explained can be used to develop generic OSGi bundles which are compliant with OSGi R4 specification. WSO2 Carbon is the platform that I am using here to deploy the bundles. WSO2 Carbon is the industry's first SOA middleware platform based on OSGi.
If you read this post till the end, you will understand how to develop OSGi bundles using Maven bundle plugin and deploying them in WSO2 Carbon.
Obviously, the first step is to generate a Maven 2 project. One option is to create from the scratch and the second option is to use the Maven archetype plugin. Since the former is time-consuming, I am using the latter here.
mvn archetype:create -DarchtetypeGroupId=org.apache.maven.archetypes
-DgroupId=org.wso2.carbon -DartifactId=org.wso2.carbon.helloworldpackage org.wso2.carbon.helloworld;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
/**
* Hello world!
*/
public class App implements BundleActivator {
public void start(BundleContext context) throws Exception {
System.out.println("Hello World!");
}
public void stop(BundleContext context) throws Exception {
System.out.println("Goodbye World!");
}
}Please note the changes done in the following pom.xml file. If you are interested in Maven bundle plugin, please refer this article on WSO2 Oxygen tank
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.helloworld</artifactId>
<packaging>bundle</packaging>
<version>1.0.0</version>
<name>org.wso2.carbon.helloworld</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
<version>3.5.0.v20090520</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${pom.name}</Bundle-Name>
<Bundle-Activator>org.wso2.carbon.helloworld.App</Bundle-Activator>
<Private-Package>org.wso2.carbon.helloworld</Private-Package>
<Import-Package>org.osgi.framework.*</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>wso2-maven2-repository</id>
<name>WSO2 Maven2 Repository</name>
<url>http://dist.wso2.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</releases>
</repository>
</repositories>
</project>
mvn installGenerated OSGi bundle(org.wso2.carbon.helloworld-1.0.0.jar) is placed in the target folder of the project. Observe the content of the bundle, specially the MANIFEST.MF file. It contains the OSGi manifest headers
If you have correctly followed above steps, now we are in a position to deploy the generated bundle in WSO2 Carbon. Download the Carbon distribution from the project site. Then unzip the it to a preferred location. Go to the "bin" directory and execute the following command. Here "-DosgiConsole=19443" option is used to allow telnet access to the Equinox OSGi console.
Linux
sh wso2server.sh -DosgiConsole=19443
Windows
wso2server -DosgiConsole=19443Now in a separate window, execute the following command to access the OSGi console
telnet localhost 19443Execute the following command to install the bundle into the Carbon instance
osgi> install file:/home/sameera/wso2/testing/maven/archtype/org.wso2.carbon.helloworld/target/org.wso2.carbon.helloworld-1.0.0.jar
Bundle id is 267
Using the given bundle id, now we can start and stop the helloworld bundle
osgi> start 267
Hello World!
osgi> stop 267
Goodbye World!
Are you still following this blog post? Great!!! now you know how to develop and deploy OSGi bundles into WSO2 Carbon.
public class Person
{
private String name;
public String Name
{
set
{
System.Console.WriteLine("assigning wow");
Name = value;
}
}
}
public class Hello
{
static void Main()
{
Person person = new Person();
person.Name = "wow";
}
}
Today, cloud applications represent a small percent of software spend. In the Piper Jaffray study, it’s 5.7%. This is expected to grow to 13.5% of total spend over the next five years. Personally, I think that figure is too conservative.
For now, 72% of respondents are leaning toward best-of-breed vendors for cloud applications. That said, though, when asked to select the tech vendor that would be a “material part of your organization’s cloud-computing plans,” Microsoft earned top billing with 65% of the vote, followed by Oracle (61%), VMware (55%), Google (53%), and salesforce.com (52%).
If you’re curious about SAP’s ranking, only 11% see the ERP leader as a key cloud vendor. The relatively low response placed the company 16th on the list, trailing RIM, Dell, Red Hat, Amazon.com, IBM, Sun, EMC, Apple, Concur, and Yahoo.
There are clear indications that ASF may stop new releases of the 1.3 and 2.0 series of its Web server product. Apparently their main focus now is on 2.2 series. Nevertheless there is a larger number of 1.3 and 2.0 series servers in production systems as of now.
Google unveiled yesterday on their official blog that Google Docs would offer to host “all” file types with a limit of 250MB. With this, you can now host all your valuable docs in a central location and share/access them from different computers. You can read the full story here.
JeOS (pronounced “juice”) stands for Just enough Operating System. In essence JeOS is not a generic, all-inclusive, bulky operating system but a customized, light-weight version for a particular application. The implication is that JeOS is for Software Appliances.
The idea is to have the minimum set of OS components that are required to run a particular software appliance so that its makes the appliance light-weight and robust.
Typically, a JeOS consist of the following:
Major OS vendors now offer their “juice” variants optimized for virtual appliances and that have been tuned to take advantage of key performance technologies of the latest virtualization products including VMware and KVM. The list includes, Ubuntu JeOS, OEL JeOS, SUSE JeOS, LimeJeOS (openSUSE version), Orange JeOS (CentOS version), etc.
WSO2 Governance as a Service is a hosted instance of WSO2 Governance Registry with multi-tenant support. WSO2 Governance as a Service provide you almost all the functionalities provided with the Governance Registry targeting the enterprise SOA governance, same time it provides all the advantages inherent with the Software as a Service model.
Here I’m talking about how to use a popular feature available in Governance Registry, inside WSO2 Governance as a Service. i.e. Remote Registry Client. With Remote Registry Client, you can access the resources in registry programatically. It uses atom/pub protocol to communicate with the registry server.
Here is an example of using Remote Registry Client. I assumed I have an account with domain name ‘example.com’ with a user name ‘example_user’ (‘example_password’). You have to change this to valid values before running this code, You can create an account in Governance as a Service freely for a limited use.
import java.net.URL; import org.wso2.carbon.registry.core.Registry; import org.wso2.carbon.registry.core.Resource; import org.wso2.carbon.registry.app.RemoteRegistry; class RegistryDemo { public static void main(String[] args) throws Exception { // calls the registry with the authentication information callRemoteRegistry("http://governance.cloud.wso2.com/registry", "example_username@example.com", "example_password"); } public static void callRemoteRegistry(String url, String username, String password) throws Exception { Registry myRegistry = new RemoteRegistry(new URL(url), username, password); if (!myRegistry.resourceExists("/demoResource")) { Resource r = myRegistry.newResource(); r.setContent("demo content"); myRegistry.put("/demoResource", r); } Resource r = myRegistry.get("/demoResource"); byte[] contentBytes = (byte[])r.getContent(); String content = new String(contentBytes); System.out.println("Content: " + content); } }
Ant was developed mainly to run java programs, so it is good at building and running java programs. But you can use the good all Make program to build and even run java programs.
Say I have an ant file that will
For this, I will only compile one java file name src/test/HelloWorld.java
<project name="HelloWorld" basedir="." default="main"> <property name="src.dir" value="src"/> <property name="build.dir" value="build"/> <property name="classes.dir" value="${build.dir}/classes"/> <property name="jar.dir" value="${build.dir}/jar"/> <property name="main-class" value="test.HelloWorld"/> <target name="clean"> <delete dir="${build.dir}"/> </target> <target name="compile"> <mkdir dir="${classes.dir}"/> <javac srcdir="${src.dir}" destdir="${classes.dir}"/> </target> <target name="jar" depends="compile"> <mkdir dir="${jar.dir}"/> <jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}"> <manifest> <attribute name="Main-Class" value="${main-class}"/> </manifest> </jar> </target> <target name="run" depends="jar"> <java jar="${jar.dir}/${ant.project.name}.jar" fork="true"/> </target> <target name="clean-build" depends="clean,jar"/> <target name="main" depends="clean,run"/> </project>
If you want to learn what each line of this means, just follow the excellent ant tutorial at http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html.
Here is the Makefile that will do the above tasks,
SRC_DIR=src BUILD_DIR=build CLASSES_DIR=$(BUILD_DIR)/classes JAR_DIR=$(BUILD_DIR)/jar PROJECT=HelloWorld MAIN_CLASS=test.HelloWorld PACKAGE=test run: clean jar java -jar $(JAR_DIR)/$(PROJECT).jar jar: $(JAR_DIR)/$(PROJECT).jar $(JAR_DIR)/$(PROJECT).jar: $(CLASSES_DIR)/$(PACKAGE)/*.class echo Main-Class: $(MAIN_CLASS)> mf test -d $(JAR_DIR) | mkdir -p $(JAR_DIR) jar cfm $@ mf -C $(CLASSES_DIR) . compile: $(CLASSES_DIR)/$(PACKAGE)/*.class $(CLASSES_DIR)/$(PACKAGE)/%.class: ${SRC_DIR}/$(PACKAGE)/*.java test -d $(CLASSES_DIR) | mkdir -p $(CLASSES_DIR) javac -sourcepath src -d ${CLASSES_DIR} $< clean: rm -rf build mf
You may notice I had to provide the package name to the compile command, as it doesn’t have a proper wildcards to represent the jar. Similar to ant all these make tasks will execute only if it is required. i.e. for an example if all the .class files are up to date with .java it will not try to recompile it.




SaaS stands for Software as a Service. It means you pay for the Software like service rather than buying and installing it locally. Why would you want to keep paying for a service when you could just buy a piece of software and pay once?. Well there are a couple of good reasons that you have never thought of.
1. Low cost of entity - Typically the periodic fee that you pay is structured so that it is much less than the cost of licensing a product on a one time basis. Specially SaaS applications are specifically built with a multi-tenant backend, thus enabling multiple customers or users to access a shared data model. This architecture naturally lowers the unit cost as in a multi-tenant implementation, you have just a single instance of the application running. In other words, its a one-to-many relationship as oppose to a one-to-one mapping. Therefore, specially small businesses will definitely fine SaaS affordable as they do not have to pay a big lump sum upfront. On the other hand, since the consumers of the service do not have to worry about hardware costs, the actual cost goes down considerably. Specially small business owners may not be comfortable at all with certain high-end hardware requirements. In good old days, most of the hardware vendors used to provide bespoke software offerings so that they could come up with hardware deals coupled with software solutions.
2. Built in updates - With SaaS all the product updates are included in your subscription. Contrast this with a typical software product which you might have to pay for upgrades each year to keep current. Possibly you need to have your own system support department to keep an eye on your systems.
3. Better reliability - The story goes that the SaaS provider has invested heavily in infrastructure, and the system is running on top of the line hardware and networks. In other words you don't have to invest in your own infrastructure before you can even install another product.
There are some decent real-world SaaS implementations. WSO2 is in the process of offering some of its great products as services and GaaS was the first to come out. GaaS stands for Governance as a Service and its powered by the WSO2 Governance Registry.
Customers are allowed to use the service free for a limited level of usage and will need to pay for usage beyond that. The free limits are:
You can try out GaaS for yourself at WSO2 GaaS homepage!.
Here is a problem that many people have asked me how to do it. “Returning an array of string” with the code first approach. The API or WSDL generation annotation guide, http://wso2.org/project/wsf/php/2.0.0/docs/wsdl_generation_api.html contain all the things required in details. Here is an example of a service that return an array of string.
<?php /** splitMe function * @param string $string_to_split string to split * (maps to the xs:string XML schema type ) * @return array of string $result split to array *(maps to the xs:double XML schema type ) */ function splitMe($string_to_split) { return array("result" => split(":", $string_to_split)); } $operations = array("splitMe"=>"splitMe"); $opParams = array("splitMe"=>"MIXED"); $svr = new WSService(array("operations"=>$operations, "bindingStyle"=>"doclit", "opParams"=>$opParams)); $svr->reply(); ?>
Note that the annotation corresponding to the return value.
* @return array of spring $result split to array
This will generate an schema with an element of maxOccurs=’unbounded’. Note that you can get the wsdl from the ’serviceurl?wsdl’.
<xsd:element name="splitMeResponse"> <xsd:complexType> <xsd:sequence> <xsd:element name="result" maxOccurs="unbounded" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element>
Now just generate a client for this service using wsdl2php and try invoke it. You will get an array of string as the response.
$input = new splitMe(); $input->string_to_split = "a:b:c:d"; // call the operation $response = $proxy->splitMe($input); print_r($response);
If you want to write rules in a Java program you have lot of choices. You can use a third party library like Drools or use the JAVA built-in JSR-94 reference implementation. In WSO2 Carbon, there is a component that abstract the behaviour of different rule engine and give you a unified API. Currently it has plugged into Drools and JAVA built-in JSR-94 implementation.
The rule component in WSO2 Carbon platform mainly used by WSO2 ESB product to mediate messages according to the given business rules. But the component is written to facilitate any requirement of using business rules in WSO2 Carbon platform. I had such a requirement in past few days and manage to use the rule component easily with the help of the component author, indika@wso2.com. So I thought it is worth sharing my experience in here.
Here You will be preparing the following stuff.
1. Rule configuration -
We can use this to provide the information about the rule implementation we are going to use, the rules (You can write rules inline or provide a reference to an external file) and the input and output adapter information.
<configuration xmlns="http://www.wso2.org/products/rule/drools"> <executionSet uri="simpleItemRuleXML"> <source key="file:src/test/resources/rules/simple-rules.drl"/> <!-- <source> <x><![CDATA[ rule InvokeABC // rules inbuilt to the rule conf end ]]> </x> </source> --> <creation> <property name="source" value="drl"/> </creation> </executionSet> <session type="stateless"/> <input name="facts" type="itemData" key="dataContext"></input> <output name="results" type="itemData" key="dataContext"></output> </configuration>
2. The Rules -
You can write rules inline in the above configuration or put it in a file and refer it from a key which can be refered from the ResourceHelper (described below).
import java.util.Calendar; rule YearEndDiscount when $item : org.test.pojo.SimpleItem(price > 100 ) then Calendar calendar = Calendar.getInstance(); if (calendar.get(Calendar.MONTH) == Calendar.JANUARY) { $item.setPrice($item.getPrice() * 80/100); } end
3. Data Context -
The context object that can be used to feed and retrieve data from and to rule engine. Here is the data context for my application.
public class SimpleDataContext { public List<NameValuePair> getInput() { // in reality the data will be retrieve from a database or some datasource List<NameValuePair> itemPairList = new ArrayList<NameValuePair>(); SimpleItem item1 = new SimpleItem(); item1.setName("item1"); item1.setPrice(50); itemPairList.add(new NameValuePair(item1.getName(), item1)); SimpleItem item2 = new SimpleItem(); item2.setName("item2"); item2.setPrice(120); itemPairList.add(new NameValuePair(item2.getName(), item2)); SimpleItem item3 = new SimpleItem(); item3.setName("item3"); item3.setPrice(130); itemPairList.add(new NameValuePair(item3.getName(), item3)); return itemPairList; } public void setResult(Object result) { if (!(result instanceof SimpleItem)) { System.out.println("it is not a SimpleItem"); } SimpleItem item = (SimpleItem)result; System.out.println("Item: " + item.getName() + ", Price: " + item.getPrice()); } }
And the Item I’m going to manipulate using rule is a simple bean like this,
public class SimpleItem { String name; int price; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getPrice() { return price; } public void setPrice(int price) { this.price = price; } }
4. Data Adapter
You have to adapt the input and output with the rule engine. Mostly here you only have to wrap the data context. The advantage of having the data adapter is, a data adapter always associated with a input/output type. So in the rule configuration I can provide the type for the input and output. If you see my rule configuration above, you see the input/output type is marked as “ItemData”. Here is my custom data adapter that is associated with the “itemData” type.
public class SimpleDataAdapter implements ResourceAdapter, InputAdaptable, OutputAdaptable { // the type associated with the adapter private final static String TYPE = "itemData"; public String getType() { return TYPE; } public Object adaptInput(ResourceDescription resourceDescription, Object tobeadapted) { if (!(tobeadapted instanceof SimpleDataContext)) { return null; } SimpleDataContext dataContext = (SimpleDataContext)tobeadapted; return dataContext.getInput(); } public boolean adaptOutput(ResourceDescription description, Object value, Object context, ResourceHelper resourceHelper) { if (!(context instanceof SimpleDataContext)) { return false; } ((SimpleDataContext)context).setResult(value); return true; } public boolean canAdapt(ResourceDescription description, Object ouptput) { String key = description.getKey(); return key != null && !"".equals(key); } }
5. Resource Helper
Resource Helper will map the keys refered from the configuration to JAVA objects. This is mostly used in mediation rule configurations which can extract the message data using a key or an xpath. In this example, we don’t have much keys refering from the configuration only the rule file and the data context.
public class SimpleResourceHelper extends ResourceHelper { public ReturnValue findByKey(String key, Object source, Object defaultValue) { if (!(source instanceof SimpleDataContext)) { return new ReturnValue(defaultValue); } SimpleDataContext dataContext = (SimpleDataContext)source; if (key.startsWith("file:")) { String filename = key.substring("file:".length()); try { BufferedInputStream in = new BufferedInputStream(new FileInputStream(filename)); return new ReturnValue(in); } catch (Exception e) { return new ReturnValue(defaultValue); } } if (key.startsWith("dataContext")) { return new ReturnValue(dataContext); } return new ReturnValue(defaultValue); } // there are few more methods to be implemented, which can just leave not implemented for this example } }
That is all the accessories. Now you will be able to write the rule engine execution code.
File ruleConfigFile = new File(ruleConfigFilename); XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new FileInputStream(ruleConfigFile)); //create the builder StAXOMBuilder builder = new StAXOMBuilder(parser); //get the root element (in this case the envelope) OMElement ruleConfig = builder.getDocumentElement(); EngineConfiguration configuration = new EngineConfigurationFactory().create(ruleConfig, new AXIOMXPathFactory()); EngineController engineController = new EngineController(configuration, new SimpleResourceHelper()); final ResourceAdapterFactory factory = ResourceAdapterFactory.getInstance(); ResourceAdapter adapter = new SimpleDataAdapter(); String adapterType = adapter.getType(); if (!factory.containsResourceAdapter(adapterType)) { factory.addResourceAdapter(adapter); } SimpleDataContext simpleContext = new SimpleDataContext(); if (!engineController.isInitialized()) { engineController.init(simpleContext); } if (engineController.isInitialized()) { engineController.execute(simpleContext, simpleContext); }
If you are fed up of using PuTTY for remote login, switch to Poderosa. It provides a tabbed shell interface so that you do not have to have a pile of shell windows open as when you are using PuTTY. Poderosa is licensed under Apache 2.0.
If you want to store binary in database, you can use BLOB as the data type of that column. In Mysql you can use TINYBLOB, BLOB, MEDIUMBLOB, LONGBLOB depending on your space requirement. Here is an example of database table using BLOB as a column type.
CREATE TABLE BloBTest ( id INT NOT NULL AUTO_INCREMENT, filename VARCHAR( 32 ) NOT NULL, content BLOB NOT NULL, PRIMARY KEY ( id ) )
Storing Data
PHP:
$filename = "myimage.png"; $filecontent = file_get_contents($filename); $filecontent_escaped = mysql_real_escape_string($filecontent); $sql = "INSERT INTO BloBTest(filename, content) " + "VALUES('$filename','$filecontent_escaped')"; mysql_query($sql, $link);
Java:
String filename = "myimage.png"; InputStream filecontent = new FileInputStream(filename); String sql = "INSERT INTO BloBTest(filename, content) VALUES(?, ?)"; int size = filecontent.available(); PreparedStatement ps = conn.prepareStatement(sql); ps.setString(1, filename); ps.setBinaryStream(2, filecontent, size); ps.executeUpdate();
Retrieving Data
PHP
$sql = "SELECT filename, content FROM BloBTest"; $result = mysql_query($sql, $link); while ($row = mysql_fetch_assoc($result)) { $filename = $row["filename"]; $content = $row["content"]; $new_filename = "new_" . $filename; file_put_contents($new_filename, $content); }
Java:
String sql = "SELECT filename, content FROM BloBTest"; PrepareStatement ps = conn.prepareStatement(resourceContentSQL); ResultSet result = ps.executeQuery(); if (result.next()){ String filename = result.getString("filename"); InputStream contentStream = result.getBinaryStream("content"); String newFilename = "new_" + filename; // storing the input stream in the file OutputStream out=new FileOutputStream(newFilename); byte buf[]=new byte[1024]; int len; while((len=contentStream.read(buf))>0) out.write(buf,0,len); out.close(); }
Retrieving the Size of the Blob
After you store your data as a blob, you can manipulate or query the data with some of the in-built String functions in mysql. For an example if you want to query the size of the blob you just stored, you can use OCTET_LENGTH function. Here is an example, (this will give you the size in bytes.)
SELECT OCTET_LENGTH(content) FROM BloBTest WHERE filename='myimage.png'
.
STAMFORD, Conn., January 5, 2010 — Gartner, Inc. (NYSE: IT), the leading provider of research and analysis on the global information technology industry, today announced that, on December 30, 2009, it acquired Burton Group, Inc. for approximately $56 million in cash. Burton Group is a leading research and advisory services firm that focuses on providing practical, technically in-depth advice to front-line IT professionals. The firm has approximately 41 research analysts, 40 sales and client service associates, and projected 2009 revenue of $30 million.
WSO2 Governance as a Service is an online multi-tenant supported instance of WSO2 Governance Registry which is the solution for SOA Governance from the WSO2 SOA stack. You can start trying out WSO2 Governance as a Service by accessing the http://governance.cloud.wso2.com and creating an account for your organization (free for limited use).
In order to identify your account, you have to provide the domain name of your organization. I will demonstrate how to create an account using the “ws.dimuthu.org” as my domain name.
1. First go to http://governance.cloud.wso2.com from a web browser and click the ‘Register’ button. You will be asked to enter the domain name as the first step.
After that, you have the option of validating the ownership of the domain right at the registration process, or you can skip the validation and continue to the next step in which case your domain will be appended ‘-trial’ suffix. You can validate the ownership of the domain later at any stage.
Here I want to validate the domain right now, so I click ‘Take me to the domain ownership confirmation page straight-away’ and click the ‘Submit’ button.
2. This will redirect you to the domain ownership validation page. You can validate the ownership of your domain in one of two ways.
Method i). Just create a text file named ‘wso2gaas.txt’ in the web root of your domain and enter the given text. This is the most simplest method of two.
Method ii). You can put a DNS entry according to the given instructions. This is a little tedious approch to validate the domain. In fact it may take a while to propagate the new DNS information, so you may have to wait hours without refreshing the page until you finally validate the domain ownership.
Click the continue button after the domain validation done. Then you will be redirected to a page requesting more information.
3. Tenant Registration Page
4) After this step, you will be notified to check for your email which will contain a mail with a link to proceed with the registration. There you will be able to select a theme for your organization and finalize creating your account. Login to the admin account for your tenant with the credential you provided a the time of the registration.
The domain ownership validation was introduced to WSO2 Governance as a Service account registration only now. So for organizations who have already have account will have a message similar to this when they are trying to login to their account.
So the account I have registered using the domain name ‘example.com’ has been renamed to ‘example.com-trial’. As the instruction of the message says you can go to the account management page after the login and validate the domain ownership.
To learn why we say WSO2 products are lean, enterprise, middleware, please read this post on Samisa’s blog.
lean . enterprise . middlewareYes we are still open source, and much into SOA.
January 2, 2010 = 01/02/2010 = 01022010
Talk Cloud but use SOA.
When I say you can do whatever, I mean whatever - recently one of our competitors sold a support contract for one of our own pieces of software! Yes, that is possible. In this case the people who will pay the eventual price is the customer who did the stupid thing of buying support from someone who has nothing to do with the software! Remember Oracle's Unbreakable Linux? Well that didn't break Redhat and neither will this act - it just shows how low some people will go to make a buck.
It has been a simply phenomenal year and I want to thank all the WSO2 team who have made it happen. The efforts have been outstanding and if anything there was more professionalism and even smoother operations this year. We are truly moving from startup to mature company. Above all the team displayed "Grace Under Pressure" - which is how Ernest Hemingway described having "guts".
I could not agree more - we are evolving into a mature company. And I think one of our key strengths is our ability to evolve as a team, in conquering "enterprise challenges".






