Java Code Examples for java.rmi.AccessException

The following are top voted examples for showing how to use java.rmi.AccessException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: oscm   File: ExceptionHandler.java   View source code 6 votes vote down vote up
/**
 * Convert a EJBException into FacesMessage which is presented to the user.
 * 
 * @param ex
 *            the EJBException to be analyzed
 */
public static void execute(EJBException ex) {
    if (ex != null && ex.getCause() instanceof Exception
            && ex.getCausedByException() instanceof AccessException) {
        handleOrganizationAuthoritiesException();
    } else if (ex != null && isInvalidUserSession(ex)) {
        HttpServletRequest request = JSFUtils.getRequest();
        request.getSession().removeAttribute(Constants.SESS_ATTR_USER);
        request.getSession().invalidate();
        handleInvalidSession();
    } else if (ex != null && isConnectionException(ex)) {
        handleMissingConnect(BaseBean.ERROR_DATABASE_NOT_AVAILABLE);
    } else {
        throw new FacesException(ex);
    }
}
 
Example 2
Project: oscm   File: AuthorizationFilter.java   View source code 6 votes vote down vote up
private void handleServletException(HttpServletRequest httpRequest,
        HttpServletResponse httpResponse, ServletException e)
        throws IOException, ServletException {
    EJBException ejbEx = ExceptionHandler.getEJBException(e);
    if (ejbEx != null && ejbEx.getCause() instanceof Exception
            && ejbEx.getCausedByException() instanceof AccessException) {
        String forwardErrorPage;
        if (BesServletRequestReader.isMarketplaceRequest(httpRequest)) {
            forwardErrorPage = Marketplace.MARKETPLACE_ROOT
                    + Constants.INSUFFICIENT_AUTHORITIES_URI;
        } else {
            forwardErrorPage = Constants.INSUFFICIENT_AUTHORITIES_URI;
        }
        JSFUtils.sendRedirect(httpResponse,
                httpRequest.getContextPath() + forwardErrorPage);
    } else {
        // make sure we do not catch exceptions cause by
        // ViewExpiredException here, they'll be handled directly in the
        // doFilter()
        throw e;
    }
}
 
Example 3
Project: OpenJSharp   File: Activation.java   View source code 6 votes vote down vote up
/**
 * Shutdown the activation system. Destroys all groups spawned by
 * the activation daemon and exits the activation daemon.
 */
public void shutdown() throws AccessException {
    RegistryImpl.checkAccess("ActivationSystem.shutdown");

    Object lock = startupLock;
    if (lock != null) {
        synchronized (lock) {
            // nothing
        }
    }

    synchronized (Activation.this) {
        if (!shuttingDown) {
            shuttingDown = true;
            (new Shutdown()).start();
        }
    }
}
 
Example 4
Project: jdk8u-jdk   File: Activation.java   View source code 6 votes vote down vote up
/**
 * Shutdown the activation system. Destroys all groups spawned by
 * the activation daemon and exits the activation daemon.
 */
public void shutdown() throws AccessException {
    RegistryImpl.checkAccess("ActivationSystem.shutdown");

    Object lock = startupLock;
    if (lock != null) {
        synchronized (lock) {
            // nothing
        }
    }

    synchronized (Activation.this) {
        if (!shuttingDown) {
            shuttingDown = true;
            (new Shutdown()).start();
        }
    }
}
 
Example 5
Project: openjdk-jdk10   File: Activation.java   View source code 6 votes vote down vote up
/**
 * Shutdown the activation system. Destroys all groups spawned by
 * the activation daemon and exits the activation daemon.
 */
public void shutdown() throws AccessException {
    // RegistryImpl.checkAccess() is done in the SameHostOnlyServerRef
    // during unmarshallCustomData and is not applicable to local access.

    Object lock = startupLock;
    if (lock != null) {
        synchronized (lock) {
            // nothing
        }
    }

    synchronized (Activation.this) {
        if (!shuttingDown) {
            shuttingDown = true;
            (new Shutdown()).start();
        }
    }
}
 
Example 6
Project: openjdk-jdk10   File: NonLocalActivationTest.java   View source code 6 votes vote down vote up
/**
 * Check the exception chain for the expected AccessException and message.
 * @param ex the exception from the remote invocation.
 */
