Thread: [Batchserver-cvs] batchserver/src/org/jmonks/batchserver/framework/repository/db4o Db4oJobController
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-03-17 05:13:29
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/repository/db4o In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18539 Modified Files: Db4oRepository.java Added Files: Db4oJobControllerHolderPredicate.java Db4oJobDataTransferHolder.java Db4oJobMgmtMntrInfoHolder.java Db4oJobMgmtMntrInfoHolderPredicate.java Db4oJobStatisticsPredicate.java Removed Files: Db4oJobDataTransfer.java Db4oMgmtMntrInfoHolder.java Log Message: no message --- Db4oJobDataTransfer.java DELETED --- --- NEW FILE: Db4oJobControllerHolderPredicate.java --- /* * Db4oJobControllerHolderPredicate.java * * Created on March 16, 2006, 7:32 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batchserver.framework.repository.db4o; import com.db4o.query.Predicate; /** * Db4oJobControllerHolderPredicate used to find the Db4oJobControllerHolder * objects in Db4o database using native query. * * @author Suresh Pragada * @version 1.0 * @since 1.0 */ class Db4oJobControllerHolderPredicate extends Predicate { /** * job name to find the controller holder objects for. */ private String jobName=null; /** * Creates a new instance of Db4oJobControllerHolderPredicate with the job name. */ Db4oJobControllerHolderPredicate(String jobName) { if(jobName==null) throw new IllegalArgumentException("job name cannot be null for Db4oJobControllerHolder Predicate."); this.jobName=jobName; } /** * Method to run the the native query. This receives the Db4oJobControllerHolder * objects and look for the job name this predicate initialized with. */ public boolean match(Db4oJobControllerHolder holder) { if(jobName.equals(holder.getJobName())) return true; else return false; } } --- Db4oMgmtMntrInfoHolder.java DELETED --- Index: Db4oRepository.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/repository/db4o/Db4oRepository.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Db4oRepository.java 16 Mar 2006 14:16:40 -0000 1.1 --- Db4oRepository.java 17 Mar 2006 05:13:25 -0000 1.2 *************** *** 23,31 **** * <br><br> * <pre> ! * <repository-config repository-class-name="org.jmonks.batchserver.framework.Db4oRepository"> * <property key="repository-location">/batchserver/repository</property> * </repository-config> * </pre> ! * <br><br> * Here repository-location defines where the DB4O database needs to create * the repository file. By default framework will be configured with the values --- 23,31 ---- * <br><br> * <pre> ! * <repository-config repository-class-name="org.jmonks.batchserver.framework.repository.db4o.Db4oRepository"> * <property key="repository-location">/batchserver/repository</property> * </repository-config> * </pre> ! * <br> * Here repository-location defines where the DB4O database needs to create * the repository file. By default framework will be configured with the values *************** *** 55,61 **** */ ObjectContainer container=null; /** * <p> ! * Creates the Db4oRepository by accepting the map consist of properties * needed to setup the repository. This make sure repository-location property * has been defined and the value defined for this property is valid. --- 55,62 ---- */ ObjectContainer container=null; + /** * <p> ! * Initializes the Db4oRepository by accepting the map consist of properties * needed to setup the repository. This make sure repository-location property * has been defined and the value defined for this property is valid. *************** *** 66,72 **** * the value specified is invalid. */ ! public Db4oRepository(Map configProps) { ! logger.trace("Entering constructor"); this.repositoryConfigProperties=new HashMap(configProps); String repositoryLocation=(String)this.repositoryConfigProperties.get(Db4oRepository.PROPERTY_REPOSIOTRY_LOCATION); --- 67,73 ---- * the value specified is invalid. */ ! protected void init(Map configProps) { ! logger.trace("Entering init"); this.repositoryConfigProperties=new HashMap(configProps); String repositoryLocation=(String)this.repositoryConfigProperties.get(Db4oRepository.PROPERTY_REPOSIOTRY_LOCATION); *************** *** 97,110 **** throw new ConfigurationException(ConfigurationException.REPOSITORY_CONFIG, "Unable to create the file " + completeRepositoryFileName + " to setup repository."); } ! logger.trace("Exiting constructor"); } /** ! * @see org.jmonks.batchserver.framework.Repository#sendDataToNextJob(String,String,String,Object) */ ! public boolean sendDatatoNextJob(final String dataIdentifier, final String sourceJobName, final String targetJobName, final Object data) { if(dataIdentifier==null || sourceJobName==null || targetJobName==null || data==null) throw new IllegalArgumentException("No arguments cannot be null to the sendDataToNextJob method."); boolean dataSaved=false; --- 98,118 ---- throw new ConfigurationException(ConfigurationException.REPOSITORY_CONFIG, "Unable to create the file " + completeRepositoryFileName + " to setup repository."); } ! logger.trace("Exiting init"); } /** ! * @see org.jmonks.batchserver.framework.repository Repository#sendDataToNextJob(String,String,String,Object) */ ! public boolean sendDataToNextJob(String dataIdentifier, String sourceJobName, String targetJobName, final Object data) { + logger.trace("Entering sendDataToNextJob);"); + logger.debug("data identifier = " + dataIdentifier + " source job name = " + sourceJobName + " target job name = " + targetJobName + " data = " + data); + if(dataIdentifier==null || sourceJobName==null || targetJobName==null || data==null) throw new IllegalArgumentException("No arguments cannot be null to the sendDataToNextJob method."); + + final String finalDataIdentifier=dataIdentifier; + final String finalSourceJobName=sourceJobName; + final String finalTargetJobName=targetJobName; boolean dataSaved=false; *************** *** 118,126 **** ObjectSet dataTransferredSet=container.query(new Predicate() { ! public boolean match(Db4oJobDataTransfer jobDataTransfer) { ! if(dataIdentifier.equals(jobDataTransfer.getDataIdentifier()) && ! sourceJobName.equals(jobDataTransfer.getSourceJobName()) && ! targetJobName.equals(jobDataTransfer.getTargetJobName())) return true; else --- 126,134 ---- ObjectSet dataTransferredSet=container.query(new Predicate() { ! public boolean match(Db4oJobDataTransferHolder jobDataTransfer) { ! if(finalDataIdentifier.equals(jobDataTransfer.getDataIdentifier()) && ! finalSourceJobName.equals(jobDataTransfer.getSourceJobName()) && ! finalTargetJobName.equals(jobDataTransfer.getTargetJobName())) return true; else *************** *** 133,168 **** } container.commit(); /** * Add the new entry. */ ! Db4oJobDataTransfer dataTransfer=new Db4oJobDataTransfer(dataIdentifier, sourceJobName, targetJobName, data); container.set(dataTransfer); container.commit(); dataSaved=true; } return dataSaved; } /** ! * @see org.jmonks.batchserver.framework.Repository#getDataFromPreviousJob(String,String,String) */ ! public Object getDataFromPreviousJob(final String dataIdentifier, final String sourceJobName, final String targetJobName) { if(dataIdentifier==null || sourceJobName==null || targetJobName==null) throw new IllegalArgumentException("Data identifer, source job name and target job name cannot be null " + "to get the data from previous job."); if(container==null) ! return null; else { ObjectSet dataTransferResultSet=container.query(new Predicate() { ! public boolean match(Db4oJobDataTransfer jobDataTransfer) { ! if(dataIdentifier.equals(jobDataTransfer.getDataIdentifier()) && ! sourceJobName.equals(jobDataTransfer.getSourceJobName()) && ! targetJobName.equals(jobDataTransfer.getTargetJobName())) { return true; --- 141,187 ---- } container.commit(); + logger.trace("deleted the data identified by " + dataIdentifier + " from the job name " + sourceJobName); /** * Add the new entry. */ ! Db4oJobDataTransferHolder dataTransfer=new Db4oJobDataTransferHolder(dataIdentifier, sourceJobName, targetJobName, data); container.set(dataTransfer); container.commit(); + logger.trace("data has been added with the identifier " + dataIdentifier + " from job name " + sourceJobName); dataSaved=true; } + logger.trace("Exiting sendDataToNextJob"); return dataSaved; } /** ! * @see org.jmonks.batchserver.framework.repository.Repository#getDataFromPreviousJob(String,String,String) */ ! public Object getDataFromPreviousJob(String dataIdentifier, String sourceJobName, String targetJobName) { + logger.trace("Entering getDataFromPreviousJob"); + logger.debug("data identifier = " + dataIdentifier + " source job name = " + sourceJobName + " target job name = " + targetJobName); + if(dataIdentifier==null || sourceJobName==null || targetJobName==null) throw new IllegalArgumentException("Data identifer, source job name and target job name cannot be null " + "to get the data from previous job."); + final String finalDataIdentifier=dataIdentifier; + final String finalSourceJobName=sourceJobName; + final String finalTargetJobName=targetJobName; + + Object data=null; if(container==null) ! data=null; else { ObjectSet dataTransferResultSet=container.query(new Predicate() { ! public boolean match(Db4oJobDataTransferHolder jobDataTransfer) { ! if(finalDataIdentifier.equals(jobDataTransfer.getDataIdentifier()) && ! finalSourceJobName.equals(jobDataTransfer.getSourceJobName()) && ! finalTargetJobName.equals(jobDataTransfer.getTargetJobName())) { return true; *************** *** 175,190 **** if(dataTransferResultSet.hasNext()) { ! return ((Db4oJobDataTransfer)dataTransferResultSet.next()).getData(); } else ! return null; } } ! ! public boolean clearDataTransferredToNextJob(final String jobName) { if(jobName==null) throw new IllegalArgumentException("job name cannot be null."); boolean dataCleared=false; if(container==null) --- 194,219 ---- if(dataTransferResultSet.hasNext()) { ! data=((Db4oJobDataTransferHolder)dataTransferResultSet.next()).getData(); ! logger.debug("data identified by " + dataIdentifier + " has been found from the source job name " + sourceJobName); } else ! data=null; } + logger.trace("Exiting getDataFromPreviousJob"); + return data; } ! ! /** ! * @see org.jmonks.batchserver.framework.repository.Repository#clearDataTransferredToNextJob(String) ! */ ! public boolean clearDataTransferredToNextJob(String jobName) { + logger.trace("Entering clearDataTransferredToNextJob"); + logger.debug("clearDataTransferredToNextJob :: job name = " + jobName); + if(jobName==null) throw new IllegalArgumentException("job name cannot be null."); + final String finalJobName=jobName; boolean dataCleared=false; if(container==null) *************** *** 194,200 **** ObjectSet dataTransferResultSet=container.query(new Predicate() { ! public boolean match(Db4oJobDataTransfer jobDataTransfer) { ! if(jobName.equals(jobDataTransfer.getSourceJobName())) { return true; --- 223,229 ---- ObjectSet dataTransferResultSet=container.query(new Predicate() { ! public boolean match(Db4oJobDataTransferHolder jobDataTransfer) { ! if(finalJobName.equals(jobDataTransfer.getSourceJobName())) { return true; *************** *** 207,248 **** while(dataTransferResultSet.hasNext()) container.delete(dataTransferResultSet.next()); ! container.commit(); dataCleared=true; } return dataCleared; } /** ! * @see org.jmonks.batchserver.framework.Repository#registerJobMgmtMntrInfo(String,Object) */ ! public boolean registerJobMgmtMntrInfo(String jobName, Object registrationInfo) { ! return true; } /** ! * @see org.jmonks.batchserver.framework.Repository#lookupJobMgmtMntrInfo(String) */ public Object lookupJobMgmtMntrInfo(String jobName) { ! return null; } /** ! * @see org.jmonks.batchserver.framework.Repository#unregisterJobMgmtMntrInfo(String) */ public boolean unregisterJobMgmtMntrInfo(String jobName) { ! return true; } /** * ! * @see org.jmonks.batchserver.framework.Repository#logStatistics(org.jmonks.batchserver.framework.JobStatistics) */ ! public boolean logStatistics(JobStatistics statistics) { if(statistics==null) throw new IllegalArgumentException("Null statistic objects will not be saved in repository"); --- 236,349 ---- while(dataTransferResultSet.hasNext()) container.delete(dataTransferResultSet.next()); ! logger.debug(jobName + " data has been cleared from the repository."); container.commit(); dataCleared=true; } + logger.trace("Exiting clearDataTransferredToNextJob"); return dataCleared; } /** ! * @see org.jmonks.batchserver.framework.repository.Repository#registerJobMgmtMntrInfo(String,Object) */ ! public boolean registerJobMgmtMntrInfo(String jobName, final Object registrationInfo) { ! logger.trace("Entering registerJobMgmtMntrInfo"); ! logger.debug("job name = " + jobName + " registratinfo = " + registrationInfo); ! ! if(jobName==null || registrationInfo==null) ! throw new IllegalArgumentException("job name and mgmt&mntr registration information cannot be null to register the job."); ! ! boolean registered=true; ! ! if(container==null) ! registered=false; ! else ! { ! ObjectSet mgmtMntrInfoHolderResultSet=container.query(new Db4oJobMgmtMntrInfoHolderPredicate(jobName)); ! ! while(mgmtMntrInfoHolderResultSet.hasNext()) ! container.delete(mgmtMntrInfoHolderResultSet.next()); ! container.commit(); ! logger.trace(jobName + " previous mgmt and mntr information has been deleted"); ! ! container.set(new Db4oJobMgmtMntrInfoHolder(jobName, registrationInfo)); ! container.commit(); ! logger.trace(jobName + " mgmt and mntr information has been added to the repository"); ! registered=true; ! } ! logger.trace("Exiting registerJobMgmtMntrInfo"); ! return registered; } /** ! * @see org.jmonks.batchserver.framework.repository.Repository#lookupJobMgmtMntrInfo(String) */ public Object lookupJobMgmtMntrInfo(String jobName) { ! logger.trace("Entering lookupJobMgmtMntrInfo"); ! logger.debug("lookupJobMgmtMntrInfo :: job name = " + jobName); ! ! if(jobName==null) ! throw new IllegalArgumentException("jobName cannot be null to lookup the mgmt and mntr information."); ! ! Object registratInfo=null; ! if(container==null) ! registratInfo=null; ! else ! { ! ObjectSet mgmtMntrInfoHolderResultSet=container.query(new Db4oJobMgmtMntrInfoHolderPredicate(jobName)); ! if(mgmtMntrInfoHolderResultSet.hasNext()) ! { ! registratInfo=((Db4oJobMgmtMntrInfoHolder)mgmtMntrInfoHolderResultSet.next()).getMgmtMntrInfo(); ! logger.debug(jobName + " management and monitoring information has been found and being returned"); ! } ! else ! registratInfo=null; ! } ! logger.trace("Exiting lookupJobMgmtMntrInfo"); ! return registratInfo; } /** ! * @see org.jmonks.batchserver.framework.repository.Repository#unregisterJobMgmtMntrInfo(String) */ public boolean unregisterJobMgmtMntrInfo(String jobName) { ! logger.trace("Entering unregisterJobMgmtMntrInfo"); ! logger.debug("unregisterJobMgmtMntrInfo :: job name = " + jobName); ! ! if(jobName==null) ! throw new IllegalArgumentException("jobName cannot be null to unregister the mgmt and mntr information."); + boolean unregistered=false; + + if(container==null) + unregistered=false; + else + { + ObjectSet mgmtMntrInfoHolderResultSet=container.query(new Db4oJobMgmtMntrInfoHolderPredicate(jobName)); + if(mgmtMntrInfoHolderResultSet.hasNext()) + { + container.delete(mgmtMntrInfoHolderResultSet.next()); + container.commit(); + logger.debug(jobName + " mgmt and mntr information has been deleted."); + unregistered=true; + } + else + unregistered=false; + } + logger.trace("Exiting unregisterJobMgmtMntrInfo"); + return unregistered; } /** * ! * @see org.jmonks.batchserver.framework.repository.Repository#logStatistics(org.jmonks.batchserver.framework.JobStatistics) */ ! public boolean logStatistics(final JobStatistics statistics) { + logger.trace("Entering logStatistics"); + if(statistics==null) throw new IllegalArgumentException("Null statistic objects will not be saved in repository"); *************** *** 255,268 **** container.set(statistics); container.commit(); logged=true; } return logged; } /** ! * @see org.jmonks.batchserver.framework.Repository#getStatistics(String) */ ! public JobStatistics[] getStatistics(final String jobName) { if(jobName==null) throw new IllegalArgumentException("job name cannot be null for querying the job statistics."); --- 356,374 ---- container.set(statistics); container.commit(); + logger.debug(statistics.getJobname() + " has been logged."); logged=true; } + logger.trace("Exiting logStatistics"); return logged; } /** ! * @see org.jmonks.batchserver.framework.repository.Repository#getStatistics(String) */ ! public JobStatistics[] getStatistics(String jobName) { + logger.trace("Entering getStatistics"); + logger.debug("getStatistics :: job name = " + jobName); + if(jobName==null) throw new IllegalArgumentException("job name cannot be null for querying the job statistics."); *************** *** 274,317 **** else { ! ObjectSet statisticsResultSet=container.query(new Predicate() ! { ! public boolean match(JobStatistics jobStatistics) ! { ! if(jobName.equals(jobStatistics.getJobname())) ! return true; ! else ! return false; ! } ! }); ! statistics=new JobStatistics[statisticsResultSet.size()]; for(int i=0;statisticsResultSet.hasNext();i++) statistics[i]=(JobStatistics)statisticsResultSet.next(); } return statistics; } /** ! * @see org.jmonks.batchserver.framework.Repository#saveController(org.jmonks.batchserver.framework.controller.JobController,String) */ ! public boolean saveController(String jobName, JobController controller) { ! return true; } /** ! * @see org.jmonks.batchserver.framework.Repository#loadController(String) */ public JobController loadController(String jobName) { ! return null; } /** ! * @see org.jmonks.batchserver.framework.Repository#releaseController(String) */ public boolean releaseController(String jobName) { ! return true; } --- 380,483 ---- else { ! ObjectSet statisticsResultSet=container.query(new Db4oJobStatisticsPredicate(jobName)); ! logger.debug("Number of statistics objects = " + statisticsResultSet.size()); statistics=new JobStatistics[statisticsResultSet.size()]; for(int i=0;statisticsResultSet.hasNext();i++) statistics[i]=(JobStatistics)statisticsResultSet.next(); } + logger.trace("Exiting getStatistics"); return statistics; } /** ! * @see org.jmonks.batchserver.framework.repository.Repository#saveController(String,org.jmonks.batchserver.framework.controller.JobController) */ ! public boolean saveController(String jobName, final JobController controller) { ! logger.trace("Entering saveController"); ! logger.debug("saveController :: job name = " + jobName + " controller = " + controller); ! if(jobName==null || controller==null) ! throw new IllegalArgumentException("job name and controller cannot be null to save the controller."); ! ! boolean saved=true; ! ! if(container==null) ! saved=false; ! else ! { ! ObjectSet jobControllerHolderResultSet=container.query(new Db4oJobControllerHolderPredicate(jobName)); ! ! while(jobControllerHolderResultSet.hasNext()) ! container.delete(jobControllerHolderResultSet.next()); ! container.commit(); ! ! container.set(new Db4oJobControllerHolder(jobName, controller)); ! container.commit(); ! logger.debug(jobName + " controller has been added to the repository."); ! saved=true; ! } ! logger.trace("Exiting saveController"); ! return saved; } /** ! * @see org.jmonks.batchserver.framework.repository.Repository#loadController(String) */ public JobController loadController(String jobName) { ! logger.trace("Entering loadController"); ! logger.debug(" loadController :: job name = " + jobName); ! ! if(jobName==null) ! throw new IllegalArgumentException("jobName cannot be null to load the controller."); ! ! JobController controller=null; ! if(container==null) ! controller=null; ! else ! { ! ObjectSet jobControllerHolderResultSet=container.query(new Db4oJobControllerHolderPredicate(jobName)); ! if(jobControllerHolderResultSet.hasNext()) ! { ! controller=((Db4oJobControllerHolder)jobControllerHolderResultSet.next()).getJobController(); ! logger.debug(jobName + " controller found and being returned"); ! } ! else ! controller=null; ! } ! logger.trace("Exiting loadController"); ! return controller; } /** ! * @see org.jmonks.batchserver.framework.repository.Repository#releaseController(String) */ public boolean releaseController(String jobName) { ! logger.trace("Entering releaseController"); ! logger.debug(" releaseController :: job name = " + jobName); ! ! if(jobName==null) ! throw new IllegalArgumentException("jobName cannot be null to release the controller."); ! ! boolean released=false; ! ! if(container==null) ! released=false; ! else ! { ! ObjectSet jobControllerHolderResultSet=container.query(new Db4oJobControllerHolderPredicate(jobName)); ! if(jobControllerHolderResultSet.hasNext()) ! { ! container.delete(jobControllerHolderResultSet.next()); ! container.commit(); ! logger.debug(jobName + " controller has been released"); ! released=true; ! } ! else ! released=false; ! } ! logger.trace("Exiting releaseController"); ! return released; } --- NEW FILE: Db4oJobMgmtMntrInfoHolder.java --- /* * Db4oJobMgmtMntrInfoHolder.java * * Created on March 15, 2006, 10:54 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batchserver.framework.repository.db4o; /** * Db4oJobMgmtMntrInfoHolder holds the job mgmt&mntr information and job name. * This will be used only by Db4oRepository. * * @author Suresh Pragada * @version 1.0 * @since 1.0 */ class Db4oJobMgmtMntrInfoHolder { /** * Holds the job name */ private String jobName=null; /** * Holds the mgmtMntrInfo object */ private Object mgmtMntrInfo=null; /** * Constructor takes job name and mgmt & mntr info and constructs the object. */ Db4oJobMgmtMntrInfoHolder(String jobName,Object mgmtMntrInfo) { this.jobName=jobName; this.mgmtMntrInfo=mgmtMntrInfo; } /** * Returns the jobName. */ public String getJobName() { return this.jobName; } /** * Returns the mgmt & mntr object. */ public Object getMgmtMntrInfo() { return this.mgmtMntrInfo; } /** * <p> * Returns the string representation of Db4oJobMgmtMntrInfoHolder class in the format * <br> {Db4oJobMgmtMntrInfoHolder [jobName = value] [mgmtMntrInfo = value]} * </p> * * @return Returns the string representation of Db4oJobMgmtMntrInfoHolder. */ public String toString() { StringBuffer stringValue=new StringBuffer("{Db4oJobMgmtMntrInfoHolder "); stringValue.append("[jobName = " + this.jobName + "]"); stringValue.append("[mgmtMntrInfo = " + this.mgmtMntrInfo + "]"); stringValue.append("}"); return stringValue.toString(); } } --- NEW FILE: Db4oJobMgmtMntrInfoHolderPredicate.java --- /* * Db4oJobMgmtMntrInfoHolderPredicate.java * * Created on March 16, 2006, 7:23 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batchserver.framework.repository.db4o; import com.db4o.query.Predicate; /** * Db4oJobMgmtMntrInfoHolderPredicate used to find the Db4oJobMgmtMntrInfoHolder * objects in Db4o database using native query. * * @author Suresh Pragada * @version 1.0 * @since 1.0 */ class Db4oJobMgmtMntrInfoHolderPredicate extends Predicate { /** * job name to find the job mgmt and mntr info objects for. */ private String jobName=null; /** * Creates a new instance of Db4oJobMgmtMntrInfoHolderPredicate with the job name. */ Db4oJobMgmtMntrInfoHolderPredicate(String jobName) { if(jobName==null) throw new IllegalArgumentException("job name cannot be null"); this.jobName=jobName; } /** * Method to run the the native query. This receives the Db4oJobMgmtMntrInfoHolder * objects and look for the job name this predicate initialized with. */ public boolean match(Db4oJobMgmtMntrInfoHolder holder) { if(jobName.equals(holder.getJobName())) return true; else return false; } } --- NEW FILE: Db4oJobStatisticsPredicate.java --- /* * Db4oJobStatisticsPredicate.java * * Created on March 16, 2006, 7:41 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batchserver.framework.repository.db4o; import com.db4o.query.Predicate; import org.jmonks.batchserver.framework.JobStatistics; /** * Db4oJobStatisticsPredicate used to find the JobStatistics * objects in Db4o database using native query. * * @author Suresh Pragada * @version 1.0 * @since 1.0 */ class Db4oJobStatisticsPredicate extends Predicate { /** * job name to find the job statistics objects for. */ private String jobName=null; /** * Creates a new instance of Db4oJobStatisticsPredicate with the given job name. */ Db4oJobStatisticsPredicate(String jobName) { if(jobName==null) throw new IllegalArgumentException("job name cannot be null"); this.jobName=jobName; } /** * Method to run the the native query. This receives the JobStatistics * objects and look for the job name this predicate initialized with. */ public boolean match(JobStatistics statistics) { if(jobName.equals(statistics.getJobname())) return true; else return false; } } --- NEW FILE: Db4oJobDataTransferHolder.java --- /* * Db4oJobDataTransferHolder.java * * Created on March 15, 2006, 10:39 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batchserver.framework.repository.db4o; /** * <p> * Db4oJobDataTransferHolder holds the data being transferred between the jobs. * This will not have any functionality except holding the data and * this will be used to store in DB4O database. * </p> * @author Suresh Pragada * @version 1.0 * @since 1.0 */ class Db4oJobDataTransferHolder { /** * Holds the identifier by which jobs will communicated. */ private String dataIdentifier; /** * Source job name. */ private String sourceJobName; /** * Target job name, where data to be sent. */ private String targetJobName; /** * Data object. */ private Object data; /** * Constructor with all the argument to make this class immutable, * once it got created. */ Db4oJobDataTransferHolder(String dataIdentifer,String sourceJobName,String targetJobName,Object data) { this.dataIdentifier=dataIdentifer; this.sourceJobName=sourceJobName; this.targetJobName=targetJobName; this.data=data; } /** * Returns the data identifier. */ public String getDataIdentifier() { return this.dataIdentifier; } /** * Returns the source job name. */ public String getSourceJobName() { return this.sourceJobName; } /** * Returns the target job name. */ public String getTargetJobName() { return this.targetJobName; } /** * Returns the job data. */ public Object getData() { return this.data; } /** * <p> * Returns the string representation of Db4oJobDataTransferHolder class in the format * <br> {Db4oJobDataTransferHolder [dataIdentifier = value] [sourceJN = value] * [targetJN = value] [data = value]} * </p> * * @return Returns the string representation of Db4oJobDataTransferHolder. */ public String toString() { StringBuffer stringValue=new StringBuffer("{Db4oJobDataTransferHolder "); stringValue.append("[dataIdentifier = " + this.dataIdentifier + "]"); stringValue.append("[sourceJobName = " + this.sourceJobName + "]"); stringValue.append("[targetJobName = " + this.targetJobName + "]"); stringValue.append("[Data = " + this.data + "]"); stringValue.append("}"); return stringValue.toString(); } } |