users@glassfish.java.net

Re: Post Deployment Configuration of MDB using JCA Inbound ...

From: <forums_at_java.net>
Date: Wed, 21 Dec 2011 12:21:10 -0600 (CST)

Thanks for your response, Julius!

My socket resource adapter handles mutliple sockets via the implementation
below.  Each socket created by the endpointActivation() method is mapped
to its activation spec and stored in a static ConcurrentMap.  The config
properties are global to the resource adapter, therefore, I'm not sure they'd
work in this case?  Perhaps, I need to redesign my SocketResourceAdapter.

I originally thought I could access the resource adapter directly through
JNDI and call the endpointActivation() with an ActivationSpec populated from
my code, but then I'd be breaking the contract with the app server.

Thanks again,
Nate

public class SocketResourceAdapter implements ResourceAdapter { private final
Log log = LogFactory.getLog(SocketResourceAdapter.class); private static
ConcurrentMap<ActivationSpec, SocketListener> socketListeners = new
ConcurrentHashMap<ActivationSpec, SocketListener>(); private WorkManager
workManager; private String defaultEncoding; private boolean isRunning =
false; public SocketResourceAdapter() { } @Override public void
start(BootstrapContext ctx) throws ResourceAdapterInternalException {
log.info("start"); workManager = ctx.getWorkManager(); for (SocketListener
socketListener : socketListeners.values()) { socketListener.start(); } }
@Override public void stop() { log.info("stop"); for (SocketListener
socketListener : socketListeners.values()) { socketListener.release(); } }
@Override public void endpointActivation(MessageEndpointFactory
endpointFactory, ActivationSpec activationSpec) throws ResourceException {
log.info("endpointActivation"); if (!(activationSpec instanceof
SocketActivationSpec)) { throw new NotSupportedException("Invalid spec" +
activationSpec); } SocketActivationSpec socketActivationSpec =
(SocketActivationSpec) activationSpec; if (socketActivationSpec.getEncoding()
== null) { socketActivationSpec.setEncoding(defaultEncoding); }
SocketListener socketListener = new SocketListener(workManager,
socketActivationSpec, endpointFactory); socketListeners.put(activationSpec,
socketListener); try { socketListener.start(); } catch (ResourceException e)
{ socketListener.release(); throw e; } } ...
 


--
[Message sent by forum member 'cerebrus']
View Post: http://forums.java.net/node/875933