|
From: <tr...@us...> - 2003-09-03 03:25:40
|
Update of /cvsroot/babeldoc/babeldoc/modules/j2ee/src/com/babeldoc/j2ee/journal
In directory sc8-pr-cvs1:/tmp/cvs-serv10506/j2ee/src/com/babeldoc/j2ee/journal
Modified Files:
EjbClientJournal.java EjbJournalBean.java
Log Message:
LARGE, EXTENSIVE UPDATE.
1. All journal classes are now IConfigurable
2. J2ee journal classes using IConfigurable and are consistent
3. Somewhat of a cleanup around the journal code.
Index: EjbClientJournal.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/j2ee/src/com/babeldoc/j2ee/journal/EjbClientJournal.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** EjbClientJournal.java 27 Aug 2003 03:32:32 -0000 1.2
--- EjbClientJournal.java 3 Sep 2003 03:25:31 -0000 1.3
***************
*** 70,76 ****
--- 70,82 ----
import com.babeldoc.core.pipeline.PipelineDocument;
import com.babeldoc.core.LogService;
+ import com.babeldoc.core.option.IConfigInfo;
+ import com.babeldoc.core.option.IConfigData;
+ import com.babeldoc.core.option.ConfigOption;
+ import com.babeldoc.core.option.IConfigOptionType;
import com.babeldoc.j2ee.ServiceLocator;
import java.rmi.RemoteException;
+ import java.util.Collection;
+ import java.util.ArrayList;
/**
***************
*** 86,105 ****
implements IJournal {
/** Bridged object */
private EjbJournalRemote journal;
/**
! * Constructor
*/
! public EjbClientJournal() {
! try {
! String journalName = EjbJournalHome.JNDI_NAME;
! EjbJournalHome home = (EjbJournalHome)ServiceLocator.getGlobal().getRemoteHome(journalName, EjbJournalHome.class);
! journal = home.create();
! } catch (Exception refx) {
! LogService.getInstance().logError("[EjbClientPipelineStageFactory]", refx);
}
}
/**
* Get an existing ticket from the string identifier.
--- 92,143 ----
implements IJournal {
+ /** jndi details */
+ public static final String EJB_NAME = "ejbName";
+ public static final String NAMING_URL = "namingUrl";
+ public static final String NAMING_PROVIDER = "namingProvider";
+
+ /** configuration information object */
+ private IConfigInfo info;
+
/** Bridged object */
private EjbJournalRemote journal;
/**
! * Set the options. This applies the configuration data
! * to the local set ONLY - the ejb pipeline factory is going to be
! * configured in the container!
! *
! * @params the options on the pipeline stage factory
*/
! public void setOptions(IConfigData data) {
! getInfo().applyConfigData(data);
! }
!
!
! public EjbJournalRemote getJournal() {
! if(journal==null) {
! try {
! String homeName = getInfo().getStrValue(EJB_NAME);
! String providerFactory = getInfo().getStrValue(NAMING_PROVIDER);
! String providerUrl = getInfo().getStrValue(NAMING_URL);
!
! ServiceLocator locator = null;
! if(providerUrl!=null&&providerFactory!=null) {
! locator = new ServiceLocator(providerUrl, providerFactory);
! } else {
! locator = ServiceLocator.getGlobal();
! }
!
! EjbJournalHome home = (EjbJournalHome)locator.
! getRemoteHome(homeName, EjbJournalHome.class);
! this.journal = home.create();
! } catch (Exception e) {
! LogService.getInstance().logError("", e);
! }
}
+ return journal;
}
+
/**
* Get an existing ticket from the string identifier.
***************
*** 111,115 ****
throws JournalException {
try {
! return journal.getTicket(identifier);
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
--- 149,153 ----
throws JournalException {
try {
! return getJournal().getTicket(identifier);
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
***************
*** 125,129 ****
throws JournalException {
try {
! return journal.newTicket();
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
--- 163,167 ----
throws JournalException {
try {
! return getJournal().newTicket();
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
***************
*** 142,146 ****
throws JournalException {
try {
! journal.logMessage(ticket, stage, message);
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
--- 180,184 ----
throws JournalException {
try {
! getJournal().logMessage(ticket, stage, message);
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
***************
*** 157,161 ****
throws JournalException {
try {
! return journal.forkTicket(parentTicket);
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
--- 195,199 ----
throws JournalException {
try {
! return getJournal().forkTicket(parentTicket);
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
***************
*** 174,178 ****
throws JournalException {
try {
! journal.updateDocument(ticket, document, stage);
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
--- 212,216 ----
throws JournalException {
try {
! getJournal().updateDocument(ticket, document, stage);
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
***************
*** 190,194 ****
throws JournalException {
try {
! journal.updateStatus(ticket, status, stage);
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
--- 228,232 ----
throws JournalException {
try {
! getJournal().updateStatus(ticket, status, stage);
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
***************
*** 205,209 ****
throws JournalException {
try {
! journal.replayTicket(ticket, step);
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
--- 243,247 ----
throws JournalException {
try {
! getJournal().replayTicket(ticket, step);
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
***************
*** 222,226 ****
throws JournalException {
try {
! return journal.getTickets(jQuery);
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
--- 260,264 ----
throws JournalException {
try {
! return getJournal().getTickets(jQuery);
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
***************
*** 236,240 ****
throws JournalException {
try {
! return journal.dummyTicket();
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
--- 274,278 ----
throws JournalException {
try {
! return getJournal().dummyTicket();
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
***************
*** 251,255 ****
throws JournalException {
try {
! return journal.getAllTicketSteps(ticket);
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
--- 289,293 ----
throws JournalException {
try {
! return getJournal().getAllTicketSteps(ticket);
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
***************
*** 268,272 ****
throws JournalException {
try {
! return journal.getDocumentAtTicketStep(ticket, step);
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
--- 306,310 ----
throws JournalException {
try {
! return getJournal().getDocumentAtTicketStep(ticket, step);
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
***************
*** 283,290 ****
throws JournalException {
try {
! return journal.getAllChildTickets(parent);
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
}
}
}
--- 321,379 ----
throws JournalException {
try {
! return getJournal().getAllChildTickets(parent);
} catch (RemoteException remotex) {
throw new JournalException("", remotex);
}
+ }
+
+ /**
+ * Get the configuration iformation for this class
+ *
+ * @return IConfigInfo object
+ */
+ public IConfigInfo getInfo() {
+ if(info==null) {
+ info = new JournalConfigInfo() {
+ /**
+ * This method returns type specific options
+ *
+ * @return comments
+ */
+ public Collection getTypeSpecificOptions() {
+ Collection options = new ArrayList();
+
+ options.add(new ConfigOption(EJB_NAME,
+ IConfigOptionType.STRING, EjbJournalHome.JNDI_NAME, false,
+ "The name of the ejb jounal to connect to. If not provided, then the name on the HomeInterface will be used instead."));
+ options.add(new ConfigOption(NAMING_PROVIDER,
+ IConfigOptionType.STRING, null, false,
+ "The class name of the naming provider to use instead of the the default"));
+ options.add(new ConfigOption(NAMING_URL,
+ IConfigOptionType.STRING, null, false,
+ "The url of the naming system to get the to the naming provider"));
+
+ return options;
+ }
+
+ /**
+ * Return description of this worker
+ *
+ * @return description
+ */
+ public String getDescription() {
+ return "Local proxy to the ejb journal";
+ }
+
+ /**
+ * return the name
+ *
+ * @return
+ */
+ public String getName() {
+ return "EjbClientJournal";
+ }
+ };
+ }
+ return null;
}
}
Index: EjbJournalBean.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/j2ee/src/com/babeldoc/j2ee/journal/EjbJournalBean.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** EjbJournalBean.java 27 Aug 2003 03:32:32 -0000 1.2
--- EjbJournalBean.java 3 Sep 2003 03:25:31 -0000 1.3
***************
*** 74,77 ****
--- 74,84 ----
import com.babeldoc.core.journal.query.JournalQuery;
import com.babeldoc.core.pipeline.PipelineDocument;
+ import com.babeldoc.core.option.IConfigInfo;
+ import com.babeldoc.core.option.ConfigOption;
+ import com.babeldoc.core.service.ServiceException;
+ import com.babeldoc.core.LogService;
+
+ import java.util.Collection;
+ import java.util.ArrayList;
/**
***************
*** 96,107 ****
implements IJournal {
! /** Configuration Constants */
! public static final String CONFIG_FILENAME = "journal/ejb/config";
! public static final String JOURNAL_CLASS = "journalClassname";
/**
! * Implementing class
*/
! IJournal journal;
/**
--- 103,132 ----
implements IJournal {
! /** Name of the journal type that actually does the work for this ejb journal */
! public static final String DELEGATED_JOURNAL = "DelegatedJournal";
!
! /** Manage this ejb journals configuration information object */
! private IConfigInfo info;
!
! /** Delegated class */
! private IJournal journal;
!
/**
! * Get the delegated journal - create if necessary.
! *
! * @return
*/
! public IJournal getJournal() {
! if(journal==null) {
! String journalName = getInfo().getStrValue(DELEGATED_JOURNAL);
! try {
! journal = (IJournal)JournalType.getJournalType(journalName).getTypeInstance();
! } catch (ServiceException e) {
! LogService.getInstance().logError(e);
! }
! }
! return journal;
! }
/**
***************
*** 114,118 ****
public IJournalTicket getTicket(String identifier)
throws JournalException {
! return journal.getTicket(identifier);
}
--- 139,143 ----
public IJournalTicket getTicket(String identifier)
throws JournalException {
! return getJournal().getTicket(identifier);
}
***************
*** 126,130 ****
public IJournalTicket dummyTicket()
throws JournalException {
! return journal.dummyTicket();
}
--- 151,155 ----
public IJournalTicket dummyTicket()
throws JournalException {
! return getJournal().dummyTicket();
}
***************
*** 138,142 ****
public IJournalTicket newTicket()
throws JournalException {
! return journal.newTicket();
}
--- 163,167 ----
public IJournalTicket newTicket()
throws JournalException {
! return getJournal().newTicket();
}
***************
*** 161,165 ****
public IJournalTicket forkTicket(IJournalTicket parentTicket)
throws JournalException {
! return journal.forkTicket(parentTicket);
}
--- 186,190 ----
public IJournalTicket forkTicket(IJournalTicket parentTicket)
throws JournalException {
! return getJournal().forkTicket(parentTicket);
}
***************
*** 175,179 ****
String stage)
throws JournalException {
! journal.updateDocument(ticket, document, stage);
}
--- 200,204 ----
String stage)
throws JournalException {
! getJournal().updateDocument(ticket, document, stage);
}
***************
*** 189,193 ****
String stage)
throws JournalException {
! journal.updateStatus(ticket, status, stage);
}
--- 214,218 ----
String stage)
throws JournalException {
! getJournal().updateStatus(ticket, status, stage);
}
***************
*** 201,205 ****
public void replayTicket(IJournalTicket ticket, int step)
throws JournalException {
! journal.replayTicket(ticket, step);
}
--- 226,230 ----
public void replayTicket(IJournalTicket ticket, int step)
throws JournalException {
! getJournal().replayTicket(ticket, step);
}
***************
*** 214,218 ****
public QueryTicket[] getTickets(JournalQuery jQuery)
throws JournalException {
! return journal.getTickets(jQuery);
}
--- 239,243 ----
public QueryTicket[] getTickets(JournalQuery jQuery)
throws JournalException {
! return getJournal().getTickets(jQuery);
}
***************
*** 227,231 ****
public QueryTicket [] getAllTicketSteps(IJournalTicket ticket)
throws JournalException {
! return journal.getAllTicketSteps(ticket);
}
--- 252,256 ----
public QueryTicket [] getAllTicketSteps(IJournalTicket ticket)
throws JournalException {
! return getJournal().getAllTicketSteps(ticket);
}
***************
*** 241,245 ****
public PipelineDocument getDocumentAtTicketStep(IJournalTicket ticket, int step )
throws JournalException {
! return journal.getDocumentAtTicketStep(ticket, step);
}
--- 266,270 ----
public PipelineDocument getDocumentAtTicketStep(IJournalTicket ticket, int step )
throws JournalException {
! return getJournal().getDocumentAtTicketStep(ticket, step);
}
***************
*** 254,281 ****
public IJournalTicket[] getAllChildTickets(IJournalTicket parent)
throws JournalException {
! return journal.getAllChildTickets(parent);
}
/**
! * Not implemented - should be overridden if needed
*
* @ejb:interface-method view="both"
*/
! public void ejbCreate() throws CreateException {
! try {
! IConfig config = ConfigService.getInstance().
! getConfig(CONFIG_FILENAME);
! String journalClass = config.getString(JOURNAL_CLASS);
! journal = (IJournal)(Class.forName(journalClass).newInstance());
! }
! catch(ClassNotFoundException classx) {
! throw new CreateException(classx.toString());
! }
! catch(InstantiationException instantx) {
! throw new CreateException(instantx.toString());
! }
! catch(IllegalAccessException accessx) {
! throw new CreateException(accessx.toString());
}
}
}
--- 279,341 ----
public IJournalTicket[] getAllChildTickets(IJournalTicket parent)
throws JournalException {
! return getJournal().getAllChildTickets(parent);
}
/**
! * Get the configuration information from the delegated object not from
! * this object.
*
* @ejb:interface-method view="both"
*/
! public IConfigInfo getDelegatedInfo() {
! return getJournal().getInfo();
! }
!
! /**
! * Get the configuration iformation for this class
! *
! * @return IConfigInfo object
! *
! * @ejb:interface-method view="both"
! */
! public IConfigInfo getInfo() {
! if(info==null) {
! info = new JournalConfigInfo() {
! /**
! * This method returns type specific options
! *
! * @return comments
! */
! public Collection getTypeSpecificOptions() {
! Collection options = new ArrayList();
!
! options.add(new ConfigOption(DELEGATED_JOURNAL, JOURNAL_TYPE,
! null, true, "The journal type of the delegated journal - this journal implmentation actually does the work."));
!
! return options;
! }
!
! /**
! * Return description of this worker
! *
! * @return description
! */
! public String getDescription() {
! return "Ejb Journal - intended for journals running inside j2ee containers.";
! }
!
! /**
! * return the name
! *
! * @return
! */
! public String getName() {
! return "EjbJournal";
! }
!
! };
}
+ return null;
}
}
+
|