3
0
Fork 0

[svn r337] removed some bugs, and made send obj from ejb work and fixed connection problem.

This commit is contained in:
willemc 2008-04-26 19:53:15 +02:00
parent 135a6400a4
commit 53855d8aae
13 changed files with 55 additions and 108 deletions

View file

@ -82,7 +82,14 @@ public class DestroyFoeiProcess extends AbstractEventInput {
FoeiProcess process = FoeiProcessFactory.getFoeiProcess();
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) {

View file

@ -36,8 +36,8 @@ import java.util.List;
* @author Willem Cazander
* @version 1.0 1/05/2005
*/
public interface ObjectBindingsManager
{
public interface ObjectBindingsManager {
/**
* Adds an binding from the input to the output EventPort.
* @param outputPort The output EventPort
@ -58,15 +58,7 @@ public interface ObjectBindingsManager
* @return Returns an List of the binded EventPorts
*/
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.
* @return

View file

@ -49,10 +49,7 @@ public class EventExecutorImpl implements EventExecutor {
/** The logger to log to. */
private Logger logger = null;
/** The event obect. */
//private Object eventObject = null;
/** The eventport */
//private EventPort eventPort = null;
/** The foei process to execute for */
private FoeiProcess foeiProcess = null;
/** True when ready */
private volatile boolean ready = false;
@ -69,22 +66,7 @@ public class EventExecutorImpl implements EventExecutor {
*/
public void setFoeiProcess(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()
@ -104,7 +86,6 @@ public class EventExecutorImpl implements EventExecutor {
ready = false;
int processed = 0;
try {
//FoeiProcess foeiProcess = FoeiProcessFactory.getFoeiProcess();
FoeiProcessFactory.bindFoeiProcess(foeiProcess);
FoeiPortMessage msg = foeiProcess.getWorkQueue().poll();
@ -112,16 +93,21 @@ public class EventExecutorImpl implements EventExecutor {
process(msg);
processed++;
msg = foeiProcess.getWorkQueue().poll();
}
Thread.sleep(200);
msg = foeiProcess.getWorkQueue().poll();
while (msg!=null) {
process(msg);
processed++;
msg = foeiProcess.getWorkQueue().poll();
}
// try 3 times to get new work, if not found then exit, EventExecutorManagerImpl work auto create new EventExecutor on new work.
if (msg==null) {
Thread.sleep(200);
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) {
logger.log(Level.WARNING,"Error while Executing Event",e);
} finally {
@ -145,23 +131,15 @@ public class EventExecutorImpl implements EventExecutor {
if(eventPort.getEventPortType()==EventPortType.output) {
eventPort.addEventsPassed(); // inc output port
// uses the faster routine to get bindings ...,
//List<EventPort> bindings = foeiProcess.getBindings(eventPort);
List<EventPort> bindings = foeiProcess.getBindingsInputPorts(eventPort);
List<EventPort> bindings = foeiProcess.getBindings(eventPort);
for (int i=0;i<bindings.size();i++) {
EventPort port = bindings.get(i); // faster then using iterator (auto)
//for(EventPort port:bindings) {
EventInput eventInput = (EventInput)port.getEventObject();
if(port.isImmediate()) {
port.addEventsPassed(); // inc Immediate import port
eventInput.doEvent(port,eventObject);
} else {
//foeiProcess.executeEvent(port,eventObject);
msg = new FoeiPortMessage();
msg.setEventObject(port);
msg.setEventPort(eventPort);
foeiProcess.getWorkQueue().add(msg);
foeiProcess.executeEvent(eventPort, eventObject);
}
}
return;

View file

@ -102,16 +102,8 @@ public class EventExecutorManagerImpl implements EventExecutorManager {
return;
}
e.setFoeiProcess(foeiProcess);
foeiProcess.getExecutors().add(e);
//e.setEventObject(eventObject);
//e.setEventPort(eventPort);
//if(eventPort.isImmediate()) {
// e.run();
//} else {
// mmmm
//execute(e,foeiProcess);
threadPoolExecutor.execute(e);
//}
foeiProcess.getExecutors().add(e); // else to much will be created on 1st X objects.
threadPoolExecutor.execute(e);
}
/**

View file

@ -39,8 +39,8 @@ import java.util.logging.Logger;
* @author Willem Cazander
* @version 1.0 Feb 7, 2006
*/
public class EventExecutorThreadFactory implements ThreadFactory
{
public class EventExecutorThreadFactory implements ThreadFactory {
/** The pool number. */
static private final AtomicInteger poolNumber = new AtomicInteger(1);
/** The thread group. */
@ -66,7 +66,7 @@ public class EventExecutorThreadFactory implements ThreadFactory
this.foeiContext=foeiContext;
SecurityManager s = System.getSecurityManager();
group = (s != null)? s.getThreadGroup():Thread.currentThread().getThreadGroup();
namePrefix = "foei-"+poolNumber.getAndIncrement()+"-thread-";
namePrefix = "foei"+poolNumber.getAndIncrement()+"-"+foeiContext.getName()+"-";
}
/**

View file

@ -190,13 +190,6 @@ public class FoeiProcessImpl implements FoeiProcess {
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()
*/

View file

@ -108,9 +108,9 @@ public class FoeiProcessManagerImpl implements FoeiProcessManager {
synchronized (foeiProcesses) {
foeiProcesses.remove(p.getName());
}
for (FoeiProcessListener l:foeiProcessListeners) {
l.foeiProcessDestroyed(p);
}
for (FoeiProcessListener l:foeiProcessListeners) {
l.foeiProcessDestroyed(p);
}
logger.finer("FoeiProcess destroyed total processes: "+foeiProcesses.size());
try {
p.getFoeiContext().getEventObjectContext().destroySubcontext(p.getName());

View file

@ -147,36 +147,21 @@ public class ObjectBindingsManagerImpl implements ObjectBindingsManager {
if(eventPort==null) {
throw new NullPointerException("eventPort may not be null.");
}
List<EventPort> result = new ArrayList<EventPort>(6);
List<EventPort> inputPorts = bindingsInput.get(eventPort);
List<EventPort> outputPorts = bindingsOutput.get(eventPort);
if(inputPorts!=null) {
result.addAll(inputPorts);
if (EventPortType.output.equals(eventPort.getEventPortType())) {
List<EventPort> inputPorts = bindingsOutput.get(eventPort);
if(inputPorts!=null) {
return 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;
}
/**

View file

@ -100,6 +100,7 @@ public class FoeiManagedConnection implements ManagedConnection {
synchronized (this.listeners) {
listeners = null;
}
foeiContext.destroy();
foeiContext = null;
}
@ -220,6 +221,7 @@ public class FoeiManagedConnection implements ManagedConnection {
*/
public void close(FoeiConnectionImpl con) {
ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
event.setConnectionHandle(con);
synchronized (this.listeners) {
Iterator<ConnectionEventListener> itr = listeners.iterator();
while (itr.hasNext()) {

View file

@ -49,7 +49,6 @@ import com.idcanet.foei.core.FoeiProcessManager;
import com.idcanet.foei.core.impl.FoeiConfiguratorImpl;
import com.idcanet.foei.core.impl.FoeiContextImpl;
import com.idcanet.foei.ee.jca.spi.FoeiResourceAdapter;
import com.idcanet.foei.ee.jca.spi.JCAEventExecutorManager;
/**
*

View file

@ -41,5 +41,5 @@ import com.idcanet.foei.event.IllegalEventPortNameException;
*/
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;
}

View file

@ -98,7 +98,7 @@ public class FoeiEventWrapper extends AbstractEventObject {
// mmm needed ?
// yes for normaly equals ..
EventPort port = input.getInputPort(eventPort.getName());
input.doEvent(foeiProcess,port, object);
input.doEvent(foeiProcess,this,port, object);
} else {
logger.warning("MessageEndPoint is null.");
}

View file

@ -32,7 +32,6 @@ import java.util.Properties;
import com.idcanet.foei.components.lang.DummyOutputPort;
import com.idcanet.foei.components.lang.Filter;
import com.idcanet.foei.core.FoeiConfigurator;
import com.idcanet.foei.core.FoeiContext;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.event.AbstractEventInput;