private ExportRegistration exportService()

in rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java [224:255]


    private ExportRegistration exportService(
            final List<String> interfaceNames,
            final ServiceReference<?> serviceReference,
            final Map<String, Object> serviceProperties) {
        LOG.info("interfaces selected for export: {}", interfaceNames);

        try {
            checkPermission(new EndpointPermission("*", EndpointPermission.EXPORT));
            final BundleContext serviceContext = getBundleContext(serviceReference);
            final Object serviceO = serviceContext.getService(serviceReference); // unget it when export is closed
            if (serviceO == null) {
                throw new IllegalStateException("service object is null (service was unregistered?)");
            }
            final Class<?>[] interfaces = getInterfaces(serviceO, interfaceNames);
            final Map<String, Object> eprops = createEndpointProps(serviceProperties, interfaces);

            Endpoint endpoint = AccessController.doPrivileged(new PrivilegedAction<Endpoint>() {
                public Endpoint run() {
                    return provider.exportService(serviceO, serviceContext, eprops, interfaces);
                }
            });
            if (endpoint == null) {
                return null;
            }
            return new ExportRegistrationImpl(serviceReference, endpoint, closeHandler, eventProducer);
        } catch (IllegalArgumentException e) {
            // TCK expects this for garbage input
            throw e;
        } catch (Exception e) {
            return new ExportRegistrationImpl(e, closeHandler, eventProducer);
        }
    }