Skip to main content

Posts

Showing posts from October, 2010

IBM WebSphere MQ 6.0.0 Admin Tutorials

WebSphere MQ Series 6.0.0 Tutorial MQ Series: - It is an IBM web sphere product which is evolved in 1990’s. MQ series does transportation from one point to other. It is an EAI tool (Middle ware) VERSIONS:-5.0, 5.1, 5.3, 6.0, 7.0(new version). The currently using version is 6.2 Note: - MQ series supports more than 35+ operating systems. It is platform Independent. For every OS we have different MQ series software’s. But the functionality of MQ series  Default path for installing MQ series is:- C: programfiles\BM\clipse\SDK30 C: programfiles\IBM\WebsphereMQ After installation it will create a group and user. Some middleware technologies are Tibco, SAP XI. MQ series deals with two things, they are OBJECTS, SERVICES. In OBJECTS we have QUEUES CHANNELS PROCESS AUTHENTICATION QUERY MANAGER. In SERVICES we have LISTENERS. Objects: - objects are used to handle the transactions with the help of services. QUEUE MANAGER maintains all the objects and services.

Log4j : Debugging Concepts - Part-4

Appenders Having all of your log requests scrolling on your console is not what you need all of the time. In fact limiting your log requests to your screen only violates all what we mentioned in the previous tutorial about how flexible logging is if compared to the use of traditional debuggers. One sometimes wants to save his log requests in the form of disk files for later analysis. These files can be used for the purpose of auditing as well. In some cases, you may want to see your log requests on a machine different from the one over which your application is running. As you can see, all these scenarios, and of course many other scenarios that are not mentioned here, are all about where the output of your log requests will go. When we speak about the destination to which your log requests will be delivered then we are essentially talking about an important log4j concept: Appenders.

Log4j : Debugging Concepts - Part-3

What we already have and what we do not? In the previous tutorial we introduced you to the central concepts of log4j. Although, with just that amount of information we presented in the previous tutorial, you are able to use some log4j aspects, you are still in need to grasp some more advanced points to reveal the full power of log4j. An interesting feature of log4j is that you can make use of it with just a little amount of knowledge about it and in the same time a developer who is keen to utilize it's full power can acquire at least a linear (or should we say exponential?) effort / benefit curve. By now, you should be familiar with what is logging and for what purposes should we use it. You should have the skill of deciding when to use (or not to use) logging. The major central concepts (e.g., loggers, appenders, and layouts) of log4j should be present in your mind as well. We are going in this tutorial to reveal more about these central concepts, to present ne

Log4j : Debugging Concepts - Part-2

