List of usage examples for java.lang Class getCanonicalName
public String getCanonicalName()
From source file:org.nuunframework.spring.SpringModule.java
@SuppressWarnings("unchecked") private void bindFromApplicationContext() { boolean debugEnabled = logger.isDebugEnabled(); ConfigurableListableBeanFactory currentBeanFactory = this.beanFactory; do {// ww w .j a va 2 s.c o m for (String beanName : currentBeanFactory.getBeanDefinitionNames()) { BeanDefinition beanDefinition = currentBeanFactory.getMergedBeanDefinition(beanName); if (!beanDefinition.isAbstract()) { Class<?> beanClass = classFromString(beanDefinition.getBeanClassName()); if (beanClass == null) { logger.warn("Cannot bind spring bean " + beanName + " because its class " + beanDefinition.getBeanClassName() + " failed to load"); return; } SpringBeanDefinition springBeanDefinition = new SpringBeanDefinition(beanName, currentBeanFactory); // Adding bean with its base type addBeanDefinition(beanClass, springBeanDefinition); // Adding bean with its parent type if enabled Class<?> parentClass = beanClass.getSuperclass(); if (parentClass != null && parentClass != Object.class) addBeanDefinition(parentClass, springBeanDefinition); // Adding bean with its immediate interfaces if enabled for (Class<?> i : beanClass.getInterfaces()) addBeanDefinition(i, springBeanDefinition); } } BeanFactory factory = currentBeanFactory.getParentBeanFactory(); if (factory != null) { if (factory instanceof ConfigurableListableBeanFactory) currentBeanFactory = (ConfigurableListableBeanFactory) factory; else { logger.info( "Cannot go up further in the bean factory hierarchy, parent bean factory doesn't implement ConfigurableListableBeanFactory"); currentBeanFactory = null; } } else currentBeanFactory = null; } while (currentBeanFactory != null); for (Map.Entry<Class<?>, Map<String, SpringBeanDefinition>> entry : this.beanDefinitions.entrySet()) { Class<?> type = entry.getKey(); Map<String, SpringBeanDefinition> definitions = entry.getValue(); // Bind by name for each bean of this type and by type if there is no ambiguity for (SpringBeanDefinition candidate : definitions.values()) { if (debugEnabled) logger.info("Binding spring bean " + candidate.getName() + " by name and type " + type.getCanonicalName()); bind(type).annotatedWith(Names.named(candidate.getName())).toProvider( new ByNameSpringContextProvider(type, candidate.getName(), candidate.getBeanFactory())); } } }
From source file:info.archinnov.achilles.internal.metadata.parsing.EmbeddedIdParser.java
private void checkForDefaultConstructor(Class<?> embeddedIdClass) { @SuppressWarnings({ "rawtypes", "unchecked" }) Set<Constructor> defaultConstructors = getAllConstructors(embeddedIdClass, withParametersCount(0)); Validator.validateBeanMappingFalse(defaultConstructors.isEmpty(), "The @EmbeddedId class '%s' should have a public default constructor", embeddedIdClass.getCanonicalName()); }
From source file:it.cilea.osd.jdyna.util.AnagraficaUtils.java
private <P extends Property<TP>, TP extends PropertiesDefinition> void toXML(PrintWriter writer, List<P> proprietaList, Class<P> proprietaClass) { for (P proprieta : proprietaList) { writer.print(" <bean id=\"" + proprietaClass.getSimpleName() + proprieta.getId() + "\" class=\"" + proprietaClass.getCanonicalName() + "\">\n"); writer.print(" <property name=\"tipologia\" value=\"" + proprieta.getTypo().getShortName() + "\" />\n"); writer.print(" <property name=\"posizione\" value=\"" + proprieta.getPositionDef() + "\" />\n"); Class valoreClass = proprieta.getTypo().getRendering().getValoreClass(); writer.print(" <property name=\"valore\">\n"); writer.print(" <bean class=\"" + valoreClass.getCanonicalName() + "\">\n"); writer.print(" <property name=\"real\">\n"); PropertyEditor propertyEditor = valorePropertyEditors .get(proprieta.getTypo().getRendering().getValoreClass()); propertyEditor.setValue(proprieta.getValue()); writer.print(/* w w w . ja v a2s . c o m*/ " <value><![CDATA[" + propertyEditor.getAsText() + "]]></value>\n"); writer.print(" </property>\n"); writer.print(" </bean>\n"); writer.print(" </property>\n"); writer.print(" </bean>\n"); } }
From source file:it.cilea.osd.jdyna.web.controller.ExportConfigurazioneAnagrafica.java
/** * Metodo di supporto per esportare un'area nella sua "bean definition". Le * tipologie di proprieta' mascherate sono referenziate localmente (bean * ref)// w ww. j ava 2 s .c o m * * @param writer * @param area */ private void toXML(PrintWriter writer, H area) { Class<H> areaClass = boxClass; writer.print(" <bean id=\"" + areaClass.getSimpleName() + area.getId() + "\" class=\"" + areaClass.getCanonicalName() + "\">\n"); writer.print(" <property name=\"title\" value=\"" + area.getTitle() + "\" />\n"); writer.print(" <property name=\"priorita\" value=\"" + area.getPriority() + "\" />\n"); writer.print(" <property name=\"maschera\">\n" + " <list>\n"); for (Containable tip : area.getMask()) { writer.print(" <ref local=\"" + tip.getShortName() + tpClass.getSimpleName() + "\" />\n"); } writer.print(" </list>\n"); writer.print(" </property>\n"); writer.print(" </bean>\n\n"); }
From source file:com.sun.socialsite.business.impl.JPAListenerManagerImpl.java
/** * {@inheritDoc}/* w w w . jav a2s.c o m*/ */ public void addListener(Class entityClass, Object listener) { Collection<Object> listenersForClass = listenersMap.get(entityClass); if (listenersForClass == null) { listenersMap.putIfAbsent(entityClass, new ConcurrentLinkedQueue<Object>()); listenersForClass = listenersMap.get(entityClass); } listenersForClass.add(listener); log.debug(String.format("addListener(%s, %s): listenersForClass.size=%d", entityClass.getCanonicalName(), listener, listenersForClass.size())); }
From source file:eu.eubrazilcc.lvl.core.xml.GbSeqXmlBinder.java
@Override @SuppressWarnings("unchecked") protected <T> JAXBElement<T> createType(final T obj) { Object element = null;//from w ww .j a v a 2 s .c o m Class<? extends Object> clazz = obj.getClass(); if (clazz.equals(GBSet.class)) { element = GBSEQ_XML_FACTORY.createGBSet(); } else if (clazz.equals(GBSeq.class)) { element = GBSEQ_XML_FACTORY.createGBSeq(); } else { throw new IllegalArgumentException("Unsupported type: " + clazz.getCanonicalName()); } return (JAXBElement<T>) element; }
From source file:me.st28.flexseries.flexcore.cookie.CookieManager.java
/** * Sets a cookie value for a player./*from w ww .j ava 2 s .c o m*/ * * @param userId The ID of the user to set the value for. * @param value The value to set for the player. * @param plugin The plugin that owns the cookie. * @param identifier The identifier of the cookie (unique per-plugin). */ public final void setValue(String userId, String value, Class<? extends FlexPlugin> plugin, String identifier) { Validate.notNull(userId, "User ID cannot be null."); Validate.notNull(plugin, "Plugin cannot be null."); Validate.notNull(identifier, "Identifier cannot be null."); Map<String, String> cookies = loadedCookies.get(userId); if (cookies == null) { loadedCookies.put(userId, cookies = new HashMap<>()); } cookies.put(plugin.getCanonicalName() + "-" + identifier, value); }
From source file:com.payu.ratel.register.ServiceRegisterPostProcessor.java
private Class<?> getFirstInterfaceOrDefined(Object bean, Class defInterface) { Class<?>[] interfaces = bean.getClass().getInterfaces(); for (Class<?> clazz : interfaces) { if (defInterface == null) { return clazz; } else {//from ww w . ja v a 2s. c o m if (clazz.equals(defInterface)) { return clazz; } } } throw new PublishException(bean.getClass().getCanonicalName() + " does not implement interface " + defInterface.getCanonicalName()); }
From source file:io.nuun.plugin.spring.SpringModule.java
@SuppressWarnings({ "unchecked", "rawtypes" }) private void bindFromApplicationContext() { boolean debugEnabled = logger.isDebugEnabled(); ConfigurableListableBeanFactory currentBeanFactory = beanFactory; do {/* w ww.j av a2 s . co m*/ for (String beanName : currentBeanFactory.getBeanDefinitionNames()) { BeanDefinition beanDefinition = currentBeanFactory.getMergedBeanDefinition(beanName); if (!beanDefinition.isAbstract()) { Class<?> beanClass = classFromString(beanDefinition.getBeanClassName()); if (beanClass == null) { logger.warn("Cannot bind spring bean " + beanName + " because its class " + beanDefinition.getBeanClassName() + " failed to load"); return; } SpringBeanDefinition springBeanDefinition = new SpringBeanDefinition(beanName, currentBeanFactory); // Adding bean with its base type addBeanDefinition(beanClass, springBeanDefinition); // Adding bean with its parent type if enabled Class<?> parentClass = beanClass.getSuperclass(); if (parentClass != null && parentClass != Object.class) { addBeanDefinition(parentClass, springBeanDefinition); } // Adding bean with its immediate interfaces if enabled for (Class<?> i : beanClass.getInterfaces()) { addBeanDefinition(i, springBeanDefinition); } } } BeanFactory factory = currentBeanFactory.getParentBeanFactory(); if (factory != null) { if (factory instanceof ConfigurableListableBeanFactory) { currentBeanFactory = (ConfigurableListableBeanFactory) factory; } else { logger.info( "Cannot go up further in the bean factory hierarchy, parent bean factory doesn't implement ConfigurableListableBeanFactory"); currentBeanFactory = null; } } else { currentBeanFactory = null; } } while (currentBeanFactory != null); for (Map.Entry<Class<?>, Map<String, SpringBeanDefinition>> entry : beanDefinitions.entrySet()) { Class<?> type = entry.getKey(); Map<String, SpringBeanDefinition> definitions = entry.getValue(); // Bind by name for each bean of this type and by type if there is no ambiguity for (SpringBeanDefinition candidate : definitions.values()) { if (debugEnabled) { logger.info("Binding spring bean " + candidate.getName() + " by name and type " + type.getCanonicalName()); } bind(type).annotatedWith(Names.named(candidate.getName())).toProvider( new ByNameSpringContextProvider(type, candidate.getName(), candidate.getBeanFactory())); } } }
From source file:com.ryantenney.metrics.spring.MetricAnnotationBeanPostProcessor.java
private com.codahale.metrics.Metric getMetric(MetricRegistry metricRegistry, Class<?> type, String metricName) { com.codahale.metrics.Metric metric;// www. ja va 2 s .c o m if (Meter.class == type) { metric = metrics.meter(metricName); } else if (Timer.class == type) { metric = metrics.timer(metricName); } else if (Counter.class == type) { metric = metrics.counter(metricName); } else if (Histogram.class == type) { metric = metrics.histogram(metricName); } else { throw new IllegalArgumentException("Invalid @Metric type " + type.getCanonicalName()); } return metric; }