Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Using Spring to get the service for your class (e.g. YourAppClass) (recommended)
    1. Add the AuthzGroupService bean to the bean for YourAppClass
      Code Block
      xml
      xml
      <bean id="org.sakaiproject.yourapp.logic.YourAppClass"
      		class="org.sakaiproject.yourapp.logic.impl.YourAppClassImpl">
      	<property name="authzGroupService"
      		ref="org.sakaiproject.authz.api.AuthzGroupService" />
      </bean>
      
    2. Add a variable and setter to YourAppClass to use the service in like so:
      Code Block
      java
      java
      private AuthzGroupService authzGroupService;
      public void setAuthzGroupService(AuthzGroupService authzGroupService) {
      	this.authzGroupService = authzGroupService;
      }
      
  2. Using the Component Manager to get the service
    • Note: This is not the recommended method, you should be using Spring to inject the service
    1. Use the CM cover to get the service
      Code Block
      java
      java
      import org.sakaiproject.component.cover.ComponentManager;
      import org.sakaiproject.authz.api.AuthzGroupService;
      ...
        private AuthzGroupService authzGroupService;
      ...
          authzGroupService = (AuthzGroupService) ComponentManager.get(AuthzGroupService.class);
      
    Using the cover to get the service
    • Note: This is not the recommended method, you should be using Spring to inject the service
    Setup a variable to hold the instance from the cover Code Blockjavajava
    
    private AuthzGroupService authzGroupService;
    
    Get access to the service using the cover Code Blockjavajava
    
    authzGroupService = org.sakaiproject.authz.cover.AuthzGroupService.getInstance();
    

Getting the users associated with a site which have a specific permission

...