Simply backup and restore your domains in GlassFish Using GlassFish Command Console

Do you ever though about creating a backup copy of your domains in GlassFish , for example before doing something unpredictable , meanwhile you like your domain because of its configurations ?
here is simple steps to create backup and restore those backup.
before we go any further you should know , domaindir that we see in many of asadmin commands has a default value its default value is : GlassFish_home/domains , in all of those commands that has domaindir parameter, if you explicitly do not identify the domaindir asadmin will use the default values. So , when you use domain1 in some command , asadmin will look inside GlassFish_home/domains for that particular domain. steps to create a backup :

  1. Execute asadmin from bin directory under GlassFish_home
    in case that you want to create a backup from a domain named domain1 (which is default domain)
  2. execute : backup-domain –description "I made this backup before changing default domain descriptor" domain1
    after you execute this command , asadmin will create a folder named backups inside GlassFish_home/domains/domain1 and place a zip file there. The zip file is a backup of your domain . For example the zip file could be : sjsas_backup_v00001.zip it means that it is first backup that you create for this domain.
    if you open the zip file you can see a file named backup.properties which contain informations like :
    #Backup Status
    #Wed Apr 26 01:00:40 IRDT 2006
    timestamp.human=Wed Apr 26 01:00:40 IRDT 2006
    domain.name=domain1
    user.name=Masoud Kalali
    domain.dir=F:\glassfish\domains\domain1
    domains.dir=F:\glassfish\domains
    timestamp.msec=1146004240218
    description=I made this backup before chaning default domain descriptor
    backup.file=F:\glassfish\domains\domain1\backups\sjsas_backup_v00001.zip

There is a command which helps you to find out how much backups you have and shows you information related to each backup entry you made.This command is : list-backups it get an operand , the operand will be your domain name. You can also tell it that your domain dir is not the default place using –domaindir parameter.

Now lets see how we can restore this backup using asadmin administration console.
there is a command named restore-domain , this command will restore a domain using a backup file. Simply you need just to pass an operand which is your domain name. If you do this , it will restore your domain using your latest backup .
So if I execute : restore-domain domain1 it will looks inside the backups folder (the default place) and select latest backup then it will try to restore the domain using that backup.
you can use –filename parameter to specify another backup file which should be passed using a full path.
I should say that this command accept domaindir parameter as other commands that we talked about them this time.

overview of XML Parsing in java , different methods and libraries

what are different technologies and implementations to simply pars some XML files ?
What Java provide you to pars XML files ?
Iin this blog entry After answering the above questions , i will introduce (by name and method of parsing) some XML parser available in java land.we may talk more about each of them in next entries.
First lets see what are different methods to pars XML files. There are Two major XML parsing method , one of them is Old and Standard method using a DOM (Documet Object Model) and the other is Stream and Event Based Parsing.

  • In DOM metod we fetch entiere XML document into memory and create a Objective representation of it in the memory then we can traverse the document using a very rich set of methods which DOM interfaces defined. So wen can access the document tree in any time and change its elements or attributes on emand.
    But it will need a high amount of memory to store the Document Tree , so it is not suitable when you have resource (memory) limitation. as you know Current Browsers use this model, so we can easily use javaScript to access an elements and Change them in runtime base on our needs.Using DOM you can create and write XML files.

  • Other model Use Streaming and is event based, what does it means ? it means that it go trough the document from start to end , and as soon as it(the Streaming parser) sees some text nodes , attribute , Maleformed elements… it will trigger an Event which you are listening for , so it is a one way parsing which in , you can not change the elements or its attributes as you can do in DOM .In Streaming model you do not need a high amount of memory becasue you are not going to create a model of your document in memory.using Stream parsers you can create an XML file.

but we should notice that we have Another categorizing for XML parser refer to parser and client communication mechanism , there are two kind of communication mechanism between parsers and client that use those parsers , by this categorizing we have two kind of parses :

  • Push parser
  • Pull parser

