use of org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter 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);
}
use of org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter in project ecf by eclipse.
the class ReflectiveRemoteServiceHandler method execute.
/*
* (non-Javadoc)
*
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.
* commands .ExecutionEvent)
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
final String clazz = event.getParameter(// $NON-NLS-1$
"org.eclipse.ecf.remoteservices.ui.commands.reflectiveMethodDialogParameter");
final IRemoteServiceContainerAdapter adapter = RemoteServiceHandlerUtil.getActiveIRemoteServiceContainerAdapterChecked(event);
if (adapter == null) {
// $NON-NLS-1$
MessageDialog.openError(// $NON-NLS-1$
null, // $NON-NLS-1$
"Handler invocation failed", // $NON-NLS-1$
"No container found");
return null;
}
final IRemoteServiceReference[] references = RemoteServiceHandlerUtil.getActiveIRemoteServiceReferencesChecked(event);
if (references == null || references.length == 0) {
// $NON-NLS-1$
MessageDialog.openError(// $NON-NLS-1$
null, // $NON-NLS-1$
"Handler invocation failed", // $NON-NLS-1$
"No remote service reference found");
return null;
}
final IRemoteService remoteService = adapter.getRemoteService(references[0]);
if (remoteService == null) {
// $NON-NLS-1$
MessageDialog.openError(// $NON-NLS-1$
null, // $NON-NLS-1$
"Handler invocation failed", // $NON-NLS-1$
"No remote service found");
return null;
}
try {
executeMethodInvocationDialog(Class.forName(clazz), remoteService);
} catch (ClassNotFoundException e) {
// $NON-NLS-1$
MessageDialog.openError(// $NON-NLS-1$
null, // $NON-NLS-1$
"Handler invocation failed", e.getLocalizedMessage());
throw new ExecutionException(e.getMessage(), e);
}
return null;
}
use of org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter in project ecf by eclipse.
the class DataProcessorServerApplication method start.
public Object start(IApplicationContext appContext) throws Exception {
bundleContext = Activator.getContext();
// Process Arguments...i.e. set queueId if specified
processArgs(appContext);
// Create container and connect to given queueId as message consumer
container = getContainerManagerService().getContainerFactory().createContainer(containerType, new Object[] { queueId });
// Get remote service container adapter
IRemoteServiceContainerAdapter remoteServiceContainerAdapter = (IRemoteServiceContainerAdapter) container.getAdapter(IRemoteServiceContainerAdapter.class);
// Create the data processor implementation
dataProcessorImpl = new DataProcessorImpl(container.getID());
// Register data processor as remote services (with queue consumer
// container)
dataProcessorRemoteServiceRegistration = remoteServiceContainerAdapter.registerRemoteService(new String[] { IDataProcessor.class.getName() }, dataProcessorImpl, null);
// Report success of registration
System.out.println("LB Server: Data Processor Registered queue=" + queueId);
// then just wait for service requests
waitForDone();
return IApplication.EXIT_OK;
}
use of org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter in project ecf by eclipse.
the class RemoteServiceAdmin method exportService.
private ExportRegistration exportService(final ServiceReference serviceReference, Map<String, ?> overridingProperties, String[] exportedInterfaces, IRemoteServiceContainer rsContainer, Map<String, Object> endpointDescriptionProperties) throws Exception {
// Create remote service properties
Map<String, Object> remoteServiceProperties = copyNonReservedProperties(serviceReference, (Map<String, Object>) overridingProperties, new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER));
// Added for R7 support. Copy intents and intent options to remote service
// properties
String[] intents = PropertiesUtil.getStringArrayWithDefault(endpointDescriptionProperties, org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_INTENTS_SUPPORTED, new String[] {});
remoteServiceProperties = PropertiesUtil.copyIntentProperties(endpointDescriptionProperties, intents, remoteServiceProperties);
IRemoteServiceContainerAdapter containerAdapter = rsContainer.getContainerAdapter();
// create serializable dictionary from remote service properties
Dictionary rsp = PropertiesUtil.createSerializableDictionaryFromMap(remoteServiceProperties);
// Register remote service via ECF container adapter to create
// remote service registration
IRemoteServiceRegistration remoteRegistration = null;
if (containerAdapter instanceof IOSGiRemoteServiceContainerAdapter) {
IOSGiRemoteServiceContainerAdapter osgiContainerAdapter = (IOSGiRemoteServiceContainerAdapter) containerAdapter;
remoteRegistration = osgiContainerAdapter.registerRemoteService(exportedInterfaces, serviceReference, rsp);
} else {
Object service = AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
return getClientBundleContext().getService(serviceReference);
}
});
remoteRegistration = containerAdapter.registerRemoteService(exportedInterfaces, service, rsp);
}
endpointDescriptionProperties.put(org.eclipse.ecf.remoteservice.Constants.SERVICE_ID, remoteRegistration.getID().getContainerRelativeID());
if (remoteRegistration instanceof IExtendedRemoteServiceRegistration) {
IExtendedRemoteServiceRegistration iersr = (IExtendedRemoteServiceRegistration) remoteRegistration;
Map<String, Object> extraProperties = iersr.getExtraProperties();
if (extraProperties != null)
endpointDescriptionProperties = PropertiesUtil.mergeProperties(endpointDescriptionProperties, extraProperties);
}
// Copy only serializable properties
endpointDescriptionProperties = PropertiesUtil.copySerializableProperties(endpointDescriptionProperties, new TreeMap<String, Object>());
// Create ExportEndpoint/ExportRegistration
return new ExportRegistration(new ExportEndpoint(serviceReference, new EndpointDescription(endpointDescriptionProperties), remoteRegistration, endpointDescriptionProperties));
}
use of org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter in project ecf by eclipse.
the class RemoteServiceAdmin method createAndRegisterProxy.
private ImportEndpoint createAndRegisterProxy(final EndpointDescription endpointDescription, final IRemoteServiceContainer rsContainer, final IRemoteServiceReference selectedRsReference) throws Exception {
final BundleContext proxyServiceFactoryContext = getProxyServiceFactoryContext(endpointDescription);
if (proxyServiceFactoryContext == null)
throw new NullPointerException(// $NON-NLS-1$
"getProxyServiceFactoryContext returned null. Cannot register proxy service factory");
final IRemoteServiceContainerAdapter containerAdapter = rsContainer.getContainerAdapter();
ID rsContainerID = rsContainer.getContainer().getID();
// First get IRemoteService for selectedRsReference
final IRemoteService rs = containerAdapter.getRemoteService(selectedRsReference);
if (rs == null)
throw new NullPointerException(// $NON-NLS-1$
"getRemoteService returned null for selectedRsReference=" + selectedRsReference + // $NON-NLS-1$
",rsContainerID=" + rsContainerID);
final Map proxyProperties = createProxyProperties(rsContainerID, endpointDescription, selectedRsReference, rs);
// sync sref props with endpoint props
endpointDescription.setPropertiesOverrides(proxyProperties);
final List<String> originalTypes = endpointDescription.getInterfaces();
final List<String> asyncServiceTypes = endpointDescription.getAsyncInterfaces();
final List<String> serviceTypes = new ArrayList<String>(originalTypes);
if (asyncServiceTypes != null)
for (String ast : asyncServiceTypes) if (ast != null && !serviceTypes.contains(ast))
serviceTypes.add(ast);
ServiceRegistration proxyRegistration = AccessController.doPrivileged(new PrivilegedAction<ServiceRegistration>() {
public ServiceRegistration run() {
return proxyServiceFactoryContext.registerService((String[]) serviceTypes.toArray(new String[serviceTypes.size()]), createProxyServiceFactory(endpointDescription, containerAdapter, selectedRsReference, rs), (Dictionary) PropertiesUtil.createDictionaryFromMap(proxyProperties));
}
});
return new ImportEndpoint(rsContainer, selectedRsReference, rs, proxyRegistration, endpointDescription);
}
Aggregations