private static void assertIsAccessException(Exception ex, String msg1) {
    Throwable t = ex;
    System.out.println();
    while (!(t instanceof AccessException) && t.getCause() != null) {
        t = t.getCause();
    }
    if (t instanceof AccessException) {
        String msg = t.getMessage();
        int asIndex = msg.indexOf(msg1);
        int disallowIndex = msg.indexOf("disallowed");
        int nonLocalHostIndex = msg.indexOf("non-local host");
        if (asIndex < 0 ||
                disallowIndex < 0 ||
                nonLocalHostIndex < 0 ) {
            throw new RuntimeException("exception message is malformed", t);
        }
        System.out.printf("Found expected AccessException: %s%n", t);
    } else {
        throw new RuntimeException("AccessException did not occur", ex);
    }
}
 
Example 7
Project: openjdk-jdk10   File: NonLocalRegistryTest.java   View source code 6 votes vote down vote up
/**
 * Check the exception chain for the expected AccessException and message.
 * @param ex the exception from the remote invocation.
 */
private static void assertIsAccessException(Throwable ex) {
    Throwable t = ex;
    while (!(t instanceof AccessException) && t.getCause() != null) {
        t = t.getCause();
    }
    if (t instanceof AccessException) {
        String msg = t.getMessage();
        int asIndex = msg.indexOf("Registry");
        int rrIndex = msg.indexOf("Registry.Registry");     // Obsolete error text
        int disallowIndex = msg.indexOf("disallowed");
        int nonLocalHostIndex = msg.indexOf("non-local host");
        if (asIndex < 0 ||
                rrIndex != -1 ||
                disallowIndex < 0 ||
                nonLocalHostIndex < 0 ) {
            throw new RuntimeException("exception message is malformed", t);
        }
        System.out.printf("Found expected AccessException: %s%n%n", t);
    } else {
        throw new RuntimeException("AccessException did not occur when expected", ex);
    }
}
 
Example 8
Project: openjdk-jdk10   File: NonLocalJMXRemoteTest.java   View source code 6 votes vote down vote up
/**
 * Check the exception chain for the expected AccessException and message.
 * @param ex the exception from the remote invocation.
 */
private static void assertIsAccessException(Throwable ex) {
    Throwable t = ex;
    while (!(t instanceof AccessException) && t.getCause() != null) {
        t = t.getCause();
    }
    if (t instanceof AccessException) {
        String msg = t.getMessage();
        int asIndex = msg.indexOf("Registry");
        int disallowIndex = msg.indexOf("disallowed");
        int nonLocalHostIndex = msg.indexOf("non-local host");
        if (asIndex < 0 ||
                disallowIndex < 0 ||
                nonLocalHostIndex < 0 ) {
            throw new RuntimeException("exception message is malformed", t);
        }
        System.out.printf("Found expected AccessException: %s%n%n", t);
    } else {
        throw new RuntimeException("AccessException did not occur when expected", ex);
    }
}
 
Example 9
Project: openjdk9   File: Activation.java   View source code 6 votes vote down vote up
/**
 * Shutdown the activation system. Destroys all groups spawned by
 * the activation daemon and exits the activation daemon.
 */
public void shutdown() throws AccessException {
    RegistryImpl.checkAccess("ActivationSystem.shutdown");

    Object lock = startupLock;
    if (lock != null) {
        synchronized (lock) {
            // nothing
        }
    }

    synchronized (Activation.this) {
        if (!shuttingDown) {
            shuttingDown = true;
            (new Shutdown()).start();
        }
    }
}
 
Example 10
Project: jdk8u_jdk   File: Activation.java   View source code 6 votes vote down vote up
/**
 * Shutdown the activation system. Destroys all groups spawned by
 * the activation daemon and exits the activation daemon.
 */
public void shutdown() throws AccessException {
    RegistryImpl.checkAccess("ActivationSystem.shutdown");

    Object lock = startupLock;
    if (lock != null) {
        synchronized (lock) {
            // nothing
        }
    }

    synchronized (Activation.this) {
        if (!shuttingDown) {
            shuttingDown = true;
            (new Shutdown()).start();
        }
    }
}
 
Example 11
Project: lookaside_java-1.8.0-openjdk   File: Activation.java   View source code 6 votes vote down vote up
/**
 * Shutdown the activation system. Destroys all groups spawned by
 * the activation daemon and exits the activation daemon.
 */
