Java Code Examples for org.springframework.remoting.RemoteLookupFailureException

The following examples show how to use org.springframework.remoting.RemoteLookupFailureException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-analysis-note   Source File: RmiClientInterceptor.java    License: MIT License 6 votes vote down vote up
/**
 * Fetches RMI stub on startup, if necessary.
 * @throws RemoteLookupFailureException if RMI stub creation failed
 * @see #setLookupStubOnStartup
 * @see #lookupStub
 */
public void prepare() throws RemoteLookupFailureException {
	// Cache RMI stub on initialization?
	if (this.lookupStubOnStartup) {
		Remote remoteObj = lookupStub();
		if (logger.isDebugEnabled()) {
			if (remoteObj instanceof RmiInvocationHandler) {
				logger.debug("RMI stub [" + getServiceUrl() + "] is an RMI invoker");
			}
			else if (getServiceInterface() != null) {
				boolean isImpl = getServiceInterface().isInstance(remoteObj);
				logger.debug("Using service interface [" + getServiceInterface().getName() +
					"] for RMI stub [" + getServiceUrl() + "] - " +
					(!isImpl ? "not " : "") + "directly implemented");
			}
		}
		if (this.cacheStub) {
			this.cachedStub = remoteObj;
		}
	}
}
 
Example 2
Source Project: spring-analysis-note   Source File: JndiRmiClientInterceptor.java    License: MIT License 6 votes vote down vote up
/**
 * Fetches the RMI stub on startup, if necessary.
 * @throws RemoteLookupFailureException if RMI stub creation failed
 * @see #setLookupStubOnStartup
 * @see #lookupStub
 */
public void prepare() throws RemoteLookupFailureException {
	// Cache RMI stub on initialization?
	if (this.lookupStubOnStartup) {
		Object remoteObj = lookupStub();
		if (logger.isDebugEnabled()) {
			if (remoteObj instanceof RmiInvocationHandler) {
				logger.debug("JNDI RMI object [" + getJndiName() + "] is an RMI invoker");
			}
			else if (getServiceInterface() != null) {
				boolean isImpl = getServiceInterface().isInstance(remoteObj);
				logger.debug("Using service interface [" + getServiceInterface().getName() +
						"] for JNDI RMI object [" + getJndiName() + "] - " +
						(!isImpl ? "not " : "") + "directly implemented");
			}
		}
		if (this.cacheStub) {
			this.cachedStub = remoteObj;
		}
	}
}
 
Example 3
Source Project: java-technology-stack   Source File: RmiClientInterceptor.java    License: MIT License 6 votes vote down vote up
/**
 * Fetches RMI stub on startup, if necessary.
 * @throws RemoteLookupFailureException if RMI stub creation failed
 * @see #setLookupStubOnStartup
 * @see #lookupStub
 */
public void prepare() throws RemoteLookupFailureException {
	// Cache RMI stub on initialization?
	if (this.lookupStubOnStartup) {
		Remote remoteObj = lookupStub();
		if (logger.isDebugEnabled()) {
			if (remoteObj instanceof RmiInvocationHandler) {
				logger.debug("RMI stub [" + getServiceUrl() + "] is an RMI invoker");
			}
			else if (getServiceInterface() != null) {
				boolean isImpl = getServiceInterface().isInstance(remoteObj);
				logger.debug("Using service interface [" + getServiceInterface().getName() +
					"] for RMI stub [" + getServiceUrl() + "] - " +
					(!isImpl ? "not " : "") + "directly implemented");
			}
		}
		if (this.cacheStub) {
			this.cachedStub = remoteObj;
		}
	}
}
 
Example 4
Source Project: java-technology-stack   Source File: JndiRmiClientInterceptor.java    License: MIT License 6 votes vote down vote up
/**
 * Fetches the RMI stub on startup, if necessary.
 * @throws RemoteLookupFailureException if RMI stub creation failed
 * @see #setLookupStubOnStartup
 * @see #lookupStub
 */
