Introduction of Castor in Java

Castor is an open source data binding framework for moving data from XML to Java programming language objects and from Java to databases. It’s the shortest path between Java objects, XML documents and relational tables. Castor provides Java-to-XML binding, Java-to-SQL persistence, and more.

Castor is made up of (independent) modules as follows:– Castor XML
– Castor XML – Code generator
– Castor JDO – Persistence framework
– Castor JDO – DDL generator
– Additional tools
– Integration with other frameworks
Castor XML
XML data binding framework to bind XML artefacts to Java objects and vice versa.
Castor XML code generator
Code generator that generates Java source code from XML Schema information.
Castor JDO
Java persistence framework to bind Java objects to RDBMS tables. Castor JDO (Java Data Objects) is an open source, 100 percent Java data binding framework. Initially released in December 1999, Castor JDO was one of the first open source data binding frameworks available. Since that time, the technology has come a long way.

Castor JDO DDL generator
Generates DDL statements from JDO mapping files.
Castor is currently integrated with the following frameworks or has support for being integrated:
Spring ORM support for Castor
– Spring OXM for Castor
– Spring XML artifacts
– Web Service toolkits
– Apache Cocoon (Castor transformer)
– extendedXML module for Mule, offering enhanced XML-transformation support for Mule, using Castor

You can find Castor Api doc on – http://www.jdocs.com/castor/1.0.1/overview-summary.html
More information you can find on – http://www.castor.org/

pimp it

Introduction to EJB

Enterprise Java beans -is a managed, server-side component architecture for modular construction of enterprise applications. EJB server is a high-level process or application that provides a run-time environment to support the execution of server applications that use enterprise beans. Enterprise beans live in an EJB container (a runtime environment within a J2EE server). The EJB container provides multiple services to support the enterprise beans.

Different types of EJBs
There are three types of enterprise beans: session beans, entity beans, and message-driven beans.

1. Session beans: Session beans are non-persistent enterprise beans. They can be stateful or stateless. A stateful session bean acts on behalf of a single client and maintains client-specific session information (called conversational state) across multiple method calls and transactions. It exists for the duration of a single client/server session. A stateless session bean, by comparison, does not maintain any conversational state. Stateless session beans are pooled by their container to handle multiple requests from multiple clients.

a) Stateless session EJBs
Stateless session EJBs are the preferred type of session EJB, since they
generally scale better than stateful session EJBs. Stateless beans are pooled by
the EJB container to handle multiple requests from multiple clients. In order to
permit this pooling, stateless beans cannot contain any state information specific to a particular client. Because of this restriction, all instances of a stateless bean are equivalent, allowing the EJB container to assign an instance
to any client.
B)Stateful session EJBs
Stateful session EJBs are useful when an EJB client needs to call several
methods and store state information in the session bean between calls. Each
stateful bean instance must be associated with exactly one client, so the
container is unable to pool stateful bean instances.

2. Entity beans: Entity beans are enterprise beans that contain persistent data and that can be saved in various persistent data stores. Each entity bean carries its own identity. Entity beans that manage their own persistence are called bean-managed persistence (BMP) entity beans. Entity beans that delegate their persistence to their EJB container are called container-managed persistence (CMP) entity beans.
A).Container-managed persistence (CMP)
The EJB container handles all database access required by the entity bean. The
bean’s code contains no database access (SQL) calls. As a result, the bean’s
code is not tied to a specific database. Because of this flexibility, even if you
redeploy the same entity bean on different J2EE servers that use different
databases, you do not have to modify or recompile the bean’s code. The
container must provide an object-relational mapping tool to allow a developer or
deployer to describe how the attributes of an entity bean map onto columns in
tables of a database.

B)Bean-managed persistence (BMP)
The developer handles all storage-specific access required by the entity bean.
This allows the developer to use non-relational storage options and features of
relational databases that are not supported by CMP entity beans, such as
complex SQL and stored procedures.

3.) Message-driven beans: Message-driven beans are enterprise beans that receive and process JMS messages. Unlike session or entity beans, message-driven beans have no interfaces. They can be accessed only through messaging and they do not maintain any conversational state. Message-driven beans allow asynchronous communication between the queue and the listener, and provide separation between message processing and business logic.

EJB container
An EJB container is a run-time environment that manages one or more enterprise beans. The EJB container manages the life cycles of enterprise bean objects, coordinates distributed transactions, and implements object security. Generally, each EJB container is provided by an EJB server and contains a set of enterprise beans that run on the server.

pimp it

Nullable Type in C#

Nullable type in C#
We can declare a variable as nullable when we want to know that a value has been assigned to that variable or not. Declaring a variable as nullable enables the HasValue and Value members. We can use the HasValue property on the variable to check if the value has been assigned to the variable.

Example of Using Nullable
Let’s take an example of boolean variable. As we know the default value for a boolean variable is false. But we want that we should be able to know if user has selected true or false. So we define the bool variable as nullable like this:

Nullable<bool> testVariable= null;

Now we have the testVariable as a boolean variable having a value of null. Now when use the properties like this :

if(testVariable.HasValue)
MessageBox.Show(String.Format("Value is {0}",testVariable.value )); 

kick it on DotNetKicks.com

Shout it

pimp it