|
From: <tr...@us...> - 2003-08-27 03:15:36
|
Update of /cvsroot/babeldoc/babeldoc/modules/j2ee/src/com/babeldoc/j2ee/pipeline In directory sc8-pr-cvs1:/tmp/cvs-serv27662/src/com/babeldoc/j2ee/pipeline Added Files: EjbClientPipelineStageFactory.java EjbPipelineStageFactoryBean.java Log Message: Re-adding of the J2ee module. THe most you can say about this is that it compiles. --- NEW FILE: EjbClientPipelineStageFactory.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/pipeline/EjbClientPipelineStageFactory.java,v 1.1 2003/08/27 03:15:30 triphop Exp $ * $DateTime$ * $Author: triphop $ * */ package com.babeldoc.j2ee.pipeline; import com.babeldoc.core.pipeline.*; import com.babeldoc.core.LogService; import com.babeldoc.core.Named; import com.babeldoc.core.journal.IJournalTicket; import com.babeldoc.core.option.IConfigData; import com.babeldoc.core.option.IConfigInfo; import com.babeldoc.core.option.ConfigOption; import com.babeldoc.core.option.IConfigOptionType; import com.babeldoc.j2ee.pipeline.EjbPipelineStageFactoryRemote; import com.babeldoc.j2ee.pipeline.EjbPipelineStageFactoryHome; import com.babeldoc.j2ee.ServiceLocator; import java.rmi.RemoteException; import java.util.Collection; import java.util.ArrayList; /** * This is the client to ejb pipeline stage factory. This is accessed * as a stub to the ejb pipeline stage factory. The order of events is: * * <ol> * <li> PipelineFactory creates this object * <li> It sets the name of the object * <li> It sets the configuration data on the object * <li> Caches it prior to use. * </ol> * This means that we have a completely configured pipeline prior to use. The * method getEjbFactory relies on all the configuration information being correct. * */ public class EjbClientPipelineStageFactory extends Named implements IPipelineStageFactory { /** jndi name of the remote object */ public static final String EJB_NAME = "ejbName"; public static final String NAMING_URL = "namingUrl"; public static final String NAMING_PROVIDER = "namingProvider"; /** EJB Proxy object */ private EjbPipelineStageFactoryRemote ejbFactory; /** configuration information object */ private IConfigInfo info; /** * 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); } /** * Get all the pipieline stage connections between stages * * @param sourceStage stage or null for all source stages * @param sinkStage stage or null for all sink stages * * @return array of PipelineStageConnection * * @throws PipelineException */ public PipelineStageConnection[] getPipelineStageConnections( String sourceStage, String sinkStage) throws PipelineException { try { return getEjbFactory().getPipelineStageConnections(sourceStage, sinkStage); } catch (RemoteException e) { throw new PipelineException("", e); } } /** * The pipeline stage * * @return a reference to the pipeline stage */ public String[] getAllPipelineStageNames() throws PipelineException { try { return getEjbFactory().getAllPipelineStageNames(); } catch (RemoteException re) { throw new PipelineException("[EjbClientPipelineStageFactory]", re); } } /** * Get the resolver. * * @return a reference to the pipeline stage resolver */ public IPipelineStageResolver getResolver() { try { return getEjbFactory().getResolver(); } catch (RemoteException re) { } return null; } /** * Get the configuration options for the stage from the * ejb pipeline stage factory * * @param stageName stage name * * @return configuration object * * @throws PipelineException */ public IConfigData getConfig(String stageName) throws PipelineException { try { return getEjbFactory().getConfig(stageName); } catch (RemoteException e) { throw new PipelineException("", e); } } /** * Get the entry point into the pipelinestage * * @return the name of the main entry point into the pipeline stage. * * @throws PipelineException */ public String getEntryStageName() throws PipelineException { try { return getEjbFactory().getEntryStageName(); } catch (RemoteException e) { throw new PipelineException("", e); } } /** * Get the name of the next pipeline stage after this one * * @param stageName * * @return next stage name * * @throws PipelineException */ public String getNextPipelineStage(String stageName) throws PipelineException { try { return getEjbFactory().getNextPipelineStage(stageName); } catch (RemoteException e) { throw new PipelineException("", e); } } /** * Must this pipeline stage track its data object * * @param stageName * @return true - track the document */ public boolean isStageTracked(String stageName) throws PipelineException { try { return getEjbFactory().isStageTracked(stageName); } catch (RemoteException re) { throw new PipelineException("", re); } } /** * Process a message * * @param stageName the name of the stage to process this message * @param document the document to process * @param ticket associated with this transaction * @param results the results from the processing * * @throws PipelineException */ public void process(String stageName, PipelineDocument document, IJournalTicket ticket, Collection results) throws PipelineException { try { getEjbFactory().process(stageName, document, ticket, results); } catch (RemoteException re) { throw new PipelineException("", re); } } /** * Get the configuration iformation for this class * * @return IConfigInfo object */ public IConfigInfo getInfo() { if(info==null) { info = new PipelineStageFactoryInfo() { /** * This method returns type specific options * * @return comments */ public Collection getTypeSpecificOptions() { Collection options = new ArrayList(); options.add(new ConfigOption(EJB_NAME, IConfigOptionType.STRING, EjbPipelineStageFactoryHome.JNDI_NAME, false, "The name of the ejb pipeline stage factory 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 pipeline stage factory"; } /** * return the name * * @return */ public String getName() { return "ejbclient"; } }; } return info; } /** * return reference to the ejb pipeline stage factory. This establishes the * reference is none is set. If the provider factory and url is not null, then * use a specific instance of the ServiceLocator otherwise use the global * instance. * * @return */ public EjbPipelineStageFactoryRemote getEjbFactory() { if(ejbFactory==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(); } EjbPipelineStageFactoryHome home = (EjbPipelineStageFactoryHome)locator. getRemoteHome(homeName, EjbPipelineStageFactoryHome.class); this.ejbFactory = home.create(); } catch (Exception e) { LogService.getInstance().logError("", e); } } return ejbFactory; } } --- NEW FILE: EjbPipelineStageFactoryBean.java --- /* * $Header: /cvsroot/babeldoc/babeldoc/modules/j2ee/src/com/babeldoc/j2ee/pipeline/EjbPipelineStageFactoryBean.java,v 1.1 2003/08/27 03:15:30 triphop Exp $ * $DateTime: 2002/07/24 18:15:55 $ * * * babeldoc: universal document processor * Copyright (C) 2002 Bruce McDonald, Elogex Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package com.babeldoc.j2ee.pipeline; import com.babeldoc.j2ee.BaseSessionBean; import com.babeldoc.core.journal.IJournalTicket; import com.babeldoc.core.pipeline.*; import com.babeldoc.core.LogService; import com.babeldoc.core.option.IConfigData; import com.babeldoc.core.option.IConfigInfo; import com.babeldoc.core.option.ConfigOption; import java.util.Collection; import java.util.ArrayList; /** * The ejb pipelnie stage factory is an stateless session bean that allows babeldoc * pipelines to be running inside a j2ee application server. This provides all the * necessary interface methods. It delegates all the pipeline processing to an internal * delegate IPipelineStageFactory. This factory is one of the already defined factories. * * @ejb:bean name="EjbPipelineStageFactory" jndi-name="EjbPipelineStageFactory" 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" */ public class EjbPipelineStageFactoryBean extends BaseSessionBean implements IPipelineStageFactory { /** Name of the option for the delegated factory */ public static final String DELEGATED_FACTORY = "delegatedFactory"; /** keep reference to the configuration information object */ private IConfigInfo info; /** pipeline stage factory delegate that does the work */ private IPipelineStageFactory factory; /** * Get the Pipeline stage factory * * @pipeline stage factory */ public IPipelineStageFactory getFactory() { if(factory == null) { String factoryName = getInfo().getStrValue(DELEGATED_FACTORY); try { factory = PipelineFactoryFactory.getPipelineStageFactory(factoryName); } catch (PipelineException e) { LogService.getInstance().logError("[getPipelineStageFactory]", e); } } return factory; } /** * Get all the pipeline stage names in this factory * * @return array of names * * @throws PipelineException * * @ejb:interface-method view="both" */ public String[] getAllPipelineStageNames() throws PipelineException { return getFactory().getAllPipelineStageNames(); } /** * Get the resolver. * * @return a reference to the pipeline stage resolver * * @ejb:interface-method view="both" */ public IPipelineStageResolver getResolver() { return getFactory().getResolver(); } /** * Get the configuration options for the stage * * @param stageName stage name * * @return configuration object * * @throws PipelineException * * @ejb:interface-method view="both" */ public IConfigData getConfig(String stageName) throws PipelineException { return getFactory().getConfig(stageName); } /** * Get the entry point into the pipelinestage * * @return the name of the main entry point into the pipeline stage. * * @throws PipelineException * * @ejb:interface-method view="both" */ public String getEntryStageName() throws PipelineException { return getFactory().getEntryStageName(); } /** * Get the name of the next pipeline stage after this one * * @param stageName * * @return next stage name * * @throws PipelineException * * @ejb:interface-method view="both" */ public String getNextPipelineStage(String stageName) throws PipelineException { return getFactory().getNextPipelineStage(stageName); } /** * Set the options on this pipeline stage factory. This is generally the * point at which your custom pipeline factory steps in and looks through * the options. * * @param configData the configuration data object * * @throws PipelineException * * @ejb:interface-method view="both" */ public void setOptions(IConfigData configData) throws PipelineException { getFactory().setOptions(configData); } /** * Get all the pipieline stage connections between stages * * @param sourceStage stage or null for all source stages * @param sinkStage stage or null for all sink stages * * @return array of PipelineStageConnection * * @throws PipelineException * * @ejb:interface-method view="both" */ public PipelineStageConnection[] getPipelineStageConnections( String sourceStage, String sinkStage) throws PipelineException { return getFactory().getPipelineStageConnections(sourceStage, sinkStage); } /** * Must this pipeline stage track its data object * * @param stageName stage to determine tracking on * * @return true - track the document * * @throws PipelineException * * @ejb:interface-method view="both" */ public boolean isStageTracked(String stageName) throws PipelineException { return getFactory().isStageTracked(stageName); } /** * Process a message * * @param stageName the name of the stage to process this message * @param document the document to process * @param ticket associated with this transaction * @param results the results from the processing * * @throws PipelineException * * @ejb:interface-method view="both" */ public void process(String stageName, PipelineDocument document, IJournalTicket ticket, Collection results) throws PipelineException { getFactory().process(stageName, document, ticket, results); } /** * Set the name of the object * * @ejb:interface-method view="both" */ public void setName(String name) { getFactory().setName(name); } /** * Get the name of the object * * @return the name of the pipelinestage * * @ejb:interface-method view="both" */ public String getName() { return getFactory().getName(); } /** * @return delegated pipeline stage factories configuration information * * @ejb:interface-method view="both" */ public IConfigInfo getDelegatedInfo() { return getFactory().getInfo(); } /** * Get the configuration iformation for this class and not the delegated * pipeline stage configuration information * * @return IConfigInfo object * * @ejb:interface-method view="both" */ public IConfigInfo getInfo() { if(info==null) { info = new PipelineStageFactoryInfo() { /** * This method returns type specific options * * @return comments */ public Collection getTypeSpecificOptions() { Collection specific = new ArrayList(); specific.add(new ConfigOption(DELEGATED_FACTORY, PipelineStageFactoryInfo.PIPELINE_FACTORY_TYPE, null, true, "The name of the pipeline stage factory that will do the processing of the pipeline")); return specific; } /** * Return description of this worker * * @return description */ public String getDescription() { return "Pipeline stage factory running inside the ejb factory"; } /** * return the name * * @return */ public String getName() { return "ejb"; } }; } return info; } } |