text:
package com.google.android.exoplayer2.database;

import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;

/**
 * Provides {@link SQLiteDatabase} instances to media library components, which may read and write
 * tables prefixed with {@link #TABLE_PREFIX}.
 */
public interface DatabaseProvider {

  /** Prefix for tables that can be read and written by media library components. */
  String TABLE_PREFIX = "ExoPlayer";

  /**
   * Creates and/or opens a database that will be used for reading and writing.
   *
   *
Once opened successfully, the database is cached, so you can call this method every time you
   * need to write to the database. Errors such as bad permissions or a full disk may cause this
   * method to fail, but future attempts may succeed if the problem is fixed.
   *
   * @throws SQLiteException If the database cannot be opened for writing.
   * @return A read/write database object.
   */
  SQLiteDatabase getWritableDatabase();

  /**
   * Creates and/or opens a database. This will be the same object returned by {@link
   * #getWritableDatabase()} unless some problem, such as a full disk, requires the database to be
   * opened read-only. In that case, a read-only database object will be returned. If the problem is
   * fixed, a future call to {@link #getWritableDatabase()} may succeed, in which case the read-only
   * database object will be closed and the read/write object will be returned in the future.
   *
   *
Once opened successfully, the database is cached, so you can call this method every time you
   * need to read from the database.
   *
   * @throws SQLiteException If the database cannot be opened.
   * @return A database object valid until {@link #getWritableDatabase()} is called.
   */
  SQLiteDatabase getReadableDatabase();
}


text:
<?php
App::uses('AppController', 'Controller');
/**
 * People Controller
 *
 * @property Person $Person
 * @property PaginatorComponent $Paginator
 */
