Package org.springframework.context

Examples of org.springframework.context.ApplicationContext


import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class Demo {
    public static void main(String[] args) {
        ApplicationContext ctx =
            new FileSystemXmlApplicationContext(
                    "resources/applicationContext.xml");
        Evaluator e = null;
        boolean ok;
       
        for (int i = 0; i < 10; i++) {
            e = (Evaluator) ctx.getBean("groovyEvaluator");
            ok = e.approve(null);
            System.out.println(ok ? "approved" : "denied");
           
            try {
                Thread.sleep(1000);
View Full Code Here


  public CustomRequestFactoryServlet() {
    super(new CustomExceptionHandler(), new ServiceLayerDecorator() {

      @Override
      public <T extends Locator<?, ?>> T createLocator(Class<T> clazz) {
        ApplicationContext context = WebApplicationContextUtils
            .getWebApplicationContext(CustomRequestFactoryServlet.getThreadLocalServletContext());
        return context.getBean(clazz);
      }
     
      @Override
      public Object invoke(Method domainMethod, Object... args) {
        if(FindService.class.equals(domainMethod.getDeclaringClass())) {
View Full Code Here

        final Authentication authentication = AuthUtils.getAuthenticationObject();
        if (authentication == null) {
            return false;
        }

        final ApplicationContext applicationContext = AuthUtils.getContext(servletContext)
       
        final Configuration configuration = arguments.getConfiguration();
       
        final int separatorPos = attributeValue.lastIndexOf(VALUE_SEPARATOR);
        if (separatorPos == -1) {
View Full Code Here

public class ResourcesServiceImplTest {

  @Test
  public void test() {
            ApplicationContext ctx = new ClassPathXmlApplicationContext("spring-*.xml")
            ResourcesServiceImpl bean = (ResourcesServiceImpl)ctx.getBean("resourcesService");
            bean.findAll();
            bean.getById("1");
            bean.getUserResources("1");
  }
View Full Code Here

        if (config == null) {
            config = new HashMap<String, Object>();
        }

        ApplicationContext ctx =
                WebApplicationContextUtils.getRequiredWebApplicationContext(context);

        PasswordEncoder passwordEncoder = null;
        try {
            ProviderManager provider = (ProviderManager) ctx.getBean("org.springframework.security.authentication.ProviderManager#0");
            for (Object o : provider.getProviders()) {
                AuthenticationProvider p = (AuthenticationProvider) o;
                if (p instanceof RememberMeAuthenticationProvider) {
                    config.put("rememberMeEnabled", Boolean.TRUE);
                } else if (ctx.getBean("passwordEncoder") != null) {
                    passwordEncoder = (PasswordEncoder) ctx.getBean("passwordEncoder");
                }
            }
        } catch (NoSuchBeanDefinitionException n) {
            log.debug("authenticationManager bean not found, assuming test and ignoring...");
            // ignore, should only happen when testing
View Full Code Here

     * This method uses the LookupManager to lookup available roles from the data layer.
     *
     * @param context The servlet context
     */
    public static void setupContext(ServletContext context) {
        ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(context);
        LookupManager mgr = (LookupManager) ctx.getBean("lookupManager");

        // get list of possible roles
        context.setAttribute(Constants.AVAILABLE_ROLES, mgr.getAllRoles());
        log.debug("Drop-down initialization complete [OK]");

        // Any manager extending GenericManager will do:
        GenericManager manager = (GenericManager) ctx.getBean("userManager");
        doReindexing(manager);
        log.debug("Full text search reindexing complete [OK]");
    }
View Full Code Here

                "Domain object is of class \"{}\" and permissions are \"{}\".",
                    new Object[] {TemplateEngine.threadIndex(), (authentication == null? null : authentication.getName()),
                            (domainObject == null? null : domainObject.getClass().getName()), permissions});
        }
       
        final ApplicationContext applicationContext =
                WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);

        final AclService aclService = getBeanOfType(applicationContext, AclService.class);

        if (authentication == null) {
View Full Code Here

   
   
   
    private static WebSecurityExpressionHandler getExpressionHandler(final ServletContext servletContext) {

        final ApplicationContext ctx =
                WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
       
        final Map<String, WebSecurityExpressionHandler> expressionHandlers =
                ctx.getBeansOfType(WebSecurityExpressionHandler.class);

        if (expressionHandlers.size() == 0) {
            throw new TemplateProcessingException(
                    "No visible WebSecurityExpressionHandler instance could be found in the application " +
                    "context. There must be at least one in order to support expressions in Spring Security " +
View Full Code Here


   
    private static WebInvocationPrivilegeEvaluator getPrivilegeEvaluator(final ServletContext servletContext) {

        final ApplicationContext ctx =
                WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
       
        final Map<String, WebInvocationPrivilegeEvaluator> privilegeEvaluators =
                ctx.getBeansOfType(WebInvocationPrivilegeEvaluator.class);

        if (privilegeEvaluators.size() == 0) {
            throw new TemplateProcessingException(
                    "No visible WebInvocationPrivilegeEvaluator instance could be found in the application " +
                    "context. There must be at least one in order to support URL access checks in " +
View Full Code Here

    public boolean acl(final Object domainObject, final String permissions) {
       
        Validate.notEmpty(permissions, "permissions cannot be null or empty");

        final ApplicationContext applicationContext = AuthUtils.getContext(this.servletContext);
       
        final List<Permission> permissionsList =
                AclAuthUtils.parsePermissionsString(applicationContext, permissions);
       
        return AclAuthUtils.authorizeUsingAccessControlList(
View Full Code Here

TOP

Related Classes of org.springframework.context.ApplicationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.