Search in sources :

Example 16 with QpidServiceLoader

use of org.apache.qpid.server.plugin.QpidServiceLoader in project qpid-broker-j by apache.

the class PluginClassProviderAction method perform.

@Override
public Object perform(Map<String, Object> request, Broker broker) {
    try {
        String className = (String) request.get("plugin");
        QpidServiceLoader serviceLoader = new QpidServiceLoader();
        final Class<Pluggable> clazz = (Class<Pluggable>) Class.forName("org.apache.qpid.server.plugin." + className);
        List<String> values = new ArrayList<String>();
        for (Pluggable instance : serviceLoader.instancesOf(clazz)) {
            values.add(instance.getType());
        }
        return values;
    } catch (ClassNotFoundException e) {
        return Collections.emptyList();
    }
}
Also used : QpidServiceLoader(org.apache.qpid.server.plugin.QpidServiceLoader) Pluggable(org.apache.qpid.server.plugin.Pluggable) ArrayList(java.util.ArrayList)

Example 17 with QpidServiceLoader

use of org.apache.qpid.server.plugin.QpidServiceLoader in project qpid-broker-j by apache.

the class MimeContentConverterRegistry method buildClassToMimeConverters.

private static Multimap<Class, ObjectToMimeContentConverter> buildClassToMimeConverters() {
    Multimap<Class, ObjectToMimeContentConverter> classToMineConverters = HashMultimap.create();
    Iterable<ObjectToMimeContentConverter> objectToMimeContentConverters = new QpidServiceLoader().instancesOf(ObjectToMimeContentConverter.class);
    for (ObjectToMimeContentConverter converter : objectToMimeContentConverters) {
        Class objectClass = converter.getObjectClass();
        for (ObjectToMimeContentConverter existing : classToMineConverters.get(objectClass)) {
            if (existing.getRank() == converter.getRank()) {
                LOGGER.warn("MIME converter for object class {} has two or more implementations" + " with the same rank {}. It is undefined which one will be used." + " Implementations are: {} {} ", existing.getObjectClass().getName(), existing.getRank(), existing.getClass().getName(), converter.getClass().getName());
            }
        }
        classToMineConverters.put(objectClass, converter);
    }
    classToMineConverters.put(Void.class, new IdentityConverter());
    return ImmutableMultimap.copyOf(classToMineConverters);
}
Also used : QpidServiceLoader(org.apache.qpid.server.plugin.QpidServiceLoader)

Example 18 with QpidServiceLoader

use of org.apache.qpid.server.plugin.QpidServiceLoader in project qpid-broker-j by apache.

the class AmqpPortImpl method getAllAvailableTransportCombinations.

@SuppressWarnings("unused")
public static Collection<String> getAllAvailableTransportCombinations() {
    Set<Set<Transport>> combinations = new HashSet<>();
    for (TransportProviderFactory providerFactory : (new QpidServiceLoader()).instancesOf(TransportProviderFactory.class)) {
        combinations.addAll(providerFactory.getSupportedTransports());
    }
    Set<String> combinationsAsString = new HashSet<>(combinations.size());
    ObjectMapper mapper = new ObjectMapper();
    for (Set<Transport> combination : combinations) {
        try (StringWriter writer = new StringWriter()) {
            mapper.writeValue(writer, combination);
            combinationsAsString.add(writer.toString());
        } catch (IOException e) {
            throw new IllegalArgumentException("Unexpected IO Exception generating JSON string", e);
        }
    }
    return Collections.unmodifiableSet(combinationsAsString);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) QpidServiceLoader(org.apache.qpid.server.plugin.QpidServiceLoader) IOException(java.io.IOException) StringWriter(java.io.StringWriter) TransportProviderFactory(org.apache.qpid.server.plugin.TransportProviderFactory) AcceptingTransport(org.apache.qpid.server.transport.AcceptingTransport) Transport(org.apache.qpid.server.model.Transport) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) HashSet(java.util.HashSet)

Example 19 with QpidServiceLoader

use of org.apache.qpid.server.plugin.QpidServiceLoader in project qpid-broker-j by apache.

the class AbstractVirtualHost method registerSystemNodes.

private void registerSystemNodes() {
    QpidServiceLoader qpidServiceLoader = new QpidServiceLoader();
    Iterable<SystemNodeCreator> factories = qpidServiceLoader.instancesOf(SystemNodeCreator.class);
    for (SystemNodeCreator creator : factories) {
        creator.register(_systemNodeRegistry);
    }
}
Also used : SystemNodeCreator(org.apache.qpid.server.plugin.SystemNodeCreator) QpidServiceLoader(org.apache.qpid.server.plugin.QpidServiceLoader)

Example 20 with QpidServiceLoader

use of org.apache.qpid.server.plugin.QpidServiceLoader in project qpid-broker-j by apache.

the class AbstractVirtualHostNode method createPreferenceStore.

@Override
public PreferenceStore createPreferenceStore() {
    final Map<String, PreferenceStoreFactoryService> preferenceStoreFactories = new QpidServiceLoader().getInstancesByType(PreferenceStoreFactoryService.class);
    String preferenceStoreType;
    PreferenceStoreAttributes preferenceStoreAttributes = getPreferenceStoreAttributes();
    Map<String, Object> attributes;
    if (preferenceStoreAttributes == null) {
        preferenceStoreType = NoopPreferenceStoreFactoryService.TYPE;
        attributes = Collections.emptyMap();
    } else {
        preferenceStoreType = preferenceStoreAttributes.getType();
        attributes = preferenceStoreAttributes.getAttributes();
    }
    final PreferenceStoreFactoryService preferenceStoreFactory = preferenceStoreFactories.get(preferenceStoreType);
    return preferenceStoreFactory.createInstance(this, attributes);
}
Also used : QpidServiceLoader(org.apache.qpid.server.plugin.QpidServiceLoader) PreferenceStoreFactoryService(org.apache.qpid.server.store.preferences.PreferenceStoreFactoryService) NoopPreferenceStoreFactoryService(org.apache.qpid.server.store.preferences.NoopPreferenceStoreFactoryService) PreferenceStoreAttributes(org.apache.qpid.server.store.preferences.PreferenceStoreAttributes) ManagedObject(org.apache.qpid.server.model.ManagedObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject)

Aggregations

QpidServiceLoader (org.apache.qpid.server.plugin.QpidServiceLoader)22 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)3 ManagedObject (org.apache.qpid.server.model.ManagedObject)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 IOException (java.io.IOException)2 List (java.util.List)2 Map (java.util.Map)2 UUID (java.util.UUID)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 ContainerType (org.apache.qpid.server.model.ContainerType)2 DynamicModel (org.apache.qpid.server.model.DynamicModel)2 Protocol (org.apache.qpid.server.model.Protocol)2 Transport (org.apache.qpid.server.model.Transport)2 ConfiguredObjectRegistration (org.apache.qpid.server.plugin.ConfiguredObjectRegistration)2 File (java.io.File)1 FileReader (java.io.FileReader)1 StringWriter (java.io.StringWriter)1 Principal (java.security.Principal)1