alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*******************************************************************************
 * Copyright (c) 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package model;

import java.util.Calendar;

import javax.xml.rpc.ServiceException;

import org.eclipse.ui.examples.rcp.adventure.Catalog;

import dk.jaoo.abwsclient.catalog.CatalogIntf;
import dk.jaoo.abwsclient.catalog.CatalogServiceLocator;

/**
 * A web service implementation of the catalog service. This does not cache the
 * result.
 */
public class WebCatalogService implements ICatalogService {

	/**
	 * Returns the Catalog service interface at the server address specified in
	 * the preferences.
	 * 
	 * @return the purchase order service interface
	 * @throws ServiceException
	 */
	private CatalogIntf getCatalogIntf() throws ServiceException {
		java.net.URL endpoint;
		try {
			String serverAddress = AdventureBuilderModel.getDefault()
					.getServerAddress();
			endpoint = new java.net.URL(serverAddress
					+ "/catalogservice/CatalogService");
		} catch (java.net.MalformedURLException e) {
			throw new javax.xml.rpc.ServiceException(e);
		}
		return new CatalogServiceLocator().getCatalogIntfPort(endpoint);
	}

	public Catalog getCatalog() {
		try {
			long t = System.currentTimeMillis();
			dk.jaoo.abwsclient.catalog.Catalog webCatalog = getCatalogIntf()
					.getCatalog();
			t = System.currentTimeMillis() - t;
			System.out.println("WebCatalogService: time to getCatalog: " + t);
			Catalog catalog = CatalogUtil.convertCatalog(webCatalog);
			catalog.setTimeToRead(t);
			catalog.setSource("Web Service");
			return catalog;
		} catch (Exception e) {
			// TODO: improve error handling
			e.printStackTrace();
			return null;
		}
	}

	public Calendar getLastModified() {
		try {
			long t = System.currentTimeMillis();
			Calendar lastModified = getCatalogIntf().getLastModified();
			t = System.currentTimeMillis() - t;
			System.out.println("WebCatalogService: time to getLastModified: " + t);
			return lastModified;
		} catch (Exception e) {
			// TODO: improve error handling
			e.printStackTrace();
			return null;
		}
	}

}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.