[svn r337] removed some bugs, and made send obj from ejb work and fixed connection problem.
This commit is contained in:
parent
135a6400a4
commit
53855d8aae
|
@ -82,7 +82,14 @@ public class DestroyFoeiProcess extends AbstractEventInput {
|
||||||
FoeiProcess process = FoeiProcessFactory.getFoeiProcess();
|
FoeiProcess process = FoeiProcessFactory.getFoeiProcess();
|
||||||
|
|
||||||
if (process.getWorkQueue().isEmpty()==false) {
|
if (process.getWorkQueue().isEmpty()==false) {
|
||||||
//return;
|
logger.info("WorkQueue not empty sleeping a bit and sending retrigger myself q="+process.getWorkQueue().size()+" for proc: "+process.getName());
|
||||||
|
try {
|
||||||
|
Thread.sleep(delayTime+500); // add some minual d
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.log(Level.WARNING,"Error sleeping: "+e.getMessage(),e);
|
||||||
|
}
|
||||||
|
process.executeEvent(getInputPort(EventPort.INPUT), "null");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(delayTime!=null) {
|
if(delayTime!=null) {
|
||||||
|
|
|
@ -36,8 +36,8 @@ import java.util.List;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 1/05/2005
|
* @version 1.0 1/05/2005
|
||||||
*/
|
*/
|
||||||
public interface ObjectBindingsManager
|
public interface ObjectBindingsManager {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Adds an binding from the input to the output EventPort.
|
* Adds an binding from the input to the output EventPort.
|
||||||
* @param outputPort The output EventPort
|
* @param outputPort The output EventPort
|
||||||
|
@ -58,15 +58,7 @@ public interface ObjectBindingsManager
|
||||||
* @return Returns an List of the binded EventPorts
|
* @return Returns an List of the binded EventPorts
|
||||||
*/
|
*/
|
||||||
public List<EventPort> getBindings(EventPort eventPort);
|
public List<EventPort> getBindings(EventPort eventPort);
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the bindings of an EventPort of InputPorts
|
|
||||||
* @param eventPort The EventPort to retreive the bindings which should be an OutputPort
|
|
||||||
* @return Returns an List of the binded EventPorts
|
|
||||||
*/
|
|
||||||
public List<EventPort> getBindingsInputPorts(EventPort eventPort);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the bindings in an xml format to render with dotty.
|
* Returns the bindings in an xml format to render with dotty.
|
||||||
* @return
|
* @return
|
||||||
|
|
|
@ -49,10 +49,7 @@ public class EventExecutorImpl implements EventExecutor {
|
||||||
|
|
||||||
/** The logger to log to. */
|
/** The logger to log to. */
|
||||||
private Logger logger = null;
|
private Logger logger = null;
|
||||||
/** The event obect. */
|
/** The foei process to execute for */
|
||||||
//private Object eventObject = null;
|
|
||||||
/** The eventport */
|
|
||||||
//private EventPort eventPort = null;
|
|
||||||
private FoeiProcess foeiProcess = null;
|
private FoeiProcess foeiProcess = null;
|
||||||
/** True when ready */
|
/** True when ready */
|
||||||
private volatile boolean ready = false;
|
private volatile boolean ready = false;
|
||||||
|
@ -69,22 +66,7 @@ public class EventExecutorImpl implements EventExecutor {
|
||||||
*/
|
*/
|
||||||
public void setFoeiProcess(FoeiProcess foeiProcess) {
|
public void setFoeiProcess(FoeiProcess foeiProcess) {
|
||||||
this.foeiProcess=foeiProcess;
|
this.foeiProcess=foeiProcess;
|
||||||
//this.eventObject=eventObject;
|
|
||||||
//ready = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see EventExecutor#setEventPort(EventPort)
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
public void setEventPort(EventPort eventPort) {
|
|
||||||
if(eventPort==null) {
|
|
||||||
throw new NullPointerException("EventPort may not be null.");
|
|
||||||
}
|
|
||||||
this.eventPort=eventPort;
|
|
||||||
ready = false;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see EventExecutor#isReady()
|
* @see EventExecutor#isReady()
|
||||||
|
@ -104,7 +86,6 @@ public class EventExecutorImpl implements EventExecutor {
|
||||||
ready = false;
|
ready = false;
|
||||||
int processed = 0;
|
int processed = 0;
|
||||||
try {
|
try {
|
||||||
//FoeiProcess foeiProcess = FoeiProcessFactory.getFoeiProcess();
|
|
||||||
FoeiProcessFactory.bindFoeiProcess(foeiProcess);
|
FoeiProcessFactory.bindFoeiProcess(foeiProcess);
|
||||||
|
|
||||||
FoeiPortMessage msg = foeiProcess.getWorkQueue().poll();
|
FoeiPortMessage msg = foeiProcess.getWorkQueue().poll();
|
||||||
|
@ -112,16 +93,21 @@ public class EventExecutorImpl implements EventExecutor {
|
||||||
process(msg);
|
process(msg);
|
||||||
processed++;
|
processed++;
|
||||||
msg = foeiProcess.getWorkQueue().poll();
|
msg = foeiProcess.getWorkQueue().poll();
|
||||||
}
|
|
||||||
Thread.sleep(200);
|
// try 3 times to get new work, if not found then exit, EventExecutorManagerImpl work auto create new EventExecutor on new work.
|
||||||
msg = foeiProcess.getWorkQueue().poll();
|
if (msg==null) {
|
||||||
while (msg!=null) {
|
Thread.sleep(200);
|
||||||
process(msg);
|
msg = foeiProcess.getWorkQueue().poll();
|
||||||
processed++;
|
}
|
||||||
msg = foeiProcess.getWorkQueue().poll();
|
if (msg==null) {
|
||||||
}
|
Thread.sleep(200);
|
||||||
|
msg = foeiProcess.getWorkQueue().poll();
|
||||||
|
}
|
||||||
|
if (msg==null) {
|
||||||
|
Thread.sleep(200);
|
||||||
|
msg = foeiProcess.getWorkQueue().poll();
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.log(Level.WARNING,"Error while Executing Event",e);
|
logger.log(Level.WARNING,"Error while Executing Event",e);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -145,23 +131,15 @@ public class EventExecutorImpl implements EventExecutor {
|
||||||
if(eventPort.getEventPortType()==EventPortType.output) {
|
if(eventPort.getEventPortType()==EventPortType.output) {
|
||||||
eventPort.addEventsPassed(); // inc output port
|
eventPort.addEventsPassed(); // inc output port
|
||||||
|
|
||||||
// uses the faster routine to get bindings ...,
|
List<EventPort> bindings = foeiProcess.getBindings(eventPort);
|
||||||
//List<EventPort> bindings = foeiProcess.getBindings(eventPort);
|
|
||||||
List<EventPort> bindings = foeiProcess.getBindingsInputPorts(eventPort);
|
|
||||||
|
|
||||||
for (int i=0;i<bindings.size();i++) {
|
for (int i=0;i<bindings.size();i++) {
|
||||||
EventPort port = bindings.get(i); // faster then using iterator (auto)
|
EventPort port = bindings.get(i); // faster then using iterator (auto)
|
||||||
//for(EventPort port:bindings) {
|
|
||||||
EventInput eventInput = (EventInput)port.getEventObject();
|
EventInput eventInput = (EventInput)port.getEventObject();
|
||||||
if(port.isImmediate()) {
|
if(port.isImmediate()) {
|
||||||
port.addEventsPassed(); // inc Immediate import port
|
port.addEventsPassed(); // inc Immediate import port
|
||||||
eventInput.doEvent(port,eventObject);
|
eventInput.doEvent(port,eventObject);
|
||||||
} else {
|
} else {
|
||||||
//foeiProcess.executeEvent(port,eventObject);
|
foeiProcess.executeEvent(eventPort, eventObject);
|
||||||
msg = new FoeiPortMessage();
|
|
||||||
msg.setEventObject(port);
|
|
||||||
msg.setEventPort(eventPort);
|
|
||||||
foeiProcess.getWorkQueue().add(msg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -102,16 +102,8 @@ public class EventExecutorManagerImpl implements EventExecutorManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
e.setFoeiProcess(foeiProcess);
|
e.setFoeiProcess(foeiProcess);
|
||||||
foeiProcess.getExecutors().add(e);
|
foeiProcess.getExecutors().add(e); // else to much will be created on 1st X objects.
|
||||||
//e.setEventObject(eventObject);
|
threadPoolExecutor.execute(e);
|
||||||
//e.setEventPort(eventPort);
|
|
||||||
//if(eventPort.isImmediate()) {
|
|
||||||
// e.run();
|
|
||||||
//} else {
|
|
||||||
// mmmm
|
|
||||||
//execute(e,foeiProcess);
|
|
||||||
threadPoolExecutor.execute(e);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -39,8 +39,8 @@ import java.util.logging.Logger;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Feb 7, 2006
|
* @version 1.0 Feb 7, 2006
|
||||||
*/
|
*/
|
||||||
public class EventExecutorThreadFactory implements ThreadFactory
|
public class EventExecutorThreadFactory implements ThreadFactory {
|
||||||
{
|
|
||||||
/** The pool number. */
|
/** The pool number. */
|
||||||
static private final AtomicInteger poolNumber = new AtomicInteger(1);
|
static private final AtomicInteger poolNumber = new AtomicInteger(1);
|
||||||
/** The thread group. */
|
/** The thread group. */
|
||||||
|
@ -66,7 +66,7 @@ public class EventExecutorThreadFactory implements ThreadFactory
|
||||||
this.foeiContext=foeiContext;
|
this.foeiContext=foeiContext;
|
||||||
SecurityManager s = System.getSecurityManager();
|
SecurityManager s = System.getSecurityManager();
|
||||||
group = (s != null)? s.getThreadGroup():Thread.currentThread().getThreadGroup();
|
group = (s != null)? s.getThreadGroup():Thread.currentThread().getThreadGroup();
|
||||||
namePrefix = "foei-"+poolNumber.getAndIncrement()+"-thread-";
|
namePrefix = "foei"+poolNumber.getAndIncrement()+"-"+foeiContext.getName()+"-";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -190,13 +190,6 @@ public class FoeiProcessImpl implements FoeiProcess {
|
||||||
return getObjectBindingsManager().getBindings(eventPort);
|
return getObjectBindingsManager().getBindings(eventPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see com.idcanet.foei.core.ObjectBindingsManager#getBindingsInputPorts(com.idcanet.foei.event.EventPort)
|
|
||||||
*/
|
|
||||||
public List<EventPort> getBindingsInputPorts(EventPort eventPort) {
|
|
||||||
return getObjectBindingsManager().getBindingsInputPorts(eventPort);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see com.idcanet.foei.core.ObjectBindingsManager#getBindingsAsXML()
|
* @see com.idcanet.foei.core.ObjectBindingsManager#getBindingsAsXML()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -108,9 +108,9 @@ public class FoeiProcessManagerImpl implements FoeiProcessManager {
|
||||||
synchronized (foeiProcesses) {
|
synchronized (foeiProcesses) {
|
||||||
foeiProcesses.remove(p.getName());
|
foeiProcesses.remove(p.getName());
|
||||||
}
|
}
|
||||||
for (FoeiProcessListener l:foeiProcessListeners) {
|
for (FoeiProcessListener l:foeiProcessListeners) {
|
||||||
l.foeiProcessDestroyed(p);
|
l.foeiProcessDestroyed(p);
|
||||||
}
|
}
|
||||||
logger.finer("FoeiProcess destroyed total processes: "+foeiProcesses.size());
|
logger.finer("FoeiProcess destroyed total processes: "+foeiProcesses.size());
|
||||||
try {
|
try {
|
||||||
p.getFoeiContext().getEventObjectContext().destroySubcontext(p.getName());
|
p.getFoeiContext().getEventObjectContext().destroySubcontext(p.getName());
|
||||||
|
|
|
@ -147,36 +147,21 @@ public class ObjectBindingsManagerImpl implements ObjectBindingsManager {
|
||||||
if(eventPort==null) {
|
if(eventPort==null) {
|
||||||
throw new NullPointerException("eventPort may not be null.");
|
throw new NullPointerException("eventPort may not be null.");
|
||||||
}
|
}
|
||||||
List<EventPort> result = new ArrayList<EventPort>(6);
|
if (EventPortType.output.equals(eventPort.getEventPortType())) {
|
||||||
List<EventPort> inputPorts = bindingsInput.get(eventPort);
|
List<EventPort> inputPorts = bindingsOutput.get(eventPort);
|
||||||
List<EventPort> outputPorts = bindingsOutput.get(eventPort);
|
if(inputPorts!=null) {
|
||||||
if(inputPorts!=null) {
|
return inputPorts;
|
||||||
result.addAll(inputPorts);
|
}
|
||||||
|
List<EventPort> result = new ArrayList<EventPort>(0);
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
List<EventPort> outputPorts = bindingsInput.get(eventPort);
|
||||||
|
if(outputPorts!=null) {
|
||||||
|
return outputPorts;
|
||||||
|
}
|
||||||
|
List<EventPort> result = new ArrayList<EventPort>(0);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
if(outputPorts!=null) {
|
|
||||||
result.addAll(outputPorts);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the bindings of an EventPort
|
|
||||||
* @param eventPort The EventPort to retreive the bindings.
|
|
||||||
* @return Returns an List of the binded EventPorts
|
|
||||||
*/
|
|
||||||
public List<EventPort> getBindingsInputPorts(EventPort eventPort) {
|
|
||||||
if(eventPort==null) {
|
|
||||||
throw new NullPointerException("eventPort may not be null.");
|
|
||||||
}
|
|
||||||
if (EventPortType.output.equals(eventPort.getEventPortType())==false) {
|
|
||||||
throw new IllegalArgumentException("eventPort should be output port.");
|
|
||||||
}
|
|
||||||
List<EventPort> inputPorts = bindingsOutput.get(eventPort);
|
|
||||||
if(inputPorts!=null) {
|
|
||||||
return inputPorts;
|
|
||||||
}
|
|
||||||
List<EventPort> result = new ArrayList<EventPort>(0);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -100,6 +100,7 @@ public class FoeiManagedConnection implements ManagedConnection {
|
||||||
synchronized (this.listeners) {
|
synchronized (this.listeners) {
|
||||||
listeners = null;
|
listeners = null;
|
||||||
}
|
}
|
||||||
|
foeiContext.destroy();
|
||||||
foeiContext = null;
|
foeiContext = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,6 +221,7 @@ public class FoeiManagedConnection implements ManagedConnection {
|
||||||
*/
|
*/
|
||||||
public void close(FoeiConnectionImpl con) {
|
public void close(FoeiConnectionImpl con) {
|
||||||
ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
|
ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
|
||||||
|
event.setConnectionHandle(con);
|
||||||
synchronized (this.listeners) {
|
synchronized (this.listeners) {
|
||||||
Iterator<ConnectionEventListener> itr = listeners.iterator();
|
Iterator<ConnectionEventListener> itr = listeners.iterator();
|
||||||
while (itr.hasNext()) {
|
while (itr.hasNext()) {
|
||||||
|
|
|
@ -49,7 +49,6 @@ import com.idcanet.foei.core.FoeiProcessManager;
|
||||||
import com.idcanet.foei.core.impl.FoeiConfiguratorImpl;
|
import com.idcanet.foei.core.impl.FoeiConfiguratorImpl;
|
||||||
import com.idcanet.foei.core.impl.FoeiContextImpl;
|
import com.idcanet.foei.core.impl.FoeiContextImpl;
|
||||||
import com.idcanet.foei.ee.jca.spi.FoeiResourceAdapter;
|
import com.idcanet.foei.ee.jca.spi.FoeiResourceAdapter;
|
||||||
import com.idcanet.foei.ee.jca.spi.JCAEventExecutorManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -41,5 +41,5 @@ import com.idcanet.foei.event.IllegalEventPortNameException;
|
||||||
*/
|
*/
|
||||||
public interface EJBFoeiBean extends EventInput,EventOutput {
|
public interface EJBFoeiBean extends EventInput,EventOutput {
|
||||||
|
|
||||||
public void doEvent(FoeiProcess process,EventPort eventPort,Object object) throws IllegalEventPortNameException;
|
public void doEvent(FoeiProcess process,FoeiEventWrapper wrapper,EventPort eventPort,Object object) throws IllegalEventPortNameException;
|
||||||
}
|
}
|
|
@ -98,7 +98,7 @@ public class FoeiEventWrapper extends AbstractEventObject {
|
||||||
// mmm needed ?
|
// mmm needed ?
|
||||||
// yes for normaly equals ..
|
// yes for normaly equals ..
|
||||||
EventPort port = input.getInputPort(eventPort.getName());
|
EventPort port = input.getInputPort(eventPort.getName());
|
||||||
input.doEvent(foeiProcess,port, object);
|
input.doEvent(foeiProcess,this,port, object);
|
||||||
} else {
|
} else {
|
||||||
logger.warning("MessageEndPoint is null.");
|
logger.warning("MessageEndPoint is null.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ import java.util.Properties;
|
||||||
|
|
||||||
import com.idcanet.foei.components.lang.DummyOutputPort;
|
import com.idcanet.foei.components.lang.DummyOutputPort;
|
||||||
import com.idcanet.foei.components.lang.Filter;
|
import com.idcanet.foei.components.lang.Filter;
|
||||||
import com.idcanet.foei.core.FoeiConfigurator;
|
|
||||||
import com.idcanet.foei.core.FoeiContext;
|
import com.idcanet.foei.core.FoeiContext;
|
||||||
import com.idcanet.foei.core.FoeiProcess;
|
import com.idcanet.foei.core.FoeiProcess;
|
||||||
import com.idcanet.foei.event.AbstractEventInput;
|
import com.idcanet.foei.event.AbstractEventInput;
|
||||||
|
|
Loading…
Reference in a new issue