Skeleton of the Ant File #Java Short Notes

Ant can be used to compile and deploy Java applications. Struts and Spring applications also make use of Ant. Here, we have provided the structure of the build.xml file with examples that is used to carry out the functionalities. The redistribution of this file is in compatible with the copyright law of The Apache Foundation.

                         <!--  These properties define custom tasks for the Ant build tool that interact  with the "/manager" web application installed with Tomcat 5.  Before they  can be successfully utilized, you must perform the following steps:  - Copy the file "server/lib/catalina-ant.jar" from your Tomcat 5    installation into the "lib" directory of your Ant installation.  - Create a "build.properties" file in your application's top-level    source directory (or your user login home directory) that defines    appropriate values for the "manager.password", "manager.url", and    "manager.username" properties described above.  For more information about the Manager web application, and the functionality  of these tasks, see .-->        <!--  These properties control option settings on the Javac compiler when it  is invoked using the  task.  compile.debug        Should compilation include the debug option?  compile.deprecation  Should compilation include the deprecation option?  compile.optimize     Should compilation include the optimize option?-->      <!--  -->          <!--    -->                                                                                                                                                                                                                                                <!--    -->                          

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

From: http://sitestree.com/?p=4961
Categories:Java Short Notes
Tags:
Post Data:2007-06-06 02:04:10

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

EJB Overview: EJB in a nutshell #Java Short Notes

  • Objects provide encapsulation/re-usability at the class level.
  • A component can be comprised of multiple objects
  • Component = logical groups of classes = distributed objects = business objects
  • A component can be developed to address a specific enterprise applications.
  • Hence, components can provide significant encapsulation/re-usability in the partitioned enterprise problems.
  • Component model = components + their environments + contracts for interaction
  • EJB is a server side component model. Used to create application server side components
  • Most sophisticated application server = CTM = Transaction Processing Monitors + Object Request Brokers = J2EE Servers
  • EJB components: entity, session, message-driven
  • Entity beans = real world objects = business objects = data objects = customers = products = may be contained as records in the database = persistent
  • Multiple clients can access entity beans concurrently
  • Session beans = processes + tasks. Example: the act of reserving a ticket = to control work flow = to handle a series of tasks carried out by the entity beans = can also access/(help to access) data = do not represent data = transient = after the task is done – no need to maintain states = do not need to support concurrent access
  • Message-driven beans = stateless beans = no component interface = respond to client requests = clients place requests through JMS = support concurrent client access = can be used to perform tasks and manage interactions among beans = asynchronous = request and response two separate processes, RMI = synchronous

From: http://sitestree.com/?p=4958
Categories:Java Short Notes
Tags:
Post Data:2012-11-26 13:23:36

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

