Translates a {@link ServiceCreationConfiguration} to an xml element

@param serviceCreationConfiguration
337468
@Override
  public Element unparseServiceCreationConfiguration(final ServiceCreationConfiguration<ClusteringService> serviceCreationConfiguration) {
    Element rootElement = unparseConfig(serviceCreationConfiguration);
    return rootElement;
  }
642910
@Override
  protected ILaunchConfigurationWorkingCopy createLaunchConfiguration(IJavaElement element)
      throws CoreException {
    ILaunchConfigurationWorkingCopy wc =  super.createLaunchConfiguration(element);

    String containerUrl = JicUnitPlugin.getDefault().getPreferenceStore()
        .getString(CONTAINER_URL);    
    String extraVwArg = "-D" + CONTAINER_URL + "=" + containerUrl;
    wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, extraVwArg);
    
    return wc;
  }
1007951
private static void generateParserOnXmlStartElement(BindTypeContext context, MethodSpec.Builder methodBuilder,
			String instanceName, String parserName, BindEntity entity) {
		BindTransform bindTransform;
		// start and inner bean
		methodBuilder.addStatement("currentTag = xmlParser.getName().toString()");

		int count = 0;
		// count property to manage
		{
			// for each elements
			for (BindProperty property : entity.getCollection()) {
				if (property.xmlInfo.xmlType != XmlType.TAG)
					continue;

				bindTransform = BindTransformer.lookup(property);

				// here we manage only property of bean type
				if (bindTransform != null) {
					count++;
				}
			}
		}

		if (count > 0) {
			// switch for tag elements
			// @formatter:off
			methodBuilder.beginControlFlow("switch(currentTag)$>");

			// for each elements
			for (BindProperty property : entity.getCollection()) {
				if (property.xmlInfo.xmlType != XmlType.TAG)
					continue;

				bindTransform = BindTransformer.lookup(property);

				// here we manage only property of bean type
				if (bindTransform != null) {
					methodBuilder.addCode("case $S:\n$>", BindProperty.xmlName(property));
					methodBuilder.addCode("// property $L (mapped on $S)\n", property.getName(),
							BindProperty.xmlName(property));

					// methodBuilder.beginControlFlow("if
					// (!xmlParser.isEmptyElement())");
					bindTransform.generateParseOnXml(context, methodBuilder, "xmlParser",
							property.getPropertyType().getTypeName(), "instance", property);
					// methodBuilder.endControlFlow();

					methodBuilder.addStatement("$<break");
				}
			}

			methodBuilder.addCode("default:\n$>");
			// methodBuilder.addStatement("$L.skipElement()", parserName);

			methodBuilder.addStatement("$<break");
			methodBuilder.endControlFlow();
		} else {
			methodBuilder.addCode("// No property to manage here\n");
		}
		// @formatter:on

	}
25497
public static ServiceInstance toServiceInstance(
            ModelServiceInstance modelInstance) {
        if (modelInstance==null) throw new NullPointerException();
        Map<String, String> meta = new HashMap<>();
        if (modelInstance.getMetadata() != null) {
            for (Entry<String, String> en : modelInstance.getMetadata()
                    .entrySet()) {
                meta.put(en.getKey(), en.getValue());
            }
        }
        return new ServiceInstance(modelInstance.getServiceName(),
                modelInstance.getUri(),
                modelInstance.isMonitorEnabled(), modelInstance.getStatus(),
                modelInstance.getAddress(),meta, modelInstance.getPort(), modelInstance.getTls_port(), modelInstance.getProtocol());
    }
1341155
private function buildServiceConfig()
    {
        if ($this->serviceConfig->keyExists('Factory') && !$this->serviceConfig->keyExists('Method')) {
            throw new ServiceManagerException(ServiceManagerException::FACTORY_SERVICE_METHOD_KEY_MISSING,
                                              [$this->serviceName]
            );
        }

        $config = new ServiceConfig();
        $config->setClass($this->serviceConfig->key('Class', null, true));
        $config->setArguments($this->serviceConfig->key('Arguments', [], true));
        $config->setCalls($this->serviceConfig->key('Calls', [], true));
        $config->setScope($this->serviceConfig->key('Scope', ServiceScope::CONTAINER, true));
        $config->setFactory($this->serviceConfig->key('Factory', null, true));
        $config->setMethod($this->serviceConfig->key('Method', null, true));
        $config->setMethodArguments($this->serviceConfig->key('MethodArguments'));
        $config->setStatic($this->serviceConfig->key('Static', true, true));

        return $config;
    }