public void prepare() throws RemoteLookupFailureException {
	// Cache RMI stub on initialization?
	if (this.lookupStubOnStartup) {
		Object remoteObj = lookupStub();
		if (logger.isDebugEnabled()) {
			if (remoteObj instanceof RmiInvocationHandler) {
				logger.debug("JNDI RMI object [" + getJndiName() + "] is an RMI invoker");
			}
			else if (getServiceInterface() != null) {
				boolean isImpl = getServiceInterface().isInstance(remoteObj);
				logger.debug("Using service interface [" + getServiceInterface().getName() +
						"] for JNDI RMI object [" + getJndiName() + "] - " +
						(!isImpl ? "not " : "") + "directly implemented");
			}
		}
		if (this.cacheStub) {
			this.cachedStub = remoteObj;
		}
	}
}
 
Example 5
Source Project: lams   Source File: RmiClientInterceptor.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Fetches RMI stub on startup, if necessary.
 * @throws RemoteLookupFailureException if RMI stub creation failed
 * @see #setLookupStubOnStartup
 * @see #lookupStub
 */
public void prepare() throws RemoteLookupFailureException {
	// Cache RMI stub on initialization?
	if (this.lookupStubOnStartup) {
		Remote remoteObj = lookupStub();
		if (logger.isDebugEnabled()) {
			if (remoteObj instanceof RmiInvocationHandler) {
				logger.debug("RMI stub [" + getServiceUrl() + "] is an RMI invoker");
			}
			else if (getServiceInterface() != null) {
				boolean isImpl = getServiceInterface().isInstance(remoteObj);
				logger.debug("Using service interface [" + getServiceInterface().getName() +
					"] for RMI stub [" + getServiceUrl() + "] - " +
					(!isImpl ? "not " : "") + "directly implemented");
			}
		}
		if (this.cacheStub) {
			this.cachedStub = remoteObj;
		}
	}
}
 
Example 6
/**
 * Fetches the RMI stub on startup, if necessary.
 * @throws RemoteLookupFailureException if RMI stub creation failed
 * @see #setLookupStubOnStartup
 * @see #lookupStub
 */
public void prepare() throws RemoteLookupFailureException {
	// Cache RMI stub on initialization?
	if (this.lookupStubOnStartup) {
		Object remoteObj = lookupStub();
		if (logger.isDebugEnabled()) {
			if (remoteObj instanceof RmiInvocationHandler) {
				logger.debug("JNDI RMI object [" + getJndiName() + "] is an RMI invoker");
			}
			else if (getServiceInterface() != null) {
				boolean isImpl = getServiceInterface().isInstance(remoteObj);
				logger.debug("Using service interface [" + getServiceInterface().getName() +
						"] for JNDI RMI object [" + getJndiName() + "] - " +
						(!isImpl ? "not " : "") + "directly implemented");
			}
		}
		if (this.cacheStub) {
			this.cachedStub = remoteObj;
		}
	}
}
 
Example 7
/**
 * Fetches RMI stub on startup, if necessary.
 * @throws RemoteLookupFailureException if RMI stub creation failed
 * @see #setLookupStubOnStartup
 * @see #lookupStub
 */
public void prepare() throws RemoteLookupFailureException {
	// Cache RMI stub on initialization?
	if (this.lookupStubOnStartup) {
		Remote remoteObj = lookupStub();
		if (logger.isDebugEnabled()) {
			if (remoteObj instanceof RmiInvocationHandler) {
				logger.debug("RMI stub [" + getServiceUrl() + "] is an RMI invoker");
			}
			else if (getServiceInterface() != null) {
				boolean isImpl = getServiceInterface().isInstance(remoteObj);
				logger.debug("Using service interface [" + getServiceInterface().getName() +
					"] for RMI stub [" + getServiceUrl() + "] - " +
					(!isImpl ? "not " : "") + "directly implemented");
			}
		}
		if (this.cacheStub) {
			this.cachedStub = remoteObj;
		}
	}
}
 
Example 8
/**
 * Fetches the RMI stub on startup, if necessary.
 * @throws RemoteLookupFailureException if RMI stub creation failed
 * @see #setLookupStubOnStartup
 * @see #lookupStub
 */