public void shutdown() throws AccessException {
    // RegistryImpl.checkAccess() is done in the SameHostOnlyServerRef
    // during unmarshallCustomData and is not applicable to local access.

    Object lock = startupLock;
    if (lock != null) {
        synchronized (lock) {
            // nothing
        }
    }

    synchronized (Activation.this) {
        if (!shuttingDown) {
            shuttingDown = true;
            (new Shutdown()).start();
        }
    }
}
 
Example 12
Project: lookaside_java-1.8.0-openjdk   File: NonLocalActivationTest.java   View source code 6 votes vote down vote up
/**
 * Check the exception chain for the expected AccessException and message.
 * @param ex the exception from the remote invocation.
 */
private static void assertIsAccessException(Exception ex, String msg1) {
    Throwable t = ex;
    System.out.println();
    while (!(t instanceof AccessException) && t.getCause() != null) {
        t = t.getCause();
    }
    if (t instanceof AccessException) {
        String msg = t.getMessage();
        int asIndex = msg.indexOf(msg1);
        int disallowIndex = msg.indexOf("disallowed");
        int nonLocalHostIndex = msg.indexOf("non-local host");
        if (asIndex < 0 ||
                disallowIndex < 0 ||
                nonLocalHostIndex < 0 ) {
            throw new RuntimeException("exception message is malformed", t);
        }
        System.out.printf("Found expected AccessException: %s%n", t);
    } else {
        throw new RuntimeException("AccessException did not occur", ex);
    }
}
 
Example 13
Project: lookaside_java-1.8.0-openjdk   File: NonLocalRegistryTest.java   View source code 6 votes vote down vote up
/**
 * Check the exception chain for the expected AccessException and message.
 * @param ex the exception from the remote invocation.
 */
private static void assertIsAccessException(Throwable ex) {
    Throwable t = ex;
    while (!(t instanceof AccessException) && t.getCause() != null) {
        t = t.getCause();
    }
    if (t instanceof AccessException) {
        String msg = t.getMessage();
        int asIndex = msg.indexOf("Registry");
        int rrIndex = msg.indexOf("Registry.Registry");     // Obsolete error text
        int disallowIndex = msg.indexOf("disallowed");
        int nonLocalHostIndex = msg.indexOf("non-local host");
        if (asIndex < 0 ||
                rrIndex != -1 ||
                disallowIndex < 0 ||
                nonLocalHostIndex < 0 ) {
            throw new RuntimeException("exception message is malformed", t);
        }
        System.out.printf("Found expected AccessException: %s%n%n", t);
    } else {
        throw new RuntimeException("AccessException did not occur when expected", ex);
    }
}
 
Example 14
Project: lookaside_java-1.8.0-openjdk   File: NonLocalJMXRemoteTest.java   View source code 6 votes vote down vote up
/**
 * Check the exception chain for the expected AccessException and message.
 * @param ex the exception from the remote invocation.
 */
private static void assertIsAccessException(Throwable ex) {
    Throwable t = ex;
    while (!(t instanceof AccessException) && t.getCause() != null) {
        t = t.getCause();
    }
    if (t instanceof AccessException) {
        String msg = t.getMessage();
        int asIndex = msg.indexOf("Registry");
        int disallowIndex = msg.indexOf("disallowed");
        int nonLocalHostIndex = msg.indexOf("non-local host");
        if (asIndex < 0 ||
                disallowIndex < 0 ||
                nonLocalHostIndex < 0 ) {
            throw new RuntimeException("exception message is malformed", t);
        }
        System.out.printf("Found expected AccessException: %s%n%n", t);
    } else {
        throw new RuntimeException("AccessException did not occur when expected", ex);
    }
}
 
Example 15
Project: javify   File: RegistryImpl.java   View source code 6 votes vote down vote up
/** @inheritDoc */
public void unbind(String name) throws RemoteException, NotBoundException,
    AccessException
{
  if (name.equals(Main.STOP))
    {
      if (bindings instanceof Persistent)
        ((Persistent) bindings).writeContent();
       // Terminate in 10 seconds.
       System.out.println("Shutdown command received. Will terminate in 10 s");
       Persistent.timer.schedule(new Persistent.ExitTask(), 10000);
    }
  else
    {
      if (Main.verbose)
        System.out.println("Unbind "+name);

      if (!bindings.containsKey(name))
        throw new NotBoundException(name);
      else
        bindings.remove(name);
    }
}
 