class PeopleController extends AppController {

/**
 * Components
 *
 * @var array
 */
	public $components = array('Paginator');

/**
 * index method
 *
 * @return void
 */
	public function index() {
		$this->Person->recursive = 0;
		$search_box = $this->Person->find("all",array('order' => array('Person.name ASC')));
		$this->Paginator->settings = array(
		        'limit' => 50,
		        'order' => array(
							'Person.name' => 'asc'
						)
		);
		$this->set('people', $this->Paginator->paginate());
		$this->set('search_box', $search_box);
	}

/**
 * view method
 *
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
	public function view($id = null) {
		if (!$this->Person->exists($id)) {
			throw new NotFoundException(__('Invalid person'),'flash_error');
		}
		$options = array('conditions' => array('Person.' . $this->Person->primaryKey => $id));
		$person = $this->Person->find('first', $options);
		$options2 = array('conditions' => array('Person.' . $this->Person->primaryKey => $person['Person']['father_id']));
		$options3 = array('conditions' => array('Person.' . $this->Person->primaryKey => $person['Person']['father2_id']));
		$options4 = array('conditions' => array('Person.' . $this->Person->primaryKey => $person['Person']['spouse_id']));
		$options_child = array('conditions' => array('Person.father_id' => $person['Person']['id']));
		$options_child2 = array('conditions' => array('Person.father2_id' => $person['Person']['id']));
		$options_child = array_merge($options_child, $options_child2);
		$this->set(compact('person'));
		$this->set('father', $this->Person->find('first', $options2));
		$this->set('father2', $this->Person->find('first', $options3));
		$this->set('spouse', $this->Person->find('first', $options4));
		$this->set('childs', $this->Person->find('all', $options_child));
	}

/**
 * add method
 *
 * @return void
 */
	public function add($modal = null) {
		if($modal){
			$this->layout = 'modal';
			$this->set("dialog",true);
		}else{
			$this->set("dialog",false);
		}

		if ($this->request->is('post')) {
			$this->Person->create();
			//In the future to check, what is the parish that user work
			//$this->request->data["Person"]["parish_id"] = 1;

			//transformando cadastro em maiusculas
			$this->request->data["Person"]["name"] = strtoupper($this->request->data["Person"]["name"]);
			$spouse = $this->request->data["Person"]["spouse_id"];
			$marriage = $this->request->data["Person"]["marriage"];
			if ($this->Person->save($this->request->data)) {
				if($spouse != 0){
					//set in spouse, the same value
					$options = array('conditions' => array('Person.id' => $spouse));
					$spouse = $this->Person->find('first', $options);
					$spouse["Person"]["spouse_id"] = $this->Person->id;
					$spouse["Person"]["marriage"] = $marriage;
					$this->Person->save($spouse);
				}else{
					$options = array('conditions' => array('Person.spouse_id' => $this->Person->id));
					$spouse = $this->Person->find('first', $options);
					$spouse["Person"]["spouse_id"] = 0;
					$spouse["Person"]["marriage"] = null;
					$this->Person->save($spouse);
				}
				if(!$modal){
					$this->Session->setFlash(__('The person has been saved.'),'flash_success');
					return $this->redirect(array('action' => 'index'));
				}else{
					$this->Session->setFlash(__('The person has been saved.'));
				}
			} else {
				$this->Session->setFlash(__('The person could not be saved. Please, try again.'),'flash_error');
			}
		}
		$parishes = $this->Person->Parish->find('list');
		$fathers = $spouses = $this->Person->find("list",array('order' => array('Person.name ASC')));
		$this->set(compact('fathers'));
		$this->set(compact('spouses'));
		$this->set(compact('parishes'));
	}

/**
 * edit method
 *
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
	public function edit($id = null) {
		if (!$this->Person->exists($id)) {
			throw new NotFoundException(__('Invalid person'));
		}
		if ($this->request->is(array('post', 'put'))) {
			//In the future to check, what is the parish that user work
			//$this->request->data["Person"]["parish_id"] = 1;
			$this->request->data["Person"]["name"] = strtoupper($this->request->data["Person"]["name"]);
			$spouse = $this->request->data["Person"]["spouse_id"];
			$marriage = $this->request->data["Person"]["marriage"];

			if ($this->Person->save($this->request->data)) {
				if($spouse != 0){
					//set in spouse, the same value
					$options = array('conditions' => array('Person.id' => $spouse));
					$spouse = $this->Person->find('first', $options);
					//var_dump($spouse);exit;
					$spouse["Person"]["spouse_id"] = $this->request->data["Person"]["id"];
					$spouse["Person"]["marriage"] = $marriage;
					$this->Person->save($spouse);
				}else{
					$options = array('conditions' => array('Person.spouse_id' => $this->request->data["Person"]["id"]));
					$spouse = $this->Person->find('first', $options);
					$spouse["Person"]["spouse_id"] = 0;
					$spouse["Person"]["marriage"] = null;
					$this->Person->save($spouse);
				}

				$this->Session->setFlash(__('The person has been saved.'),'flash_success');
				return $this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The person could not be saved. Please, try again.'),'flash_error');
			}
		} else {
			$options = array('conditions' => array('Person.' . $this->Person->primaryKey => $id));
			$this->request->data = $this->Person->find('first', $options);
		}
		$parishes = $this->Person->Parish->find('list');
		$fathers = $spouses = $this->Person->find("list",array('order' => array('Person.name ASC')));
		$this->set(compact('fathers'));
		$this->set(compact('spouses'));
		$this->set(compact('parishes'));
	}

/**
 * delete method
 *
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
	public function delete($id = null) {
		$this->Person->id = $id;
		if (!$this->Person->exists()) {
			throw new NotFoundException(__('Invalid person'));
		}
		$this->request->onlyAllow('post', 'delete');
		if ($this->Person->delete()) {
			$this->Session->setFlash(__('The person has been deleted.'),'flash_success');
		} else {
			$this->Session->setFlash(__('The person could not be deleted. Please, try again.'),'flash_error');
		}
		return $this->redirect(array('action' => 'index'));
	}

	public function toList(){
		$this->autoRender = false;
        if($this->request->is('ajax')){
			$this->layout='ajax';
            $result = $this->Person->find('list',
                    array('fields' => array('Person.name','Person.id'),
                          'order' => array('Person.name ASC')));
            echo json_encode($result);
        }
	}

    public function report_birthday($month = null){

        $limitDate = $this->get_limit_date();

		$meses = array(__('January'),__('February'),__('March'),__('April'),__('May'),__('June'),__('July'),__('August'),__('September'),
					__('October'),__('November'),__('December'));
        $options = array(
                'fields'=>array(
                        'Person.name as name',
                        'Person.birth as birth',
                ),
                'conditions'=>array(
                    'MONTH(birth)'=>$month,
                    'CONCAT(Tithe.year,Tithe.month) >='=>$limitDate
                ),
                'group'=>array(
                        'Person.id'
                ),
                'order'=>array(
                    'DAY(Person.birth) ASC',
                ),
                'recursive'=>0
        );
        $options['joins'] = array(
            array('table' => 'tithes',
                'alias' => 'Tithe',
                'type' => 'INNER',
                'conditions' => array(
                    'Person.id = Tithe.person_id',
                )
            )
        );

            $people = $this->Person->find('all', $options);
            $this->layout = 'report';
			$this->set('month',$meses[$month-1]);
            $this->set('people',$people);
            $this->render();
    }

    public function beforeFilter() {
        parent::beforeFilter();
        $this->Security->blackHoleCallback = 'blackhole';
    }

    public function blackhole($type) {
        // handle errors.
        if($type =="auth"){
            $this->Session->setFlash(__('Erro de validação do formulário. Deslogue e faça login novamente.'),'flash_error');
            throw new Exception( 'Erro de validação do formulário. Deslogue e faça login novamente.' );
        }elseif($type =="csrf"){
            $this->Session->setFlash(__('Erro de csrf contate o suporte.'),'flash_error');
            throw new Exception( 'Erro de csrf contate o suporte.' );
        }elseif($type =="get"){
            $this->Session->setFlash(__('Falha de requisição GET, contate o suporte.'),'flash_error');
            throw new Exception( 'Falha de requisição GET, contate o suporte.' );
        }elseif($type =="post"){
            $this->Session->setFlash(__('Falha de restrição POST, o suporte.'),'flash_error');
            throw new Exception( 'Falha de restrição POST, o suporte.' );
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
<?php

namespace Payum\Core\Tests\Request;

use Payum\Core\Request\GetToken;
use Payum\Core\Security\TokenInterface;
use PHPUnit\Framework\TestCase;

class GetTokenTest extends TestCase
{
    public function testShouldAllowGetHashSetInConstructor()
    {
        $request = new GetToken('theHash');

        $this->assertSame('theHash', $request->getHash());
    }

    public function testShouldAllowGetPreviouslySetToken()
    {
        /** @var TokenInterface $token */
        $token = $this->createMock(TokenInterface::class);

