001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */package org.apache.cxf.systest.clustering;
019:
020: import java.util.HashMap;
021: import java.util.Map;
022: import java.util.concurrent.Future;
023: import java.util.logging.Logger;
024:
025: import javax.jws.WebService;
026: import javax.xml.ws.AsyncHandler;
027: import javax.xml.ws.Endpoint;
028: import javax.xml.ws.Response;
029:
030: import org.apache.cxf.greeter_control.Control;
031: import org.apache.cxf.greeter_control.Greeter;
032: import org.apache.cxf.greeter_control.types.FaultLocation;
033: import org.apache.cxf.greeter_control.types.StartGreeterResponse;
034: import org.apache.cxf.greeter_control.types.StopGreeterResponse;
035:
036: @WebService(serviceName="ControlService",portName="ControlPort",endpointInterface="org.apache.cxf.greeter_control.Control",targetNamespace="http://cxf.apache.org/greeter_control")
037: public class ControlImpl implements Control {
038:
039: private static final Logger LOG = Logger
040: .getLogger(ControlImpl.class.getName());
041:
042: private Map<String, Greeter> implementors;
043: private Map<String, Endpoint> endpoints;
044:
045: ControlImpl() {
046: implementors = new HashMap<String, Greeter>();
047: implementors.put(FailoverTest.REPLICA_A, new GreeterImplA());
048: implementors.put(FailoverTest.REPLICA_B, new GreeterImplB());
049: implementors.put(FailoverTest.REPLICA_C, new GreeterImplC());
050: implementors.put(FailoverTest.REPLICA_D, new GreeterImplD());
051: endpoints = new HashMap<String, Endpoint>();
052: }
053:
054: public boolean startGreeter(String address) {
055: endpoints.put(address, Endpoint.publish(address, implementors
056: .get(address)));
057: LOG.info("Published greeter endpoint on: " + address);
058: return true;
059: }
060:
061: public boolean stopGreeter(String address) {
062: Endpoint endpoint = endpoints.get(address);
063: if (null != endpoint) {
064: LOG.info("Stopping Greeter endpoint on: " + address);
065: endpoint.stop();
066: } else {
067: LOG.info("No endpoint active for: " + address);
068: }
069: endpoint = null;
070: return true;
071: }
072:
073: //--Irrelevant Boilerplate
074:
075: public void setFaultLocation(FaultLocation fl) {
076: // never called
077: }
078:
079: public Future<?> startGreeterAsync(String requestType,
080: AsyncHandler<StartGreeterResponse> asyncHandler) {
081: // never called
082: return null;
083: }
084:
085: public Response<StartGreeterResponse> startGreeterAsync(
086: String requestType) {
087: // never called
088: return null;
089: }
090:
091: public Response<StopGreeterResponse> stopGreeterAsync(
092: String requestType) {
093: // never called
094: return null;
095: }
096:
097: public Future<?> stopGreeterAsync(String requestType,
098: AsyncHandler<StopGreeterResponse> asyncHandler) {
099: // never called
100: return null;
101: }
102: }
|