本文整理汇总了Java中java.rmi.AccessException类的典型用法代码示例。如果您正苦于以下问题:Java AccessException类的具体用法?Java AccessException怎么用?Java AccessException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AccessException类属于java.rmi包,在下文中一共展示了AccessException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import java.rmi.AccessException; //导入依赖的package包/类
/**
* 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);
}
}
示例2: handleServletException
import java.rmi.AccessException; //导入依赖的package包/类
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;
}
}
示例3: shutdown
import java.rmi.AccessException; //导入依赖的package包/类
/**
* 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();
}
}
}
示例4: shutdown
import java.rmi.AccessException; //导入依赖的package包/类
/**
* 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();
}
}
}
示例5: assertIsAccessException
import java.rmi.AccessException; //导入依赖的package包/类
/**
* 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);
}
}
示例6: assertIsAccessException
import java.rmi.AccessException; //导入依赖的package包/类
/**
* 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);
}
}
示例7: assertIsAccessException
import java.rmi.AccessException; //导入依赖的package包/类
/**
* 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);
}
}
示例8: unbind
import java.rmi.AccessException; //导入依赖的package包/类
/** @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);
}
}
示例9: handleServletException
import java.rmi.AccessException; //导入依赖的package包/类
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;
}
}
示例10: unbind
import java.rmi.AccessException; //导入依赖的package包/类
/** @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);
}
}
示例11: takeCharge
import java.rmi.AccessException; //导入依赖的package包/类
@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);
}
示例12: testProviderMethodWithSubclassOfExceptionIsOk
import java.rmi.AccessException; //导入依赖的package包/类
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());
}
}
示例13: bind
import java.rmi.AccessException; //导入依赖的package包/类
/**
* @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);
}
示例14: lookup
import java.rmi.AccessException; //导入依赖的package包/类
/**
* @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;
}
示例15: testCxtorWithSubclassOfExceptionIsOk
import java.rmi.AccessException; //导入依赖的package包/类
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());
}
}