        $request = new GetToken('aHash');
        $request->setToken($token);

        $this->assertSame($token, $request->getToken());
    }
}


text:
int main()
{
	Engine engine;

	while (!engine.shouldClose())
		engine.tick();

	return 1;
}


text:
package org.opencloudb.backend;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.locks.ReentrantLock;

import org.apache.log4j.Logger;
import org.opencloudb.MycatServer;
import org.opencloudb.config.Alarms;
import org.opencloudb.heartbeat.DBHeartbeat;
import org.opencloudb.mysql.nio.handler.GetConnectionHandler;
import org.opencloudb.mysql.nio.handler.ResponseHandler;

public class PhysicalDBPool {
	public static final int BALANCE_NONE = 0;
	public static final int BALANCE_ALL_BACK = 1;
	public static final int BALANCE_ALL = 2;
	public static final int BALANCE_ALL_READ = 3;
	public static final int WRITE_ONLYONE_NODE = 0;
	public static final int WRITE_RANDOM_NODE = 1;
	public static final int WRITE_ALL_NODE = 2;
	protected static final Logger LOGGER = Logger
			.getLogger(PhysicalDBPool.class);
	private final String hostName;
	protected PhysicalDatasource[] writeSources;
	protected Map<Integer, PhysicalDatasource[]> readSources;
	protected volatile int activedIndex;
	protected volatile boolean initSuccess;
	protected final ReentrantLock switchLock = new ReentrantLock();
	private final Collection<PhysicalDatasource> allDs;
	private final int banlance;
	private final int writeType;
	private final Random random = new Random();
	private final Random wnrandom = new Random();
	private String[] schemas;

	public PhysicalDBPool(String name, PhysicalDatasource[] writeSources,
			Map<Integer, PhysicalDatasource[]> readSources, int balance,
			int writeType) {
		this.hostName = name;
		this.writeSources = writeSources;
		this.banlance = balance;
		this.writeType = writeType;
		Iterator<Map.Entry<Integer, PhysicalDatasource[]>> entryItor = readSources
				.entrySet().iterator();
		while (entryItor.hasNext()) {
			PhysicalDatasource[] values = entryItor.next().getValue();
			if (values.length == 0) {
				entryItor.remove();
			}
		}
		this.readSources = readSources;
		this.allDs = this.genAllDataSources();
		LOGGER.info("total resouces of dataHost " + this.hostName + " is :"
				+ allDs.size());
		setDataSourceProps();
	}