public void prepare() throws RemoteLookupFailureException {
	// Cache RMI stub on initialization?
	if (this.lookupStubOnStartup) {
		Object remoteObj = lookupStub();
		if (logger.isDebugEnabled()) {
			if (remoteObj instanceof RmiInvocationHandler) {
				logger.debug("JNDI RMI object [" + getJndiName() + "] is an RMI invoker");
			}
			else if (getServiceInterface() != null) {
				boolean isImpl = getServiceInterface().isInstance(remoteObj);
				logger.debug("Using service interface [" + getServiceInterface().getName() +
						"] for JNDI RMI object [" + getJndiName() + "] - " +
						(!isImpl ? "not " : "") + "directly implemented");
			}
		}
		if (this.cacheStub) {
			this.cachedStub = remoteObj;
		}
	}
}
 
Example 9
Source Project: spring-analysis-note   Source File: RmiClientInterceptor.java    License: MIT License 5 votes vote down vote up
/**
 * Return the RMI stub to use. Called for each invocation.
 * <p>The default implementation returns the stub created on initialization,
 * if any. Else, it invokes {@link #lookupStub} to get a new stub for
 * each invocation. This can be overridden in subclasses, for example in
 * order to cache a stub for a given amount of time before recreating it,
 * or to test the stub whether it is still alive.
 * @return the RMI stub to use for an invocation
 * @throws RemoteLookupFailureException if RMI stub creation failed
 * @see #lookupStub
 */
protected Remote getStub() throws RemoteLookupFailureException {
	if (!this.cacheStub || (this.lookupStubOnStartup && !this.refreshStubOnConnectFailure)) {
		return (this.cachedStub != null ? this.cachedStub : lookupStub());
	}
	else {
		synchronized (this.stubMonitor) {
			if (this.cachedStub == null) {
				this.cachedStub = lookupStub();
			}
			return this.cachedStub;
		}
	}
}
 
Example 10
Source Project: spring-analysis-note   Source File: JndiRmiClientInterceptor.java    License: MIT License 5 votes vote down vote up
/**
 * Return the RMI stub to use. Called for each invocation.
 * <p>The default implementation returns the stub created on initialization,
 * if any. Else, it invokes {@link #lookupStub} to get a new stub for
 * each invocation. This can be overridden in subclasses, for example in
 * order to cache a stub for a given amount of time before recreating it,
 * or to test the stub whether it is still alive.
 * @return the RMI stub to use for an invocation
 * @throws NamingException if stub creation failed
 * @throws RemoteLookupFailureException if RMI stub creation failed
 */
protected Object getStub() throws NamingException, RemoteLookupFailureException {
	if (!this.cacheStub || (this.lookupStubOnStartup && !this.refreshStubOnConnectFailure)) {
		return (this.cachedStub != null ? this.cachedStub : lookupStub());
	}
	else {
		synchronized (this.stubMonitor) {
			if (this.cachedStub == null) {
				this.cachedStub = lookupStub();
			}
			return this.cachedStub;
		}
	}
}
 
Example 11
/**
 * Refresh the EJB home object and retry the given invocation.
 * Called by invoke on connect failure.
 * @param invocation the AOP method invocation
 * @return the invocation result, if any
 * @throws Throwable in case of invocation failure
 * @see #invoke
 */
@Nullable
protected Object refreshAndRetry(MethodInvocation invocation) throws Throwable {
	try {
		refreshHome();
	}
	catch (NamingException ex) {
		throw new RemoteLookupFailureException("Failed to locate remote EJB [" + getJndiName() + "]", ex);
	}
	return doInvoke(invocation);
}
 
Example 12
Source Project: spring-analysis-note   Source File: HessianClientInterceptor.java    License: MIT License 5 votes vote down vote up
/**
 * Initialize the Hessian proxy for this interceptor.
 * @throws RemoteLookupFailureException if the service URL is invalid
 */
public void prepare() throws RemoteLookupFailureException {
	try {
		this.hessianProxy = createHessianProxy(this.proxyFactory);
	}
	catch (MalformedURLException ex) {
		throw new RemoteLookupFailureException("Service URL [" + getServiceUrl() + "] is invalid", ex);
	}
}
 
