/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
package org.apache.stonehenge.stocktrader.services;
import java.io.IOException;
import java.io.InputStream;
import java.rmi.RemoteException;
import java.util.Properties;
import org.apache.axis2.context.MessageContext;
/*import org.apache.stonehenge.stocktrader.config.xsd.BSConfigRequest;
import org.apache.stonehenge.stocktrader.config.xsd.BSConfigRequestE;
import org.apache.stonehenge.stocktrader.config.xsd.BSConfigResponse;
import org.apache.stonehenge.stocktrader.config.xsd.BSConfigResponseE;*/
import org.apache.stonehenge.stocktrader.util.StockTraderUtility;
import org.apache.stonehenge.stocktrader.config.ConfigServiceStub;
import org.apache.stonehenge.stocktrader.config.trade_configservicedatacontract.*;
import org.apache.stonehenge.stocktrader.config.trade.*;
public class TradeConfigServiceClient {
private static final String SERVICE_URL = "org.apache.stonehenge.stocktrader.TradeConfigServiceClient.url";
private static TradeConfigServiceClient self = null;
private Properties prop = new Properties();
public static TradeConfigServiceClient getInstance() throws IOException {
if (self == null) {
self = new TradeConfigServiceClient();
}
return self;
}
private TradeConfigServiceClient() throws IOException {
super();
// CHECKME .. there might be a better of doing this
ClassLoader cl = MessageContext.getCurrentMessageContext().getAxisService().getClassLoader();
InputStream is = cl.getResourceAsStream(StockTraderUtility.TRADE_ORDER_SERVICE_PROPERTY_FILE);
prop.load(is);
}
public TradeOrderConfig getTradeOrderConfig() throws RemoteException {
/*ConfigServiceStub stub = new ConfigServiceStub(prop.getProperty(SERVICE_URL));
BSConfigRequestE configRequestE = new BSConfigRequestE();
BSConfigRequest param = new BSConfigRequest();
param.setBS("WSAS_BS");
configRequestE.setBSConfigRequest(param);
BSConfigResponseE configResponseE = stub.bSConfigRequest(configRequestE);
BSConfigResponse configResponse = configResponseE.getBSConfigResponse();
TradeOrderConfig config = new TradeOrderConfig();
config.setEndpointURL(configResponse.getOPS().toString());
config.setSecure(configResponse.getSec());*/
ConfigServiceStub stub = new ConfigServiceStub(prop.getProperty(SERVICE_URL));
BSConfigRequest configRequest = new BSConfigRequest();
configRequest.setBSName("WSAS_BS");
GetBSConfig bsConfig = new GetBSConfig();
bsConfig.setBs(configRequest);
GetBSConfigResponse configResponse = stub.getBSConfig(bsConfig);
TradeOrderConfig orderConfig = new TradeOrderConfig();
orderConfig.setEndpointURL(configResponse.getGetBSConfigResult().getOPS().toString());
orderConfig.setSecure(configResponse.getGetBSConfigResult().getSec());
return orderConfig;
}
}