use of org.eclipse.ecf.remoteservice.RemoteServiceContainer in project ecf by eclipse.
the class SimpleConcatClient method start.
public void start(int port) throws Exception {
IContainer client = ContainerFactory.getDefault().createContainer(CLIENT_TYPE);
// Get adapter for accessing remote services
IRemoteServiceContainerAdapter adapter = (IRemoteServiceContainerAdapter) client.getAdapter(IRemoteServiceContainerAdapter.class);
rsContainer = new RemoteServiceContainer(client, adapter);
System.out.println("Client created with ID=" + client.getID());
ID connectTargetID = IDFactory.getDefault().createStringID(NLS.bind(SERVER_ID, new Integer(port)));
System.out.println("Attempting connect to id=" + connectTargetID);
client.connect(connectTargetID, null);
System.out.println("Client connected to connectTargetID=" + connectTargetID);
Thread.sleep(1000);
// Get remote service reference
IRemoteServiceReference[] refs = adapter.getRemoteServiceReferences((ID[]) null, IConcatService.class.getName(), null);
rsReference = refs[0];
System.out.println("Remote service with ref=" + refs[0]);
}
use of org.eclipse.ecf.remoteservice.RemoteServiceContainer in project ecf by eclipse.
the class SSLSimpleConcatClient method start.
public void start(int port) throws Exception {
IContainer client = ContainerFactory.getDefault().createContainer(CLIENT_TYPE);
// Get adapter for accessing remote services
IRemoteServiceContainerAdapter adapter = (IRemoteServiceContainerAdapter) client.getAdapter(IRemoteServiceContainerAdapter.class);
rsContainer = new RemoteServiceContainer(client, adapter);
System.out.println("Client created with ID=" + client.getID());
ID connectTargetID = IDFactory.getDefault().createStringID(NLS.bind(SERVER_ID, new Integer(port)));
System.out.println("Attempting connect to id=" + connectTargetID);
client.connect(connectTargetID, null);
System.out.println("Client connected to connectTargetID=" + connectTargetID);
Thread.sleep(1000);
// Get remote service reference
IRemoteServiceReference[] refs = adapter.getRemoteServiceReferences((ID[]) null, IConcatService.class.getName(), null);
rsReference = refs[0];
System.out.println("Remote service with ref=" + refs[0]);
}
use of org.eclipse.ecf.remoteservice.RemoteServiceContainer in project ecf by eclipse.
the class AbstractHostContainerSelector method selectExistingHostContainers.
/**
* @param serviceReference service reference
* @param overridingProperties overriding properties
* @param serviceExportedInterfaces service exported interfaces to select for
* @param serviceExportedConfigs service exported configs to select for
* @param serviceIntents service exported intents to select for
* @return Collection of existing host containers
* @since 2.0
*/
protected Collection selectExistingHostContainers(ServiceReference serviceReference, Map<String, Object> overridingProperties, String[] serviceExportedInterfaces, String[] serviceExportedConfigs, String[] serviceIntents) {
List results = new ArrayList();
// Get all existing containers
IContainer[] containers = getContainers();
// If nothing there, then return empty array
if (containers == null || containers.length == 0)
return results;
for (int i = 0; i < containers.length; i++) {
ID cID = containers[i].getID();
// $NON-NLS-1$ //$NON-NLS-2$
trace("selectExistingHostContainers", "Considering existing container=" + cID);
// Check to make sure it's a rs container adapter. If it's not go
// onto next one
IRemoteServiceContainerAdapter adapter = hasRemoteServiceContainerAdapter(containers[i]);
if (adapter == null) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
trace("selectExistingHostContainers", "Existing container=" + cID + " does not implement IRemoteServiceContainerAdapter");
continue;
}
// Get container type description and intents
ContainerTypeDescription description = getContainerTypeDescription(containers[i]);
// If it has no description go onto next
if (description == null) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
trace("selectExistingHostContainers", "Existing container=" + cID + " does not have container type description");
continue;
}
// http://bugs.eclipse.org/331532
if (!description.isServer()) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
trace("selectExistingHostContainers", "Existing container=" + cID + " is not server");
continue;
}
if (matchExistingHostContainer(serviceReference, overridingProperties, containers[i], adapter, description, serviceExportedConfigs, serviceIntents)) {
trace("selectExistingHostContainers", // $NON-NLS-1$ //$NON-NLS-2$
"INCLUDING containerID=" + containers[i].getID() + // $NON-NLS-1$
" configs=" + ((serviceExportedConfigs == null) ? "null" : // $NON-NLS-1$
Arrays.asList(serviceExportedConfigs).toString()) + // $NON-NLS-1$
" intents=" + ((serviceIntents == null) ? "null" : // $NON-NLS-1$
Arrays.asList(serviceIntents).toString()));
results.add(new RemoteServiceContainer(containers[i], adapter));
} else {
trace("selectExistingHostContainers", // $NON-NLS-1$ //$NON-NLS-2$
"EXCLUDING containerID=" + containers[i].getID() + // $NON-NLS-1$
" configs=" + ((serviceExportedConfigs == null) ? "null" : // $NON-NLS-1$
Arrays.asList(serviceExportedConfigs).toString()) + // $NON-NLS-1$
" intents=" + ((serviceIntents == null) ? "null" : // $NON-NLS-1$
Arrays.asList(serviceIntents).toString()));
}
}
return results;
}
use of org.eclipse.ecf.remoteservice.RemoteServiceContainer in project ecf by eclipse.
the class AbstractConsumerContainerSelector method createContainer.
/**
* @param containerTypeDescription containerTypeDescription
* @param containerTypeDescriptionName containerTypeDescriptionName
* @param properties properties
* @return IRemoteServiceContainer created container. Should not be <code>null</code>
* @throws SelectContainerException thrown if container cannot be created or configured
* @since 2.0
*/
protected IRemoteServiceContainer createContainer(ContainerTypeDescription containerTypeDescription, String containerTypeDescriptionName, Map properties) throws SelectContainerException {
try {
IContainer container = (properties == null) ? getContainerFactory().createContainer(containerTypeDescriptionName) : getContainerFactory().createContainer(containerTypeDescriptionName, properties);
IRemoteServiceContainerAdapter adapter = (IRemoteServiceContainerAdapter) container.getAdapter(IRemoteServiceContainerAdapter.class);
if (adapter == null)
throw new SelectContainerException("Container config id=" + containerTypeDescriptionName + " does not implement IRemoteServiceContainerAdapter", null, // $NON-NLS-1$ //$NON-NLS-2$
containerTypeDescription);
return new RemoteServiceContainer(container);
} catch (ContainerCreateException e) {
String message = // $NON-NLS-1$
"Cannot create container config id=" + containerTypeDescriptionName;
logException(message, e);
throw new SelectContainerException(message, e, containerTypeDescription);
}
}
use of org.eclipse.ecf.remoteservice.RemoteServiceContainer in project ecf by eclipse.
the class AbstractHostContainerSelector method createRSContainer.
/**
* @param serviceReference serviceReference
* @param properties properties
* @param containerTypeDescription container type description
* @return IRemoteServiceContainer created remote service container
* @throws SelectContainerException if could not be created
* @since 4.6
*/
protected IRemoteServiceContainer createRSContainer(ServiceReference serviceReference, Map<String, Object> properties, ContainerTypeDescription containerTypeDescription, String[] intents) throws SelectContainerException {
trace(// $NON-NLS-1$
"createRSContainer", // $NON-NLS-1$ //$NON-NLS-2$
"Creating container instance for ref=" + serviceReference + ";properties=" + properties + ";description=" + containerTypeDescription.getName() + // $NON-NLS-1$ //$NON-NLS-2$
";intents=" + // $NON-NLS-1$
((intents == null) ? "" : Arrays.asList(intents).toString()));
IContainer container = createContainer(serviceReference, properties, containerTypeDescription, intents);
if (container == null)
return null;
IRemoteServiceContainerAdapter adapter = (IRemoteServiceContainerAdapter) container.getAdapter(IRemoteServiceContainerAdapter.class);
if (adapter == null)
throw new SelectContainerException("Container does not implement IRemoteServiceContainerAdapter", null, // $NON-NLS-1$
containerTypeDescription);
return new RemoteServiceContainer(container, adapter);
}
Aggregations