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();
}
}
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);
}
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);
}
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);
}
}
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);
}
Aggregations