// Path: examples/org.eclipse.ecf.examples.hello/src/org/eclipse/ecf/examples/hello/IHello.java
// public interface IHello {
// 
// 	/**
// 	 * Synchronously provide 'from' and 'message' Strings to service, and receive a
// 	 * String response.
// 	 *  
// 	 * @param from a String identifying the sender
// 	 * @param message a String message
// 	 * @return String response from remote service after synchronously invoking remote method
// 	 */
// 	String sayHello(String from, String message);
// 	
// 	/**
// 	 * Asynchronously invoke remote method and provide String result via returned
// 	 * CompletableFuture.
// 	 * 
// 	 * @param from a String identifying the sender
// 	 * @param message a String message
// 	 * @return CompletableFuture that invokes remote method asynchronously to complete.  
// 	 * Will throw java.util.concurrent.TimeoutException if response is not
// 	 * received in within timeout provided via osgi.basic.timeout service prop on imple
// 	 */
// 	CompletableFuture<String> sayHelloAsync(String from, String message);
// 	
// 	/**
// 	 * Asynchronously invoke remote method and provide String result via returned 
// 	 * Promise.
// 	 * 
// 	 * @param from a String identifying the sender
// 	 * @param message a String message
// 	 * @return Promis that invokes remote method asynchronously to complete.  
// 	 * Will throw java.util.concurrent.TimeoutException if response is not
// 	 * received in within timeout provided via osgi.basic.timeout service prop on impl
// 	 */
// 	Promise<String> sayHelloPromise(String from, String message);
// 	
// }


import java.util.concurrent.CompletableFuture;
import org.eclipse.ecf.examples.hello.IHello;
import org.osgi.service.component.annotations.Component;
import org.osgi.util.promise.Deferred;
import org.osgi.util.promise.Promise;
/*******************************************************************************
 * Copyright (c) 2017 Composent, Inc. and others. All rights reserved. This
 * program and the accompanying materials are made available under the terms of
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
 * available at http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors: Composent, Inc. - initial API and implementation
 ******************************************************************************/
package org.eclipse.ecf.examples.hello.javahost;



@Component(immediate=true,property = { "service.exported.interfaces=*",  // RS/RSA-required to export as remote service
									   "service.exported.configs=ecf.py4j.host",  // Required to specify py4j java provider
									   "osgi.basic.timeout:Long=50000",    // timeout of 50000ms=50 seconds
									   "service.intents=osgi.async"}) // osgi.async intent to get the behavior
																	   // defined <a href="https://osgi.org/specification/osgi.cmpn/7.0.0/service.remoteservices.html#d0e1407">here</a>.
/**
 * Example impl of IHello remote service with asynchronous remote methods
 */
// Path: examples/org.eclipse.ecf.examples.hello/src/org/eclipse/ecf/examples/hello/IHello.java
// public interface IHello {
// 
// 	/**
// 	 * Synchronously provide 'from' and 'message' Strings to service, and receive a
// 	 * String response.
// 	 *  
// 	 * @param from a String identifying the sender
// 	 * @param message a String message
// 	 * @return String response from remote service after synchronously invoking remote method
// 	 */
// 	String sayHello(String from, String message);
// 	
// 	/**
// 	 * Asynchronously invoke remote method and provide String result via returned
// 	 * CompletableFuture.
// 	 * 
// 	 * @param from a String identifying the sender
// 	 * @param message a String message
// 	 * @return CompletableFuture that invokes remote method asynchronously to complete.  
// 	 * Will throw java.util.concurrent.TimeoutException if response is not
// 	 * received in within timeout provided via osgi.basic.timeout service prop on imple
// 	 */
// 	CompletableFuture<String> sayHelloAsync(String from, String message);
// 	
// 	/**
// 	 * Asynchronously invoke remote method and provide String result via returned 
// 	 * Promise.
// 	 * 
// 	 * @param from a String identifying the sender
// 	 * @param message a String message
// 	 * @return Promis that invokes remote method asynchronously to complete.  
// 	 * Will throw java.util.concurrent.TimeoutException if response is not
// 	 * received in within timeout provided via osgi.basic.timeout service prop on impl
// 	 */
// 	Promise<String> sayHelloPromise(String from, String message);
// 	
// }


// Path: examples/org.eclipse.ecf.examples.hello.javahost/src/org/eclipse/ecf/examples/hello/javahost/HelloImpl.java
import java.util.concurrent.CompletableFuture;
import org.eclipse.ecf.examples.hello.IHello;
import org.osgi.service.component.annotations.Component;
import org.osgi.util.promise.Deferred;
import org.osgi.util.promise.Promise;

/*******************************************************************************
 * Copyright (c) 2017 Composent, Inc. and others. All rights reserved. This
 * program and the accompanying materials are made available under the terms of
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
 * available at http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors: Composent, Inc. - initial API and implementation
 ******************************************************************************/
package org.eclipse.ecf.examples.hello.javahost;



@Component(immediate=true,property = { "service.exported.interfaces=*",  // RS/RSA-required to export as remote service
									   "service.exported.configs=ecf.py4j.host",  // Required to specify py4j java provider
									   "osgi.basic.timeout:Long=50000",    // timeout of 50000ms=50 seconds
									   "service.intents=osgi.async"}) // osgi.async intent to get the behavior
																	   // defined <a href="https://osgi.org/specification/osgi.cmpn/7.0.0/service.remoteservices.html#d0e1407">here</a>.
/**
 * Example impl of IHello remote service with asynchronous remote methods
 */
public class HelloImpl implements IHello {