Java Connector Overview and an Example #Java Short Notes

  • Java Connector Architecture (JCA) enables integration of the J2EE components to any Enterprise Information Systems (EIS). EIS can be heterogeneous where scalability is a must.
  • JDBC assumes DBMS/RDBMS in the back-end, JCA targets any kind of EIS.
  • One of the key parts of JCA is the Resource Adapter – usually a part of the application servers. Multiple resource adapters can be used to connect to different EISs of heterogeneous types.
  • When resource adapters are plugged into the Application Servers they provide necessary transaction, security, and connection pooling mechanisms
  • In the JCA, an application contract defines the API that provides the client view to access EISs. The API can be EIS/resource adapter specific or standard.
  • Common Client Interface (CCI) – a set of interfaces and classes that allows J2EE applications to interact with heterogeneous EISs.
  • Example of JCA
    • EJBs, Servlets can connect to EISs through CCI and then access the EISs as required
    • J2EE SDK provides a black box resource adapter that we will use in our example to connect to EISs. We will assume RDBMS as the EIS in the example
    • Example: The flow of the application: client->servlet->resource adapter->EIS Tier (RDBMS – stored procedure)
    • In a servlet example: first step: import javax.resource.cci.*;
    • javax.resource.cci.*; – for ResourceException class
    • import cci blackbox classes: import com.sun.connector.cciblackbox.*;
    • Also, import servlet and application specific classes
    • public class ExampleServletConnector extends HttpServlet{   private Connection con;   private ConnectionFactory cf;   private String user;  public void init() throws ServletException{      try{            //establish JNDI interface            InitialContext ic = new InitialContext();           //look up user and password           user = (String) ic.lookup("java:comp/env/user");           String password = (String) ic.lookup("java:comp/env/password");          //reference to the connection factory for the CCI black box resource adapter - coded name CCIEIS          cf = (ConnectionFactory) ic.lookup("java:comp/env/CCIEIS");         //collect connection specification, connect to the database         ConnectionSpec conSpec = new ConnectionSpec (user,password);       con = cf.getConnection(conSpec);      }catch(ResourceException rex){         rex.printStackTrace();      }catch(NamingException nex){        nex.printStackTrace();      }  }
    • Now define the doGet method for processing. An example doGet method is as follows
    • public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException {  PrintWriter output = null;  res.setContentType("text/html");  try{     PrintWriter out = res.getWriter();     //find the number of rows in the account table - check getAccountAccountCount method in the next item     int accCount = getAccountAccountCount();     out.println("Account Count" + accCount);  }catch(Exception ex){   ex.printStackTrace();  }}
    • getAccountAccountCount() method: to query the database and determine the number of rows in the account table
    • public int getAccountCount(){   int count = -1;   try{       Interaction ix = con.createInteraction();       CciInteractionSpec iSpec = new CciInteractionSpec();        iSpec.setSchema(user);        iSpec.setCatalog(null);        //stored procedure name to calculate the number of rows       iSpec.setFunctionName("ACCOUNTCOUNT");       RecordFactory rf = cf.getRecordFactory();       IndexedRecord iRec = rf.createIndexedRecord("InputRecord");       Record oRec = ix.execute(iSpec, iRec);       Iterator it = ((IndexedRecord)oRec).iterator();       //process        while(it.hasNext()){          Object obj = it.next();          if (obj instanceof Integer){             count = ((Integer) obj).intValue();          }else if (obj instanceOf BigDecimal){           count = ((BigDecimal) obj).intValue();          }        }   }catch(Exception ex){   }   return count;}

From: http://sitestree.com/?p=4956
Categories:Java Short Notes
Tags:
Post Data:2010-01-15 20:19:20

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

Hello World: Web Service Application: IntelliJ, Tomcat, Apache Axis/Glassfish #Java Short Notes

This is an excellent document to start with. A sample server and a sample client are built in both Apache Axis and Glassfish

From: http://sitestree.com/?p=4946
Categories:Java Short Notes
Tags:
Post Data:2008-06-28 19:28:56

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

Java File Operation Example #Java Short Notes

Code that helped me to create http://add.justEtc.net – the Bangladesh section based on the the web-site http://winnipeg.justEtc.net

package hello;import javax.swing.JOptionPane;import java.util.ArrayList;import java.util.Iterator;import java.io.*;/** * Created by IntelliJ IDEA. * User: Sayed Ahmed * Date: May 30, 2008 * Time: 9:45:08 PM * To change this template use File | Settings | File Templates. *//**Class containing major methods - operation methods*/class Process{    private FileReader src = null; //source folder    private FileWriter dest = null; //destination folder    private ArrayList cityList = new ArrayList(); //arraylist to contain 	//the names of all cities    private String cityFileName; //reference to the file containing all city names    private String folderToCopy; //path to the folder to be copied    private String destination; // path  to the folder where the copy will be kept    /**     * Constructor     */    Process(){//JOptionPane.showInputDialog(null,"City File Name");        cityFileName = "C:test_developmentjavaresourcescityList.txt";  //JOptionPane.showInputDialog(null,"Folder to Copy");        folderToCopy = "C:test_developmentjavahellosrcresourcessource	Winnipeg";  //JOptionPane.showInputDialog(null,"Destination Path");         destination = "C:test_developmentjavahellosrcresources	destination";                 //load city list from the file to an arraylist        copyCityList(cityFileName);        //to create a file with links to all the cities of Bangladesh        //createFile();        //copy a folder (winnipeg) and rename it to all the city names of 	//Bangladesh -- one by one        Iterator it = cityList.iterator();        while(it.hasNext()){            copyDirectory((String) it.next());        }    }    /**     * load city list into an ArrayList     */    private void copyCityList(String cityFileName){        String city = "";        try {            BufferedReader bfCity = new BufferedReader(new FileReader(cityFileName));            while(null != (city = bfCity.readLine())){                cityList.add(city);            }        } catch (IOException e) {            e.printStackTrace();  //To change body of catch statement use File 				//| Settings | File Templates.        } finally {        }    }    /**     * copy a folder , name the folder as the city name     */    private void copyDirectory(String city){        try {            copyDirectory(new File(folderToCopy), new File(destination+"/"+city), 		city);        }catch (IOException e){            e.printStackTrace();        }    }    /**     * Copies all files under srcDir to dstDir.     * If dstDir does not exist, it will be created.     * @param srcDir - folder to copy     * @param dstDir - where to keep     * @param city  - new folder name     * @throws IOException     */    public void copyDirectory(File srcDir, File dstDir, String city) throws 	IOException {        //if srcDirectory is a directory , create the directory        if (srcDir.isDirectory()) {            if (!dstDir.exists()) {                dstDir.mkdir();            }            //if srcDir has child directories , create child directories - 		Recursively            String[] children = srcDir.list();            for (int i=0; i<children .length; i++) {                copyDirectory(new File(srcDir, children[i]),                                     new File(dstDir, children[i]),city);            }        } else {            //srcDir is a file, so copy it to the new location            copyFile(srcDir, dstDir, city);        }    }    /**     * Copy a file     * @param src - source file     * @param dst - destination file     * @param city - city under consideration     */    private void copyFile(File src, File dst, String city) {        InputStream in;        OutputStream out;        try {            in = new FileInputStream(src);            out = new FileOutputStream(dst);            BufferedReader myInput = new BufferedReader   (new InputStreamReader(in));            PrintWriter myOutput = new PrintWriter(dst);            String thisLine = "";            //replace old city name with the new city name            while ((thisLine = myInput.readLine()) != null) {              if (thisLine.contains("Winnipeg")){                  thisLine=thisLine.replaceAll("Winnipeg", city);                  thisLine=thisLine.replaceAll("Manitoba,", "");                  thisLine=thisLine.replaceAll("Canada", "Bangladesh");              }              myOutput.write(thisLine);              myOutput.write("n");            }            myOutput.flush();            in.close();            out.close();        } catch (IOException e) {            e.printStackTrace();  //To change body of catch statement use File | 				//Settings | File Templates.        } finally {        }    }    /**       Creates a file with links to all cities     */    private void createFile() {        try {            FileWriter out = new FileWriter("test.txt");            PrintWriter myOutput = new PrintWriter(out);            Iterator it = cityList.iterator();            String city = "";            while(it.hasNext()){            city = (String) it.next();String thisLine =                        "n" +                                "t t  ""+				city+""n"" +                        ""n"";                              myOutput.write(thisLine);                  myOutput.write(""n"");                  myOutput.flush();            }        } catch (IOException e) {            e.printStackTrace();  //To change body of catch statement use File 				//| Settings | File Templates.        }    }}/** * Main class - class containing the main method */public class Hello {    public static void main(String args[]){        Process process = new Process();    }}

” From: http://sitestree.com/?p=4945
Categories:Java Short Notes
Tags:
Post Data:2013-03-18 14:29:36

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

Java Fundamentals #Java Short Notes

  • An abstract class may have constructors
  • It is illegal to invoke the new operator on an abstract class
  • An abstract class is allowed to have method implementations
  • There is no restriction about the placement of abstract classes in a class hierarchy
  • It is legal for an abstract class to implement an interface and implement one or more interface methods
  • A well-encapsulated class must have all of its attributes marked private
  • A well-encapsulated class must hide all internal methods.
  • NOT all attributes require accessor or mutator methods

From: http://sitestree.com/?p=4936
Categories:Java Short Notes
Tags:
Post Data:2008-07-21 09:28:29

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

Your First EJB Application #Java Short Notes

From: http://sitestree.com/?p=4935
Categories:Java Short Notes
Tags:
Post Data:2011-11-10 23:41:54

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

Java Design Patterns and Examples #Java Short Notes

From: http://sitestree.com/?p=4934
Categories:Java Short Notes
Tags:
Post Data:2007-06-04 16:27:01

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

A simple EJB 3.0 application: Explanation of EJB 3.0 technology: EJB => Spring Framework #Java Short Notes

A simple EJB 3.0 application: Explanation of EJB 3.0 technology: EJB => Spring Framework ……. …. …

From: http://sitestree.com/?p=4933
Categories:Java Short Notes
Tags:
Post Data:2008-05-07 18:54:31

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

EJB 3.0: Specifications : Simplified API #Java Short Notes

  • Focused on annotations – reduces the number of classes and interfaces, eliminates the need for a deployment descriptor
  • Encapsulation of environmental dependencies and JNDI access: annotations, dependency injection, simple lookup mechanism
  • Simpler enterprise bean types
  • session beans: business interface can be a plain Java interface
  • session beans: no need for a home interface
  • entity persistence: Java Persistence API.
  • A query language for Java persistence
  • session beans and message driven beans: an interceptor facility
  • implementation of callback interfaces is not a must
  • Java persistence API: provide object relational mapping, can replace Hibernate
  • A POJO (Plain Old Java Object) programming model
  • A lightweight ORM persistence framework
  • Dependency injection
  • Metadata annotations
  • Configuration by exception
  • Elimination of component interfaces
  • Elimination of home interfaces
  • Reduction of the use of checked exceptions

From: http://sitestree.com/?p=4932
Categories:Java Short Notes
Tags:
Post Data:2009-06-10 02:59:25

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada