The Artima Developer Community
Sponsored Link

Java Buzz Forum
LazyWeb: Advice on Started Threads

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Brian McCallister

Posts: 1282
Nickname: frums
Registered: Sep, 2003

Brian McCallister is JustaProgrammer who thinks too much.
LazyWeb: Advice on Started Threads Posted: May 13, 2004 9:34 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Brian McCallister.
Original Post: LazyWeb: Advice on Started Threads
Feed Title: Waste of Time
Feed URL: http://kasparov.skife.org/blog/index.rss
Feed Description: A simple waste of time and weblog experiment
Latest Java Buzz Posts
Latest Java Buzz Posts by Brian McCallister
Latest Posts From Waste of Time

Advertisement

Code shows the problem best, so... Given the following sample code:

    public void testSubjectFollowsSpawnedThreads()
    {
        // Never allow access to teacher
        rp.addRules(Teacher.class, new Rules()
        {
            public boolean allow(Object subject, Object object)
            {
                return false;
            }
        });
        Teacher teacher = new Teacher("Mr. Brown");
        final ClassRoom english = new ClassRoom(teacher);

        filter.setSubject(new Object());
        // Verify subject set on current thread
        assertNull(english.getTeacher());

        final boolean [] blocked = {false};
        final boolean [] finished = {false};
        Thread thread = new Thread(new Runnable()
        {
            public void run()
            {
                blocked[0] = (english.getTeacher() == null);
                finished[0] = true;
            }
        });
        thread.start();
        while (!finished[0])
        {
            Thread.yield();
        }
        assertTrue(blocked[0]);
    }

I am trying to define a pointcut in AspectJ to match the beginning of the execution of the Runnable associated with thread. I need to be able to access some static context in the spawning thread and pass it into the advice (the current security subject). I have tried a couple things and failed to get it right =( I am seriously thinking that a static thread-local subject may not be the best way of specifying the subject, but I don't have a better one. Any thoughts on pointcut definition?

Read: LazyWeb: Advice on Started Threads

Topic: Fancy a pack of cards with Hani and Marc Fleury as the jokers? Previous Topic   Next Topic Topic: C# code conventions I'll be breaking for the time being

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use