|
From: <tr...@us...> - 2003-08-27 03:15:36
|
Update of /cvsroot/babeldoc/babeldoc/modules/j2ee/src/com/babeldoc/j2ee/journal In directory sc8-pr-cvs1:/tmp/cvs-serv27662/src/com/babeldoc/j2ee/journal Added Files: EjbClientJournal.java EjbJournalBean.java EjbJournalTest.java Log Message: Re-adding of the J2ee module. THe most you can say about this is that it compiles. --- NEW FILE: EjbClientJournal.java --- /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact ap...@ap.... * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * Portions of this software are based upon public domain software * originally written at the National Center for Supercomputing Applications, * University of Illinois, Urbana-Champaign. * ==================================================================== * * Babeldoc: The Universal Document Processor * * $Header: /cvsroot/babeldoc/babeldoc/modules/j2ee/src/com/babeldoc/j2ee/journal/EjbClientJournal.java,v 1.1 2003/08/27 03:15:30 triphop Exp $ * $DateTime$ * $Author: triphop $ * */ package com.babeldoc.j2ee.journal; import com.babeldoc.core.journal.*; import com.babeldoc.core.journal.query.*; import com.babeldoc.core.pipeline.PipelineDocument; import com.babeldoc.core.LogService; import com.babeldoc.j2ee.ServiceLocator; import java.rmi.RemoteException; /** * ImplEjbJournal - Brige to the EjbJournal from the client code. This code is NOT TESTED * Please do not complain if it breaks!!!!!!! * * TODO: making this work * * <p>Title: babel</p> * <p>Description: universal document processor</p> * <p>Copyright: Copyright (c) 2002</p> * @author bmcdonald * @version 1.0 */ public class EjbClientJournal 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. * @param identifier; * @return the created tracker ticket */ public IJournalTicket getTicket(String identifier) throws JournalException { try { return journal.getTicket(identifier); } catch (RemoteException remotex) { throw new JournalException("", remotex); } } /** * Get a ticket for tracking a document. * @return the created tracker ticket */ public IJournalTicket newTicket() throws JournalException { try { return journal.newTicket(); } catch (RemoteException remotex) { throw new JournalException("", remotex); } } /** * Log a message into the log file * * @param ticket * @param stage * @param message * @throws JournalException */ public void logMessage(IJournalTicket ticket, String stage, String message) throws JournalException { try { journal.logMessage(ticket, stage, message); } catch (RemoteException remotex) { throw new JournalException("", remotex); } } /** * Get a ticket for tracking a document from a parent ticket. * @param parentTicket the creating ticket * @return the created tracker ticket */ public IJournalTicket forkTicket(IJournalTicket parentTicket) throws JournalException { try { return journal.forkTicket(parentTicket); } catch (RemoteException remotex) { throw new JournalException("", remotex); } } /** * Update a document associated with this ticket * @param ticket - the ticket to replay * @param document the document to update * @param stage the pipeline stage resulting in this status change */ public void updateDocument(IJournalTicket ticket, PipelineDocument document, String stage) throws JournalException { try { journal.updateDocument(ticket, document, stage); } catch (RemoteException remotex) { throw new JournalException("", remotex); } } /** * Update the status of this ticket * @param ticket - the ticket for this status * @param status - the status of the ticket * @param stage the pipeline stage resulting in this status change */ public void updateStatus(IJournalTicket ticket, IJournalStatus status, String stage) throws JournalException { try { journal.updateStatus(ticket, status, stage); } catch (RemoteException remotex) { throw new JournalException("", remotex); } } /** * Replay this ticket from the step * @param ticket - the ticket to replay * @param step - the step to replay from */ public void replayTicket(IJournalTicket ticket, int step) throws JournalException { try { journal.replayTicket(ticket, step); } catch (RemoteException remotex) { throw new JournalException("", remotex); } } /** * get tickets between the specified dates. Return up to the maxreturned * number of results. * * @param jQuery * @return * @throws JournalException */ public QueryTicket[] getTickets(JournalQuery jQuery) throws JournalException { try { return journal.getTickets(jQuery); } catch (RemoteException remotex) { throw new JournalException("", remotex); } } /** * Get a ticket for tracking a document. * * @return the created tracker ticket */ public IJournalTicket dummyTicket() throws JournalException { try { return journal.dummyTicket(); } catch (RemoteException remotex) { throw new JournalException("", remotex); } } /** * getJournalForTicket. Get all the ticketsteps for the ticket. * * @param ticket number * @return array of querytickets */ public QueryTicket [] getAllTicketSteps(IJournalTicket ticket) throws JournalException { try { return journal.getAllTicketSteps(ticket); } catch (RemoteException remotex) { throw new JournalException("", remotex); } } /** * retrieve the document from the journal for this ticket, step. * @param ticket - the ticket to replay * @param step - the step to replay from * @return * @throws JournalException */ public PipelineDocument getDocumentAtTicketStep(IJournalTicket ticket, int step ) throws JournalException { try { return journal.getDocumentAtTicketStep(ticket, step); } catch (RemoteException remotex) { throw new JournalException("", remotex); } } /** * getChildrenTickets. Get all the tickets which are children of this ticket * * @param parent * @return array of child tickets. * * @ejb:interface-method view="remote" */ public IJournalTicket[] getAllChildTickets(IJournalTicket parent) throws JournalException { try { return journal.getAllChildTickets(parent); } catch (RemoteException remotex) { throw new JournalException("", remotex); } } } --- NEW FILE: EjbJournalBean.java --- /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact ap...@ap.... * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * Portions of this software are based upon public domain software * originally written at the National Center for Supercomputing Applications, * University of Illinois, Urbana-Champaign. * ==================================================================== * * Babeldoc: The Universal Document Processor * * $Header: /cvsroot/babeldoc/babeldoc/modules/j2ee/src/com/babeldoc/j2ee/journal/EjbJournalBean.java,v 1.1 2003/08/27 03:15:30 triphop Exp $ * $DateTime$ * $Author: triphop $ * */ package com.babeldoc.j2ee.journal; import javax.ejb.CreateException; import com.babeldoc.core.config.*; import com.babeldoc.j2ee.BaseSessionBean; import com.babeldoc.core.journal.*; import com.babeldoc.core.journal.query.QueryTicket; import com.babeldoc.core.journal.query.JournalQuery; import com.babeldoc.core.pipeline.PipelineDocument; /** * EJB Interface for the tracking subsystem. This is meant to provide * a means to track a document through the system as well as reprocessing * opportunities later on * * @ejb:bean name="EjbJournal" jndi-name="EjbJournal" type="Stateless" * @ejb:interface generate="local,remote" extends="javax.ejb.EJBObject" local-extends="javax.ejb.EJBLocalObject" * @ejb:home generate="local,remote" extends="javax.ejb.EJBHome" local-extends="javax.ejb.EJBLocalHome" * @ejb:transaction type="Required" * @ejb:resource-ref res-name="jdbc/babelPool" res-type="javax.sql.Datasource" res-auth="Container" * @ejb:util generate="physical" * * @jboss:resource-ref res-ref-name="jdbc/babelPool" resource-name="jdbc/babelPool" * */ public class EjbJournalBean extends BaseSessionBean implements IJournal { /** Configuration Constants */ public static final String CONFIG_FILENAME = "journal/ejb/config"; public static final String JOURNAL_CLASS = "journalClassname"; /** * Implementing class */ IJournal journal; /** * Get an existing ticket from the string identifier. * @param identifier; * @return the created tracker ticket * * @ejb:interface-method view="both" */ public IJournalTicket getTicket(String identifier) throws JournalException { return journal.getTicket(identifier); } /** * Get a ticket for tracking a document. * * @return the created tracker ticket * * @ejb:interface-method view="both" */ public IJournalTicket dummyTicket() throws JournalException { return journal.dummyTicket(); } /** * Get a ticket for tracking a document. * * @return the created tracker ticket * * @ejb:interface-method view="both" */ public IJournalTicket newTicket() throws JournalException { return journal.newTicket(); } /** * Log a message into the log file * @param stage the stage to log * @param message The message to log * * @ejb:interface-method view="both" */ public void logMessage(IJournalTicket ticket, String stage, String message) throws JournalException { } /** * Get a ticket for tracking a document from a parent ticket. * @param parentTicket the creating ticket * @return the created tracker ticket * * @ejb:interface-method view="both" */ public IJournalTicket forkTicket(IJournalTicket parentTicket) throws JournalException { return journal.forkTicket(parentTicket); } /** * Update a document associated with this ticket * @param ticket - the ticket to replay * @param document the document to update * @param stage the pipeline stage resulting in this status change * * @ejb:interface-method view="remote" */ public void updateDocument(IJournalTicket ticket, PipelineDocument document, String stage) throws JournalException { journal.updateDocument(ticket, document, stage); } /** * Update the status of this ticket * @param ticket - the ticket for this status * @param status - the status of the ticket * @param stage the pipeline stage resulting in this status change * * @ejb:interface-method view="both" */ public void updateStatus(IJournalTicket ticket, IJournalStatus status, String stage) throws JournalException { journal.updateStatus(ticket, status, stage); } /** * Replay this ticket from the step * @param ticket - the ticket to replay * @param step - the step to replay from * * @ejb:interface-method view="both" */ public void replayTicket(IJournalTicket ticket, int step) throws JournalException { journal.replayTicket(ticket, step); } /** * get tickets between the specified dates. Return up to the maxreturned * number of results. * * @param jQuery the number of tickets to query * * @ejb:interface-method view="both" */ public QueryTicket[] getTickets(JournalQuery jQuery) throws JournalException { return journal.getTickets(jQuery); } /** * getJournalForTicket. Get all the ticketsteps for the ticket. * * @param ticket number * @return array of querytickets * * @ejb:interface-method view="both" */ public QueryTicket [] getAllTicketSteps(IJournalTicket ticket) throws JournalException { return journal.getAllTicketSteps(ticket); } /** * retrieve the document from the journal for this ticket, step. * @param ticket - the ticket to replay * @param step - the step to replay from * @return * @throws JournalException * * @ejb:interface-method view="both" */ public PipelineDocument getDocumentAtTicketStep(IJournalTicket ticket, int step ) throws JournalException { return journal.getDocumentAtTicketStep(ticket, step); } /** * getChildrenTickets. Get all the tickets which are children of this ticket * * @param parent * @return array of child tickets. * * @ejb:interface-method view="both" */ 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()); } } } --- NEW FILE: EjbJournalTest.java --- /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact ap...@ap.... * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * Portions of this software are based upon public domain software * originally written at the National Center for Supercomputing Applications, * University of Illinois, Urbana-Champaign. * ==================================================================== * * Babeldoc: The Universal Document Processor * * $Header: /cvsroot/babeldoc/babeldoc/modules/j2ee/src/com/babeldoc/j2ee/journal/EjbJournalTest.java,v 1.1 2003/08/27 03:15:30 triphop Exp $ * $DateTime$ * $Author: triphop $ * */ package com.babeldoc.j2ee.journal; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import com.babeldoc.core.journal.IJournalTicket; import com.babeldoc.core.journal.IJournal; /** * Test the journal functionality. */ public class EjbJournalTest extends TestCase { IJournal journal; /** * Run all the test methods in this class. */ static public void main(String[] args) { junit.textui.TestRunner.run(suite()); } public EjbJournalTest(java.lang.String testName) { super(testName); } public static Test suite() { TestSuite suite = new TestSuite(EjbJournalTest.class); return suite; } protected void setUp() throws Exception { journal = new EjbClientJournal(); } protected void tearDown() throws Exception { } public void testGetTicket() throws Exception { for (int i = 0; i < 100; ++i) { IJournalTicket ticket = journal.newTicket(); } // System.out.println("Ticket: "+ticket); } } |