Example 16
Project: development   File: ExceptionHandler.java   View source code 6 votes vote down vote up
/**
 * Convert a EJBException into FacesMessage which is presented to the user.
 * 
 * @param ex
 *            the EJBException to be analyzed
 */
public static void execute(EJBException ex) {
    if (ex != null && ex.getCause() instanceof Exception
            && ex.getCausedByException() instanceof AccessException) {
        handleOrganizationAuthoritiesException();
    } else if (ex != null && isInvalidUserSession(ex)) {
        HttpServletRequest request = JSFUtils.getRequest();
        request.getSession().removeAttribute(Constants.SESS_ATTR_USER);
        request.getSession().invalidate();
        handleInvalidSession();
    } else if (ex != null && isConnectionException(ex)) {
        handleMissingConnect(BaseBean.ERROR_DATABASE_NOT_AVAILABLE);
    } else {
        throw new FacesException(ex);
    }
}
 
Example 17
Project: development   File: AuthorizationFilter.java   View source code 6 votes vote down vote up
private void handleServletException(HttpServletRequest httpRequest,
        HttpServletResponse httpResponse, ServletException e)
        throws IOException, ServletException {
    EJBException ejbEx = ExceptionHandler.getEJBException(e);
    if (ejbEx != null && ejbEx.getCause() instanceof Exception
            && ejbEx.getCausedByException() instanceof AccessException) {
        String forwardErrorPage;
        if (BesServletRequestReader.isMarketplaceRequest(httpRequest)) {
            forwardErrorPage = Marketplace.MARKETPLACE_ROOT
                    + Constants.INSUFFICIENT_AUTHORITIES_URI;
        } else {
            forwardErrorPage = Constants.INSUFFICIENT_AUTHORITIES_URI;
        }
        JSFUtils.sendRedirect(httpResponse, httpRequest.getContextPath()
                + forwardErrorPage);
    } else {
        // make sure we do not catch exceptions cause by
        // ViewExpiredException here, they'll be handled directly in the
        // doFilter()
        throw e;
    }
}
 
Example 18
Project: jvm-stm   File: RegistryImpl.java   View source code 6 votes vote down vote up
/** @inheritDoc */
public void unbind(String name) throws RemoteException, NotBoundException,
    AccessException
{
  if (name.equals(Main.STOP))
    {
      if (bindings instanceof Persistent)
        ((Persistent) bindings).writeContent();
       // Terminate in 10 seconds.
       System.out.println("Shutdown command received. Will terminate in 10 s");
       Persistent.timer.schedule(new Persistent.ExitTask(), 10000);
    }
  else
    {
      if (Main.verbose)
        System.out.println("Unbind "+name);
      
      if (!bindings.containsKey(name))
        throw new NotBoundException(name);
      else
        bindings.remove(name);
    }
}
 
Example 19
Project: infobip-open-jdk-8   File: Activation.java   View source code 6 votes vote down vote up
/**
 * Shutdown the activation system. Destroys all groups spawned by
 * the activation daemon and exits the activation daemon.
 */
public void shutdown() throws AccessException {
    RegistryImpl.checkAccess("ActivationSystem.shutdown");

    Object lock = startupLock;
    if (lock != null) {
        synchronized (lock) {
            // nothing
        }
    }

    synchronized (Activation.this) {
        if (!shuttingDown) {
            shuttingDown = true;
            (new Shutdown()).start();
        }
    }
}
 
Example 20
Project: jdk8u-dev-jdk   File: Activation.java   View source code 6 votes vote down vote up
/**
 * Shutdown the activation system. Destroys all groups spawned by
 * the activation daemon and exits the activation daemon.
 */
public void shutdown() throws AccessException {
    RegistryImpl.checkAccess("ActivationSystem.shutdown");

    Object lock = startupLock;
    if (lock != null) {
        synchronized (lock) {
            // nothing
        }
    }

    synchronized (Activation.this) {
        if (!shuttingDown) {
            shuttingDown = true;
            (new Shutdown()).start();
        }
    }
}
 
Example 21
Project: RMI-based-DFS   File: ReplicaServer.java   View source code 6 votes vote down vote up
@Override
public void takeCharge(String fileName, List<ReplicaLoc> slaveReplicas) throws AccessException, RemoteException, NotBoundException {
	System.out.println("[@Replica] taking charge of file: "+fileName);
	System.out.println(slaveReplicas);
	
	List<ReplicaReplicaInterface> slaveReplicasStubs = new ArrayList<ReplicaReplicaInterface>(slaveReplicas.size());
	
	for (ReplicaLoc loc : slaveReplicas) {
		// if the current locations is this replica .. ignore
		if (loc.getId() == this.id)
			continue;
		  
		// if this is a new replica generate stub for this replica
		if (!replicaServersLoc.containsKey(loc.getId())){
			replicaServersLoc.put(loc.getId(), loc);
			ReplicaReplicaInterface stub = (ReplicaReplicaInterface) registry.lookup("ReplicaClient"+loc.getId());
			replicaServersStubs.put(loc.getId(), stub);
		}
		ReplicaReplicaInterface replicaStub = replicaServersStubs.get(loc.getId());
		slaveReplicasStubs.add(replicaStub);
	}
	
	filesReplicaMap.put(fileName, slaveReplicasStubs);
}
 
Example 22
Project: guice-old   File: ThrowingProviderTest.java   View source code 6 votes vote down vote up
public void testProviderMethodWithSubclassOfExceptionIsOk() {
  providesInjector = Guice.createInjector(new AbstractModule() {
    protected void configure() {
      install(ThrowingProviderBinder.forModule(this));
    }
    
    @SuppressWarnings("unused")
    @CheckedProvides(RemoteProvider.class)
    String foo() throws AccessException {
      throw new AccessException("boo!");
    }
  });
  
  RemoteProvider<String> remoteProvider = 
    providesInjector.getInstance(Key.get(remoteProviderOfString));

  try {
    remoteProvider.get();
    fail();
  } catch (RemoteException expected) {
    assertTrue(expected instanceof AccessException);
    assertEquals("boo!", expected.getMessage());
  }
}
 
Example 23
Project: openjdk-source-code-learn   File: Activation.java   View source code 6 votes vote down vote up
/**
 * Shutdown the activation system. Destroys all groups spawned by
 * the activation daemon and exits the activation daemon.
 */
public void shutdown() throws AccessException {
    RegistryImpl.checkAccess("ActivationSystem.shutdown");

    Object lock = startupLock;
    if (lock != null) {
        synchronized (lock) {
            // nothing
        }
    }

    synchronized (Activation.this) {
        if (!shuttingDown) {
            shuttingDown = true;
            (new Shutdown()).start();
        }
    }
}
 
Example 24
Project: OLD-OpenJDK8   File: Activation.java   View source code 6 votes vote down vote up
/**
 * Shutdown the activation system. Destroys all groups spawned by
 * the activation daemon and exits the activation daemon.
 */
public void shutdown() throws AccessException {
    RegistryImpl.checkAccess("ActivationSystem.shutdown");

    Object lock = startupLock;
    if (lock != null) {
        synchronized (lock) {
            // nothing
        }
    }

    synchronized (Activation.this) {
        if (!shuttingDown) {
            shuttingDown = true;
            (new Shutdown()).start();
        }
    }
}
 
Example 25
Project: cn1   File: RegistryImpl.java   View source code 6 votes vote down vote up
/**
 * @see Registry.bind(String, Remote)
 */
public void bind(String name, Remote obj)
        throws RemoteException, AlreadyBoundException, AccessException {
    if (name == null) {
        // rmi.5D=name could not be null.
        throw new NullPointerException(Messages.getString("rmi.5D")); //$NON-NLS-1$
    }

    if (obj == null) {
        // rmi.5C=obj could not be null.
        throw new NullPointerException(Messages.getString("rmi.5C")); //$NON-NLS-1$
    }

    if (table.containsKey(name)) {
        // rmi.5E=There is already binding to the name {0}.
        throw new AlreadyBoundException(Messages.getString("rmi.5E", name)); //$NON-NLS-1$
    }
    checkAccess("RegistryImpl.bind"); //$NON-NLS-1$
    table.put(name, obj);
}
 
Example 26
Project: cn1   File: RegistryImpl.java   View source code 6 votes vote down vote up
/**
 * @see Registry.lookup(String)
 */
public Remote lookup(String name)
        throws RemoteException, NotBoundException, AccessException {
    if (name == null) {
        // rmi.5D=name could not be null.
        throw new NullPointerException(Messages.getString("rmi.5D")); //$NON-NLS-1$
    }
    Remote ref = (Remote) table.get(name);

    if (ref == null) {
        // rmi.5F=Name {0} is not associated with any remote reference.
        throw new NotBoundException(Messages.getString("rmi.5F", name)); //$NON-NLS-1$

    }
    return ref;
}
 
