Examples of AppContext

  • sisc.AppContext
  • sisc.interpreter.AppContext
  • sun.awt.AppContext
    The AppContext is a table referenced by ThreadGroup which stores application service instances. (If you are not writing an application service, or don't know what one is, please do not use this class.) The AppContext allows applet access to what would otherwise be potentially dangerous services, such as the ability to peek at EventQueues or change the look-and-feel of a Swing application.

    Most application services use a singleton object to provide their services, either as a default (such as getSystemEventQueue or getDefaultToolkit) or as static methods with class data (System). The AppContext works with the former method by extending the concept of "default" to be ThreadGroup-specific. Application services lookup their singleton in the AppContext.

    For example, here we have a Foo service, with its pre-AppContext code:

     public class Foo { private static Foo defaultFoo = new Foo(); public static Foo getDefaultFoo() { return defaultFoo; } ... Foo service methods }

    The problem with the above is that the Foo service is global in scope, so that applets and other untrusted code can execute methods on the single, shared Foo instance. The Foo service therefore either needs to block its use by untrusted code using a SecurityManager test, or restrict its capabilities so that it doesn't matter if untrusted code executes it.

    Here's the Foo class written to use the AppContext:

     public class Foo { public static Foo getDefaultFoo() { Foo foo = (Foo)AppContext.getAppContext().get(Foo.class); if (foo == null) { foo = new Foo(); getAppContext().put(Foo.class, foo); } return foo; } ... Foo service methods }

    Since a separate AppContext can exist for each ThreadGroup, trusted and untrusted code have access to different Foo instances. This allows untrusted code access to "system-wide" services -- the service remains within the AppContext "sandbox". For example, say a malicious applet wants to peek all of the key events on the EventQueue to listen for passwords; if separate EventQueues are used for each ThreadGroup using AppContexts, the only key events that applet will be able to listen to are its own. A more reasonable applet request would be to change the Swing default look-and-feel; with that default stored in an AppContext, the applet's look-and-feel will change without disrupting other applets or potentially the browser itself.

    Because the AppContext is a facility for safely extending application service support to applets, none of its methods may be blocked by a a SecurityManager check in a valid Java implementation. Applets may therefore safely invoke any of its methods without worry of being blocked. Note: If a SecurityManager is installed which derives from sun.awt.AWTSecurityManager, it may override the AWTSecurityManager.getAppContext() method to return the proper AppContext based on the execution context, in the case where the default ThreadGroup-based AppContext indexing would return the main "system" AppContext. For example, in an applet situation, if a system thread calls into an applet, rather than returning the main "system" AppContext (the one corresponding to the system thread), an installed AWTSecurityManager may return the applet's AppContext based on the execution context. @author Thomas Ball @author Fred Ecks


  • Examples of ae.sun.awt.AppContext

                }
            }
        }

        private synchronized void initContext() {
            final AppContext context = AppContext.getAppContext();

            if (contentsContext != context) {
                // Need to synchronize on the AppContext to guarantee that it cannot
                // be disposed after the check, but before the listener is added.
                synchronized (context) {
                    if (context.isDisposed()) {
                        throw new IllegalStateException("Can't set contents from disposed AppContext");
                    }
                    context.addPropertyChangeListener
                        (AppContext.DISPOSED_PROPERTY_NAME, this);
                }
                if (contentsContext != null) {
                    contentsContext.removePropertyChangeListener
                        (AppContext.DISPOSED_PROPERTY_NAME, this);
    View Full Code Here

    Examples of com.antlersoft.appcontext.AppContext

        public static void main( String argv[])
        throws Exception
        {
          ILDBContainer c=new ILDBContainer();
          AppContext ac = c.createContextWithLegacyCommandLine(argv);
         
          c.initializeFromContext( ac,
              "test.bbq", "com.antlersoft.browsebyquery.il");
         
            final UIQuery app = new UIQuery(c);
    View Full Code Here

    Examples of com.google.appengine.tools.development.AppContext

                this.devAppServer = devAppServer;
            }

            private synchronized boolean appHasPermission(Permission perm) {
                synchronized (PERMISSION_LOCK) {
                    AppContext context = this.devAppServer.getAppContext();
                    if ((context.getUserPermissions().implies(perm)) || (context.getApplicationPermissions().implies(perm))) {
                        return true;
                    }
                }
                return ("read".equals(perm.getActions())) && (perm.getName().endsWith(KEYCHAIN_JNILIB));
            }
    View Full Code Here

    Examples of com.google.collide.client.AppContext

    * Tests the search model
    */
    public class SearchModelTests extends TestCase {

      private static AppContext createMockContext() {
        AppContext mockContext = EasyMock.createMock(AppContext.class);
        Resources mockResources = EasyMock.createMock(Resources.class);
        Css mockCss = EasyMock.createMock(Css.class);

        expect(mockContext.getResources()).andReturn(mockResources).anyTimes();
        expect(mockResources.searchMatchRendererCss()).andReturn(mockCss).anyTimes();
        expect(mockCss.match()).andReturn("match").anyTimes();

        replay(mockCss, mockResources, mockContext);
        return mockContext;
    View Full Code Here

    Examples of com.google.devtools.moe.client.AppContext

    * @author dbentley@google.com (Daniel Bentley)
    */
    public class AppContextForTesting {

      public static void initForTest() {
        AppContext.RUN = new AppContext(
            new InMemoryProjectContextFactory(),
            new RecordingUi(),
            null, null);
      }
    View Full Code Here

    Examples of com.tll.server.AppContext

          @Override
          public AppContext get() {
            final String stage = config.getString(ConfigKeys.STAGE.getKey(), AppContext.DEFAULT_STAGE);
            final String environment = config.getString(ConfigKeys.ENVIRONMENT.getKey(), AppContext.DEFAULT_ENVIRONMENT);
            final String dfltUserEmail = config.getString(ConfigKeys.NOSECURITY_USER_EMAIL.getKey());
            return new AppContext(stage, environment, dfltUserEmail, aas);
          }
        }).in(Scopes.SINGLETON);
      }
    View Full Code Here

    Examples of diva.gui.AppContext

         * Construct a new instance of graph demo, which does the work of
         * setting up the graphs and displaying itself.
         * @param argv Command line arguments, currently ignored.
         */
        public static void main(String[] argv) {
            AppContext context = new BasicFrame("Basic Graph Demo");
            new BasicGraphDemo(context);
        }
    View Full Code Here

    Examples of net.hasor.core.AppContext

    public class UserControllerTest {
        @Test
        public void userControllerTest() throws Throwable {
            System.out.println("--->>userControllerTest<<--");
            //1.创建一个标准的 Hasor 容器。
            AppContext appContext = Hasor.createAppContext(new Module() {
                public void loadModule(ApiBinder apiBinder) throws Throwable {
                    /*绑定一个接口的实现类*/
                    apiBinder.installModule(new ControllerModule());
                }
            });
            //
            RootController root = appContext.getInstance(RootController.class);
            Map<String, String> data = new HashMap<String, String>();
            data.put("userID", "zyc");
            //
            root.findMapping("/users/@add").invoke(data);
            root.findMapping("/users/@del").invoke(data);
    View Full Code Here

    Examples of org.apache.hadoop.mapreduce.v2.app.AppContext

        TestingJobEventHandler jeh = new TestingJobEventHandler();
        dispatcher.register(JobEventType.class, jeh);

        SystemClock clock = new SystemClock();
        AppContext appContext = mock(AppContext.class);
        ApplicationAttemptId attemptid =
          ConverterUtils.toApplicationAttemptId("appattempt_1234567890000_0001_0");
        when(appContext.getApplicationID()).thenReturn(attemptid.getApplicationId());
        when(appContext.getApplicationAttemptId()).thenReturn(attemptid);
        when(appContext.getEventHandler()).thenReturn(
            dispatcher.getEventHandler());
        when(appContext.getClock()).thenReturn(clock);
        OutputCommitter committer = mock(OutputCommitter.class);
        TestingRMHeartbeatHandler rmhh =
            new TestingRMHeartbeatHandler();

        CommitterEventHandler ceh = new CommitterEventHandler(appContext,
    View Full Code Here

    Examples of org.apache.hadoop.mapreduce.v2.app.AppContext

        }
      }

      @Test
      public void testBasic() throws Exception {
        AppContext mockContext = mock(AppContext.class);
        OutputCommitter mockCommitter = mock(OutputCommitter.class);
        Clock mockClock = mock(Clock.class);
       
        CommitterEventHandler handler = new CommitterEventHandler(mockContext,
            mockCommitter, new TestingRMHeartbeatHandler());
        YarnConfiguration conf = new YarnConfiguration();
        conf.set(MRJobConfig.MR_AM_STAGING_DIR, stagingDir);
        JobContext mockJobContext = mock(JobContext.class);
        ApplicationAttemptId attemptid =
          ConverterUtils.toApplicationAttemptId("appattempt_1234567890000_0001_0");
        JobId jobId =  TypeConverter.toYarn(
            TypeConverter.fromYarn(attemptid.getApplicationId()));
       
        WaitForItHandler waitForItHandler = new WaitForItHandler();
       
        when(mockContext.getApplicationID()).thenReturn(attemptid.getApplicationId());
        when(mockContext.getApplicationAttemptId()).thenReturn(attemptid);
        when(mockContext.getEventHandler()).thenReturn(waitForItHandler);
        when(mockContext.getClock()).thenReturn(mockClock);
       
        handler.init(conf);
        handler.start();
        try {
          handler.handle(new CommitterJobCommitEvent(jobId, mockJobContext));
    View Full Code Here
    TOP
    Copyright © 2018 www.massapi.com. 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.