/** * Returns Data Spaces implementation for an application, if it has been successfully configured. * * @return configured implementation of Data Spaces for application or <code>null</code> when node * has not been configured yet (in terms of node-specific or application-specific * configuration) */ public synchronized DataSpacesImpl getDataSpacesImpl() { if (appConfigurator == null) { logger.debug("Requested unavailable Data Spaces implementation for an application"); return null; } return appConfigurator.getDataSpacesImpl(); }
/** * Closes application-specific configuration when needed (there is one opened). * * <p>That involves unregistering application scratch space from NamingService and closing all * objects configured for produced {@link DataSpacesImpl}. {@link DataSpacesImpl} will not be * usable after this call. * * <p>If no application is configured, it does nothing. If closing fails, application-specific * configuration will be silently deleted. */ public synchronized void tryCloseAppConfigurator() { if (appConfigurator == null) return; logger.debug("Closing Data Spaces application node configuration"); appConfigurator.close(); appConfigurator = null; logger.debug("Closed Data Spaces application node configuration"); }
/** * Configures node for a specific application with its identifier, resulting in creation of * configured {@link DataSpacesImpl}. * * <p>Configuration of a node for an application involves association to provided NamingService * and registration of application scratch space for this node, if it exists. * * <p>This method may be called several times for different applications, after node has been * configured through {@link #configureNode(Node, BaseScratchSpaceConfiguration)}. Subsequent * calls will close existing application-specific configuration and create a new one. * * <p>If configuration fails, instance of this class remains not configured for an application, * any subsequent {@link #getDataSpacesImpl()} call will throw {@link IllegalStateException} until * successful configuration. * * @param appId id of application running on this node * @param namingServiceURL URL of naming service remote object for that application * @throws IllegalStateException when node has not been configured yet in terms of node-specific * configuration * @throws URISyntaxException when exception occurred on namingServiceURL parsing * @throws ProActiveException when exception occurred during contacting with NamingService * @throws ConfigurationException when space appears to be already registered or application is * not registered in Naming Service * @throws FileSystemException VFS related exception during scratch data space creation */ public synchronized void configureApplication(long appId, String namingServiceURL) throws IllegalStateException, FileSystemException, ProActiveException, ConfigurationException, URISyntaxException { logger.debug("Configuring node for Data Spaces application"); checkConfigured(); tryCloseAppConfigurator(); appConfigurator = new NodeApplicationConfigurator(); boolean appConfigured = false; try { appConfigurator.configure(appId, namingServiceURL); appConfigured = true; } finally { if (!appConfigured) appConfigurator = null; } logger.debug("Node configured for Data Spaces application"); }