Example 27
Project: JamVM-PH   File: RegistryImpl.java   View source code 6 votes vote down vote up
/** @inheritDoc */
public void unbind(String name) throws RemoteException, NotBoundException,
    AccessException
{
  if (name.equals(Main.STOP))
    {
      if (bindings instanceof Persistent)
        ((Persistent) bindings).writeContent();
       // Terminate in 10 seconds.
       System.out.println("Shutdown command received. Will terminate in 10 s");
       Persistent.timer.schedule(new Persistent.ExitTask(), 10000);
    }
  else
    {
      if (Main.verbose)
        System.out.println("Unbind "+name);
      
      if (!bindings.containsKey(name))
        throw new NotBoundException(name);
      else
        bindings.remove(name);
    }
}
 
Example 28
Project: guice-old   File: CheckedProviderTest.java   View source code 6 votes vote down vote up
public void testCxtorWithSubclassOfExceptionIsOk() throws Exception {
  cxtorInjector = Guice.createInjector(new AbstractModule() {
      @Override
      protected void configure() {
        ThrowingProviderBinder.create(binder())
            .bind(RemoteProvider.class, Foo.class)
            .providing(SubclassExceptionFoo.class);
      }
    });
  
  RemoteProvider<Foo> remoteProvider = 
      cxtorInjector.getInstance(Key.get(remoteProviderOfFoo));

    try {
      remoteProvider.get();
      fail();
    } catch (RemoteException expected) {
      assertTrue(expected instanceof AccessException);
      assertEquals("boo!", expected.getMessage());
    }
}
 
Example 29
Project: dawnsci   File: RMIServerProvider.java   View source code 6 votes vote down vote up
/**
 * Export the remote object under a given name for access as a service. This is the method you call on the server
 * side to make an object available. The registry connection must have been initialised already with a call to
 * {@link #initServer()} for the bound object to be immediately available. Otherwise, the requested binding will be
 * queued until the registry connection is available.
 *
 * @param serviceName
 *            name of the service
 * @param object
 *            object to export
 * @throws AccessException
 *             if the registry is available and local, and security restrictions prevent binding
 * @throws RemoteException
 *             if RMI is disabled entirely, or if object binding fails for a non-security related reason
 */
public synchronized void exportAndRegisterObject(String serviceName, Remote object) throws AccessException,
		RemoteException {

	disabledCheck();

	remotes.put(serviceName, object);

	if (serverRegistry == null) {
		LOGGER.info("Registry not initialised. Queuing " + serviceName);

		if (waitingRemotes == null) {
			waitingRemotes = new LinkedList<String>();
		}

		waitingRemotes.add(serviceName);

	} else {
		bindExportedObject(serviceName, object);
	}
}
 
Example 30
Project: guice   File: CheckedProviderTest.java   View source code 6 votes vote down vote up
public void testProviderMethodWithSubclassOfExceptionIsOk() throws Exception {
  providesInjector =
      Guice.createInjector(
          new AbstractModule() {
            @Override
            protected void configure() {
              install(ThrowingProviderBinder.forModule(this));
            }

            @SuppressWarnings("unused")
            @CheckedProvides(RemoteProvider.class)
            Foo foo() throws AccessException {
              throw new AccessException("boo!");
            }
          });

  RemoteProvider<Foo> remoteProvider = providesInjector.getInstance(Key.get(remoteProviderOfFoo));

  try {
    remoteProvider.get();
    fail();
  } catch (RemoteException expected) {
    assertTrue(expected instanceof AccessException);
    assertEquals("boo!", expected.getMessage());
  }
}
 
Example 31
Project: guice   File: CheckedProviderTest.java   View source code 6 votes vote down vote up
public void testCxtorWithSubclassOfExceptionIsOk() throws Exception {
  cxtorInjector =
      Guice.createInjector(
          new AbstractModule() {
            @Override
            protected void configure() {
              ThrowingProviderBinder.create(binder())
                  .bind(RemoteProvider.class, Foo.class)
                  .providing(SubclassExceptionFoo.class);
            }
          });

  RemoteProvider<Foo> remoteProvider = cxtorInjector.getInstance(Key.get(remoteProviderOfFoo));

  try {
    remoteProvider.get();
    fail();
  } catch (RemoteException expected) {
    assertTrue(expected instanceof AccessException);
    assertEquals("boo!", expected.getMessage());
  }
}
 
