1 25 26 package org.snipsnap.render.macro; 27 28 import org.radeox.macro.Macro; 29 import org.radeox.macro.BaseMacro; 30 import org.radeox.macro.parameter.MacroParameter; 31 import org.radeox.util.i18n.ResourceManager; 32 import org.snipsnap.user.UserManager; 33 import org.snipsnap.user.UserManagerFactory; 34 import org.snipsnap.container.Components; 35 36 import java.io.IOException ; 37 import java.io.Writer ; 38 39 45 46 public class UserCountMacro extends BaseMacro { 47 public String getName() { 48 return "user-count"; 49 } 50 51 public String getDescription() { 52 return ResourceManager.getString("i18n.messages", "macro.usercount.description"); 53 } 54 55 public void execute(Writer writer, MacroParameter params) 56 throws IllegalArgumentException , IOException { 57 if (params.getLength() == 0) { 58 UserManager um = (UserManager)Components.getComponent(UserManager.class); 59 writer.write(Integer.toString(um.getUserCount())); 60 } else { 61 throw new IllegalArgumentException ("Number of arguments does not match"); 62 } 63 } 64 } 65 | Popular Tags |