/* * Copyright 2006 - 2012 Hannes Holtzhausen * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * $Id: ProductServiceWSClientImpl.java,v 1.1 2009/05/12 08:26:36 hannes Exp $ * * Description: * */ package app.services; import java.util.*; import app.beans.*; import toolbox.allegato.*; import toolbox.services.*; import org.apache.cxf.frontend.ClientProxyFactoryBean; import org.apache.cxf.aegis.databinding.AegisDatabinding; /** * Web Service client implementation of the ProductService interface. * * @author Hannes Holtzhausen */ public class ProductServiceWSClientImpl extends BaseService implements ProductService { /** * Default constructor. */ public ProductServiceWSClientImpl() { } /** * Obtain a reference to the web service implementation through the * CXF ClientProxyFactoryBean. * * @param name The name of the service. * @param confHome The path to the configuration home directory. * @param env ServiceEnvironment of this service. * @param xmlProps XML configuration properties. * * @throws ServiceException if the service cannot be created. */ public void create(String name, String confHome, ServiceEnvironment env, XMLProperties xmlProps) throws ServiceException { super.create(name,confHome,env,xmlProps); ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); factory.setServiceClass(ProductService.class); factory.setAddress(getProperty("service.address")); factory.getServiceFactory().setDataBinding(new AegisDatabinding()); m_client = (ProductService)factory.create(); } /** * Add the product information contained in the given Product. * * @param product Product containing product information. * * @throws ProductException if the information cannot be committed. */ public void addProduct(Product product) throws ProductException { m_client.addProduct(product); } /** * Add the product type information contained in the given ProductType. * * @param type ProductType containing type information. * * @throws ProductException if the information cannot be committed. */ public void addProductType(ProductType type) throws ProductException { m_client.addProductType(type); } /** * Add the vendor information contained in the given Vendor. * * @param vendor Vendor containing information. * * @throws ProductException if the information cannot be committed. */ public void addVendor(Vendor vendor) throws ProductException { m_client.addVendor(vendor); } /** * Update the product information contained in the given Product. * * @param product Product containing product information. * * @throws ProductException if the information cannot be committed. */ public void updateProduct(Product product) throws ProductException { m_client.updateProduct(product); } /** * Update the product type information contained in the given ProductType. * * @param type ProductType containing type information. * * @throws ProductException if the information cannot be committed. */ public void updateProductType(ProductType type) throws ProductException { m_client.updateProductType(type); } /** * Update the vendor information contained in the given Vendor. * * @param vendor Vendor containing vendor information. * * @throws ProductException if the information cannot be committed. */ public void updateVendor(Vendor vendor) throws ProductException { m_client.updateVendor(vendor); } /** * Return product information as a Product instance using the given id. * * @param id Product identifier. * * @return Product instance containing product information. */ public Product getProduct(Integer id) throws ProductException { return m_client.getProduct(id); } /** * Return product type information as a ProductType instance using the given * id. * * @param id ProductType identifier. * * @return ProductType instance containing type information. */ public ProductType getProductType(Integer id) throws ProductException { return m_client.getProductType(id); } /** * Return vendor information as a Vendor instance using the given id. * * @param id Vendor identifier. * * @return Vendor instance containing vendor information. */ public Vendor getVendor(Integer id) throws ProductException { return m_client.getVendor(id); } /** * Remove the product with the given identifier. * * @param id Product identifier. * * @throws ProductException if the product cannot be removed. */ public void removeProduct(Integer id) throws ProductException { m_client.removeProduct(id); } /** * Remove the product type with the given identifier. * * @param id ProductType identifier. * * @throws ProductException if the product type cannot be removed. */ public void removeProductType(Integer id) throws ProductException { m_client.removeProductType(id); } /** * Remove the vendor with the given identifier. * * @param id Vendor identifier. * * @throws ProductException if the vendor cannot be removed. */ public void removeVendor(Integer id) throws ProductException { m_client.removeVendor(id); } /** * Return all products. * * @return List containing Product instances. * * @throws ProductException if the product information cannot be retrieved. */ public List getProducts() throws ProductException { return m_client.getProducts(); } /** * Return all product types. * * @return List containing ProductType instances. * * @throws ProductException if the product type information cannot be * retrieved. */ public List getProductTypes() throws ProductException { return m_client.getProductTypes(); } /** * Return all vendors. * * @return List containing Vendor instances. * * @throws ProductException if the vendor information cannot be retrieved. */ public List getVendors() throws ProductException { return m_client.getVendors(); } //members private ProductService m_client = null; }