Author: gseitz Date: Mon May 19 14:58:35 2008 New Revision: 658001 URL: http://svn.apache.org/viewvc?rev=658001&view=rev Log: take this, javac! (aka another shot at generics that javac is able to process)
Modified: wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/annotations/AnnotationsRoleAuthorizationStrategy.java wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/InstantiationPermissions.java wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/MetaDataRoleAuthorizationStrategy.java Modified: wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/annotations/AnnotationsRoleAuthorizationStrategy.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/annotations/AnnotationsRoleAuthorizationStrategy.java?rev=658001&r1=658000&r2=658001&view=diff ============================================================================== --- wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/annotations/AnnotationsRoleAuthorizationStrategy.java (original) +++ wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/annotations/AnnotationsRoleAuthorizationStrategy.java Mon May 19 14:58:35 2008 @@ -46,8 +46,7 @@ /** * @see org.apache.wicket.authorization.IAuthorizationStrategy#isInstantiationAuthorized(java.lang.Class) */ - @SuppressWarnings("unchecked") - public boolean isInstantiationAuthorized(final Class componentClass) + public <T extends Component<?>> boolean isInstantiationAuthorized(final Class<T> componentClass) { // We are authorized unless we are found not to be boolean authorized = true; @@ -64,7 +63,7 @@ } // Check class annotation - final AuthorizeInstantiation classAnnotation = (AuthorizeInstantiation)componentClass.getAnnotation(AuthorizeInstantiation.class); + final AuthorizeInstantiation classAnnotation = componentClass.getAnnotation(AuthorizeInstantiation.class); if (classAnnotation != null) { // If roles are defined for the class, that overrides the package @@ -78,11 +77,10 @@ * @see org.apache.wicket.authorization.IAuthorizationStrategy#isActionAuthorized(org.apache.wicket.Component, * org.apache.wicket.authorization.Action) */ - @SuppressWarnings("unchecked") public boolean isActionAuthorized(final Component<?> component, final Action action) { // Get component's class - final Class<? extends Component<?>> componentClass = (Class<? extends Component<?>>)component.getClass(); + final Class<?> componentClass = component.getClass(); // Check for a single action if (!check(action, componentClass.getAnnotation(AuthorizeAction.class))) Modified: wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/InstantiationPermissions.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/InstantiationPermissions.java?rev=658001&r1=658000&r2=658001&view=diff ============================================================================== --- wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/InstantiationPermissions.java (original) +++ wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/InstantiationPermissions.java Mon May 19 14:58:35 2008 @@ -38,17 +38,18 @@ private static final long serialVersionUID = 1L; /** Holds roles objects for component classes */ - private final Map<Class<? extends Component>, Roles> rolesForComponentClass = new HashMap<Class<? extends Component>, Roles>(); + private final Map<Class<? extends Component<?>>, Roles> rolesForComponentClass = new HashMap<Class<? extends Component<?>>, Roles>(); /** * Gives the given role permission to instantiate the given class. * + * @param <T> * @param componentClass * The component class * @param rolesToAdd * The roles to add */ - public final void authorize(final Class<? extends Component> componentClass, + public final <T extends Component<?>> void authorize(final Class<T> componentClass, final Roles rolesToAdd) { if (componentClass == null) @@ -75,10 +76,11 @@ * a role was previously authorized for that class. If no roles where previously authorized the * effect of the unauthorize call is that no roles at all will be authorized for that class. * + * @param <T> * @param componentClass * The component class */ - public final void authorizeAll(final Class<? extends Component> componentClass) + public final <T extends Component<?>> void authorizeAll(final Class<T> componentClass) { if (componentClass == null) { @@ -91,12 +93,14 @@ /** * Gets the roles that have a binding with the given component class. * + * @param <T> + * * @param componentClass * the component class * @return the roles that have a binding with the given component class, or null if no entries * are found */ - public Roles authorizedRoles(final Class<? extends Component> componentClass) + public <T extends Component<?>> Roles authorizedRoles(final Class<T> componentClass) { if (componentClass == null) { @@ -109,12 +113,14 @@ /** * Removes permission for the given role to instantiate the given class. * + * @param <T> + * * @param componentClass * The class * @param rolesToRemove * The role to deny */ - public final void unauthorize(final Class<? extends Component> componentClass, + public final <T extends Component<?>> void unauthorize(final Class<T> componentClass, final Roles rolesToRemove) { if (componentClass == null) @@ -150,7 +156,7 @@ /** * @return gets map with roles objects for a component classes */ - protected final Map<Class<? extends Component>, Roles> getRolesForComponentClass() + protected final Map<Class<? extends Component<?>>, Roles> getRolesForComponentClass() { return rolesForComponentClass; } Modified: wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/MetaDataRoleAuthorizationStrategy.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/MetaDataRoleAuthorizationStrategy.java?rev=658001&r1=658000&r2=658001&view=diff ============================================================================== --- wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/MetaDataRoleAuthorizationStrategy.java (original) +++ wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/MetaDataRoleAuthorizationStrategy.java Mon May 19 14:58:35 2008 @@ -77,13 +77,15 @@ * Authorizes the given role to create component instances of type componentClass. This * authorization is added to any previously authorized roles. * + * @param <T> + * * @param componentClass * The component type that is subject for the authorization * @param roles * The comma separated roles that are authorized to create component instances of * type componentClass */ - public static final void authorize(final Class<? extends Component> componentClass, + public static final <T extends Component<?>> void authorize(final Class<T> componentClass, final String roles) { final Application application = Application.get(); @@ -121,10 +123,12 @@ /** * Grants permission to all roles to create instances of the given component class. * + * @param <T> + * * @param componentClass * The component class */ - public static final void authorizeAll(final Class<? extends Component<?>> componentClass) + public static final <T extends Component<?>> void authorizeAll(final Class<T> componentClass) { Application application = Application.get(); InstantiationPermissions authorizedRoles = application.getMetaData(INSTANTIATION_PERMISSIONS); @@ -158,13 +162,15 @@ * automatically be added, effectively denying access to all roles (if this was not done, all * roles would suddenly have access since no authorization is equivalent to full access). * + * @param <T> + * * @param componentClass * The component type * @param roles * The comma separated list of roles that are no longer to be authorized to create * instances of type componentClass */ - public static final void unauthorize(final Class<? extends Component> componentClass, + public static final <T extends Component<?>> void unauthorize(final Class<T> componentClass, final String roles) { final InstantiationPermissions permissions = Application.get().getMetaData( @@ -204,10 +210,12 @@ * Grants authorization to instantiate the given class to just the role NO_ROLE, effectively * denying all other roles. * + * @param <T> + * * @param componentClass * The component class */ - public static final void unauthorizeAll(Class<? extends Component<?>> componentClass) + public static final <T extends Component<?>> void unauthorizeAll(Class<T> componentClass) { authorizeAll(componentClass); authorize(componentClass, NO_ROLE); @@ -269,8 +277,7 @@ * * @see org.apache.wicket.authorization.IAuthorizationStrategy#isInstantiationAuthorized(java.lang.Class) */ - @SuppressWarnings("unchecked") - public boolean isInstantiationAuthorized(final Class componentClass) + public <T extends Component<?>> boolean isInstantiationAuthorized(final Class<T> componentClass) { if (componentClass == null) { @@ -295,13 +302,15 @@ /** * Gets the roles for creation of the given component class, or null if none were registered. * + * @param <T> + * * @param componentClass * the component class * @return the roles that are authorized for creation of the componentClass, or null if no * specific authorization was configured */ - private static Roles rolesAuthorizedToInstantiate( - final Class<? extends Component<?>> componentClass) + private static <T extends Component<?>> Roles rolesAuthorizedToInstantiate( + final Class<T> componentClass) { final InstantiationPermissions permissions = Application.get().getMetaData( INSTANTIATION_PERMISSIONS);