@Override public Set<Class<? extends java.lang.annotation.Annotation>> init(ProcessingContext env) { return Tools.<Class<? extends java.lang.annotation.Annotation>> set(Shiro.class, RequiresGuest.class, RequiresUser.class, RequiresAuthentication.class, RequiresPermissions.class, RequiresRoles.class, Login.class, Logout.class); }
public Set<Class<? extends java.lang.annotation.Annotation>> init(ProcessingContext env) { return Tools.<Class<? extends java.lang.annotation.Annotation>>set(View.class, Action.class, Consumes.class, Resource.class); }
public Set<Class<? extends java.lang.annotation.Annotation>> init(ProcessingContext env) { return Tools.<Class<? extends java.lang.annotation.Annotation>>set(View.class, Action.class, Consumes.class, Resource.class); }
public AssetMetaData(String id, String type, AssetLocation location, String value, Boolean header, String minified, Integer maxAge, String... dependencies) { this.id = id; this.type = type; this.value = value; this.header = header; this.minified = minified; this.location = location; this.maxAge = maxAge; this.dependencies = Collections.unmodifiableSet(Tools.set(dependencies)); }
public AssetMetaData(String id, String type, AssetLocation location, String value, Boolean header, String minified, Integer maxAge, String... dependencies) { this.id = id; this.type = type; this.value = value; this.header = header; this.minified = minified; this.location = location; this.maxAge = maxAge; this.dependencies = Collections.unmodifiableSet(Tools.set(dependencies)); }
public static <E> HashSet<E> set(Iterable<E> elements) { return set(elements.iterator()); }
public static <E> HashSet<E> set(Iterable<E> elements) { return set(elements.iterator()); }
@Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { String username = (String)getAvailablePrincipal(principals); if ("marry".equals(username)) { SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); info.setRoles(Tools.set("role3")); info.setStringPermissions(Tools.set("permission3")); return info; } return null; }
@Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { String username = (String)getAvailablePrincipal(principals); if ("root".equals(username)) { SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); info.setRoles(Tools.set("role1", "role2")); info.setStringPermissions(Tools.set("permission1", "permission2")); return info; } else if ("john".equals(username)) { SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); info.setRoles(Tools.set("role2")); info.setStringPermissions(Tools.set("permission2")); return info; } return null; }
@Test public void testNestedJarEntry() throws Exception { File tmp = File.createTempFile("juzu", ".jar"); tmp.deleteOnExit(); FileOutputStream baos = new FileOutputStream(tmp); jar.as(ZipExporter.class).exportTo(baos); URL url = new URL("jar:" + tmp.toURI().toURL() + "!/foo/"); URLFileSystem fs = new URLFileSystem(); fs.add(url); Node root = fs.getRoot(); HashSet<Node> children = Tools.set(fs.getChildren(root)); assertEquals(2, children.size()); }
@Test public void testNestedJarEntry() throws Exception { File tmp = File.createTempFile("juzu", ".jar"); tmp.deleteOnExit(); FileOutputStream baos = new FileOutputStream(tmp); jar.as(ZipExporter.class).exportTo(baos); URL url = new URL("jar:" + tmp.toURI().toURL() + "!/foo/"); URLFileSystem fs = new URLFileSystem(); fs.add(url); Node root = fs.getRoot(); HashSet<Node> children = Tools.set(fs.getChildren(root)); assertEquals(2, children.size()); }
void afterBeanDiscovery(@Observes AfterBeanDiscovery event, BeanManager beanManager) { if (context != null) { for (Scope scope : context.injector.scopes) { if (!scope.isBuiltIn()) { event.addContext(new ContextImpl(context.injector.scopeController, scope, scope.getAnnotationType())); } } // Add the manager event.addBean(new SingletonBean(InjectionContext.class, Tools.set(AbstractBean.DEFAULT_QUALIFIER, AbstractBean.ANY_QUALIFIER), context)); // Add bound beans for (AbstractBean bean : context.injector.boundBeans) { bean.register(beanManager); event.addBean(bean); } } }
void afterBeanDiscovery(@Observes AfterBeanDiscovery event, BeanManager beanManager) { if (context != null) { for (Scope scope : context.injector.scopes) { if (!scope.isBuiltIn()) { event.addContext(new ContextImpl(context.injector.scopeController, scope, scope.getAnnotationType())); } } // Add the manager event.addBean(new SingletonBean(InjectionContext.class, Tools.set(AbstractBean.DEFAULT_QUALIFIER, AbstractBean.ANY_QUALIFIER), context)); // Add bound beans for (AbstractBean bean : context.injector.boundBeans) { bean.register(beanManager); event.addBean(bean); } } }
Set<String> set = Tools.set(fs.getChildren("")); HashSet<String> expectedSet = Tools.set("META-INF/", "javax/"); assertEquals(expectedSet, set); Set<String> set2 = Tools.set(fs.getChildren("META-INF/")); HashSet<String> expectedSet2 = Tools.set("META-INF/MANIFEST.MF"); assertTrue(set2.containsAll(expectedSet2)); Set<String> set3 = Tools.set(fs.getChildren("javax/")); HashSet<String> expectedSet3 = Tools.set("javax/portlet/"); assertTrue(set3.containsAll(expectedSet3)); Set<String> set4 = Tools.set(fs.getChildren("javax/portlet/filter/")); Set<String> expectedSet4 = new HashSet<String>(); expectedSet4.add("javax/portlet/filter/EventFilter.class");
@Test public void test() throws Exception { init(); bootstrap.declareBean(Bean1.class, null, null, null); bootstrap.declareBean(Bean2.class, null, null, null); boot(); // ArrayList<B> beans = Tools.list(mgr.resolveBeans(AbstractBean.class)); assertEquals(2, beans.size()); HashSet<Class<?>> classes = new HashSet<Class<?>>(); for (B bean : beans) { I instance = mgr.createContext(bean); Object o = mgr.getInstance(bean, instance); classes.add(o.getClass()); } assertEquals(Tools.<Class<?>>set(Bean1.class, Bean2.class), classes); } }
ControllerHandler handler = resolver.resolveMethod(Phase.VIEW, "A.m", Tools.<String>set()); assertEquals("m", handler.getName()); assertEquals(Tools.<String>set(), handler.getParameterNames()); handler = resolver.resolveMethod(Phase.VIEW, "A.m", Tools.<String>set("foo")); assertEquals("m", handler.getName()); assertEquals(Tools.<String>set("foo"), handler.getParameterNames()); handler = resolver.resolveMethod(Phase.VIEW, "A.m", Tools.<String>set("foo", "bar")); assertEquals("m", handler.getName()); assertEquals(Tools.<String>set("foo", "bar"), handler.getParameterNames()); handler = resolver.resolveMethod(Phase.VIEW, "A.m", Tools.<String>set("bar")); assertEquals("m", handler.getName()); assertEquals(Tools.<String>set("foo", "bar"), handler.getParameterNames()); handler = resolver.resolveMethod(Phase.VIEW, "A.m", Tools.<String>set("bar")); assertEquals("m", handler.getName()); assertEquals(Tools.<String>set("foo", "bar"), handler.getParameterNames()); handler = resolver.resolveMethod(Phase.VIEW, "A.m", Tools.<String>set("daa")); assertEquals("m", handler.getName()); assertEquals(Tools.<String>set(), handler.getParameterNames());
@Test public void test() throws Exception { init(); bootstrap.declareBean(Bean1.class, null, null, null); bootstrap.declareBean(Bean2.class, null, null, null); boot(); // ArrayList<B> beans = Tools.list(mgr.resolveBeans(AbstractBean.class)); assertEquals(2, beans.size()); HashSet<Class<?>> classes = new HashSet<Class<?>>(); for (B bean : beans) { I instance = mgr.createContext(bean); Object o = mgr.getInstance(bean, instance); classes.add(o.getClass()); } assertEquals(Tools.<Class<?>>set(Bean1.class, Bean2.class), classes); } }
ControllerHandler handler = resolver.resolveMethod(Phase.VIEW, "A.m", Tools.<String>set()); assertEquals("m", handler.getName()); assertEquals(Tools.<String>set(), handler.getParameterNames()); handler = resolver.resolveMethod(Phase.VIEW, "A.m", Tools.<String>set("foo")); assertEquals("m", handler.getName()); assertEquals(Tools.<String>set("foo"), handler.getParameterNames()); handler = resolver.resolveMethod(Phase.VIEW, "A.m", Tools.<String>set("foo", "bar")); assertEquals("m", handler.getName()); assertEquals(Tools.<String>set("foo", "bar"), handler.getParameterNames()); handler = resolver.resolveMethod(Phase.VIEW, "A.m", Tools.<String>set("bar")); assertEquals("m", handler.getName()); assertEquals(Tools.<String>set("foo", "bar"), handler.getParameterNames()); handler = resolver.resolveMethod(Phase.VIEW, "A.m", Tools.<String>set("bar")); assertEquals("m", handler.getName()); assertEquals(Tools.<String>set("foo", "bar"), handler.getParameterNames()); handler = resolver.resolveMethod(Phase.VIEW, "A.m", Tools.<String>set("daa")); assertEquals("m", handler.getName()); assertEquals(Tools.<String>set(), handler.getParameterNames());
HashSet<? extends P> fooChildren = Tools.set(fs.getChildren(foo)); assertEquals(2, fooChildren.size());
HashSet<? extends P> fooChildren = Tools.set(fs.getChildren(foo)); assertEquals(2, fooChildren.size());