[svn r331] made the SPI interface also work.
This commit is contained in:
parent
46f1863f05
commit
64ca1c8f3a
|
@ -62,11 +62,11 @@ should not be interpreted as representing official policies, either expressed or
|
|||
<inbound-resourceadapter>
|
||||
<messageadapter>
|
||||
<messagelistener>
|
||||
<messagelistener-type>com.idcanet.foei.event.EventInput</messagelistener-type>
|
||||
<messagelistener-type>com.idcanet.foei.ee.jca.spi.EJBFoeiBean</messagelistener-type>
|
||||
<activationspec>
|
||||
<activationspec-class>com.idcanet.foei.ee.jca.spi.FoeiActivationSpec</activationspec-class>
|
||||
<required-config-property>
|
||||
<config-property-name>beanName</config-property-name>
|
||||
<config-property-name>foeiBeanName</config-property-name>
|
||||
</required-config-property>
|
||||
</activationspec>
|
||||
</messagelistener>
|
||||
|
|
42
src/com/idcanet/foei/core/FoeiProcessListener.java
Normal file
42
src/com/idcanet/foei/core/FoeiProcessListener.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright 2004-2008 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.core;
|
||||
|
||||
/**
|
||||
* Gets called when process is created or destroyed.<br/>
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 26, 2008
|
||||
*/
|
||||
public interface FoeiProcessListener {
|
||||
|
||||
public void foeiProcessCreated(FoeiProcess process);
|
||||
|
||||
public void foeiProcessDestroyed(FoeiProcess process);
|
||||
|
||||
}
|
|
@ -63,4 +63,8 @@ public interface FoeiProcessManager {
|
|||
* @return
|
||||
*/
|
||||
public Collection<FoeiProcess> getFoeiProcesses();
|
||||
|
||||
public void addFoeiProcessListener(FoeiProcessListener foeiProcessListener);
|
||||
|
||||
public void removeFoeiProcessListener(FoeiProcessListener foeiProcessListener);
|
||||
}
|
|
@ -28,11 +28,14 @@ package com.idcanet.foei.core.impl;
|
|||
|
||||
import com.idcanet.foei.core.FoeiContext;
|
||||
import com.idcanet.foei.core.FoeiProcess;
|
||||
import com.idcanet.foei.core.FoeiProcessListener;
|
||||
import com.idcanet.foei.core.FoeiProcessManager;
|
||||
import com.idcanet.foei.core.ObjectBindingsManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
@ -53,12 +56,15 @@ public class FoeiProcessManagerImpl implements FoeiProcessManager {
|
|||
/** The logger to log to. */
|
||||
private Logger logger = null;
|
||||
|
||||
private List<FoeiProcessListener> foeiProcessListeners = null;
|
||||
|
||||
/**
|
||||
* Creates an FoeiProcessManagerImpl
|
||||
*/
|
||||
public FoeiProcessManagerImpl() {
|
||||
logger = Logger.getLogger(FoeiProcessManagerImpl.class.getName());
|
||||
foeiProcesses = new HashMap<String,FoeiProcess>(5);
|
||||
foeiProcessListeners = new ArrayList<FoeiProcessListener>(5);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,6 +84,10 @@ public class FoeiProcessManagerImpl implements FoeiProcessManager {
|
|||
synchronized (foeiProcesses) {
|
||||
foeiProcesses.put(fp.getName(),fp);
|
||||
}
|
||||
for (FoeiProcessListener l:foeiProcessListeners) {
|
||||
l.foeiProcessCreated(fp);
|
||||
}
|
||||
|
||||
logger.finer("FoeiProcess created and added total processes: "+foeiProcesses.size());
|
||||
return fp;
|
||||
} catch (Exception e) {
|
||||
|
@ -98,6 +108,9 @@ public class FoeiProcessManagerImpl implements FoeiProcessManager {
|
|||
synchronized (foeiProcesses) {
|
||||
foeiProcesses.remove(p.getName());
|
||||
}
|
||||
for (FoeiProcessListener l:foeiProcessListeners) {
|
||||
l.foeiProcessDestroyed(p);
|
||||
}
|
||||
logger.finer("FoeiProcess destroyed total processes: "+foeiProcesses.size());
|
||||
try {
|
||||
p.getFoeiContext().getEventObjectContext().destroySubcontext(p.getName());
|
||||
|
@ -122,4 +135,18 @@ public class FoeiProcessManagerImpl implements FoeiProcessManager {
|
|||
public Collection<FoeiProcess> getFoeiProcesses() {
|
||||
return foeiProcesses.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.FoeiProcessManager#addFoeiProcessListener(com.idcanet.foei.core.FoeiProcessListener)
|
||||
*/
|
||||
public void addFoeiProcessListener(FoeiProcessListener foeiProcessListener) {
|
||||
foeiProcessListeners.add(foeiProcessListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.FoeiProcessManager#removeFoeiProcessListener(com.idcanet.foei.core.FoeiProcessListener)
|
||||
*/
|
||||
public void removeFoeiProcessListener(FoeiProcessListener foeiProcessListener) {
|
||||
foeiProcessListeners.remove(foeiProcessListener);
|
||||
}
|
||||
}
|
85
src/com/idcanet/foei/ee/jca/cci/EJBFoeiProcessListener.java
Normal file
85
src/com/idcanet/foei/ee/jca/cci/EJBFoeiProcessListener.java
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright 2004-2008 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.ee.jca.cci;
|
||||
|
||||
import javax.resource.spi.endpoint.MessageEndpointFactory;
|
||||
|
||||
import com.idcanet.foei.core.FoeiProcess;
|
||||
import com.idcanet.foei.core.FoeiProcessListener;
|
||||
import com.idcanet.foei.ee.jca.spi.FoeiActivationSpec;
|
||||
import com.idcanet.foei.ee.jca.spi.FoeiEventWrapper;
|
||||
import com.idcanet.foei.ee.jca.spi.FoeiResourceAdapter;
|
||||
|
||||
/**
|
||||
* Injects the ejb3 beans in the process.<br/>
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 26, 2008
|
||||
*/
|
||||
public class EJBFoeiProcessListener implements FoeiProcessListener {
|
||||
|
||||
private FoeiResourceAdapter foeiResourceAdapter = null;
|
||||
|
||||
|
||||
public EJBFoeiProcessListener(FoeiResourceAdapter foeiResourceAdapter) {
|
||||
this.foeiResourceAdapter=foeiResourceAdapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.FoeiProcessListener#foeiProcessCreated(com.idcanet.foei.core.FoeiProcess)
|
||||
*/
|
||||
public void foeiProcessCreated(FoeiProcess process) {
|
||||
|
||||
// list all beans.
|
||||
for (String name:foeiResourceAdapter.getEJBFoeiBeanNames()) {
|
||||
|
||||
FoeiActivationSpec foeiActivationSpec = foeiResourceAdapter.getFoeiActivationSpec(name);
|
||||
MessageEndpointFactory endpointFactory = foeiResourceAdapter.getMessageEndpointFactory(name);
|
||||
|
||||
// check context name
|
||||
if (process.getFoeiContext().getName().matches(foeiActivationSpec.getFoeiContextName())) {
|
||||
|
||||
// check process name
|
||||
if (process.getName().matches(foeiActivationSpec.getFoeiProcessName())) {
|
||||
|
||||
// create wrapper for in foei, which can get an instance of the EJB bean.
|
||||
FoeiEventWrapper wrapper = new FoeiEventWrapper(endpointFactory,process);
|
||||
|
||||
// inject bean
|
||||
process.addEventObject(wrapper, foeiActivationSpec.getFoeiBeanName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.FoeiProcessListener#foeiProcessDestroyed(com.idcanet.foei.core.FoeiProcess)
|
||||
*/
|
||||
public void foeiProcessDestroyed(FoeiProcess process) {
|
||||
}
|
||||
}
|
|
@ -86,8 +86,13 @@ public class FoeiManagedConnectionFactory implements ManagedConnectionFactory,Re
|
|||
Map<String,String> properties = new HashMap<String,String>(0);
|
||||
try {
|
||||
objectContext = FoeiConfiguratorImpl.newContext(properties);
|
||||
eventExecutorManager = new JCAEventExecutorManager((FoeiResourceAdapter)getResourceAdapter());
|
||||
//eventExecutorManager = new JCAEventExecutorManager((FoeiResourceAdapter)getResourceAdapter());
|
||||
eventExecutorManager = FoeiConfiguratorImpl.newEventExecutorManager(properties);
|
||||
foeiProcessManager = FoeiConfiguratorImpl.newFoeiProcessManager(properties);
|
||||
|
||||
// inject ejb beans per process
|
||||
foeiProcessManager.addFoeiProcessListener(new EJBFoeiProcessListener((FoeiResourceAdapter)getResourceAdapter()));
|
||||
|
||||
FoeiConfiguratorImpl.loadEventThreadListeners(properties,eventExecutorManager);
|
||||
} catch (Exception e) {
|
||||
throw new ResourceException("Error while building childs objects:",e);
|
||||
|
|
45
src/com/idcanet/foei/ee/jca/spi/EJBFoeiBean.java
Normal file
45
src/com/idcanet/foei/ee/jca/spi/EJBFoeiBean.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright 2004-2008 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.ee.jca.spi;
|
||||
|
||||
import com.idcanet.foei.core.FoeiProcess;
|
||||
import com.idcanet.foei.event.EventInput;
|
||||
import com.idcanet.foei.event.EventOutput;
|
||||
import com.idcanet.foei.event.EventPort;
|
||||
import com.idcanet.foei.event.IllegalEventPortNameException;
|
||||
|
||||
/**
|
||||
* Gets called when process is created or destroyed.<br/>
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 26, 2008
|
||||
*/
|
||||
public interface EJBFoeiBean extends EventInput,EventOutput {
|
||||
|
||||
public void doEvent(FoeiProcess process,EventPort eventPort,Object object) throws IllegalEventPortNameException;
|
||||
}
|
|
@ -45,18 +45,42 @@ public class FoeiActivationSpec implements ActivationSpec, Serializable {
|
|||
/** The resource adapter */
|
||||
private transient ResourceAdapter resourceAdapter = null;
|
||||
|
||||
private String beanName = null;
|
||||
private String foeiBeanName = null;
|
||||
|
||||
private String foeiProcessName = null;
|
||||
|
||||
private String foeiContextName = null;
|
||||
|
||||
/**
|
||||
* @see javax.resource.spi.ActivationSpec#validate()
|
||||
*/
|
||||
public void validate() throws InvalidPropertyException {
|
||||
if (beanName==null) {
|
||||
throw new InvalidPropertyException("beanName is null,please set beanName property.");
|
||||
if (foeiBeanName==null) {
|
||||
throw new InvalidPropertyException("foeiBeanName is null,please set foeiBeanName property.");
|
||||
}
|
||||
if (beanName.isEmpty()) {
|
||||
throw new InvalidPropertyException("beanName is empty,please set beanName property.");
|
||||
if (foeiBeanName.isEmpty()) {
|
||||
throw new InvalidPropertyException("foeiBeanName is empty,please set foeiBeanName property.");
|
||||
}
|
||||
if (foeiProcessName==null) {
|
||||
foeiProcessName=".*";
|
||||
}
|
||||
if (foeiProcessName.isEmpty()) {
|
||||
foeiProcessName=".*";
|
||||
}
|
||||
if ("*".equals(foeiProcessName)) {
|
||||
foeiProcessName=".*";
|
||||
}
|
||||
if (foeiContextName==null) {
|
||||
foeiContextName=".*";
|
||||
}
|
||||
if (foeiContextName.isEmpty()) {
|
||||
foeiContextName=".*";
|
||||
}
|
||||
if ("*".equals(foeiContextName)) {
|
||||
foeiContextName=".*";
|
||||
}
|
||||
|
||||
// TODO: check if is regex
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,16 +101,44 @@ public class FoeiActivationSpec implements ActivationSpec, Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return the beanName
|
||||
* @return the foeiBeanName
|
||||
*/
|
||||
public String getBeanName() {
|
||||
return beanName;
|
||||
public String getFoeiBeanName() {
|
||||
return foeiBeanName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param beanName the beanName to set
|
||||
* @param foeiBeanName the foeiBeanName to set
|
||||
*/
|
||||
public void setBeanName(String beanName) {
|
||||
this.beanName = beanName;
|
||||
public void setFoeiBeanName(String foeiBeanName) {
|
||||
this.foeiBeanName = foeiBeanName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the foeiProcessName
|
||||
*/
|
||||
public String getFoeiProcessName() {
|
||||
return foeiProcessName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param foeiProcessName the foeiProcessName to set
|
||||
*/
|
||||
public void setFoeiProcessName(String foeiProcessName) {
|
||||
this.foeiProcessName = foeiProcessName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the foeiContextName
|
||||
*/
|
||||
public String getFoeiContextName() {
|
||||
return foeiContextName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param foeiContextName the foeiContextName to set
|
||||
*/
|
||||
public void setFoeiContextName(String foeiContextName) {
|
||||
this.foeiContextName = foeiContextName;
|
||||
}
|
||||
}
|
|
@ -29,35 +29,85 @@ package com.idcanet.foei.ee.jca.spi;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
import javax.resource.spi.endpoint.MessageEndpoint;
|
||||
import javax.resource.spi.endpoint.MessageEndpointFactory;
|
||||
|
||||
import com.idcanet.foei.event.AbstractEventInput;
|
||||
import com.idcanet.foei.core.FoeiProcess;
|
||||
import com.idcanet.foei.event.AbstractEventObject;
|
||||
import com.idcanet.foei.event.EventPort;
|
||||
import com.idcanet.foei.event.IllegalEventPortNameException;
|
||||
|
||||
/**
|
||||
*
|
||||
* Wrappers the ejb bean into the foei executing context.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 19, 2008
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class FoeiEventWrapper extends AbstractEventInput {
|
||||
public class FoeiEventWrapper extends AbstractEventObject {
|
||||
|
||||
private Logger logger = Logger.getLogger(FoeiEventWrapper.class.getName());
|
||||
|
||||
private MessageEndpointFactory endpointFactory = null;
|
||||
|
||||
private FoeiProcess foeiProcess = null;
|
||||
|
||||
public FoeiEventWrapper(MessageEndpointFactory endpointFactory,FoeiProcess foeiProcess) {
|
||||
this.endpointFactory=endpointFactory;
|
||||
this.foeiProcess=foeiProcess;
|
||||
|
||||
MessageEndpoint endpoint = null;
|
||||
try {
|
||||
endpoint = endpointFactory.createEndpoint(null); // creates new EJB3 bean instance !!
|
||||
if (endpoint != null) {
|
||||
EJBFoeiBean bean = (EJBFoeiBean) endpoint;
|
||||
|
||||
// copy ports, todo: go to annotations
|
||||
|
||||
// TODO: check if has input port at all...
|
||||
for (EventPort p:bean.getInputPorts()) {
|
||||
this.addInputPort(p.getName(), p.getObjectClass());
|
||||
}
|
||||
for (EventPort p:bean.getOutputPorts()) {
|
||||
this.addOutputPort(p.getName(), p.getObjectClass());
|
||||
}
|
||||
|
||||
} else {
|
||||
logger.warning("MessageEndPoint is null.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (endpoint != null) {
|
||||
endpoint.release();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.event.AbstractEventInput#doEvent(com.idcanet.foei.event.EventPort, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void doEvent(EventPort eventPort, Object object) throws IllegalEventPortNameException {
|
||||
MessageEndpoint endpoint = null;
|
||||
//MessageEndpointFactory endpointFactory = null; //(MessageEndpointFactory)"endpointFactory";
|
||||
//endpoint = endpointFactory.createEndpoint(null);
|
||||
try {
|
||||
endpoint = endpointFactory.createEndpoint(null); // creates new EJB3 bean instance !!
|
||||
if (endpoint != null) {
|
||||
AbstractEventInput input = (AbstractEventInput) endpoint;
|
||||
input.doEvent(eventPort, object);
|
||||
EJBFoeiBean input = (EJBFoeiBean) endpoint;
|
||||
|
||||
// mmm needed ?
|
||||
// yes for normaly equals ..
|
||||
EventPort port = input.getInputPort(eventPort.getName());
|
||||
input.doEvent(foeiProcess,port, object);
|
||||
} else {
|
||||
logger.warning("MessageEndPoint is null.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new IllegalEventPortNameException(e);
|
||||
} finally {
|
||||
if (endpoint != null) {
|
||||
endpoint.release(); // release ejb bean
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue