newswsmanager.java

来自「这个例子举例说明了一个简单的新闻 Portal。新闻内容是从数据源(这里称为 D」· Java 代码 · 共 97 行

JAVA
97
字号
/** * NewsWSManager acts as a publisher of a webservice * It reuses the model service component, get the relevant * messages in a pre-defined data access object and converts this * into a required format to publish it a a webservice. * This class doesn't contain any struts related references or any * servlet related references thus making this as loosely coupled. * Exceptions are caught and rethrown as SOAPExceptions. * * *//** * Change History: * Author               Date            Version   Details * Jerome Josephraj  28 October 2002    1.00.01   Created */package com.ddj.wsstruts.wsmanager.publisher;import com.ddj.wsstruts.ms.NewsMs;import com.ddj.wsstruts.valueobject.*;import com.ddj.wsstruts.constant.SystemConstants;import java.util.*;import java.util.Iterator;import javax.xml.soap.*;//Log4J statementsimport org.apache.log4j.Category;public class NewsWSManager {        /** Creates new NewsWSManager */    public NewsWSManager() {    }        //Log4J    // define a static category variable so that it references the    // category instance of the same name as this class.    static final Category category = Category.getInstance(NewsWSManager.class.getName());            /*     * This method is exposed as a webservice.     * It calls the relevant method in Model service, gets the result     * in a predefined Data Access Object and populates a String array     * with the obtained result.     *     * @return String[] object     */    public String[] getNewsContent() throws SOAPException {                try {                        if(category.isDebugEnabled()){                category.debug(SystemConstants.METHOD_START);            }                        NewsMs newsMs = new NewsMs();            NewsSearchResult newsSearchCOD = null;            NewsSearchResult newsSearchResultCOD = new NewsSearchResult();            Collection newsResult = null;            String[] newsResultArray = new String[50];            Iterator i = null;            int j = 1;                        //Create a Collection to get all news content            newsSearchCOD = new NewsSearchResult();            newsResult = newsMs.getNews(newsSearchResultCOD);            i = newsResult.iterator();                        //Get newsSearchCod from newsResult collection            //and get news content from each newsSearchCod            //and build a string of array            while(i.hasNext()) {                newsSearchResultCOD = (NewsSearchResult) i.next();                newsResultArray[j] = newsSearchResultCOD.getNewsContent();                j++;            }                        //return the array            return newsResultArray;                    }        catch(Exception e) {                        //Catch any eception and throw it as a SOAPException            e.printStackTrace();            SOAPException se = new SOAPException(e.getMessage());            throw se;        }                    }    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?