}
// Subscribe the service to the bus.
bus.subscribe(svcName, (MessageCallback) svc);
RolesRequiredRule rule = null;
if (clazz.isAnnotationPresent(RequireRoles.class)) {
rule = new RolesRequiredRule(clazz.getAnnotation(RequireRoles.class).value(), bus);
}
else if (clazz.isAnnotationPresent(RequireAuthentication.class)) {
rule = new RolesRequiredRule(new HashSet<Object>(), bus);
}
if (rule != null) {
bus.addRule(svcName, rule);
}
}
if (svc == null) {
svc = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(MessageBus.class).toInstance(bus);
bind(RequestDispatcher.class).toInstance(dispatcher);
// Add any extension bindings.
for (Map.Entry<Class, Provider> entry : extensionBindings.entrySet()) {
bind(entry.getKey()).toProvider(entry.getValue());
}
}
}).getInstance(loadClass);
}
Map<String, MessageCallback> epts = new HashMap<String, MessageCallback>();
// we scan for endpoints
for (final Method method : loadClass.getDeclaredMethods()) {
if (method.isAnnotationPresent(Endpoint.class)) {
epts.put(method.getName(), method.getReturnType() == Void.class ?
new EndpointCallback(svc, method) :
new ConversationalEndpointCallback(svc, method, bus));
}
}
if (!epts.isEmpty()) {
bus.subscribe(loadClass.getSimpleName() + ":RPC", new RemoteServiceCallback(epts));
}
}
else if (loadClass.isAnnotationPresent(ExposeEntity.class)) {
log.info("Marked " + loadClass + " as serializable.");
loadedComponents.add(loadClass.getName());
serializableTypes.add(loadClass);
}
}
}
);
}
else {
log.info("auto-scan disabled.");
}
String requireAuthenticationForAll = "errai.require_authentication_for_all";
if (hasProperty(requireAuthenticationForAll) && "true".equals(getProperty(requireAuthenticationForAll))) {
log.info("authentication for all requests required, adding rule ... ");
bus.addRule("AuthorizationService", new RolesRequiredRule(new HashSet<Object>(), bus));
}
ConfigUtil.cleanupStartupTempFiles();
log.info("running deferred configuration tasks ...");