3
Fork 0

[svn r331] made the SPI interface also work.

This commit is contained in:
willemc 2008-04-26 02:30:39 +02:00
parent 46f1863f05
commit 64ca1c8f3a
10 changed files with 371 additions and 49 deletions

View file

@ -26,7 +26,10 @@
package com.idcanet.foei.ee.jca.spi;
import java.util.logging.Level;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import javax.resource.ResourceException;
@ -34,12 +37,9 @@ import javax.resource.spi.ActivationSpec;
import javax.resource.spi.BootstrapContext;
import javax.resource.spi.ResourceAdapter;
import javax.resource.spi.ResourceAdapterInternalException;
import javax.resource.spi.endpoint.MessageEndpoint;
import javax.resource.spi.endpoint.MessageEndpointFactory;
import javax.transaction.xa.XAResource;
import com.idcanet.foei.server.FoeiContextManagerFactory;
/**
*
*
@ -52,11 +52,14 @@ public class FoeiResourceAdapter implements ResourceAdapter {
private BootstrapContext bootstrapContext = null;
private Map<String,SpecBean> ejbs = null;
/**
* @see javax.resource.spi.ResourceAdapter#start(javax.resource.spi.BootstrapContext)
*/
public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
logger.info("Starting FoeiResourceAdapter");
ejbs = new HashMap<String,SpecBean>(5);
this.bootstrapContext=bootstrapContext;
}
@ -65,12 +68,8 @@ public class FoeiResourceAdapter implements ResourceAdapter {
*/
public void stop() {
logger.info("Stopping FoeiResourceAdapter");
try {
FoeiContextManagerFactory.getFoeiContextManager().destroyAll();
} catch (Exception e) {
logger.log(Level.WARNING,"Error while shutdowning Foei: "+e.getMessage(),e);
throw new RuntimeException(e);
}
ejbs.clear();
bootstrapContext=null;
}
/**
@ -84,27 +83,21 @@ public class FoeiResourceAdapter implements ResourceAdapter {
* @see javax.resource.spi.ResourceAdapter#endpointActivation(javax.resource.spi.endpoint.MessageEndpointFactory, javax.resource.spi.ActivationSpec)
*/
public void endpointActivation(MessageEndpointFactory endPointFactory,ActivationSpec spec) throws ResourceException {
FoeiActivationSpec fac = (FoeiActivationSpec)spec;
MessageEndpoint endPoint = endPointFactory.createEndpoint(null);
endPoint.release();
//endPoint.
fac.getBeanName();
// reg bean to foei context
logger.info("Activation of: "+fac.getFoeiBeanName());
SpecBean s = new SpecBean();
s.messageEndpointFactory=endPointFactory;
s.foeiActivationSpec=fac;
ejbs.put(fac.getFoeiBeanName(),s);
}
/**
* @see javax.resource.spi.ResourceAdapter#endpointDeactivation(javax.resource.spi.endpoint.MessageEndpointFactory, javax.resource.spi.ActivationSpec)
*/
public void endpointDeactivation(MessageEndpointFactory endPointFactory,ActivationSpec spec) {
//FoeiActivationSpec fac = (FoeiActivationSpec)spec;
//for (FoeiProcess proc:foeiContext.getFoeiProcessManager().getFoeiProcesses()) {
// proc.removeEventObject(fac.getBeanName());
//}
FoeiActivationSpec fac = (FoeiActivationSpec)spec;
logger.info("Deactivation of "+fac.getFoeiBeanName());
ejbs.remove(fac.getFoeiBeanName());
}
/**
@ -120,4 +113,23 @@ public class FoeiResourceAdapter implements ResourceAdapter {
public void setBootstrapContext(BootstrapContext bootstrapContext) {
this.bootstrapContext = bootstrapContext;
}
public List<String> getEJBFoeiBeanNames() {
return new ArrayList<String>(ejbs.keySet());
}
public FoeiActivationSpec getFoeiActivationSpec(String name) {
SpecBean s = ejbs.get(name);
return s.foeiActivationSpec;
}
public MessageEndpointFactory getMessageEndpointFactory(String name) {
SpecBean s = ejbs.get(name);
return s.messageEndpointFactory;
}
private class SpecBean {
FoeiActivationSpec foeiActivationSpec;
MessageEndpointFactory messageEndpointFactory;
}
}