List of usage examples for java.lang Class getCanonicalName
public String getCanonicalName()
From source file:info.archinnov.achilles.helper.EntityIntrospector.java
public Field getInheritedPrivateFields(Class<?> type, Class<?> annotation) { log.debug("Find private field from hierarchy with annotation {} for entity class {}", annotation.getCanonicalName(), type.getCanonicalName()); Class<?> i = type;/*from w ww. ja v a2 s . co m*/ while (i != null && i != Object.class) { for (Field declaredField : i.getDeclaredFields()) { if (filter.matches(declaredField, annotation)) { log.trace("Found inherited private field : {}", declaredField); return declaredField; } } i = i.getSuperclass(); } return null; }
From source file:org.zlogic.vogon.web.TomcatConfigurer.java
/** * Configures SSL for Tomcat container// ww w . j av a 2 s.c om * * @param container ConfigurableEmbeddedServletContainer instance to * configure */ private void configureSSL(ConfigurableEmbeddedServletContainer container) { if (serverTypeDetector.getKeystoreFile().isEmpty() || serverTypeDetector.getKeystorePassword().isEmpty()) { log.debug(messages.getString("KEYSTORE_FILE_OR_PASSWORD_NOT_DEFINED")); return; } log.info(MessageFormat.format(messages.getString("USING_KEYSTORE_WITH_PASSWORD"), new Object[] { serverTypeDetector.getKeystoreFile(), serverTypeDetector.getKeystorePassword().replaceAll(".{1}", "*") })); //NOI18N Object connector; Class connectorClass = null; try { log.debug(messages.getString("CONFIGURING_CONNECTOR")); connectorClass = getClass().getClassLoader().loadClass("org.apache.catalina.connector.Connector"); //NOI18N connector = connectorClass.newInstance(); connectorClass.getMethod("setPort", Integer.TYPE).invoke(connector, 8443); //NOI18N connectorClass.getMethod("setSecure", Boolean.TYPE).invoke(connector, true); //NOI18N connectorClass.getMethod("setScheme", String.class).invoke(connector, "https"); //NOI18N connectorClass.getMethod("setURIEncoding", String.class).invoke(connector, utf8Charset.name()); //NOI18N } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException | IllegalArgumentException | InvocationTargetException ex) { throw new RuntimeException(messages.getString("CANNOT_CONFIGURE_CONNECTOR"), ex); } Object proto; try { log.debug(messages.getString("CONFIGURING_PROTOCOLHANDLER_PARAMETERS")); proto = connectorClass.getMethod("getProtocolHandler").invoke(connector); //NOI18N Class protoClass = proto.getClass(); log.debug(java.text.MessageFormat.format(messages.getString("CONFIGURING_PROTOCOLHANDLER_CLASS"), new Object[] { protoClass.getCanonicalName() })); protoClass.getMethod("setSSLEnabled", Boolean.TYPE).invoke(proto, true); //NOI18N protoClass.getMethod("setKeystorePass", String.class).invoke(proto, serverTypeDetector.getKeystorePassword()); //NOI18N protoClass.getMethod("setKeystoreType", String.class).invoke(proto, "JKS"); //NOI18N protoClass.getMethod("setKeyAlias", String.class).invoke(proto, "vogonkey"); //NOI18N protoClass.getMethod("setKeystoreFile", String.class).invoke(proto, new File(serverTypeDetector.getKeystoreFile()).getAbsolutePath()); //NOI18N } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { throw new RuntimeException(messages.getString("CANNOT_CONFIGURE_PROTOCOLHANDLER"), ex); } try { log.debug(messages.getString("ADDING_CONNECTOR_TO_TOMCATEMBEDDEDSERVLETCONTAINERFACTORY")); Object connectors = Array.newInstance(connectorClass, 1); Array.set(connectors, 0, connector); container.getClass().getMethod("addAdditionalTomcatConnectors", connectors.getClass()).invoke(container, connectors); //NOI18N } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { throw new RuntimeException( messages.getString("CANNOT_ADD_CONNECTOR_TO_TOMCATEMBEDDEDSERVLETCONTAINERFACTORY"), ex); } }
From source file:info.archinnov.achilles.helper.EntityIntrospector.java
public <T> Pair<ConsistencyLevel, ConsistencyLevel> findConsistencyLevels(Class<T> entity, AchillesConsistencyLevelPolicy policy) { log.debug("Find consistency levels for entity class {}", entity.getCanonicalName()); ConsistencyLevel defaultGlobalRead = getDefaultGlobalReadConsistency(policy); ConsistencyLevel defaultGlobalWrite = getDefaultGlobalWriteConsistency(policy); Consistency clevel = entity.getAnnotation(Consistency.class); if (clevel != null) { defaultGlobalRead = clevel.read(); defaultGlobalWrite = clevel.write(); }//from w w w. j a v a2 s . c om log.trace("Found consistency levels : {}/{}", defaultGlobalRead, defaultGlobalWrite); return Pair.create(defaultGlobalRead, defaultGlobalWrite); }
From source file:info.archinnov.achilles.internal.metadata.parsing.EmbeddedIdParser.java
private Map<Integer, Field> extractComponentsOrdering(Class<?> embeddedIdClass) { log.trace("Extract components ordering from embedded id class {} ", embeddedIdClass.getCanonicalName()); String embeddedIdClassName = embeddedIdClass.getCanonicalName(); Map<Integer, Field> components = new TreeMap<Integer, Field>(); @SuppressWarnings("unchecked") Set<Field> candidateFields = getFields(embeddedIdClass, ReflectionUtils.<Field>withAnnotation(Order.class)); Set<Integer> orders = new HashSet<Integer>(); int orderSum = 0; int componentCount = candidateFields.size(); for (Field candidateField : candidateFields) { Order orderAnnotation = candidateField.getAnnotation(Order.class); int order = orderAnnotation.value(); Class<?> componentType = candidateField.getType(); orderSum = validateNoDuplicateOrderAndType(embeddedIdClassName, orders, orderSum, order, componentType); components.put(order, candidateField); }// w w w .jav a2s . co m validateConsistentOrdering(embeddedIdClassName, orderSum, componentCount); Validator.validateBeanMappingTrue(componentCount > 1, "There should be at least 2 fields annotated with @Order for the @EmbeddedId class '%s'", embeddedIdClass.getCanonicalName()); return components; }
From source file:csns.model.core.dao.jpa.SubscriptionDaoImpl.java
@Override public List<Subscription> getSubscriptions(User subscriber, Class<?> clazz) { String query = "from Subscription where subscriber = :subscriber " + "and subscribable.class = :clazz"; return entityManager.createQuery(query, Subscription.class).setParameter("subscriber", subscriber) .setParameter("clazz", clazz.getCanonicalName()).getResultList(); }
From source file:net.famzangl.minecraft.minebot.ai.command.CommandRegistry.java
public void register(Class<?> commandClass) { LOGGER.info(MARKER_REGISTER, "Registering: " + commandClass.getCanonicalName()); checkCommandClass(commandClass);/* w ww. j a va 2 s . co m*/ final String name = commandClass.getAnnotation(AICommand.class).name(); List<CommandDefinition> list = commandTable.get(name); if (list == null) { list = new ArrayList<CommandDefinition>(); commandTable.put(name, list); } getCommandsForClass(commandClass, list); }
From source file:com.kurento.kmf.content.internal.ContentApiWebApplicationInitializer.java
/** * It seeks declared handlers in the classpath by using reflections. * /*from w w w. j av a2 s . c o m*/ * @param handlerClass * Handler class ({@link HttpPlayerHandler}, * {@link HttpRecorderHandler}, {@link WebRtcContentHandler}, * {@link RtpContentHandler}) * @param serviceAnnotation * Service annotation ({@link HttpPlayerService}, * {@link HttpRecorderService}, {@link WebRtcContentService}, * {@link RtpContentService}) * @return List of services * @throws ServletException * Exception raised when an incorrect implementation of handler * is detected (mismatching between annotation and inheritance * in handler) */ private List<String> findServices(Class<?> handlerClass, Class<? extends Annotation> serviceAnnotation) throws ServletException { Set<Class<?>> annotatedList = ReflectionUtils.getTypesAnnotatedWith(serviceAnnotation); List<String> handlerList = new ArrayList<String>(); for (Class<?> clazz : annotatedList) { if (handlerClass.isAssignableFrom(clazz)) { handlerList.add(clazz.getCanonicalName()); } else { String error = "Incorrect implementation of handler: class " + clazz.getCanonicalName() + " is annotated with " + serviceAnnotation.getSimpleName() + " (instead, " + clazz.getSimpleName() + " should extend " + handlerClass.getSimpleName() + " or use the correct annotation)"; log.error(error); throw new ServletException(error); } } return handlerList; }
From source file:info.archinnov.achilles.internal.metadata.parsing.EntityIntrospector.java
public <T> Pair<ConsistencyLevel, ConsistencyLevel> findConsistencyLevels(Class<T> entity, Pair<ConsistencyLevel, ConsistencyLevel> defaultConsistencyLevels) { log.debug("Find consistency levels for entity class {}", entity.getCanonicalName()); ConsistencyLevel defaultGlobalRead = defaultConsistencyLevels.left; ConsistencyLevel defaultGlobalWrite = defaultConsistencyLevels.right; Consistency clevel = entity.getAnnotation(Consistency.class); if (clevel != null) { defaultGlobalRead = clevel.read(); defaultGlobalWrite = clevel.write(); }// w w w. j a va 2s . c o m log.trace("Found consistency levels : {}/{}", defaultGlobalRead, defaultGlobalWrite); return Pair.create(defaultGlobalRead, defaultGlobalWrite); }
From source file:org.createnet.raptor.auth.service.services.AclManagerService.java
@Override public <T> void removePermission(Class<T> clazz, Serializable identifier, Sid sid, Permission permission) { ObjectIdentity identity = new ObjectIdentityImpl(clazz.getCanonicalName(), identifier); MutableAcl acl = (MutableAcl) aclService.readAclById(identity); AccessControlEntry[] entries = acl.getEntries().toArray(new AccessControlEntry[acl.getEntries().size()]); for (int i = 0; i < acl.getEntries().size(); i++) { if (entries[i].getSid().equals(sid) && entries[i].getPermission().equals(permission)) { acl.deleteAce(i);/*from w w w . j a v a 2s .c o m*/ } } aclService.updateAcl(acl); }
From source file:info.archinnov.achilles.test.integration.tests.BatchModeIT.java
private <T> Composite createCounterKey(Class<T> clazz, Long id) { Composite comp = new Composite(); comp.setComponent(0, clazz.getCanonicalName(), STRING_SRZ); comp.setComponent(1, id.toString(), STRING_SRZ); return comp;//from ww w . j a v a2s . c o m }