Search in sources :

Example 1 with ConfiguredObjectRecordConverter

use of org.apache.qpid.server.store.ConfiguredObjectRecordConverter in project qpid-broker-j by apache.

the class AbstractVirtualHostNode method getInitialRecords.

protected final ConfiguredObjectRecord[] getInitialRecords() throws IOException {
    ConfiguredObjectRecordConverter converter = new ConfiguredObjectRecordConverter(getModel());
    Collection<ConfiguredObjectRecord> records = new ArrayList<>(converter.readFromJson(VirtualHost.class, this, getInitialConfigReader()));
    if (!records.isEmpty()) {
        ConfiguredObjectRecord vhostRecord = null;
        for (ConfiguredObjectRecord record : records) {
            if (record.getType().equals(VirtualHost.class.getSimpleName())) {
                vhostRecord = record;
                break;
            }
        }
        if (vhostRecord != null) {
            records.remove(vhostRecord);
            vhostRecord = enrichInitialVirtualHostRootRecord(vhostRecord);
            records.add(vhostRecord);
        } else {
            // this should be impossible as the converter should always generate a parent record
            throw new IllegalConfigurationException("Somehow the initial configuration has records but " + "not a VirtualHost. This must be a coding error in Qpid");
        }
        addStandardExchangesIfNecessary(records, vhostRecord);
        enrichWithAuditInformation(records);
    }
    return records.toArray(new ConfiguredObjectRecord[records.size()]);
}
Also used : ConfiguredObjectRecordConverter(org.apache.qpid.server.store.ConfiguredObjectRecordConverter) ArrayList(java.util.ArrayList) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) VirtualHost(org.apache.qpid.server.model.VirtualHost) NonStandardVirtualHost(org.apache.qpid.server.virtualhost.NonStandardVirtualHost)

Example 2 with ConfiguredObjectRecordConverter

use of org.apache.qpid.server.store.ConfiguredObjectRecordConverter in project qpid-broker-j by apache.

the class AbstractSystemConfig method convertToConfigurationRecords.

private ConfiguredObjectRecord[] convertToConfigurationRecords(final String initialConfigurationLocation) throws IOException {
    ConfiguredObjectRecordConverter converter = new ConfiguredObjectRecordConverter(getModel());
    Reader reader;
    try {
        URL url = new URL(initialConfigurationLocation);
        reader = new InputStreamReader(url.openStream());
    } catch (MalformedURLException e) {
        reader = new FileReader(initialConfigurationLocation);
    }
    try {
        Collection<ConfiguredObjectRecord> records = converter.readFromJson(null, this, reader);
        return records.toArray(new ConfiguredObjectRecord[records.size()]);
    } finally {
        reader.close();
    }
}
Also used : ConfiguredObjectRecordConverter(org.apache.qpid.server.store.ConfiguredObjectRecordConverter) MalformedURLException(java.net.MalformedURLException) InputStreamReader(java.io.InputStreamReader) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) FileReader(java.io.FileReader) FileReader(java.io.FileReader) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) URL(java.net.URL)

Aggregations

ConfiguredObjectRecord (org.apache.qpid.server.store.ConfiguredObjectRecord)2 ConfiguredObjectRecordConverter (org.apache.qpid.server.store.ConfiguredObjectRecordConverter)2 FileReader (java.io.FileReader)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)1 VirtualHost (org.apache.qpid.server.model.VirtualHost)1 NonStandardVirtualHost (org.apache.qpid.server.virtualhost.NonStandardVirtualHost)1