	public int getWriteType() {
		return writeType;
	}

	private void setDataSourceProps() {
		for (PhysicalDatasource ds : this.allDs) {
			ds.setDbPool(this);
		}
	}

	public PhysicalDatasource findDatasouce(BackendConnection exitsCon) {

		for (PhysicalDatasource ds : this.allDs) {
			if (ds.isReadNode() == exitsCon.isFromSlaveDB()) {
				if (ds.isMyConnection(exitsCon)) {
					return ds;
				}
			}
		}
		LOGGER.warn("can't find connection in pool " + this.hostName + " con:"
				+ exitsCon);
		return null;
	}

	public String getHostName() {
		return hostName;
	}

	/**
	 * all write datanodes
	 *
	 * @return
	 */
	public PhysicalDatasource[] getSources() {
		return writeSources;
	}

	public PhysicalDatasource getSource() {
		switch (writeType) {
		case WRITE_ONLYONE_NODE: {
			return writeSources[activedIndex];
		}
		case WRITE_RANDOM_NODE: {

			int index = Math.abs(wnrandom.nextInt()) % writeSources.length;
			PhysicalDatasource result = writeSources[index];
			if (!this.isAlive(result)) {
				// find all live nodes
				ArrayList<Integer> alives = new ArrayList<Integer>(
						writeSources.length - 1);
				for (int i = 0; i < writeSources.length; i++) {
					if (i != index) {
						if (this.isAlive(writeSources[i])) {
							alives.add(i);
						}
					}
				}
				if (alives.isEmpty()) {
					result = writeSources[0];
				} else {
					// random select one
					index = Math.abs(wnrandom.nextInt()) % alives.size();
					result = writeSources[alives.get(index)];

				}
			}
			if (LOGGER.isDebugEnabled()) {
				LOGGER.debug("select write source " + result.getName()
						+ " for dataHost:" + this.getHostName());
			}
			return result;
		}
		default: {
			throw new java.lang.IllegalArgumentException("writeType is "
					+ writeType + " ,so can't return one write datasource ");
		}
		}

	}

	public int getActivedIndex() {
		return activedIndex;
	}

	public boolean isInitSuccess() {
		return initSuccess;
	}

	public int next(int i) {
		if (checkIndex(i)) {
			return (++i == writeSources.length) ? 0 : i;
		} else {
			return 0;
		}
	}

	/**
	 * 鍒囨崲鏁版嵁婧�
	 */
	public boolean switchSource(int newIndex, boolean isAlarm, String reason) {
		if (this.writeType != PhysicalDBPool.WRITE_ONLYONE_NODE
				|| !checkIndex(newIndex)) {
			return false;
		}
		final ReentrantLock lock = this.switchLock;
		lock.lock();
		try {
			int current = activedIndex;
			if (current != newIndex) {
				// switch index
				activedIndex = newIndex;
				// init again
				this.init(activedIndex);
				// clear all connections
				this.getSources()[current].clearCons("switch datasource");
				// write log
				LOGGER.warn(switchMessage(current, newIndex, false, reason));
				return true;
			}
		} finally {
			lock.unlock();
		}
		return false;
	}

	private String switchMessage(int current, int newIndex, boolean alarm,
			String reason) {
		StringBuilder s = new StringBuilder();
		if (alarm) {
			s.append(Alarms.DATANODE_SWITCH);
		}
		s.append("[Host=").append(hostName).append(",result=[").append(current)
				.append("->");
		s.append(newIndex).append("],reason=").append(reason).append(']');
		return s.toString();
	}

	private int loop(int i) {
		return i < writeSources.length ? i : (i - writeSources.length);
	}

