001: /**
002: * $Id: PropertiesRemoteServiceStubManagerImpl.java,v 1.6 2005/06/14 11:06:31 ak118254 Exp $
003: * Copyright 2003 Sun Microsystems, Inc. All
004: * rights reserved. Use of this product is subject
005: * to license terms. Federal Acquisitions:
006: * Commercial Software -- Government Users
007: * Subject to Standard License Terms and
008: * Conditions.
009: *
010: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011: * are trademarks or registered trademarks of Sun Microsystems,
012: * Inc. in the United States and other countries.
013: */package com.sun.portal.wsrp.consumer.common.impl;
014:
015: import com.sun.portal.container.*;
016: import com.sun.portal.wsrp.common.stubs.*;
017: import java.net.*;
018: import javax.xml.rpc.Stub;
019: import javax.xml.rpc.Call;
020: import java.net.URL;
021: import javax.xml.rpc.Service;
022: import javax.xml.rpc.JAXRPCException;
023: import javax.xml.rpc.ServiceFactory;
024: import java.util.*;
025: import com.sun.portal.wsrp.consumer.common.RemoteServiceStubManager;
026:
027: import java.io.FileInputStream;
028: import java.io.IOException;
029:
030: public class PropertiesRemoteServiceStubManagerImpl implements
031: RemoteServiceStubManager {
032:
033: private Properties endpoints = new Properties();
034:
035: public PropertiesRemoteServiceStubManagerImpl() {
036: this ("/etc/opt/SUNWportal/wsrp/wsrpconsumerconfig.properties");
037: }
038:
039: public PropertiesRemoteServiceStubManagerImpl(String configFileName) {
040: try {
041: FileInputStream fis = new FileInputStream(configFileName);
042: endpoints.load(fis);
043: } catch (IOException ioe) {
044: throw new RuntimeException(
045: "could not load wsrp consumer configuration file");
046: }
047: }
048:
049: public WSRP_v1_Markup_PortType getMarkupPortType(String endpoint,
050: boolean isNew) {
051: Stub stub = (Stub) (new WSRPService_Impl().getWSRPBaseService());
052:
053: endpoint = getEndpoint(null, MARKUP_PORT_BINDING);
054: stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, endpoint);
055:
056: return (WSRP_v1_Markup_PortType) stub;
057: }
058:
059: public WSRP_v1_Registration_PortType getRegistrationPortType(
060: String endpoint) {
061: Stub stub = (Stub) (new WSRPService_Impl()
062: .getWSRPRegistrationService());
063:
064: endpoint = getEndpoint(null, REGISTRATION_PORT_BINDING);
065: stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, endpoint);
066:
067: return (WSRP_v1_Registration_PortType) stub;
068: }
069:
070: public WSRP_v1_ServiceDescription_PortType getServiceDescriptionPortType(
071: String endpoint) {
072: Stub stub = (Stub) (new WSRPService_Impl()
073: .getWSRPServiceDescriptionService());
074:
075: endpoint = getEndpoint(null, SERVICE_DESCRIPTION_PORT_BINDING);
076: stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, endpoint);
077:
078: return (WSRP_v1_ServiceDescription_PortType) stub;
079: }
080:
081: public WSRP_v1_PortletManagement_PortType getPortletManagementPortType(
082: String endpoint) {
083: Stub stub = (Stub) (new WSRPService_Impl()
084: .getWSRPPortletManagementService());
085:
086: endpoint = getEndpoint(null, PORTLET_MANAGEMENT_PORT_BINDING);
087: stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, endpoint);
088:
089: return (WSRP_v1_PortletManagement_PortType) stub;
090: }
091:
092: public String getEndpoint(URL producerWsdl, String portBinding) {
093:
094: String endpoint = null;
095:
096: if (portBinding.equals(MARKUP_PORT_BINDING)) {
097: endpoint = endpoints.getProperty("markupEndpoint");
098: } else if (portBinding.equals(SERVICE_DESCRIPTION_PORT_BINDING)) {
099: endpoint = endpoints
100: .getProperty("servicedescriptionEndpoint");
101: } else if (portBinding.equals(REGISTRATION_PORT_BINDING)) {
102: endpoint = endpoints.getProperty("registrationEndpoint");
103: } else if (portBinding.equals(PORTLET_MANAGEMENT_PORT_BINDING)) {
104: endpoint = endpoints
105: .getProperty("portletmanagementEndpoint");
106: }
107:
108: return endpoint;
109: }
110: }
|