What is log4j? Log4j is a popular library of ready Java classes that enable you to easily implement logging for your Java applications. Being used as a logging tool for huge reputable applications (like IBM's NetView), log4j is known for it's efficiency and flexibility. Log4j is the result of the countless efforts made by the E. U. SEMPER project in 1996 and is currently being distributed under the Apache Software License; or more simply an open source license. What is our working environment / platform ? Any Java developer with average experience can easily adapt the use of log4j for his own working environment. For reference purposes, we are documenting here what environment we used in this tutorial : Operating system: Microsoft Windows XP Professional SP2 JDK: J2SE Development Kit 5.0 Update 6 Log4j: Version 1.2.13 How to install log4j? The installation of log4j is rather simple. First of all download it from link [5] below. It comes in form of

Log4j : Debugging Concepts - Part-1

Who are you? If you or your client once discovered a bug in your application and never being able to reproduce it again. If you once felt that your too late discovered application bug let you down by reducing your reputation in front of your client. If you are not completely satisfied with the traditional debugger you are using or even have no access to a debugger at all. If you ever set in front of your running application wondering what it's doing now and what exact parts of it are currently being executed. You are already familiar with Java know how to compile your code, and how to use JDK. If you are any one of the those people then please read on ... logging is for you! Introduction Every time we attend a meeting or a conference that is some how related to debugging, we frequently hear the famous statement: 'Fixing bugs is not easy!'. Our experience shows that fixing bugs is rather easy. What makes people think like that is they topic

Bean with Indexed Properties and Accessing Indexed values through JSP Bean tags

In this example, A component is built that can perform statistical calculations on a series of numbers. The numbers themselves are stored in a single, indexed property. Other properties of Bean hold the value of statistical calculations, like the average or the sum. JSP Bean tags deal exclusively with scalar properties, the only way to interact with indexed properties such as these is through JSP scriptlets in the body of the tag to pass an array of integers to the Bean’s numbers property. "stat"  class = "DemoStatBean" > <%    double []  mynums =  { 100 , 200 , 300 , 400 , 500 )    stat..setNumbers ( mynums ) ; %> The average of 

What are Different Web Services Technologies and Tools

There are a variety of tools available for the Web Services. Microsoft Has C# as the development language for Web services and .NET framework. Sun Microsystems has JAX/RPC( JAVA API for XML Remote Procedure Calls) and JAXR (Java API for XML Registries). IBM also has Web Services Toolkit (WSTK), WSDL Toolkit, and Web Services Development Environment (WSDE). Apache Axis is an implementation of the SOAP ("Simple Object Access Protocol")

How to access EJB from a Servlet with in the same container

Since servlets represent a front-end technology you may want to contact an EJB from a servlet. With the recent push to use web applications for enterprise solutions, servlets have started to perform important roles in business applications. While servlets control the flow and validation of page presentation, they also are the main access point to the back-end business logic contained in EJBs. In our sample we are to create a login servlet with uses EJB behind to perform authentification. When contacting an EJB in the same container (the same virtual machine), you need only make use of a default instance of the InitialContext class. Our servlet contacts a Login EJB in order to process a user login. ... public class LoginServlet extends HttpServlet { // home interface for the EJB Login: private LoginHome _loginHome = null;

What is a Web Service ?

Web Service is an application that provides web API to communicate using XML and the Web. Web services makes distributed computer architecture made up of many different machines on different platform trying to communicate over the network to form one system. A set of standards are used that allow developers to implement distributed applications.

What is Simple Object Access Protocol (SOAP)?

This protocol is used to initiate communication to UDDI service. A SOAP based application creates a request block in XML, and then it passes that to the service In Simple Words SOAP is a protocol for exchanging structured information in a decentralized, distributed environment. It consists of two parts: An envelope that defines a framework for describing what is in a message and how to process it. A set of encoding rules for expressing instances of application-defined data types, and a convention for representing remote procedure calls and responses.

What is UDDI Protocol

In simple words this is a way for describing available Web services components. It allows Different web Services to register with an internet Directory that helps to advertise web services So one can find another service here and can use that. It is usually done with XML and HTTPS.

What is the use of Web Services?

Basically Web services mitigate the application integration crisis. It helps integrating applications at a significantly lower price point than any other integration technology. It’s a new kind of middleware based on XML and the Web. XML and the Web help solve the challenges associated with traditional application-to-application integration like heterogeneity. They are platform and language independent. Web Services has following advantages: Exposing your API onto a network Connecting Different Applications Low Cost of communication Support for Loosely Coupled Applications Web Services are Self Describing using WSDL Automatic Discovery using UDDI Business Opportunity to grow your business

How To Use For Each Loop

JDK 5.0 provides a special kind of for loop to access through all the elements of it. Syntax For(vaiable : collection){ Statements; } Example:    int []  a= { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 } ;    for ( int  i : a ){      System.out.println ( i ) ;    }

What are rules of serialization in Java?

Here is a summary of some rules of Java serialization: An object is serializable only if its class or its superclass implements the Serializable (or   Externalizable ) interface. An object is serializable (itself implements the Serializable interface) even if its superclass is not. However, the first superclass in the hierarchy of the serializable class, that does not implements Serializable interface, MUST have a no-arg constructor. If this is violated, readObject() will produce a java.io.InvalidClassException in runtime. The no-arg contructor of every non-serializable superclass will run when an object is deserialized. However, the deserialized objects? constructor does not run when it is deserialized. The class must be visible at the point of serialization.

What are results of the Remainder Operator in Java?

-- The remainder operator % returns the remainder from the division of the left operand by the right operand;the left-hand operand is the dividend and the right-hand operand is the divisor. In Java, the remainder operator % can be used with integral operands as well as floating-point operands ( $15.17.3 Remainder Operator % ). For the integral type remainder operation whose operands are integers after binary numeric promotion, the remainder operator is defined by the following identity (if b is not 0): (a/b)*b + a%b = a If the divisor b evaluates to zero, then an ArithmeticException is thrown. If the dividend evaluates to zero, the result is zero. The sign of the result equals the sign of the dividend. The magnitude of the result |a%b| is always less than the magnitude of the divisor |b|.

How to loop through a Map?

-- Using Map in java is a convenient way to store objects into a collection and identified by their names.  The Map interface provides API of adding and getting a particular object by the name it’s stored with.  However, there is no simple API to loop through all the items in the Map.  An older fashion to do this is to use the java.util.Iterator, for example: public void test () {         Map testMap = new HashMap();         testMap.put("key1", "value1");         testMap.put("key2", "value2");         Iterator it = testMap.keySet() .iterator () ;          while (  it.hasNext ()   )   {              String key =  (String) it.next () ;              System.out.println ( "key:"  +  key);              System.out.println ("value:" + testMap.get ( key )  ) ;        }     }

What are differences among greedy, reluctant, and possessive quantifiers in Java patterns?

-- The greedy, reluctant, and possessive quantifiers are for matching a specified expression x number of times. Quantifiers allow you to specify x number of occurrences to match against. The greedy quantifier is used to match with the longest possible string that matches the pattern while the reluctant quantifier is used to match with the shortest possible string that matches the pattern. The possessive quantifier is used to match the regular expression to the entire string and only matches when the whole string satisfies the criteria. Quantifiers Meaning Greedy Reluctant Possessive   X?   X??   X?+   X , once or not at all   X*   X*?   X*+   X , zero or more times   X+   X+?   X++   X , one or more times   X{n}   X{n}?   X{n}+   X , exactly n times   X{n,}   X{n,}?   X{n,}+   X , at least n times   X{n,m}   X{n,m}?   X{n,m}+   X , at least n but not more than m times For example we have string: xxfoooooooooofoo , let'

What is the difference between JDK and JRE?

-- The JRE is the Java RunTime Environment that is a plug-in needed for running java programs. The JRE is an implementation of the Java Virtual Machine which actually executes Java programs. The JDK is the Java Development Kit for Java application developers. The JDK is bundle of software which contains one (or more) JRE's along with the various development tools like the Java source compilers, bundling and deployment tools, debuggers, development libraries, etc.

What is difference between User and Daemon Thread in Java?

-- Java makes a distinction between a user thread and another type of thread known as a daemon thread. The daemon threads are typically used to perform services for user threads. The main() method of the application thread is a user thread. Threads created by a user thread are user thread. JVM doesn't terminates unless all the user thread terminate. You can explicitly specify a thread created by a user thread to be a daemon thread by calling setDaemon(true) on a Thread object. For example, the clock handler thread, the idle thread, the garbage collector thread, the screen updater thread, and the garbage collector thread are all daemon threads. A new created thread inherits the "daemon-status" of the thread that created it unless you explicitly calling setDaemon on that Thread object to change its status.

How to read input from console (keyboard) in Java?

-- There are few ways to read input string from  your console/keyboard. The following smaple code shows how to read a string from the console/keyboard by using Java. public class ConsoleReadingDemo {     public static void main(String[] args) {         // ====         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));         System.out.print("Please enter user name : ");         String username = null;         try {             username = reader.readLine();         } catch (IOException e) {             e.printStackTrace();         }

How to get my current system properties in Java?

-- The System class contains several useful class fields and methods. Accessing the current system properties is one of facilities provided by the System class. For example, to get the operating system name string in Java use the static System.getProperty("os.name") method. Here is a sample code to walk through system properties in Java: public class SystemPropertiesWalker  {        public static void main(String[] args) {           Properties properties = System.getProperties();         Set   sysPropertiesKeys = properties.keySet();         for (Object key : sysPropertiesKeys) {             System.out.println(key + " =" + properties.getProperty((String)key));         }     } } If there is no current set of system properties, a set of system properties is first created and initialized. This set of system properties always includes values for the following keys:

How to create a class instance by using class name in Java?

-- The Class.forName() method allows you to map a case-sensitive class name to the Class instance representing gaven class. Then you can invoke its newInstance() to create an instance of that class.  For Example:    Class tc = Class.forName("com.abcde.common.Type");    Tyep myType = tc.newInstance(); In the event that the Class could not be found, resolved, verified, or loaded, Class.forName throws one of several different Exceptions, all of which are listed in the javadoc page for java.lang.Class. Another example to check where class's jar file is:

How to access a resource (image, xml or properties file) insider a jar file?

-- How to accessing a resource within a jar file? You access some resources (images, xml file or properties file) that are inside a jar. For example, you can retrieve an image with the following way:     InputStream in = this.getClass().getClassLoader()                          .getResourceAsStream("com/linar/java2com/plus.gif");     int c;     ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();     while ((c = in.read()) != -1) {         byteArrayOutputStream.write((char) c);     } Here is another example using the getResource() method that takes an URL parameter to retrieve an image:     URL url = this.getClass().getClassLoader()                   .getResource("com/linar/java2com/plus.gif");     ImageIcon image = (new ImageIcon(url));

How to determine which jar a class is loaded from?

-- Did you ever encounter an runtime exception saying a method not found? How can the code compile if the method is not defined? Or after you made some changes to the code, you don't see it takes effect, even after you clean built, and redeploy for a couple of times? When these situations occurs, besides trying to pull your hair out, you can in fact find out which jar the class in trouble is loaded from. More than often, there is another jar file sitting the the classpath which contains the exact same class.   If you are handy in shell scripts, you may come up with a simple script using "find" to track down all the jar files in the class path that contains the class you are looking for.

How to run external programs by using Java ProcessBuilder class?

-- The class java.lang.ProcessBuilder, in Java 1.5, is used to create operating system processes. Each process builder manages these process attributes : (See Java API Document ) a command, a list of strings which signifies the external program file to be invoked and its arguments, if any. Which string lists represent a valid operating system command is system-dependent. For example, it is common for each conceptual argument to be an element in this list, but there are operating systems where programs are expected to tokenize command line strings themselves - on such a system a Java implementation might require commands to contain exactly two elements. an environment, which is a system-dependent mapping from variables to values. The initial value is a copy of the environment of the current process (see System.getenv()). a working directory. The default value is the current working directory of the current process, usually the directory named by the system property use

How to reverse lookup an enum from its values in Java?

-- Sometime, you need to lookup an enum from its value (may be a integer, string or other types). This reverse lookup can be easily implemented by using a static java.util.Map inside your enum class. For example, import java.util.HashMap; import java.util.Map; public enum Day {      SUNDAY(0),      MONDAY(1),      TUESDAY(2),      WEDNESDAY(3),      THURSDAY(4),      FRIDAY(5),      SATURDAY(6);        private static final Map lookup = new HashMap();      static {          //Create reverse lookup hash map          for(Day d : Day.values())              lookup.put(d.getDayValue(), d);      }