Parsers that we have had before StAX are push parsers, which parser push XML data to client whether it needs those data or not or even it is ready to recieve data or not.
Pull Parsers which come along with StaX parsers provide another mechanism for letting Client to have the data . it give the ability of asking for XML data to client , so Client will recive Data when it asks for those Data.
Now you should know that DOM / SAX are both push parsers , and the only pull parser implementation that i used is StAX.
some features that make StAX a suitable parsing method when you need just to pars xml files while there is no need to create or update an XML file, you should know that StAX is one was parser as SAX parsers are.

  • With StAX you can write XML documents too , meanwhile with SAX you can not write XML documents.
  • using StAX as i will show you in next part is much easier than using SAX
  • In pull parsing your own code has the control of Parser client Thread becasue its you that engage with Parser MeanWhile in a push parser it is parse that is mainStream in your code becase it parse and give the parsed data back to you whether you ask for it or not
  • You can works with several XML Streams (parsing and processing them ) in pull parsing mode when your client code is one thread, meanwhile you can not do this in a push parsing mode

Now Lets see what XML parsers support which models:

Model / XML Parsing Library

Crimson
1.1.3

Xerces
1.4.4

JAXP
1.3

NekoPull1
0.2.4
   

Piccolo
1.04

StAX
1.2 RC

dom4j
1.6.1

Push Parsing

Yes

Yes

Yes

No

Yes

No

Yes

Pull Parsing

No

No

No

Yes

No

Yes

No

Stream Parsing  implementation (SAX)

Yes

Yes

Yes

Yes

Yes

Yes

Yes

DOM Parsing implementation

Yes

Yes

Yes

No

No

No

Yes

 

1- It Extends  XNI to provide pull parsing.

An overview of Different Software development models with a deeper look at RUP Development model

Here is an Presentation that i made last year . it is about different lifecycle models like spiral , waterfall and iterative models.
this presentation contain following contents :

  1. Part I
    1. Basics and Explanations
    1. Terms and definitions
    2. Well known Life Cycle models / Methodologies
    1. Waterfall
    2. Spiral
    3. Iterative
    4. XP
  2. Part II

  1. RUP as a SDP Life Cycle Model
    1. Phases and Milestones
    2. RUP and System Evolution
  2. EUP (Explanation)

You can get OO.org ODP from Here
Hoping you find it useful.

Testing some FrameWorks and applications on Glassfish build 40+ part V , And some tips about Application deployment

It is a short entry that shows i used DWR Ajax Toolkit On GlassFish But to make the entry a bit more usefull , i would like to tell you how you can deploy an application to GlassFish .
so far I know two methods that allows us to deploy application into GlassFish ,

  1. Using its web based Admin console which usally run on port 4848
  2. Using the Autodeply library of your desierd Domain
  3. Using Asadmin administration console

Lets see how we can deply sample war file of DWR Ajax Toolkit using each of the above methods. A war file like this one has simplest form of deployment because we have no resource definition , for example there is no datasource , connection pool , jms destination ,…. which needs to be defined. To start your server goto GlassFish_Home/bin and execute
asadmin start-domain it will start the application server default domain , in case that you did not change the administration port then you can access the web based admin console using http://127.0.0.1:4848/asadmin/admingui/TopFrameset
after you loged in just in your left panel click on the web applications node , you will see that content frame shows you all deployed application and also provide some buttons to deploy new web application something like :

click on deploy and you will see the web application deployment page , here you can browse to WAR file ad select it to be deployed into current Domain.lets do it by selecting DWR.war which we download from DWR website. next image show how the war file deployment will looks like

Now press next , and you will see that DWR is deployed very easily. Now you can naviate to Web applications node and see your DWR entry in web application list , lets check and see how does it works on glassfish.
To check that it works on GlassFish it will be enough to run one of its samples. so do it yourself to see what happens. I for my sel JDate Sample as the first one and i saw that it works fine.

Now lets see how we can deploy the application using autodeploy folder , this folder is located in your domain folder somewhere like :

Auto Deploy Folder Place

you can use this folder to deploy all kind of applications , so you can put a war file inside that folder and GlassFish will deploy it for you , you can put an EAR file there and GlassFish will deploy it for you even You can deploy Resource Adapters (RAR files) using this folder.
to test this folder , goto web administration console and inside web applications management page undeploy DWR project then come back here and put DWR.war inside autodeploy folder now go to web based management console and you will see DWR in deployed web application list.

Now that you find out how this magic folder works , lets see how that administration Script ( asadmin.bat/sh) works for us. it is even easier than the previus one , you just need to call : Glassfish_Home/bin/asadmin deploy c:/DWR.war

Deployment Using Console

In next parts i will talk more about deploying application into GlassFish , we will see how an ear file or rar file can be deployed and be configured to works inside GlassFish .