1+ /**
2+ * The MIT License
3+ * Copyright (c) 2014-2016 Ilkka Seppälä
4+ *
5+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6+ * of this software and associated documentation files (the "Software"), to deal
7+ * in the Software without restriction, including without limitation the rights
8+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+ * copies of the Software, and to permit persons to whom the Software is
10+ * furnished to do so, subject to the following conditions:
11+ *
12+ * The above copyright notice and this permission notice shall be included in
13+ * all copies or substantial portions of the Software.
14+ *
15+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+ * THE SOFTWARE.
22+ */
123package com .iluwatar .ambassador ;
224
25+ /**
26+ *
27+ * The ambassador pattern creates a helper service that sends network requests on behalf of a
28+ * client. It is often used in cloud-based applications to offload features of a remote service.
29+ *
30+ * An ambassador service can be thought of as an out-of-process proxy that is co-located with
31+ * the client. Similar to the proxy design pattern, the ambassador service provides an interface
32+ * for another remote service. In addition to the interface, the ambassador provides extra
33+ * functionality and features, specifically offloaded common connectivity tasks. This usually
34+ * consists of monitoring, logging, routing, security etc. This is extremely useful in
35+ * legacy applications where the codebase is difficult to modify and allows for improvements
36+ * in the application's networking capabilities.
37+ *
38+ * In this example, we will the ({@link ServiceAmbassador}) class represents the ambassador while the
39+ * ({@link RemoteService}) class represents a remote application.
40+ *
41+ */
342public class App {
443
544 /**
@@ -9,11 +48,7 @@ public static void main(String[] args) {
948
1049 Client host1 = new Client ();
1150 Client host2 = new Client ();
12-
1351 host1 .useService (12 );
1452 host2 .useService (73 );
15-
16- host1 .useNewService (12 );
17- host2 .useNewService (73 );
1853 }
1954}
0 commit comments