Example 13
Source Project: spring-analysis-note   Source File: JaxWsPortClientInterceptor.java    License: MIT License 5 votes vote down vote up
/**
 * Prepare the given JAX-WS port stub, applying properties to it.
 * Called by {@link #prepare}.
 * @param stub the current JAX-WS port stub
 * @see #setUsername
 * @see #setPassword
 * @see #setEndpointAddress
 * @see #setMaintainSession
 * @see #setCustomProperties
 */
protected void preparePortStub(Object stub) {
	Map<String, Object> stubProperties = new HashMap<>();
	String username = getUsername();
	if (username != null) {
		stubProperties.put(BindingProvider.USERNAME_PROPERTY, username);
	}
	String password = getPassword();
	if (password != null) {
		stubProperties.put(BindingProvider.PASSWORD_PROPERTY, password);
	}
	String endpointAddress = getEndpointAddress();
	if (endpointAddress != null) {
		stubProperties.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress);
	}
	if (isMaintainSession()) {
		stubProperties.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
	}
	if (isUseSoapAction()) {
		stubProperties.put(BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
	}
	String soapActionUri = getSoapActionUri();
	if (soapActionUri != null) {
		stubProperties.put(BindingProvider.SOAPACTION_URI_PROPERTY, soapActionUri);
	}
	stubProperties.putAll(getCustomProperties());
	if (!stubProperties.isEmpty()) {
		if (!(stub instanceof BindingProvider)) {
			throw new RemoteLookupFailureException("Port stub of class [" + stub.getClass().getName() +
					"] is not a customizable JAX-WS stub: it does not implement interface [javax.xml.ws.BindingProvider]");
		}
		((BindingProvider) stub).getRequestContext().putAll(stubProperties);
	}
}
 
Example 14
Source Project: java-technology-stack   Source File: RmiClientInterceptor.java    License: MIT License 5 votes vote down vote up
/**
 * Return the RMI stub to use. Called for each invocation.
 * <p>The default implementation returns the stub created on initialization,
 * if any. Else, it invokes {@link #lookupStub} to get a new stub for
 * each invocation. This can be overridden in subclasses, for example in
 * order to cache a stub for a given amount of time before recreating it,
 * or to test the stub whether it is still alive.
 * @return the RMI stub to use for an invocation
 * @throws RemoteLookupFailureException if RMI stub creation failed
 * @see #lookupStub
 */
protected Remote getStub() throws RemoteLookupFailureException {
	if (!this.cacheStub || (this.lookupStubOnStartup && !this.refreshStubOnConnectFailure)) {
		return (this.cachedStub != null ? this.cachedStub : lookupStub());
	}
	else {
		synchronized (this.stubMonitor) {
			if (this.cachedStub == null) {
				this.cachedStub = lookupStub();
			}
			return this.cachedStub;
		}
	}
}
 
Example 15
Source Project: java-technology-stack   Source File: JndiRmiClientInterceptor.java    License: MIT License 5 votes vote down vote up
/**
 * Return the RMI stub to use. Called for each invocation.
 * <p>The default implementation returns the stub created on initialization,
 * if any. Else, it invokes {@link #lookupStub} to get a new stub for
 * each invocation. This can be overridden in subclasses, for example in
 * order to cache a stub for a given amount of time before recreating it,
 * or to test the stub whether it is still alive.
 * @return the RMI stub to use for an invocation
 * @throws NamingException if stub creation failed
 * @throws RemoteLookupFailureException if RMI stub creation failed
 */
protected Object getStub() throws NamingException, RemoteLookupFailureException {
	if (!this.cacheStub || (this.lookupStubOnStartup && !this.refreshStubOnConnectFailure)) {
		return (this.cachedStub != null ? this.cachedStub : lookupStub());
	}
	else {
		synchronized (this.stubMonitor) {
			if (this.cachedStub == null) {
				this.cachedStub = lookupStub();
			}
			return this.cachedStub;
		}
	}
}
 