	public void init(int index) {
		if (!checkIndex(index)) {
			index = 0;
		}
		int active = -1;
		for (int i = 0; i < writeSources.length; i++) {
			int j = loop(i + index);
			if (initSource(j, writeSources[j])) {
				active = j;
				activedIndex = active;
				initSuccess = true;
				LOGGER.info(getMessage(active, " init success"));

				if (this.writeType == WRITE_ONLYONE_NODE) {
					// only init one write datasource
					MycatServer.getInstance().saveDataHostIndex(hostName,
							activedIndex);
					break;
				}
			}
		}
		if (!checkIndex(active)) {
			initSuccess = false;
			StringBuilder s = new StringBuilder();
			s.append(Alarms.DEFAULT).append(hostName).append(" init failure");
			LOGGER.error(s.toString());
		}
	}

	private boolean checkIndex(int i) {
		return i >= 0 && i < writeSources.length;
	}

	private String getMessage(int index, String info) {
		return new StringBuilder().append(hostName).append(" index:")
				.append(index).append(info).toString();
	}

	private boolean initSource(int index, PhysicalDatasource ds) {
		int initSize = ds.getConfig().getMinCon();
		LOGGER.info("init backend myqsl source ,create connections total "
				+ initSize + " for " + ds.getName() + " index :" + index);
		CopyOnWriteArrayList<BackendConnection> list = new CopyOnWriteArrayList<BackendConnection>();
		GetConnectionHandler getConHandler = new GetConnectionHandler(list,
				initSize);
		// long start=System.currentTimeMillis();
		// long timeOut=start+5000*1000L;

		for (int i = 0; i < initSize; i++) {
			try {
				ConnectionMeta conMeta = new ConnectionMeta(this.schemas[i
						% schemas.length], "utf8", -1, true);
				ds.getConnection(conMeta, getConHandler, null);
			} catch (Exception e) {
				LOGGER.warn(getMessage(index, " init connection error."), e);
			}
		}
		long timeOut = System.currentTimeMillis() + 60 * 1000;

		// waiting for finish
		while (!getConHandler.finished()
				&& (System.currentTimeMillis() < timeOut)) {
			try {
				Thread.sleep(200);

			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		LOGGER.info("init result :" + getConHandler.getStatusInfo());
		for (BackendConnection c : list) {
			c.release();
		}
		return !list.isEmpty();
	}

	public void doHeartbeat() {

		// 妫�煡鍐呴儴鏄惁鏈夎繛鎺ユ睜閰嶇疆淇℃伅
		if (writeSources == null || writeSources.length == 0) {
			return;
		}

		for (PhysicalDatasource source : this.allDs) {
			// 鍑嗗鎵ц蹇冭烦妫�祴
			if (source != null) {
				source.doHeartbeat();
			} else {
				StringBuilder s = new StringBuilder();
				s.append(Alarms.DEFAULT).append(hostName)
						.append(" current dataSource is null!");
				LOGGER.error(s.toString());
			}
		}
		// 璇诲簱鐨勫績璺虫娴�
		// todo
	}

	/**
	 * back physical connection heartbeat check
	 */
	public void heartbeatCheck(long ildCheckPeriod) {
		for (PhysicalDatasource ds : allDs) {
			// only readnode or all write node or writetype=WRITE_ONLYONE_NODE
			// and current write node will check
			if (ds != null
					&& (ds.getHeartbeat().getStatus() == DBHeartbeat.OK_STATUS)
					&& (ds.isReadNode()
							|| (this.writeType != WRITE_ONLYONE_NODE) || (this.writeType == WRITE_ONLYONE_NODE && ds == this
							.getSource()))) {
				ds.heatBeatCheck(ds.getConfig().getIdleTimeout(),
						ildCheckPeriod);
			}
		}
	}

	public void startHeartbeat() {
		for (PhysicalDatasource source : this.allDs) {
			source.startHeartbeat();
		}
	}

	public void stopHeartbeat() {
		for (PhysicalDatasource source : this.allDs) {
			source.stopHeartbeat();
		}
	}

	public void clearDataSources(String reason) {
		LOGGER.info("clear datasours of pool " + this.hostName);
		for (PhysicalDatasource source : this.allDs) {
			LOGGER.info("clear datasoure of pool  " + this.hostName + " ds:"
					+ source.getConfig());
			source.clearCons(reason);
			source.stopHeartbeat();
		}

	}

	public Collection<PhysicalDatasource> genAllDataSources() {
		LinkedList<PhysicalDatasource> allSources = new LinkedList<PhysicalDatasource>();
		for (PhysicalDatasource ds : writeSources) {
			if (ds != null) {
				allSources.add(ds);
			}
		}
		for (PhysicalDatasource[] dataSources : this.readSources.values()) {
			for (PhysicalDatasource ds : dataSources) {
				if (ds != null) {
					allSources.add(ds);
				}
			}
		}
		return allSources;
	}

	public Collection<PhysicalDatasource> getAllDataSources() {
		return this.allDs;
	}

	/**
	 * return connection for read balance
	 *
	 * @param handler
	 * @param attachment
	 * @param database
	 * @throws Exception
	 */
	public void getRWBanlanceCon(ConnectionMeta conMeta,
			ResponseHandler handler, Object attachment, String database)
			throws Exception {
		PhysicalDatasource theNode = null;
		ArrayList<PhysicalDatasource> okSources = null;
		switch (banlance) {
		case BALANCE_ALL_BACK: {// all read nodes and the standard by masters
			okSources = getAllActiveRWSources(false);
			theNode = randomSelect(okSources);
			break;
		}
		case BALANCE_ALL: {
			okSources = getAllActiveRWSources(true);
			theNode = randomSelect(okSources);
			break;
		}
		case BALANCE_ALL_READ: {
			okSources = getAllActiveReadSources();
			theNode = randomSelect(okSources);
			break;
		}
		case BALANCE_NONE:
		default:
			// return default write data source
			theNode = this.getSource();
		}
		if (LOGGER.isDebugEnabled()) {
			LOGGER.debug("select read source " + theNode.getName()
					+ " for dataHost:" + this.getHostName());
		}
		theNode.getConnection(conMeta, handler, attachment);
	}

	private PhysicalDatasource randomSelect(
			ArrayList<PhysicalDatasource> okSources) {
		if (okSources.isEmpty()) {
			return this.getSource();
		} else {
			int index = Math.abs(random.nextInt()) % okSources.size();
			return okSources.get(index);
		}

	}

	private boolean isAlive(PhysicalDatasource theSource) {
		return (theSource.getHeartbeat().getStatus() == DBHeartbeat.OK_STATUS);
	}

	/**
	 * return all backup write sources
	 *
	 * @return
	 */
	private ArrayList<PhysicalDatasource> getAllActiveRWSources(
			boolean includeCurWriteNode) {
		int curActive = activedIndex;
		ArrayList<PhysicalDatasource> okSources = new ArrayList<PhysicalDatasource>(
				this.allDs.size());
		for (int i = 0; i < this.writeSources.length; i++) {
			if (isAlive(writeSources[i])) {// write node is active
				if (i == curActive && includeCurWriteNode == false) {
					// not include cur active source
				} else {
					okSources.add(writeSources[i]);
				}
				if (!readSources.isEmpty()) {
					// check all slave nodes
					PhysicalDatasource[] allSlaves = this.readSources.get(i);
					if (allSlaves != null) {
						for (PhysicalDatasource slave : allSlaves) {
							if (isAlive(slave)) {
								okSources.add(slave);
							}
						}
					}
				}
			}

		}
		return okSources;
	}

	/**
	 * return all read sources
	 *
	 * @return
	 */
	private ArrayList<PhysicalDatasource> getAllActiveReadSources(){
		ArrayList<PhysicalDatasource> okSources = new ArrayList<PhysicalDatasource>(
				this.allDs.size());
		for (int i = 0; i < this.writeSources.length; i++) {
			if (isAlive(writeSources[i])) {// write node is active

				if (!readSources.isEmpty()) {
					// check all slave nodes
					PhysicalDatasource[] allSlaves = this.readSources.get(i);
					if (allSlaves != null) {
						for (PhysicalDatasource slave : allSlaves) {
							if (isAlive(slave)) {
								okSources.add(slave);
							}
						}
					}
				}
			}

		}
		return okSources;
	}

	public String[] getSchemas() {
		return schemas;
	}

	public void setSchemas(String[] mySchemas) {
		this.schemas = mySchemas;
	}

}


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
		 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<artifactId>spring-cloud-lattice-discovery</artifactId>
	<packaging>jar</packaging>
	<name>Spring Cloud Lattice Discovery</name>
	<description>Spring Cloud Lattice Discovery</description>

	<parent>
		<groupId>org.springframework.cloud</groupId>
		<artifactId>spring-cloud-lattice</artifactId>
		<version>1.0.0.BUILD-SNAPSHOT</version>
		<relativePath>..</relativePath>
	</parent>

	<dependencies>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-lattice-core</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-commons</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-config-client</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-netflix-core</artifactId>
		</dependency>
		<dependency>
			<groupId>com.netflix.ribbon</groupId>
			<artifactId>ribbon</artifactId>
		</dependency>
		<dependency>
			<groupId>com.netflix.ribbon</groupId>
			<artifactId>ribbon-core</artifactId>
		</dependency>
		<dependency>
			<groupId>com.netflix.ribbon</groupId>
			<artifactId>ribbon-loadbalancer</artifactId>
		</dependency>
		<dependency>
			<groupId>com.netflix.ribbon</groupId>
			<artifactId>ribbon-httpclient</artifactId>
		</dependency>
		<dependency>
			<groupId>com.netflix.archaius</groupId>
			<artifactId>archaius-core</artifactId>
		</dependency>
		<dependency>
			<groupId>org.cloudfoundry.receptor</groupId>
			<artifactId>receptor-client</artifactId>
		</dependency>
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<!-- Only needed at compile time -->
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

</project>


text:
package de.tudarmstadt.ukp.clarin.webanno.ui.mm;

import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.input.SAXBuilder;

import de.uhh.lt.webanno.mm.io.HiatTeiMetadata.Speaker;

public class SpeakerDetailsWindow extends ModalWindow {

    private static final long serialVersionUID = -6911254813496835955L;

    private final Speaker speaker;

    public SpeakerDetailsWindow(String id, Speaker spk) {
        super(id);

        speaker = spk;

        setInitialWidth(450);
        setInitialHeight(350);
        setResizable(true);
        setWidthUnit("px");
        setHeightUnit("px");
        setTitle("Speaker Details");

    }

    @Override
    public void show(IPartialPageRequestHandler aTarget) {

        setContent(new SpeakerDetailsWindowContent(getContentId(), this));

        super.show(aTarget);
    }

    public Speaker getSpeaker() {
        return speaker;
    }

    public static class SpeakerDetailsWindowContent extends Panel {

        public SpeakerDetailsWindowContent(String id, final SpeakerDetailsWindow window) {
            super(id);
            String speaker_xml = window.getSpeaker().xml_string;
            List<Pair<String, String>> key_value_pairs = parseXML(speaker_xml);
            add(new ListView<Pair<String, String>>("xmlelementcontainer", key_value_pairs) {
                private static final long serialVersionUID = 1L;
                @Override
                protected void populateItem(ListItem<Pair<String, String>> item) {
                    Pair<String, String> pair = item.getModelObject();
                    item.add(new Label("xmlelementname", pair.getKey() + ":"));
                    item.add(new Label("xmlelementtext", pair.getValue()));
                }
            });
        }

        /**
         *
         */
        private static final long serialVersionUID = 1L;

    }

    public static List<Pair<String, String>> parseXML(String xml){
        List<Pair<String, String>> result = new ArrayList<>();
        try {
            Reader r = new StringReader(xml);
            SAXBuilder saxBuilder = new SAXBuilder();
            Document document = saxBuilder.build(r);
            Element root = document.getRootElement();
            parseElement(root, result, "");
            r.close();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

    private static void parseElement(Element element, List<Pair<String, String>> currentlist, String prefix){
        String key = element.getName();
        if("langKnown".equals(key)){
            parseLang(element, currentlist);
            return;
        }
        if("persName".equals(key))
            key = "Name";
        if("birth".equals(key))
            prefix = "Birth ";
        String val = element.getTextNormalize();
        if(!StringUtils.isEmpty(val))
            currentlist.add(Pair.of(String.format("%s%s", prefix, StringUtils.capitalize(key)), val));
        for(Element child : element.getChildren())
            parseElement(child, currentlist, prefix);
    }

    private static void parseLang(Element langKnown, List<Pair<String, String>> currentlist){
        String key = String.format("Language (%s)", langKnown.getAttributeValue("level"));
        String val = String.format("%s (%s)", langKnown.getTextNormalize(),  langKnown.getAttributeValue("tag"));
        currentlist.add(Pair.of(StringUtils.capitalize(key), val));

    }

}