Example 32
Project: openjdk-jdk7u-jdk   File: Activation.java   View source code 6 votes vote down vote up
/**
 * Shutdown the activation system. Destroys all groups spawned by
 * the activation daemon and exits the activation daemon.
 */
public void shutdown() throws AccessException {
    RegistryImpl.checkAccess("ActivationSystem.shutdown");

    Object lock = startupLock;
    if (lock != null) {
        synchronized (lock) {
            // nothing
        }
    }

    synchronized (Activation.this) {
        if (!shuttingDown) {
            shuttingDown = true;
            (new Shutdown()).start();
        }
    }
}
 
Example 33
Project: guice-old   File: CheckedProviderTest.java   View source code 6 votes vote down vote up
public void testProviderMethodWithSubclassOfExceptionIsOk() throws Exception {
  providesInjector = Guice.createInjector(new AbstractModule() {
    @Override
    protected void configure() {
      install(ThrowingProviderBinder.forModule(this));
    }
    
    @SuppressWarnings("unused")
    @CheckedProvides(RemoteProvider.class)
    Foo foo() throws AccessException {
      throw new AccessException("boo!");
    }
  });
  
  RemoteProvider<Foo> remoteProvider = 
    providesInjector.getInstance(Key.get(remoteProviderOfFoo));

  try {
    remoteProvider.get();
    fail();
  } catch (RemoteException expected) {
    assertTrue(expected instanceof AccessException);
    assertEquals("boo!", expected.getMessage());
  }
}
 
Example 34
Project: OpenJSharp   File: Activation.java   View source code 5 votes vote down vote up
public void bind(String name, Remote obj)
    throws RemoteException, AlreadyBoundException, AccessException
{
    if (name.equals(NAME)) {
        throw new AccessException(
            "binding ActivationSystem is disallowed");
    } else {
        super.bind(name, obj);
    }
}
 
Example 35
Project: OpenJSharp   File: Activation.java   View source code 5 votes vote down vote up
public void unbind(String name)
    throws RemoteException, NotBoundException, AccessException
{
    if (name.equals(NAME)) {
        throw new AccessException(
            "unbinding ActivationSystem is disallowed");
    } else {
        super.unbind(name);
    }
}
 
Example 36
Project: OpenJSharp   File: Activation.java   View source code 5 votes vote down vote up
public void rebind(String name, Remote obj)
    throws RemoteException, AccessException
{
    if (name.equals(NAME)) {
        throw new AccessException(
            "binding ActivationSystem is disallowed");
    } else {
        super.rebind(name, obj);
    }
}
 
Example 37
Project: monarch   File: DUnitLauncher.java   View source code 5 votes vote down vote up
public void init(Registry registry, int numVMs) throws AccessException, RemoteException, NotBoundException, InterruptedException {
  for(int i = 0; i < numVMs; i++) {
    RemoteDUnitVMIF remote = processManager.getStub(i);
    addVM(i, remote);
  }

  addLocator(LOCATOR_VM_NUM, processManager.getStub(LOCATOR_VM_NUM));

  addHost(this);
}
 
Example 38
Project: monarch   File: DUnitLauncher.java   View source code 5 votes vote down vote up
public void init(Registry registry, int numVMs)
    throws AccessException, RemoteException, NotBoundException, InterruptedException {
  for (int i = 0; i < numVMs; i++) {
    RemoteDUnitVMIF remote = processManager.getStub(i);
    addVM(i, remote);
  }

  addLocator(LOCATOR_VM_NUM, processManager.getStub(LOCATOR_VM_NUM));

  addHost(this);
}
 
Example 39
Project: jdk8u-jdk   File: Activation.java   View source code 5 votes vote down vote up
public void bind(String name, Remote obj)
    throws RemoteException, AlreadyBoundException, AccessException
{
    if (name.equals(NAME)) {
        throw new AccessException(
            "binding ActivationSystem is disallowed");
    } else {
        super.bind(name, obj);
    }
}
 
Example 40
Project: jdk8u-jdk   File: Activation.java   View source code 5 votes vote down vote up
public void unbind(String name)
    throws RemoteException, NotBoundException, AccessException
{
    if (name.equals(NAME)) {
        throw new AccessException(
            "unbinding ActivationSystem is disallowed");
    } else {
        super.unbind(name);
    }
}