Example 16
/**
 * Refresh the EJB home object and retry the given invocation.
 * Called by invoke on connect failure.
 * @param invocation the AOP method invocation
 * @return the invocation result, if any
 * @throws Throwable in case of invocation failure
 * @see #invoke
 */
@Nullable
protected Object refreshAndRetry(MethodInvocation invocation) throws Throwable {
	try {
		refreshHome();
	}
	catch (NamingException ex) {
		throw new RemoteLookupFailureException("Failed to locate remote EJB [" + getJndiName() + "]", ex);
	}
	return doInvoke(invocation);
}
 
Example 17
Source Project: java-technology-stack   Source File: HessianClientInterceptor.java    License: MIT License 5 votes vote down vote up
/**
 * Initialize the Hessian proxy for this interceptor.
 * @throws RemoteLookupFailureException if the service URL is invalid
 */
public void prepare() throws RemoteLookupFailureException {
	try {
		this.hessianProxy = createHessianProxy(this.proxyFactory);
	}
	catch (MalformedURLException ex) {
		throw new RemoteLookupFailureException("Service URL [" + getServiceUrl() + "] is invalid", ex);
	}
}
 
Example 18
Source Project: java-technology-stack   Source File: JaxWsPortClientInterceptor.java    License: MIT License 5 votes vote down vote up
/**
 * Prepare the given JAX-WS port stub, applying properties to it.
 * Called by {@link #prepare}.
 * @param stub the current JAX-WS port stub
 * @see #setUsername
 * @see #setPassword
 * @see #setEndpointAddress
 * @see #setMaintainSession
 * @see #setCustomProperties
 */
protected void preparePortStub(Object stub) {
	Map<String, Object> stubProperties = new HashMap<>();
	String username = getUsername();
	if (username != null) {
		stubProperties.put(BindingProvider.USERNAME_PROPERTY, username);
	}
	String password = getPassword();
	if (password != null) {
		stubProperties.put(BindingProvider.PASSWORD_PROPERTY, password);
	}
	String endpointAddress = getEndpointAddress();
	if (endpointAddress != null) {
		stubProperties.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress);
	}
	if (isMaintainSession()) {
		stubProperties.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
	}
	if (isUseSoapAction()) {
		stubProperties.put(BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
	}
	String soapActionUri = getSoapActionUri();
	if (soapActionUri != null) {
		stubProperties.put(BindingProvider.SOAPACTION_URI_PROPERTY, soapActionUri);
	}
	stubProperties.putAll(getCustomProperties());
	if (!stubProperties.isEmpty()) {
		if (!(stub instanceof BindingProvider)) {
			throw new RemoteLookupFailureException("Port stub of class [" + stub.getClass().getName() +
					"] is not a customizable JAX-WS stub: it does not implement interface [javax.xml.ws.BindingProvider]");
		}
		((BindingProvider) stub).getRequestContext().putAll(stubProperties);
	}
}
 
Example 19
/**
 * Initialize the Hessian proxy for this interceptor.
 * @throws RemoteLookupFailureException if the service URL is invalid
 */
public void prepare() throws RemoteLookupFailureException {
	try {
		this.hessianProxy = createHessianProxy(this.proxyFactory);
	}
	catch (MalformedURLException ex) {
		throw new RemoteLookupFailureException("Service URL [" + getServiceUrl() + "] is invalid", ex);
	}
}
 
Example 20
Source Project: lams   Source File: BurlapClientInterceptor.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initialize the Burlap proxy for this interceptor.
 * @throws RemoteLookupFailureException if the service URL is invalid
 */
public void prepare() throws RemoteLookupFailureException {
	try {
		this.burlapProxy = createBurlapProxy(this.proxyFactory);
	}
	catch (MalformedURLException ex) {
		throw new RemoteLookupFailureException("Service URL [" + getServiceUrl() + "] is invalid", ex);
	}
}
 
