首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

Juddiv3 公布 查询web services

2012-07-02 
Juddiv3 发布 查询web servicespackage juddiv3admin.juddiv3?import java.awt.Frameimport javax.swing

Juddiv3 发布 查询web services

package juddiv3admin.juddiv3;?import java.awt.Frame;import javax.swing.SwingWorker;import juddiv3admin.Juddiv3Admin;import juddiv3admin.gui.GUI;import juddiv3admin.gui.SwingWorkerCompletionWaiter;import org.apache.juddi.api_v3.*;import org.apache.juddi.v3.client.ClassUtil;import org.apache.juddi.v3.client.config.UDDIClientContainer;import org.apache.juddi.v3.client.transport.Transport;import org.apache.juddi.v3_service.JUDDIApiPortType;import org.uddi.api_v3.*;import org.uddi.v3_service.*;?public class Tools{    private static UDDISecurityPortType security = null;?    private static JUDDIApiPortType juddiApi = null;?    private static UDDIPublicationPortType publish = null;?    private static UDDIInquiryPortType inquiry = null;?    public Tools() throws Exception    {        String clazz = UDDIClientContainer.getUDDIClerkManager(null).getClientConfig().getUDDINode("default").getProxyTransport();        Class<?> transportClass = ClassUtil.forName(clazz, Transport.class);        if (transportClass != null)        {            Transport transport = (Transport) transportClass.getConstructor(String.class).newInstance("default");            security = transport.getUDDISecurityService();            juddiApi = transport.getJUDDIApiService();            publish = transport.getUDDIPublishService();            inquiry = transport.getUDDIInquiryService();        }?        publisherWorker = new PublisherWorker();        businessWorker = new BusinessWorker();        serviceWorker = new SerivceWorker();    }        public AuthToken currentAuthToken = null;?    PublisherWorker publisherWorker = null;?    BusinessWorker businessWorker = null;?    SerivceWorker serviceWorker = null;?    public AuthToken getAuthToken(String userID, String cred) throws Exception    {        GetAuthToken getAuthToken = new GetAuthToken();        getAuthToken.setUserID(userID);        getAuthToken.setCred(cred);        return security.getAuthToken(getAuthToken);    }?    public void discardAuthToken(AuthToken authToken) throws Exception    {        DiscardAuthToken dat = new DiscardAuthToken();        dat.setAuthInfo(authToken.getAuthInfo());        security.discardAuthToken(dat);    }?    public Object submitQuery(final Frame frame, final Object query) throws Exception    {        SwingWorker swingWorker = new SwingWorker()        {            @Override            protected Object doInBackground()            {                try                {                    //#####################                    //business                    if (query instanceof FindBusiness)                    {                        return businessWorker.findBusinessDetail((FindBusiness) query);                    }                    if (query instanceof SaveBusiness)                    {                        return businessWorker.saveBusiness((SaveBusiness) query);                    }                    if (query instanceof DeleteBusiness)                    {                        return businessWorker.deleteBusiness((DeleteBusiness) query);                    }                    //service                    if (query instanceof FindService)                    {                        return serviceWorker.findServiceDetail((FindService) query);                    }                    if (query instanceof SaveService)                    {                        return serviceWorker.saveService((SaveService) query);                    }                    if (query instanceof DeleteService)                    {                        return serviceWorker.deleteService((DeleteService) query);                    }                    //publisher                    if (query instanceof GetAllPublisherDetail)                    {                        return publisherWorker.findPublisherAll((GetAllPublisherDetail) query);                    }                    if (query instanceof SavePublisher)                    {                        return publisherWorker.savePublisher((SavePublisher) query);                    }                    if (query instanceof DeletePublisher)                    {                        publisherWorker.deletePublisher((DeletePublisher) query);                        return true;                    }                    //#####################                    return null;                } catch (Exception e)                {                    GUI.ShowError(frame, e);                    return null;                }            }        };        SwingWorkerCompletionWaiter.showJDialog(frame, true, swingWorker, "Submitting Query ...");        return swingWorker.get();    }?    // ------------------------ PublisherWorker ------------------------    public class PublisherWorker    {        public PublisherDetail findPublisherAll(GetAllPublisherDetail gapd) throws Exception        {            return juddiApi.getAllPublisherDetail(gapd);        }?        public PublisherDetail savePublisher(SavePublisher savePublisher) throws Exception        {            return juddiApi.savePublisher(savePublisher);        }?        public void deletePublisher(DeletePublisher deletePublisher) throws Exception        {            juddiApi.deletePublisher(deletePublisher);        }    }    // ------------------------ end of PublisherWorker ------------------------?    // ------------------------ BusinessWorker ------------------------    public class BusinessWorker    {        public BusinessDetail saveBusiness(SaveBusiness saveBusiness) throws Exception        {            return publish.saveBusiness(saveBusiness);        }?        public DispositionReport deleteBusiness(DeleteBusiness deleteBusiness) throws Exception        {            return publish.deleteBusiness(deleteBusiness);        }?        public BusinessList findBusiness(FindBusiness findBusiness) throws Exception        {            return inquiry.findBusiness(findBusiness);        }?        public BusinessDetail findBusinessDetail(FindBusiness findBusiness) throws Exception        {            return findBusinessDetail(findBusiness(findBusiness));        }?        public BusinessDetail findBusinessDetail(BusinessList businessList) throws Exception        {            if (businessList == null)            {                return null;            }            if (businessList.getBusinessInfos() == null)            {                return null;            }            GetBusinessDetail gbd = new GetBusinessDetail();            for (BusinessInfo businessInfo : businessList.getBusinessInfos().getBusinessInfo())            {                gbd.getBusinessKey().add(businessInfo.getBusinessKey());            }            return inquiry.getBusinessDetail(gbd);        }    }    // ------------------------ end of BusinessWorker ------------------------    // ------------------------ SerivceWorker ------------------------?    public class SerivceWorker    {        public DispositionReport deleteService(DeleteService deleteService) throws Exception        {            return publish.deleteService(deleteService);        }?        public ServiceDetail saveService(SaveService saveService) throws Exception        {            return publish.saveService(saveService);        }?        public ServiceList findService(FindService findService) throws Exception        {            return inquiry.findService(findService);        }?        public ServiceDetail findServiceDetail(ServiceList serviceList) throws Exception        {            if (serviceList == null)            {                return null;            }            if (serviceList.getServiceInfos() == null)            {                return null;            }            GetServiceDetail gsd = new GetServiceDetail();            for (ServiceInfo serviceInfo : serviceList.getServiceInfos().getServiceInfo())            {                gsd.getServiceKey().add(serviceInfo.getServiceKey());            }            return inquiry.getServiceDetail(gsd);        }?        public ServiceDetail findServiceDetail(FindService findService) throws Exception        {            return findServiceDetail(findService(findService));        }    }    // ------------------------ end of SerivceWorker ------------------------}
1 楼 endual 2011-08-07   http://www.codepaste.net/dijvwq

热点排行