/** * The name to use when declaring a field in Objective C cross-compilation. * * @return objectiveCTypeName, if one was passed in explicitly. otherwise, the objectiveCTypeName * of the default Collection or Map type. */ @Override public String deriveObjectiveCTypeName() { String objectiveCTypeName = super.getObjectiveCTypeName(); return objectiveCTypeName != null ? objectiveCTypeName : TypeRegistry.getDefaultCollectionOrMapType(isMap).getObjectiveCTypeName(); }
/** * The name to use when declaring a field in C# cross-compilation. * * @return cSharpTypeName, if one was passed in explicitly. otherwise, the cSharpTypeName of the * default Collection or Map type. */ @Override public String deriveCSharpTypeName() { String cSharpTypeName = super.getCSharpTypeName(); return cSharpTypeName != null ? cSharpTypeName : TypeRegistry.getDefaultCollectionOrMapType(isMap).getCSharpTypeName(); }
@Override public void registerExtension(Extension extension) { String xp = extension.getExtensionPoint(); if (xp.equals("types")) { typeRegistry.registerExtension(extension); } else if (xp.equals("default_layout")) { registerTypeWidgetExtension(extension); } }
private void subscribeServices(final BeanManager beanManager, final MessageBus bus) { for (final Map.Entry<AnnotatedType, List<AnnotatedMethod>> entry : managedTypes.getServiceMethods().entrySet()) { final Class<?> type = entry.getKey().getJavaClass(); for (final AnnotatedMethod method : entry.getValue()) { final Service svc = method.getAnnotation(Service.class); final String svcName = svc.value().equals("") ? method.getJavaMember().getName() : svc.value(); final Method callMethod = method.getJavaMember(); bus.subscribe( svcName, new MessageCallback() { @Override public void callback(final Message message) { final Object targetBean = CDIServerUtil.lookupBean(beanManager, type); try { callMethod.invoke(targetBean, message); } catch (Exception e) { ErrorHelper.sendClientError(bus, message, "Error dispatching service", e); } } }); } } /** * Due to the lack of contract in CDI guaranteeing when beans will be available, we use an * executor to search for the beans every 100ms until it finds them. Or, after a 25 seconds, * blow up if they don't become available. */ final ScheduledExecutorService startupScheduler = Executors.newScheduledThreadPool(1); startupScheduler.scheduleAtFixedRate( new StartupCallback(beanManager, bus, startupScheduler, 25), 0, 100, TimeUnit.MILLISECONDS); for (final Class<?> remoteInterfaceType : managedTypes.getRemoteInterfaces()) { createRPCScaffolding(remoteInterfaceType, bus, beanManager); } }
public Subtype() { id = TypeRegistry.registerType(this); }
protected IntegerType() { id = TypeRegistry.registerType(this); }
public Collection<Type> getTypes() { Collection<Type> types = new ArrayList<Type>(); types.addAll(typeRegistry.getTypes()); return types; }
public boolean hasType(String typeName) { return typeRegistry.hasType(typeName); }
public Type getType(String typeName) { return typeRegistry.getType(typeName); }
/** * Register managed beans as Errai services * * @param event - * @param <T> - */ @SuppressWarnings("UnusedDeclaration") public <T> void observeResources(@Observes final ProcessAnnotatedType<T> event) { final AnnotatedType<T> type = event.getAnnotatedType(); for (final Annotation a : type.getJavaClass().getAnnotations()) { if (a.annotationType().isAnnotationPresent(Qualifier.class)) { beanQualifiers.put(a.annotationType().getName(), a); } } // services if (type.isAnnotationPresent(Service.class)) { log.debug("discovered Errai annotation on type: " + type); boolean isRpc = false; final Class<T> javaClass = type.getJavaClass(); for (final Class<?> intf : javaClass.getInterfaces()) { isRpc = intf.isAnnotationPresent(Remote.class); if (isRpc) { if (!managedTypes.getRemoteInterfaces().contains(intf)) { managedTypes.addRemoteInterface(intf); } } } if (!isRpc) { managedTypes.addServiceEndpoint(type); } } else { for (final AnnotatedMethod method : type.getMethods()) { if (method.isAnnotationPresent(Service.class)) { managedTypes.addServiceMethod(type, method); } } } // veto on client side implementations that contain CDI annotations // (i.e. @Observes) Otherwise Weld might try to invoke on them if (vetoClasses.contains(type.getJavaClass().getName()) || (type.getJavaClass().getPackage().getName().contains("client") && !type.getJavaClass().isInterface())) { event.veto(); } /** We must scan for Event consumer injection points to build the tables */ final Class clazz = type.getJavaClass(); for (final Field f : clazz.getDeclaredFields()) { if (f.isAnnotationPresent(Inject.class) && f.isAnnotationPresent(ObserverModel.class)) { processEventInjector(f.getType(), f.getGenericType(), f.getAnnotations()); } } for (final Method m : clazz.getDeclaredMethods()) { if (m.isAnnotationPresent(Inject.class) && m.isAnnotationPresent(ObserverModel.class)) { final Class<?>[] parameterTypes = m.getParameterTypes(); for (int i = 0, parameterTypesLength = parameterTypes.length; i < parameterTypesLength; i++) { final Class<?> parmType = parameterTypes[i]; processEventInjector( parmType, m.getGenericParameterTypes()[i], m.getParameterAnnotations()[i]); } } } for (final Constructor c : clazz.getDeclaredConstructors()) { if (c.isAnnotationPresent(Inject.class) && c.isAnnotationPresent(ObserverModel.class)) { final Class<?>[] parameterTypes = c.getParameterTypes(); for (int i = 0, parameterTypesLength = parameterTypes.length; i < parameterTypesLength; i++) { final Class<?> parmType = parameterTypes[i]; processEventInjector( parmType, c.getGenericParameterTypes()[i], c.getParameterAnnotations()[i]); } } } }
private void assertIsNodeModule(String id, String path) { Module module = typeRegistry.getModule(id); assertThat(module.getPath().toString()).isEqualTo(path); assertThat(module.getType()).isEqualTo(Module.Type.NODE); }