Example 21
Source Project: lams   Source File: RmiClientInterceptor.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the RMI stub to use. Called for each invocation.
 * <p>The default implementation returns the stub created on initialization,
 * if any. Else, it invokes {@link #lookupStub} to get a new stub for
 * each invocation. This can be overridden in subclasses, for example in
 * order to cache a stub for a given amount of time before recreating it,
 * or to test the stub whether it is still alive.
 * @return the RMI stub to use for an invocation
 * @throws RemoteLookupFailureException if RMI stub creation failed
 * @see #lookupStub
 */
protected Remote getStub() throws RemoteLookupFailureException {
	if (!this.cacheStub || (this.lookupStubOnStartup && !this.refreshStubOnConnectFailure)) {
		return (this.cachedStub != null ? this.cachedStub : lookupStub());
	}
	else {
		synchronized (this.stubMonitor) {
			if (this.cachedStub == null) {
				this.cachedStub = lookupStub();
			}
			return this.cachedStub;
		}
	}
}
 
Example 22
/**
 * Return the RMI stub to use. Called for each invocation.
 * <p>The default implementation returns the stub created on initialization,
 * if any. Else, it invokes {@link #lookupStub} to get a new stub for
 * each invocation. This can be overridden in subclasses, for example in
 * order to cache a stub for a given amount of time before recreating it,
 * or to test the stub whether it is still alive.
 * @return the RMI stub to use for an invocation
 * @throws NamingException if stub creation failed
 * @throws RemoteLookupFailureException if RMI stub creation failed
 */
protected Object getStub() throws NamingException, RemoteLookupFailureException {
	if (!this.cacheStub || (this.lookupStubOnStartup && !this.refreshStubOnConnectFailure)) {
		return (this.cachedStub != null ? this.cachedStub : lookupStub());
	}
	else {
		synchronized (this.stubMonitor) {
			if (this.cachedStub == null) {
				this.cachedStub = lookupStub();
			}
			return this.cachedStub;
		}
	}
}
 
Example 23
/**
 * Prepare the given JAX-WS port stub, applying properties to it.
 * Called by {@link #prepare}.
 * @param stub the current JAX-WS port stub
 * @see #setUsername
 * @see #setPassword
 * @see #setEndpointAddress
 * @see #setMaintainSession
 * @see #setCustomProperties
 */
protected void preparePortStub(Object stub) {
	Map<String, Object> stubProperties = new HashMap<String, Object>();
	String username = getUsername();
	if (username != null) {
		stubProperties.put(BindingProvider.USERNAME_PROPERTY, username);
	}
	String password = getPassword();
	if (password != null) {
		stubProperties.put(BindingProvider.PASSWORD_PROPERTY, password);
	}
	String endpointAddress = getEndpointAddress();
	if (endpointAddress != null) {
		stubProperties.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress);
	}
	if (isMaintainSession()) {
		stubProperties.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
	}
	if (isUseSoapAction()) {
		stubProperties.put(BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
	}
	String soapActionUri = getSoapActionUri();
	if (soapActionUri != null) {
		stubProperties.put(BindingProvider.SOAPACTION_URI_PROPERTY, soapActionUri);
	}
	stubProperties.putAll(getCustomProperties());
	if (!stubProperties.isEmpty()) {
		if (!(stub instanceof BindingProvider)) {
			throw new RemoteLookupFailureException("Port stub of class [" + stub.getClass().getName() +
					"] is not a customizable JAX-WS stub: it does not implement interface [javax.xml.ws.BindingProvider]");
		}
		((BindingProvider) stub).getRequestContext().putAll(stubProperties);
	}
}
 
Example 24
/**
 * This overridden lookup implementation performs a narrow operation
 * after the JNDI lookup, provided that a home interface is specified.
 * @see #setHomeInterface
 * @see javax.rmi.PortableRemoteObject#narrow
 */
@Override
protected Object lookup() throws NamingException {
	Object homeObject = super.lookup();
	if (this.homeInterface != null) {
		try {
			homeObject = PortableRemoteObject.narrow(homeObject, this.homeInterface);
		}
		catch (ClassCastException ex) {
			throw new RemoteLookupFailureException(
					"Could not narrow EJB home stub to home interface [" + this.homeInterface.getName() + "]", ex);
		}
	}
	return homeObject;
}
 
Example 25
/**
 * Refresh the EJB home object and retry the given invocation.
 * Called by invoke on connect failure.
 * @param invocation the AOP method invocation
 * @return the invocation result, if any
 * @throws Throwable in case of invocation failure
 * @see #invoke
 */
protected Object refreshAndRetry(MethodInvocation invocation) throws Throwable {
	try {
		refreshHome();
	}
	catch (NamingException ex) {
		throw new RemoteLookupFailureException("Failed to locate remote EJB [" + getJndiName() + "]", ex);
	}
	return doInvoke(invocation);
}
 
Example 26
/**
 * Return the RMI stub to use. Called for each invocation.
 * <p>The default implementation returns the stub created on initialization,
 * if any. Else, it invokes {@link #lookupStub} to get a new stub for
 * each invocation. This can be overridden in subclasses, for example in
 * order to cache a stub for a given amount of time before recreating it,
 * or to test the stub whether it is still alive.
 * @return the RMI stub to use for an invocation
 * @throws RemoteLookupFailureException if RMI stub creation failed
 * @see #lookupStub
 */
protected Remote getStub() throws RemoteLookupFailureException {
	if (!this.cacheStub || (this.lookupStubOnStartup && !this.refreshStubOnConnectFailure)) {
		return (this.cachedStub != null ? this.cachedStub : lookupStub());
	}
	else {
		synchronized (this.stubMonitor) {
			if (this.cachedStub == null) {
				this.cachedStub = lookupStub();
			}
			return this.cachedStub;
		}
	}
}
 
Example 27
/**
 * Return the RMI stub to use. Called for each invocation.
 * <p>The default implementation returns the stub created on initialization,
 * if any. Else, it invokes {@link #lookupStub} to get a new stub for
 * each invocation. This can be overridden in subclasses, for example in
 * order to cache a stub for a given amount of time before recreating it,
 * or to test the stub whether it is still alive.
 * @return the RMI stub to use for an invocation
 * @throws NamingException if stub creation failed
 * @throws RemoteLookupFailureException if RMI stub creation failed
 */
protected Object getStub() throws NamingException, RemoteLookupFailureException {
	if (!this.cacheStub || (this.lookupStubOnStartup && !this.refreshStubOnConnectFailure)) {
		return (this.cachedStub != null ? this.cachedStub : lookupStub());
	}
	else {
		synchronized (this.stubMonitor) {
			if (this.cachedStub == null) {
				this.cachedStub = lookupStub();
			}
			return this.cachedStub;
		}
	}
}
 
Example 28
/**
 * This overridden lookup implementation performs a narrow operation
 * after the JNDI lookup, provided that a home interface is specified.
 * @see #setHomeInterface
 * @see javax.rmi.PortableRemoteObject#narrow
 */
@Override
protected Object lookup() throws NamingException {
	Object homeObject = super.lookup();
	if (this.homeInterface != null) {
		try {
			homeObject = PortableRemoteObject.narrow(homeObject, this.homeInterface);
		}
		catch (ClassCastException ex) {
			throw new RemoteLookupFailureException(
					"Could not narrow EJB home stub to home interface [" + this.homeInterface.getName() + "]", ex);
		}
	}
	return homeObject;
}
 
Example 29
/**
 * Refresh the EJB home object and retry the given invocation.
 * Called by invoke on connect failure.
 * @param invocation the AOP method invocation
 * @return the invocation result, if any
 * @throws Throwable in case of invocation failure
 * @see #invoke
 */
protected Object refreshAndRetry(MethodInvocation invocation) throws Throwable {
	try {
		refreshHome();
	}
	catch (NamingException ex) {
		throw new RemoteLookupFailureException("Failed to locate remote EJB [" + getJndiName() + "]", ex);
	}
	return doInvoke(invocation);
}
 
Example 30
/**
 * Initialize the Hessian proxy for this interceptor.
 * @throws RemoteLookupFailureException if the service URL is invalid
 */
public void prepare() throws RemoteLookupFailureException {
	try {
		this.hessianProxy = createHessianProxy(this.proxyFactory);
	}
	catch (MalformedURLException ex) {
		throw new RemoteLookupFailureException("Service URL [" + getServiceUrl() + "] is invalid", ex);
	}
}