public List<WadlSaasResource> getResources() { if (resources == null) { resources = new ArrayList<WadlSaasResource>(); try { for (org.netbeans.modules.websvc.saas.model.wadl.Resources wadlResources : getWadlModel().getResources()) { for (Resource r : wadlResources.getResource()) { resources.add(new WadlSaasResource(this, null, r)); } } } catch (Exception ex) { Exceptions.printStackTrace(ex); return Collections.<WadlSaasResource>emptyList(); } } return new ArrayList<WadlSaasResource>(resources); }
@Test public void testScanOtherPackage() { //There can't be a class that is annotated with Inject final DefaultClasspathScanner scanner = new DefaultClasspathScanner(CLASSPATH_SCAN); Set<Class<?>> classes = scanner.getTypesAnnotatedWith(Resources.class); assertNotNull(classes); assertEquals(classes.size(), 0); classes = scanner.getTypesAnnotatedWith(AnnotationForClasspathScanTest.class); assertNotNull(classes); assertEquals(classes.size(), 0); classes = scanner.getTypesAnnotatedWith(Documented.class); assertNotNull(classes); assertEquals(classes.size(), 1); assertTrue(classes.contains(DocumentAnnotatedClass.class)); }
public String getBaseURL() { try { List<org.netbeans.modules.websvc.saas.model.wadl.Resources> wadlResources = getWadlModel().getResources(); if ( wadlResources.size() >0 ){ return wadlResources.get(0).getBase(); } return null; } catch (IOException ioe) { // should not happen at this point return NbBundle.getMessage(WadlSaas.class, "LBL_BAD_WADL"); } }
@Test public void testSimpleScan() { //There can't be a class that is annotated with Inject final DefaultClasspathScanner scanner = new DefaultClasspathScanner(); Set<Class<?>> classes = scanner.getTypesAnnotatedWith(Resources.class); assertNotNull(classes); assertEquals(classes.size(), 0); classes = scanner.getTypesAnnotatedWith(AnnotationForClasspathScanTest.class); assertNotNull(classes); assertEquals(classes.size(), 1); assertTrue(classes.contains(AnnotatedClassForClasspathScan.class)); }
/** * Retrieves the HTML code for the description of the class. * The description of the class is given in the resource annotation which * has the type of the given class. * * <br/> * E.g. * <br/> * @Resource(description="Batchjob for finding URLs which matches a given" * + " regular expression and has a mimetype which matches another" * + " regular expression.", * type=dk.netarkivet.common.utils.batch.UrlSearch.class)} * * <br/><br/> * Which gives the UrlSearch batchjob the following description: * <br/><br/> * Description: Batchjob for finding URLs which matches a given regular * expression and has a mimetype which matches another regular expression. * <br/><br/> * * @param c The class to be described. * @param locale The locale language package. * @return The HTML code describing the class. */ @SuppressWarnings({ "rawtypes", "unchecked" }) private static String getClassDescription(Class c, Locale locale) { // retrieve the resources. Resources r = (Resources) c.getAnnotation(Resources.class); if(r == null) { return "<br/>\n"; } // Find and return the description of this class (if any). for(Resource resource : r.value()) { if(resource.type().getName().equals(c.getName())) { return I18N.getString(locale, "batchpage;Description", new Object[]{}) + ": "+ resource.description() + "<br/><br/>\n"; } } // no description found, then return empty string. return "<br/>\n"; }
public void testResources() { assertTrue(Resources.class.isAnnotation()); }