899592
@Override
    public <T> T create(EntityCreateOperation<T> creator)
            throws ServiceException {
        try {
            return service.create(creator);
        } catch (UniformInterfaceException e) {
            throw processCatch(new ServiceException(e));
        } catch (ClientHandlerException e) {
            throw processCatch(new ServiceException(e));
        }
    }
720339
public void setServiceConfigurations(java.util.Collection<ServiceConfiguration> serviceConfigurations) {
        if (serviceConfigurations == null) {
            this.serviceConfigurations = null;
            return;
        }

        this.serviceConfigurations = new com.amazonaws.internal.SdkInternalList<ServiceConfiguration>(serviceConfigurations);
    }
520254
public function loadConfiguration(): void
	{
		if (!class_exists('Symfony\Component\Console\Application')) {
			throw new ServiceCreationException('Missing Symfony\Component\Console\Application service');
		}

		// Skip if it's not CLI mode
		if (!$this->cliMode) return;

		$builder = $this->getContainerBuilder();

		// Helpers
		$builder->addDefinition($this->prefix('connectionHelper'))
			->setFactory(ConnectionHelper::class)
			->setAutowired(false);

		//Commands
		$builder->addDefinition($this->prefix('importCommand'))
			->setFactory(ImportCommand::class)
			->addTag('console.command', 'dbal:import')
			->setAutowired(false);

		$builder->addDefinition($this->prefix('reservedWordsCommand'))
			->setFactory(ReservedWordsCommand::class)
			->addTag('console.command', 'dbal:reserved-words')
			->setAutowired(false);

		$builder->addDefinition($this->prefix('runSqlCommand'))
			->setFactory(RunSqlCommand::class)
			->addTag('console.command', 'dbal:run-sql')
			->setAutowired(false);
	}
1259479
public void parseEndpointConfiguration(BeanDefinitionBuilder endpointConfiguration, Element element) {
        JdbcServerConfiguration serverConfiguration = new JdbcServerConfiguration();

        if (element.hasAttribute("host")) {
            serverConfiguration.setHost(element.getAttribute("host"));
        }

        if (element.hasAttribute("port")) {
            serverConfiguration.setPort(Integer.valueOf(element.getAttribute("port")));
        }

        if (element.hasAttribute("database-name")) {
            serverConfiguration.setDatabaseName(element.getAttribute("database-name"));
        }

        if (element.hasAttribute("max-connections")) {
            serverConfiguration.setMaxConnections(Integer.valueOf(element.getAttribute("max-connections")));
        }

        endpointConfiguration.addPropertyValue("serverConfiguration", serverConfiguration);

        BeanDefinitionParserUtils.setPropertyValue(endpointConfiguration, element.getAttribute("timeout"), "timeout");

        BeanDefinitionParserUtils.setPropertyValue(endpointConfiguration, element.getAttribute("auto-connect"), "autoConnect");
        BeanDefinitionParserUtils.setPropertyValue(endpointConfiguration, element.getAttribute("auto-create-statement"), "autoCreateStatement");
        BeanDefinitionParserUtils.setPropertyValue(endpointConfiguration, element.getAttribute("auto-transaction-handling"), "autoTransactionHandling");

        BeanDefinitionParserUtils.setPropertyReference(endpointConfiguration, element.getAttribute("auto-handle-queries"), "autoHandleQueries");

        BeanDefinitionParserUtils.setPropertyValue(endpointConfiguration, element.getAttribute("polling-interval"), "pollingInterval");
        BeanDefinitionParserUtils.setPropertyReference(endpointConfiguration, element.getAttribute("message-correlator"), "correlator");
    }
1179928
public Configuration create(InputStream stream) {
        try {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setValidating(false);
            factory.setIgnoringElementContentWhitespace(true);
            factory.setNamespaceAware(true);
            DocumentBuilder documentBuilder = factory.newDocumentBuilder();
            Document document = documentBuilder.parse(stream);
            return domConfigurationFactory.create(document);
        } catch (ParserConfigurationException e) {
            throw new TextProcessorFactoryException(e);
        } catch (IOException e) {
            throw new TextProcessorFactoryException(e);
        } catch (SAXException e) {
            throw new TextProcessorFactoryException(e);
        }
    }
1313930
@Override
    public List<URI> importServices(InputStream servicesContentStream,
                                    String mediaType) throws SalException {

        boolean isNativeFormat = MediaType.NATIVE_MEDIATYPE_SYNTAX_MAP.containsKey(mediaType);
        // Throw error if Format Unsupported
        if (!isNativeFormat && !this.serviceTransformationEngine.canTransform(mediaType)) {
            log.error("The media type {} is not natively supported and has no suitable transformer.", mediaType);
            throw new ServiceException("Unable to import service. Format unsupported.");
        }

        // Obtain the file extension to use
        String fileExtension = findFileExtensionToUse(mediaType, isNativeFormat);

        List<Service> services = null;
        List<URI> importedServices = new ArrayList<URI>();
        URI sourceDocUri = null;
        InputStream localStream = null;
        try {
            // 1st Store the document
            sourceDocUri = this.docManager.createDocument(servicesContentStream, fileExtension, mediaType);
            if (sourceDocUri == null) {
                throw new ServiceException("Unable to save service document. Operation aborted.");
            }

            // 2nd Parse and Transform the document
            // The original stream may be a one-of stream so save it first and read locally
            localStream = this.docManager.getDocument(sourceDocUri);
            services = getServicesFromStream(mediaType, isNativeFormat, localStream);

            // 3rd - Store the resulting MSM services. There may be more than one
            URI serviceUri = null;
            if (services != null && !services.isEmpty()) {
                log.info("Importing {} services", services.size());
                for (Service service : services) {
                    // The service is being imported -> update the source
                    service.setSource(sourceDocUri);
                    serviceUri = this.serviceManager.addService(service);
                    if (serviceUri != null) {
                        importedServices.add(serviceUri);
                    }
                }
            }

            // 4th Log it was all done correctly
            // TODO: log to the system and notify observers
            log.info("Source document imported: {}", sourceDocUri.toASCIIString());

        } finally {
            // Rollback if something went wrong
            if ((services == null || (services != null && services.size() != importedServices.size()))
                    && sourceDocUri != null) {
                this.docManager.deleteDocument(sourceDocUri);
                for (URI svcUri : importedServices) {
                    this.serviceManager.deleteService(svcUri);
                }
                log.warn("There were problems importing the service. Changes undone.");
            }

            if (localStream != null)
                try {
                    localStream.close();
                } catch (IOException e) {
                    log.error("Error closing the service content stream", e);
                }
        }

        return importedServices;
    }
443428
@Help(help = "Creates a new service")
  public String create(String serviceName, List<String> roles) throws SDKException {
    HashMap<String, Object> requestBody = new HashMap<>();
    requestBody.put("name", serviceName);
    requestBody.put("roles", roles);

    return new String(
        (byte[])
            requestPost(
                "create",
                requestBody,
                MediaType.APPLICATION_OCTET_STREAM_VALUE,
                MediaType.APPLICATION_JSON_VALUE));
  }
97048
public ConfigurationResult getConfiguration ()
        throws ServiceException
    {
        requireAdminUser();

        final ServletWaiter<ConfigurationResult> waiter =
            new ServletWaiter<ConfigurationResult>("getConfiguration");

        _omgr.postRunnable(new Runnable() {
            public void run () {
                Map<String, ConfigurationRecord> tabs = Maps.newHashMap();
                for (String key : _confReg.getKeys()) {
                    ConfigurationRecord record = buildRecord(key);
                    if (record == null) {
                        waiter.requestFailed(
                            new ServiceException(InvocationCodes.E_INTERNAL_ERROR));
                        return;
                    }
                    tabs.put(key, record);
                }

                ConfigurationResult result = new ConfigurationResult();
                result.records = tabs;
                waiter.requestCompleted(result);
            }
        });

        return waiter.waitForResult();
    }
194227
protected void prepareXMLReader() throws VerifierConfigurationException {
		try {
			SAXParserFactory factory = SAXParserFactory.newInstance();
			factory.setNamespaceAware(true);
			reader = factory.newSAXParser().getXMLReader();
		} catch( SAXException e ) {
			throw new VerifierConfigurationException(e);
		} catch( ParserConfigurationException pce ) {
			throw new VerifierConfigurationException(pce);
		}
	}
1219141
public void readConfiguration(InputStream inputStream) throws TracerFactory.Exception {
    if (this.traceConfigSchema == null)
      System.err.println("CAUTION: Unable to validate the given configuration against a schema.");

    DocumentBuilderFactory builderFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
    builderFactory.setNamespaceAware(true);
    builderFactory.setXIncludeAware(false);

    try {
      DocumentBuilder parser = builderFactory.newDocumentBuilder();
      Document tracerConfigDoc = parser.parse(inputStream);

      if (this.traceConfigSchema != null) {
        DOMSource domSource = new DOMSource(tracerConfigDoc);
        Validator traceConfigValidator = this.traceConfigSchema.newValidator();
        TracerFactory.ErrorHandler errorHandler = new TracerFactory.ErrorHandler();
        traceConfigValidator.setErrorHandler(errorHandler);
        traceConfigValidator.validate(domSource);
      }
      
      this.poolWriteLock.lock();
      try {
        NodeList tracerNodes = (NodeList) this.xpath.evaluate("/dns:TraceConfig/dns:Pool/dns:TraceLogger", tracerConfigDoc.getDocumentElement(), XPathConstants.NODESET);
        System.out.println();
        System.out.println("Configured Pool Tracers = " + tracerNodes.getLength());
        for (int i = 0; i < tracerNodes.getLength(); i++) {
          System.out.println();
          System.out.println("(+) " + (i + 1) + ". TraceLogger");
          Element tracerElement = (Element) tracerNodes.item(i);
          if (!tracerElement.hasAttribute("name"))
            throw new TracerFactory.Exception("Missing 'name' attribut.");
          String name = tracerElement.getAttribute("name");
          String className = tracerElement.getAttribute("class");
          System.out.println("name = " + name);
          System.out.println("className = " + className);
          Class<?> tracerClass = Class.forName(className);
          if (!AbstractTracer.class.isAssignableFrom(tracerClass))
            throw new TracerFactory.Exception("Illegal tracer class!");
          AbstractTracer tracer = createTracer((Class<? extends AbstractTracer>) tracerClass, name);
          tracer.readConfiguration(this.xpath, tracerElement);

  //        synchronized (this.mapGuardObj) {
  //          this.tracerPool.put(name, tracer);
  //        }
          this.tracerPool.put(name, tracer);
        }

        NodeList threadNodes = (NodeList) this.xpath.evaluate("/dns:TraceConfig/dns:Map/dns:Threads/dns:Thread", tracerConfigDoc.getDocumentElement(), XPathConstants.NODESET);
        System.out.println();
        System.out.println("Configured Tracermappings = " + threadNodes.getLength());
        for (int i = 0; i < threadNodes.getLength(); i++) {
          System.out.println();
          System.out.println("(+) " + (i + 1) + ". Mapping");
          Element threadElement = (Element) threadNodes.item(i);
          String threadName = threadElement.getAttribute("name");
          String referencedTracerName = (String) this.xpath.evaluate("./dns:TraceLogger/@ref", threadElement, XPathConstants.STRING);
          System.out.println(threadName + " => " + referencedTracerName);
          this.threadName2Element.put(threadName, threadElement);
        }

        Node defaultTracerNode = (Node) this.xpath.evaluate("/dns:TraceConfig/dns:DefaultTracer", tracerConfigDoc.getDocumentElement(), XPathConstants.NODE);
        if (defaultTracerNode != null) {
          String className = ((Element) defaultTracerNode).getAttribute("class");
          Class<?> tracerClass = Class.forName(className);
          if (!NullTracer.class.isAssignableFrom(tracerClass))
            throw new TracerFactory.Exception("Requiring a NullTracer as default tracer!");
          this.defaultTracer = createTracer((Class<? extends NullTracer>) tracerClass);
        }
        else {
          this.defaultTracer = TracerFactory.NULLTRACER;
        }
      }
      finally {
        this.poolWriteLock.unlock();
      }
      
      this.queueWriteLock.lock();
      try {
        Node queueNode = (Node) this.xpath.evaluate("/dns:TraceConfig/dns:Queue", tracerConfigDoc.getDocumentElement(), XPathConstants.NODE);
        if (queueNode != null) {
          this.queueConfig = new Queue(queueNode);
        }
        else {
          this.queueConfig = new Queue();
        }
      }
      finally {
        this.queueWriteLock.unlock();
      }
    }
    catch (IOException | ParserConfigurationException | SAXException | XPathExpressionException | ClassNotFoundException | AbstractTracer.Exception ex) {
      throw new TracerFactory.Exception(ex);
    }
  }
629173
public void parseEndpointConfiguration(BeanDefinitionBuilder endpointConfiguration, Element element) {
        BeanDefinitionParserUtils.setPropertyValue(endpointConfiguration, element.getAttribute("timeout"), "timeout");

        BeanDefinitionParserUtils.setPropertyValue(endpointConfiguration, element.getAttribute("host"), "host");
        BeanDefinitionParserUtils.setPropertyValue(endpointConfiguration, element.getAttribute("port"), "port");
        BeanDefinitionParserUtils.setPropertyValue(endpointConfiguration, element.getAttribute("binding"), "binding");

        BeanDefinitionParserUtils.setPropertyValue(endpointConfiguration, element.getAttribute("polling-interval"), "pollingInterval");
        BeanDefinitionParserUtils.setPropertyReference(endpointConfiguration, element.getAttribute("message-converter"), "messageConverter");
    }
634606
public void initConfiguration(Map<?, ?> configurationMap, ServiceRegistryImplementor serviceRegistry) {
		ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
		ConfigurationPropertyReader propertyReader = new ConfigurationPropertyReader( configurationMap, classLoaderService );

		this.configurationResource = propertyReader
				.property( InfinispanRemoteProperties.CONFIGURATION_RESOURCE_NAME, URL.class )
				.withDefaultStringValue( InfinispanRemoteProperties.DEFAULT_CONFIGURATION_RESOURCE_NAME )
				.getValue();

		this.clientProperties = getHotRodConfiguration( configurationMap, propertyReader, this.configurationResource );

		this.schemaCaptureService = propertyReader
				.property( InfinispanRemoteProperties.SCHEMA_CAPTURE_SERVICE, SchemaCapture.class )
				.instantiate()
				.getValue();

		this.schemaOverrideService = propertyReader
				.property( InfinispanRemoteProperties.SCHEMA_OVERRIDE_SERVICE, SchemaOverride.class )
				.instantiate()
				.getValue();

		this.schemaOverrideResource = propertyReader
				.property( InfinispanRemoteProperties.SCHEMA_OVERRIDE_RESOURCE, URL.class )
				.getValue();

		this.schemaPackageName = propertyReader
				.property( InfinispanRemoteProperties.SCHEMA_PACKAGE_NAME, String.class )
				.withDefault( InfinispanRemoteProperties.DEFAULT_SCHEMA_PACKAGE_NAME )
				.getValue();

		this.schemaFileName = propertyReader
				.property( InfinispanRemoteProperties.SCHEMA_FILE_NAME, String.class )
				.withDefault( InfinispanRemoteProperties.DEFAULT_SCHEMA_FILE_NAME )
				.withValidator( InfinispanRemoteValidators.SCHEMA_FILE_NAME )
				.getValue();

		this.createCachesEnabled = propertyReader
				.property( OgmProperties.CREATE_DATABASE, boolean.class )
				.withDefault( false )
				.getValue();

		this.cacheConfiguration = propertyReader
				.property( InfinispanRemoteProperties.CACHE_CONFIGURATION, String.class )
				.withDefault( null )
				.getValue();

		String transactionModeString = propertyReader
				.property( InfinispanRemoteProperties.TRANSACTION_MODE, String.class )
				.withDefault( InfinispanRemoteProperties.DEFAULT_TRANSACTION_MODE )
				.getValue();

		this.transactionMode = extractTransactionMode( transactionModeString );

		log.tracef( "Initializing Infinispan Hot Rod client from configuration file at '%1$s'", configurationResource );
	}