புத்தாண்டு வாழ்த்துக்கள்
புதியதை பூத்த புத்தாண்டு வருக !
புதிய இன்பம் தருக , துன்பம் எடு
சுறுசுப்பை கொடு , சோம்பலை எடு
வெற்றியை கொடு , தோல்வியை எடு
விலைவாசி எங்களை விழுங்காமல் பார்துக்கொள்
லஞ்சம் எங்களை நெருங்காமல் பார்துக்கொள்
நோய்களை நோயுர செய், சாவுக்கு சாவு கொடு
ஆரோக்கிய வாழ்க்கையை அன்பாக்கு
மனைவியுடன் நேசதையும் மழலையுடன் பாசத்தையும் தா
நண்பர்களுடன் நெருக்கமும் எதிரிக்கு சருக்கம் கொடு
Wednesday, February 8, 2012
Thursday, January 6, 2011
புத்தாண்டு வாழ்த்துக்கள்
புத்தாண்டு வாழ்த்துக்கள்
புதியதை பூத்த புத்தாண்டு வருக !
புதிய இன்பம் தருக , துன்பம் எடு
சுறுசுப்பை கொடு , சோம்பலை எடு
வெற்றியை கொடு , தோல்வியை எடு
விலைவாசி எங்களை விழுங்காமல் பார்துக்கொள்
லஞ்சம் எங்களை நெருங்காமல் பார்துக்கொள்
நோய்களை நோயுர செய், சாவுக்கு சாவு கொடு
ஆரோக்கிய வாழ்க்கையை அன்பாக்கு
மனைவியுடன் நேசதையும் மழலையுடன் பாசத்தையும் தா
நண்பர்களுடன் நெருக்கமும் எதிரிக்கு சருக்கம் கொடு
புதியதை பூத்த புத்தாண்டு வருக !
புதிய இன்பம் தருக , துன்பம் எடு
சுறுசுப்பை கொடு , சோம்பலை எடு
வெற்றியை கொடு , தோல்வியை எடு
விலைவாசி எங்களை விழுங்காமல் பார்துக்கொள்
லஞ்சம் எங்களை நெருங்காமல் பார்துக்கொள்
நோய்களை நோயுர செய், சாவுக்கு சாவு கொடு
ஆரோக்கிய வாழ்க்கையை அன்பாக்கு
மனைவியுடன் நேசதையும் மழலையுடன் பாசத்தையும் தா
நண்பர்களுடன் நெருக்கமும் எதிரிக்கு சருக்கம் கொடு
Saturday, August 28, 2010
WebService3.0
package com.ws;
TestWS.java
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
@WebService(name = "TestWS")
@SOAPBinding(
style = SOAPBinding.Style.DOCUMENT,
use = SOAPBinding.Use.LITERAL,
parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
public class TestWS {
/**
* This method will accept a string and prefix with Hello.
*
* @param name
* @return
*/
@WebMethod
public String greet(@WebParam(name="name") String name )
{
return "Hello" + name;
}
}
web.xml
TestWS.java
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
@WebService(name = "TestWS")
@SOAPBinding(
style = SOAPBinding.Style.DOCUMENT,
use = SOAPBinding.Use.LITERAL,
parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
public class TestWS {
/**
* This method will accept a string and prefix with Hello.
*
* @param name
* @return
*/
@WebMethod
public String greet(@WebParam(name="name") String name )
{
return "Hello" + name;
}
}
web.xml
HelloWorldWeb
TestWS
com.ws.TestWS
1
TestWS
/TestWS
30
EJB_30
Hello.java
package src;
import javax.ejb.Remote;
@Remote
public interface Hello {
public String sayHello(String name);
}
HelloLocal
package src;
import javax.ejb.Remote;
@Remote
public interface Hello {
public String sayHello(String name);
}
HelloBean.java
package src;
import java.util.Properties;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.jboss.aop.microcontainer.aspects.jndi.JndiBinding;
import src.count.Count;
/**
* Session Bean implementation class HelloBean
*/
@Stateless(name="HelloBean")
@JndiBinding(name="HelloBean")
public class HelloBean implements Hello, HelloLocal {
@EJB(name="CountBean") Count count;
//Count count = null;
/**
* Default constructor.
*/
public HelloBean() {
// TODO Auto-generated constructor stub
}
@PostConstruct
public void init()
{
}
public String sayHello(String name)
{
//count = lookupCountBean();
count.addVisitor(name);
count.saveVisitor();
return "Hello, " + name;
}
private Count lookupCountBean() {
try {
Properties properties = new Properties();
properties.put("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
properties.put("java.naming.factory.url.pkgs",
"org.jboss.naming rg.jnp.interfaces");
properties.put("java.naming.provider.url", "jnp://localhost:1091");
Context ctx = new InitialContext(properties);
System.out.println("Got context");
return (Count) ctx.lookup("CountBean/remote");
}
catch(NamingException ne) {
throw new RuntimeException(ne);
}
}
}
Count.java
package src.count;
import java.util.ArrayList;
import javax.ejb.Remote;
@Remote
public interface Count {
public void saveVisitor();
public void addVisitor(String user);
public int totalVisitor();
public int onlineVisitor();
public ArrayList getVisitors();
}
CountLocal.java
Same as above Count.java
Contents
CountBean.java
package src.count;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Vector;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ejb.Stateful;
import org.jboss.aop.microcontainer.aspects.jndi.JndiBinding;
/**
* Session Bean implementation class CountBean
*/
@Stateful(name="CountBean")
@JndiBinding(name="CountBean")
public class CountBean implements Count, CountLocal {
/**
* Default constructor.
*/
Vector visitors = new Vector();
int onlineUsers = 0;
int totalUsers = 0;
public CountBean() {
}
@PostConstruct
public void init(String name) {
// TODO Auto-generated constructor stub
visitors.add(name);
onlineUsers ++;
totalUsers ++;
}
public CountBean(String name) {
// TODO Auto-generated constructor stub
visitors.add(name);
onlineUsers ++;
totalUsers ++;
}
@PreDestroy
public void remove() {
onlineUsers --;
FileWriter file = null;
BufferedWriter bFile = null;
try
{
file = new FileWriter(new File("c:\\users.txt"));
bFile = new BufferedWriter(file);
for( String strName : visitors)
{
bFile.write(strName+"\n");
}
}
catch(Exception ex)
{
}
finally
{
try {
if (bFile!= null) bFile.close();
if (file != null) file.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public int totalVisitor() {return onlineUsers; }
public int onlineVisitor() { return totalUsers; }
public ArrayList getVisitors(){ return null; }
public void addVisitor(String user) {
visitors.add(user);
}
public void saveVisitor() {
FileWriter file = null;
BufferedWriter bFile = null;
try
{
file = new FileWriter(new File("c:\\users.txt"));
bFile = new BufferedWriter(file);
for( String strName : visitors)
{
bFile.write(strName+"\n");
System.out.println("Name = " + strName);
}
}
catch(Exception ex)
{
}
finally
{
try {
if (bFile!= null) bFile.close();
if (file != null) file.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
index.jsp
InitialContext ctx = new InitialContext();
try
{
Hello hello = (Hello) ctx.lookup("HelloBean/remote");
String name = "";
if (request.getParameter("tname") == null)
{
name = (String) session.getValue("name");
}
else
name = request.getParameter("tname");
out.println( hello.sayHello( name ));
}
catch(Exception ex)
{
ex.printStackTrace();
}
package src;
import javax.ejb.Remote;
@Remote
public interface Hello {
public String sayHello(String name);
}
HelloLocal
package src;
import javax.ejb.Remote;
@Remote
public interface Hello {
public String sayHello(String name);
}
HelloBean.java
package src;
import java.util.Properties;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.jboss.aop.microcontainer.aspects.jndi.JndiBinding;
import src.count.Count;
/**
* Session Bean implementation class HelloBean
*/
@Stateless(name="HelloBean")
@JndiBinding(name="HelloBean")
public class HelloBean implements Hello, HelloLocal {
@EJB(name="CountBean") Count count;
//Count count = null;
/**
* Default constructor.
*/
public HelloBean() {
// TODO Auto-generated constructor stub
}
@PostConstruct
public void init()
{
}
public String sayHello(String name)
{
//count = lookupCountBean();
count.addVisitor(name);
count.saveVisitor();
return "Hello, " + name;
}
private Count lookupCountBean() {
try {
Properties properties = new Properties();
properties.put("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
properties.put("java.naming.factory.url.pkgs",
"org.jboss.naming rg.jnp.interfaces");
properties.put("java.naming.provider.url", "jnp://localhost:1091");
Context ctx = new InitialContext(properties);
System.out.println("Got context");
return (Count) ctx.lookup("CountBean/remote");
}
catch(NamingException ne) {
throw new RuntimeException(ne);
}
}
}
Count.java
package src.count;
import java.util.ArrayList;
import javax.ejb.Remote;
@Remote
public interface Count {
public void saveVisitor();
public void addVisitor(String user);
public int totalVisitor();
public int onlineVisitor();
public ArrayList
}
CountLocal.java
Same as above Count.java
Contents
CountBean.java
package src.count;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Vector;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ejb.Stateful;
import org.jboss.aop.microcontainer.aspects.jndi.JndiBinding;
/**
* Session Bean implementation class CountBean
*/
@Stateful(name="CountBean")
@JndiBinding(name="CountBean")
public class CountBean implements Count, CountLocal {
/**
* Default constructor.
*/
Vector
int onlineUsers = 0;
int totalUsers = 0;
public CountBean() {
}
@PostConstruct
public void init(String name) {
// TODO Auto-generated constructor stub
visitors.add(name);
onlineUsers ++;
totalUsers ++;
}
public CountBean(String name) {
// TODO Auto-generated constructor stub
visitors.add(name);
onlineUsers ++;
totalUsers ++;
}
@PreDestroy
public void remove() {
onlineUsers --;
FileWriter file = null;
BufferedWriter bFile = null;
try
{
file = new FileWriter(new File("c:\\users.txt"));
bFile = new BufferedWriter(file);
for( String strName : visitors)
{
bFile.write(strName+"\n");
}
}
catch(Exception ex)
{
}
finally
{
try {
if (bFile!= null) bFile.close();
if (file != null) file.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public int totalVisitor() {return onlineUsers; }
public int onlineVisitor() { return totalUsers; }
public ArrayList
public void addVisitor(String user) {
visitors.add(user);
}
public void saveVisitor() {
FileWriter file = null;
BufferedWriter bFile = null;
try
{
file = new FileWriter(new File("c:\\users.txt"));
bFile = new BufferedWriter(file);
for( String strName : visitors)
{
bFile.write(strName+"\n");
System.out.println("Name = " + strName);
}
}
catch(Exception ex)
{
}
finally
{
try {
if (bFile!= null) bFile.close();
if (file != null) file.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
index.jsp
InitialContext ctx = new InitialContext();
try
{
Hello hello = (Hello) ctx.lookup("HelloBean/remote");
String name = "";
if (request.getParameter("tname") == null)
{
name = (String) session.getValue("name");
}
else
name = request.getParameter("tname");
out.println( hello.sayHello( name ));
}
catch(Exception ex)
{
ex.printStackTrace();
}
Tuesday, August 24, 2010
Profiling_Java_WLST
Profiling using JRockit Flight Recorder (Please switch on Flight Recorder using XX:+FlightRecorder)
CreateDataSource.sh
$JDK_BIN/java weblogic.WLST $SERVICE_JYTHON_DIR/createDataSourceFactory.py $1 $2 $3
DAYSTAMP=`(set \`date\`; echo $3)`_`(set \`date\`; echo $2)`_`(set \`date\`; echo $6)`_`(set \`date\`; echo $4)`
export PID=`ps -wwef | grep java | grep WLST | awk '{print $2 }'`
$JDK_BIN/jrcmd $PID start_flightrecording filename=/tmp/${WLS_RELEASE}_${WLS_BUILD}_CreateDataSourceFactory_${DAYSTAMP}.jfr &
sleep 10
createDataSourceFactory.py
import os
import jarray
URL=os.environ['ADMIN_URL']
dataSourceFactoryName=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
dbhost=os.environ['DB_HOSTNAME']
dbport=os.environ['DB_PORT']
dbsid=os.environ['DB_SID']
#=====================================================================#
# connect to the AdminServer #
#=====================================================================#
connect( os.environ['WLS_USER'], os.environ['WLS_PW'], URL)
edit()
startEdit()
cd("/")
import time
startTime=time.time()
cmo.createJDBCDataSourceFactory(dataSourceFactoryName)
cd('/JDBCDataSourceFactories/'+dataSourceFactoryName)
set("UserName", username)
set("Password",password)
set("FactoryName", "MyFactory")
set("DriverClassName", "weblogic.jdbcx.oracle.OracleDataSource")
set("URL", "jdbc:oracle:thin:@"+dbhost+":"+dbport+":"+dbsid)
activate()
import time
endTime=time.time()
print "CreateDataSourceFactory: %.3f" % (endTime-startTime)
exit()
CreateDataSource.sh
$JDK_BIN/java weblogic.WLST $SERVICE_JYTHON_DIR/createDataSourceFactory.py $1 $2 $3
DAYSTAMP=`(set \`date\`; echo $3)`_`(set \`date\`; echo $2)`_`(set \`date\`; echo $6)`_`(set \`date\`; echo $4)`
export PID=`ps -wwef | grep java | grep WLST | awk '{print $2 }'`
$JDK_BIN/jrcmd $PID start_flightrecording filename=/tmp/${WLS_RELEASE}_${WLS_BUILD}_CreateDataSourceFactory_${DAYSTAMP}.jfr &
sleep 10
createDataSourceFactory.py
import os
import jarray
URL=os.environ['ADMIN_URL']
dataSourceFactoryName=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
dbhost=os.environ['DB_HOSTNAME']
dbport=os.environ['DB_PORT']
dbsid=os.environ['DB_SID']
#=====================================================================#
# connect to the AdminServer #
#=====================================================================#
connect( os.environ['WLS_USER'], os.environ['WLS_PW'], URL)
edit()
startEdit()
cd("/")
import time
startTime=time.time()
cmo.createJDBCDataSourceFactory(dataSourceFactoryName)
cd('/JDBCDataSourceFactories/'+dataSourceFactoryName)
set("UserName", username)
set("Password",password)
set("FactoryName", "MyFactory")
set("DriverClassName", "weblogic.jdbcx.oracle.OracleDataSource")
set("URL", "jdbc:oracle:thin:@"+dbhost+":"+dbport+":"+dbsid)
activate()
import time
endTime=time.time()
print "CreateDataSourceFactory: %.3f" % (endTime-startTime)
exit()
Thursday, June 10, 2010
NFS Sharing
NFS Settings
1. Create a Folder in Target Server /JMSFileStore on remotehost
2. Provide the permission like chmod 777 /JMSFileStore
3. Login to Node1 -> execute the following commands
4. Login as root
5. mkdir /JMSFileStore on Node1
6. mount -t nfs remotehost:/private/JMSStore /JMSStore -o rw,rsize=16384,wsize=16384,hard,tcp,nolock,addr=10.xxx.xxx.52
7. Now the folder is shared on Node1
1. Create a Folder in Target Server /JMSFileStore on remotehost
2. Provide the permission like chmod 777 /JMSFileStore
3. Login to Node1 -> execute the following commands
4. Login as root
5. mkdir /JMSFileStore on Node1
6. mount -t nfs remotehost:/private/JMSStore /JMSStore -o rw,rsize=16384,wsize=16384,hard,tcp,nolock,addr=10.xxx.xxx.52
7. Now the folder is shared on Node1
Profile
Using JProfile6
export LD_LIBRARY_PATH=/jprofiler6/bin/linux-x86
Append this line -agentlib:jprofilerti=port=8849 -Xbootclasspath/a:/jprofiler6/bin/agent.jar
Taking Thread Dump
connect('weblogic','weblogic1','t3://localhost.com:8001')
threadDump(writeToFile='true', fileName='/tmp/thread_dump.log', serverName='soa_server1')
exit()
export LD_LIBRARY_PATH=/jprofiler6/bin/linux-x86
Append this line -agentlib:jprofilerti=port=8849 -Xbootclasspath/a:/jprofiler6/bin/agent.jar
Taking Thread Dump
connect('weblogic','weblogic1','t3://localhost.com:8001')
threadDump(writeToFile='true', fileName='/tmp/thread_dump.log', serverName='soa_server1')
exit()
Subscribe to:
Posts (Atom)