List of usage examples for org.springframework.core.type.classreading SimpleMetadataReaderFactory SimpleMetadataReaderFactory
public SimpleMetadataReaderFactory(@Nullable ClassLoader classLoader)
From source file:org.openmrs.module.webservices.rest.web.OpenmrsClassScanner.java
OpenmrsClassScanner() { this.metadataReaderFactory = new SimpleMetadataReaderFactory(OpenmrsClassLoader.getInstance()); this.resourceResolver = new PathMatchingResourcePatternResolver(OpenmrsClassLoader.getInstance()); }
From source file:com.sxj.jsonrpc.client.spring.AutoJsonRpcClientProxyCreator.java
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { SimpleMetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(applicationContext); DefaultListableBeanFactory dlbf = (DefaultListableBeanFactory) beanFactory; String resolvedPath = resolvePackageToScan(); LOG.debug(format("Scanning '%s' for JSON-RPC service interfaces.", resolvedPath)); try {// w ww .ja v a2s .c o m for (Resource resource : applicationContext.getResources(resolvedPath)) { if (resource.isReadable()) { MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource); ClassMetadata classMetadata = metadataReader.getClassMetadata(); AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata(); String jsonRpcPathAnnotation = JsonRpcService.class.getName(); if (annotationMetadata.isAnnotated(jsonRpcPathAnnotation)) { String className = classMetadata.getClassName(); String path = (String) annotationMetadata.getAnnotationAttributes(jsonRpcPathAnnotation) .get("value"); boolean useNamedParams = (Boolean) annotationMetadata .getAnnotationAttributes(jsonRpcPathAnnotation).get("useNamedParams"); LOG.debug(format("Found JSON-RPC service to proxy [%s] on path '%s'.", className, path)); registerJsonProxyBean(dlbf, className, path, useNamedParams); } } } } catch (IOException e) { throw new RuntimeException(format("Cannot scan package '%s' for classes.", resolvedPath), e); } }
From source file:com.googlecode.jsonrpc4j.spring.AutoJsonRpcClientProxyCreator.java
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { SimpleMetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(applicationContext); DefaultListableBeanFactory dlbf = (DefaultListableBeanFactory) beanFactory; String resolvedPath = resolvePackageToScan(); LOG.debug(format("Scanning '%s' for JSON-RPC service interfaces.", resolvedPath)); try {//from ww w . j a v a2 s . c om for (Resource resource : applicationContext.getResources(resolvedPath)) { if (resource.isReadable()) { MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource); ClassMetadata classMetadata = metadataReader.getClassMetadata(); AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata(); String jsonRpcPathAnnotation = JsonRpcService.class.getName(); if (annotationMetadata.isAnnotated(jsonRpcPathAnnotation)) { String className = classMetadata.getClassName(); String path = (String) annotationMetadata.getAnnotationAttributes(jsonRpcPathAnnotation) .get("value"); boolean useNamedParams = (Boolean) annotationMetadata .getAnnotationAttributes(jsonRpcPathAnnotation).get("useNamedParams"); LOG.debug(format("Found JSON-RPC service to proxy [%s] on path '%s'.", className, path)); registerJsonProxyBean(dlbf, className, path, useNamedParams); } } } } catch (IOException e) { throw new RuntimeException(format("Cannot scan package '%s' for classes.", resolvedPath), e); } }
From source file:org.openmrs.module.metadatasharing.reflection.OpenmrsClassScanner.java
OpenmrsClassScanner() { this.classLoader = OpenmrsClassLoader.getInstance(); this.metadataReaderFactory = new SimpleMetadataReaderFactory(classLoader); this.resourceResolver = new PathMatchingResourcePatternResolver(classLoader); }
From source file:org.guzz.builder.GuzzConfigFileBuilder.java
public void loadScanedBusinessesToGuzz() throws IOException { /*//from w ww . j ava 2 s .c om <business-scan dbgroup="default" resources="classpath*:org/guzz/test/*.hbm.xml" /> */ List bus = this.rootDoc.selectNodes("business-scan"); for (int i = 0; i < bus.size(); i++) { Element e = (Element) bus.get(i); String m_dbgroup = e.attributeValue("dbgroup"); String resources = e.attributeValue("resources"); if (StringUtil.isEmpty(resources)) { throw new GuzzException("attribute resources not found. xml:[" + e.asXML() + "]"); } PathMatchingResourcePatternResolver pr = new PathMatchingResourcePatternResolver(); MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(pr); org.springframework.core.io.Resource[] rs = pr.getResources(resources); for (org.springframework.core.io.Resource r : rs) { if (r.isReadable()) { try { //Load as annotated class first. MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(r); String className = metadataReader.getClassMetadata().getClassName(); if (gf.getBusiness(className) != null) { log.info("business-scan ignored domain class [" + className + "] in resource [" + r.getURL() + "] business already registered."); continue; } POJOBasedObjectMapping map = JPA2AnnotationsBuilder.parseDomainClass(gf, m_dbgroup, null, Class.forName(className)); log.info("business-scan add business [" + r.getURL() + "]"); gf.addNewGhostBusinessToSystem(map); } catch (GuzzException e1) { log.debug("business-scan ignored invalid resource [" + r.getURL() + "]. msg:" + e1.getMessage()); } catch (Exception eee) { //Not a class? Try to interpret it as a hbm.xml file. try { POJOBasedObjectMapping map = HbmXMLBuilder.parseHbmStream(gf, m_dbgroup, new BusinessValidChecker() { public boolean shouldParse(Class domainClass) { return gf.getBusiness(domainClass.getName()) == null; } }, null, null, null, r.getInputStream()); if (map == null) { log.info( "business-scan ignored [" + r.getURL() + "]. business already registered."); continue; } log.info("business-scan add business [" + r.getURL() + "]"); gf.addNewGhostBusinessToSystem(map); } catch (GuzzException e1) { log.debug("business-scan ignored invalid resource [" + r.getURL() + "]. msg:" + e1.getMessage()); } catch (Exception eeeee) { log.debug("business-scan ignored invalid resource [" + r.getURL() + "]."); } } } } } }
From source file:org.openmrs.util.OpenmrsClassScanner.java
private OpenmrsClassScanner() { this.metadataReaderFactory = new SimpleMetadataReaderFactory(OpenmrsClassLoader.getInstance()); this.resourceResolver = new PathMatchingResourcePatternResolver(OpenmrsClassLoader.getInstance()); }