3
0
Fork 0

[svn r392] some small fixes

This commit is contained in:
willemc 2010-04-20 22:46:41 +02:00
parent c540c7e531
commit 349a636e66
14 changed files with 103 additions and 41 deletions

View file

@ -5,6 +5,11 @@
<projects> <projects>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name> <name>org.eclipse.jdt.core.javabuilder</name>
<arguments> <arguments>
@ -19,5 +24,6 @@
<natures> <natures>
<nature>org.maven.ide.eclipse.maven2Nature</nature> <nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

13
pom.xml
View file

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.idcanet</groupId> <groupId>com.idcanet</groupId>
<artifactId>foei</artifactId> <artifactId>foei-main</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>0.8-SNAPSHOT</version> <version>0.8-SNAPSHOT</version>
<name>foei</name> <name>foei</name>
@ -99,6 +99,17 @@
</configuration> </configuration>
</plugin> </plugin>
<!-- Package source -->
<plugin>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals><goal>jar</goal></goals>
</execution>
</executions>
</plugin>
<!-- Generate site --> <!-- Generate site -->
<plugin> <plugin>
<artifactId>maven-site-plugin</artifactId> <artifactId>maven-site-plugin</artifactId>

View file

@ -83,16 +83,27 @@ public class Filter extends AbstractEventObjectStepController {
*/ */
@Override @Override
public Object processEventSteps(Object object) { public Object processEventSteps(Object object) {
Object o = object; if (object==null) {
for (int i=0;i<getEventSteps().size();i++) {
EventStep e = getEventSteps().get(i); // faster then useing iterator object in j5 for loop
if(o==null) {
return null; return null;
} }
o = e.processObject(object); if (getEventSteps().isEmpty()) {
return object; // no steps so no filtering
}
Object result = null;
Object resultOld = null;
for (int i=0;i<getEventSteps().size();i++) {
EventStep e = getEventSteps().get(i); // faster then useing iterator object in j5 for loop
result = e.processObject(object);
if (e.getEventStepOperand()!=null && i>0) {
boolean op = e.getEventStepOperand().execute(result!=null, resultOld!=null);
if (op==false) {
return null;
}
}
resultOld = result;
} }
// Check for for last(or only) EventStep // Check for for last(or only) EventStep
if(o==null) { if(result==null) {
return null; return null;
} }
return object; return object;

View file

@ -31,7 +31,7 @@ import com.idcanet.foei.event.AbstractEventObject;
import com.idcanet.foei.event.EventInput; import com.idcanet.foei.event.EventInput;
import com.idcanet.foei.event.EventPort; import com.idcanet.foei.event.EventPort;
import com.idcanet.foei.event.IllegalEventPortNameException; import com.idcanet.foei.event.IllegalEventPortNameException;
import com.idcanet.x4o.impl.DefaultElementParameterHelper; import com.idcanet.x4o.impl.DefaultElementObjectPropertyValue;
/** /**
* Gets the property of an Bean * Gets the property of an Bean
@ -51,7 +51,7 @@ public class GetBeanProperty extends AbstractEventObject {
//private Object propertyValue = null; //private Object propertyValue = null;
private DefaultElementParameterHelper helper = null; private DefaultElementObjectPropertyValue helper = null;
/** /**
* Creates an SetBeanProperty * Creates an SetBeanProperty
@ -60,7 +60,7 @@ public class GetBeanProperty extends AbstractEventObject {
addInputPort(EventPort.INPUT,Object.class); addInputPort(EventPort.INPUT,Object.class);
//addInputPort(PROPERTY,Object.class); //addInputPort(PROPERTY,Object.class);
addOutputPort(EventPort.OUTPUT); addOutputPort(EventPort.OUTPUT);
helper = new DefaultElementParameterHelper(); helper = new DefaultElementObjectPropertyValue();
} }
/** /**
@ -78,7 +78,7 @@ public class GetBeanProperty extends AbstractEventObject {
return; return;
} }
try { try {
object = helper.getParameter(object,property); // todo: fix error this wil only return String !!!!!!!!!!!!!!!!! object = helper.getProperty(object,property); // todo: fix error this wil only return String !!!!!!!!!!!!!!!!!
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return; return;

View file

@ -31,7 +31,7 @@ import com.idcanet.foei.event.AbstractEventObject;
import com.idcanet.foei.event.EventInput; import com.idcanet.foei.event.EventInput;
import com.idcanet.foei.event.EventPort; import com.idcanet.foei.event.EventPort;
import com.idcanet.foei.event.IllegalEventPortNameException; import com.idcanet.foei.event.IllegalEventPortNameException;
import com.idcanet.x4o.impl.DefaultElementParameterHelper; import com.idcanet.x4o.impl.DefaultElementObjectPropertyValue;
/** /**
* Sets an property of an bean which is set on the propery input port. * Sets an property of an bean which is set on the propery input port.
@ -50,7 +50,7 @@ public class SetBeanProperty extends AbstractEventObject {
private Object propertyValue = null; private Object propertyValue = null;
private DefaultElementParameterHelper helper = null; private DefaultElementObjectPropertyValue helper = null;
/** /**
* Creates an SetBeanProperty * Creates an SetBeanProperty
@ -59,7 +59,7 @@ public class SetBeanProperty extends AbstractEventObject {
addInputPort(EventPort.INPUT,Object.class); addInputPort(EventPort.INPUT,Object.class);
addInputPort(PROPERTY,Object.class); addInputPort(PROPERTY,Object.class);
addOutputPort(EventPort.OUTPUT); addOutputPort(EventPort.OUTPUT);
helper = new DefaultElementParameterHelper(); helper = new DefaultElementObjectPropertyValue();
} }
/** /**
@ -77,7 +77,7 @@ public class SetBeanProperty extends AbstractEventObject {
return; return;
} }
try { try {
helper.setParameter(object,property,propertyValue); helper.setProperty(object,property,propertyValue);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return; return;

View file

@ -27,7 +27,7 @@
package com.idcanet.foei.components.steps.lang; package com.idcanet.foei.components.steps.lang;
import com.idcanet.foei.event.AbstractEventStepController; import com.idcanet.foei.event.AbstractEventStepController;
import com.idcanet.x4o.impl.DefaultElementParameterHelper; import com.idcanet.x4o.impl.DefaultElementObjectPropertyValue;
/** /**
* Gets the property of an java bean. * Gets the property of an java bean.
@ -42,10 +42,10 @@ public class GetBeanPropertyStep extends AbstractEventStepController {
/** Holds the key which contains the object in the map. */ /** Holds the key which contains the object in the map. */
private String property = null; private String property = null;
private DefaultElementParameterHelper helper = null; private DefaultElementObjectPropertyValue helper = null;
public GetBeanPropertyStep() { public GetBeanPropertyStep() {
helper = new DefaultElementParameterHelper(); helper = new DefaultElementObjectPropertyValue();
} }
//----------- get/set functions //----------- get/set functions
@ -70,7 +70,7 @@ public class GetBeanPropertyStep extends AbstractEventStepController {
} }
Object result = null; Object result = null;
try { try {
result = helper.getParameter(object,property); result = helper.getProperty(object,property);
} catch (Exception e) { } catch (Exception e) {
//logger.log(Level.WARNING,"property:"+property+" is not an property of object: "+object.getClass().getName(),e); //logger.log(Level.WARNING,"property:"+property+" is not an property of object: "+object.getClass().getName(),e);
e.printStackTrace(); e.printStackTrace();

View file

@ -8,7 +8,7 @@ import com.idcanet.foei.event.EventStep;
import com.idcanet.foei.event.EventStepController; import com.idcanet.foei.event.EventStepController;
import com.idcanet.x4o.element.AbstractElementBindingHandler; import com.idcanet.x4o.element.AbstractElementBindingHandler;
import com.idcanet.x4o.element.Element; import com.idcanet.x4o.element.Element;
import com.idcanet.x4o.element.ElementBindingException; import com.idcanet.x4o.element.ElementBindingHandlerException;
/** /**
* *
@ -66,7 +66,7 @@ public class FoeiEventBindingRuleHandler extends AbstractElementBindingHandler {
* @param object2 * @param object2
* @throws ClassCastException * @throws ClassCastException
*/ */
public void doBind(Element element) throws ElementBindingException { public void doBind(Element element) throws ElementBindingHandlerException {
Object parent = element.getParent().getElementObject(); Object parent = element.getParent().getElementObject();
Object child = element.getElementObject(); Object child = element.getElementObject();
if(parent==null) { if(parent==null) {

View file

@ -40,7 +40,6 @@ import java.util.List;
import java.util.Queue; import java.util.Queue;
import java.util.Set; import java.util.Set;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.naming.Context; import javax.naming.Context;

View file

@ -26,8 +26,6 @@
package com.idcanet.foei.core.impl; package com.idcanet.foei.core.impl;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.core.FoeiProcessFactory;
import com.idcanet.foei.core.X2OExecutor; import com.idcanet.foei.core.X2OExecutor;
import com.idcanet.x4o.core.X4OParser; import com.idcanet.x4o.core.X4OParser;
@ -65,15 +63,9 @@ public class X2OExecutorImpl implements X2OExecutor {
try { try {
// config parser // config parser
FoeiProcess foeiProcess = FoeiProcessFactory.getFoeiProcess(); //FoeiProcess foeiProcess = FoeiProcessFactory.getFoeiProcess();
X4OParser parser = new X4OParser("foei"); X4OParser parser = new X4OParser("foei");
for (String key:foeiProcess.getFoeiContext().getStartProperties().keySet()) {
String value = foeiProcess.getFoeiContext().getStartProperties().get(key);
parser.setProperty(key, value);
}
logger.info("Executing X2O Parsing."); logger.info("Executing X2O Parsing.");
if(parseFileName!=null) { if(parseFileName!=null) {

View file

@ -31,7 +31,7 @@ import com.idcanet.foei.core.FoeiProcessFactory;
import com.idcanet.foei.event.EventInput; import com.idcanet.foei.event.EventInput;
import com.idcanet.foei.event.EventOutput; import com.idcanet.foei.event.EventOutput;
import com.idcanet.foei.event.EventPort; import com.idcanet.foei.event.EventPort;
import com.idcanet.x4o.element.AbstractElementParameterHandler; import com.idcanet.x4o.element.AbstractElementAttributeHandler;
import com.idcanet.x4o.element.Element; import com.idcanet.x4o.element.Element;
import com.idcanet.x4o.element.ElementConfiguratorException; import com.idcanet.x4o.element.ElementConfiguratorException;
import com.idcanet.x4o.element.ElementException; import com.idcanet.x4o.element.ElementException;
@ -42,14 +42,14 @@ import com.idcanet.x4o.element.ElementException;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Apr 15, 2006 * @version 1.0 Apr 15, 2006
*/ */
public class BindAttributeHandler extends AbstractElementParameterHandler { public class BindAttributeHandler extends AbstractElementAttributeHandler {
/** /**
* @see com.idca.foei.xml.x2o.eld.GlobalParameterHandler#doParameter(java.lang.Object, java.lang.String) * @see com.idca.foei.xml.x2o.eld.GlobalParameterHandler#doConfigElement(java.lang.Object, java.lang.String)
*/ */
@Override @Override
public void doConfigElement(Element element) throws ElementConfiguratorException { public void doConfigElement(Element element) throws ElementConfiguratorException {
String parameterValue = element.getAttributes().get(getParameterName()); String parameterValue = element.getAttributes().get(getAttributeName());
String[] port = parameterValue.split(":"); String[] port = parameterValue.split(":");
if(port.length!=2) { if(port.length!=2) {
return; return;

View file

@ -30,7 +30,7 @@ import com.idcanet.foei.event.EventStep;
import com.idcanet.foei.event.EventStepController; import com.idcanet.foei.event.EventStepController;
import com.idcanet.x4o.element.AbstractElementBindingHandler; import com.idcanet.x4o.element.AbstractElementBindingHandler;
import com.idcanet.x4o.element.Element; import com.idcanet.x4o.element.Element;
import com.idcanet.x4o.element.ElementBindingException; import com.idcanet.x4o.element.ElementBindingHandlerException;
/** /**
* *
@ -58,7 +58,7 @@ public class EventStepBindRuleHandler extends AbstractElementBindingHandler {
/** /**
* @see com.idca.foei.xml.x2o.eld.BindingRuleHandler#doBind(java.lang.Object, java.lang.Object) * @see com.idca.foei.xml.x2o.eld.BindingRuleHandler#doBind(java.lang.Object, java.lang.Object)
*/ */
public void doBind(Element element) throws ElementBindingException { public void doBind(Element element) throws ElementBindingHandlerException {
Object parent = element.getParent().getElementObject(); Object parent = element.getParent().getElementObject();
Object child = element.getElementObject(); Object child = element.getElementObject();
((EventStepController)parent).addEventStep((EventStep)child); ((EventStepController)parent).addEventStep((EventStep)child);

View file

@ -29,7 +29,7 @@ package com.idcanet.foei.core.x4o;
import com.idcanet.foei.core.FoeiBindingException; import com.idcanet.foei.core.FoeiBindingException;
import com.idcanet.foei.core.FoeiProcess; import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.core.FoeiProcessFactory; import com.idcanet.foei.core.FoeiProcessFactory;
import com.idcanet.x4o.element.AbstractElementParameterHandler; import com.idcanet.x4o.element.AbstractElementAttributeHandler;
import com.idcanet.x4o.element.Element; import com.idcanet.x4o.element.Element;
import com.idcanet.x4o.element.ElementConfiguratorException; import com.idcanet.x4o.element.ElementConfiguratorException;
@ -39,15 +39,15 @@ import com.idcanet.x4o.element.ElementConfiguratorException;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Jul 8, 2006 * @version 1.0 Jul 8, 2006
*/ */
public class IdAttributeHandler extends AbstractElementParameterHandler { public class IdAttributeHandler extends AbstractElementAttributeHandler {
/** /**
* @see com.idca.foei.xml.x2o.eld.GlobalParameterHandler#doParameter(java.lang.Object, java.lang.String) * @see com.idca.foei.xml.x2o.eld.GlobalParameterHandler#doConfigElement(java.lang.Object, java.lang.String)
*/ */
@Override @Override
public void doConfigElement(Element element) throws ElementConfiguratorException { public void doConfigElement(Element element) throws ElementConfiguratorException {
// add to objext context // add to objext context
String parameterValue = element.getAttributes().get(getParameterName()); String parameterValue = element.getAttributes().get(getAttributeName());
if(element.getElementObject()==null | "".equals(parameterValue)) { if(element.getElementObject()==null | "".equals(parameterValue)) {
parameterValue= "auto."+Integer.toHexString(element.getElementObject().hashCode()); parameterValue= "auto."+Integer.toHexString(element.getElementObject().hashCode());
//logger.finest("Generated auto id: "+parameterValue); //logger.finest("Generated auto id: "+parameterValue);

View file

@ -34,4 +34,19 @@ package com.idcanet.foei.event;
*/ */
abstract public class AbstractEventStep implements EventStep { abstract public class AbstractEventStep implements EventStep {
private EventStepOperand eventStepOperand = null;
/**
* @return the eventStepOperand
*/
public EventStepOperand getEventStepOperand() {
return eventStepOperand;
}
/**
* @param eventStepOperand the eventStepOperand to set
*/
public void setEventStepOperand(EventStepOperand eventStepOperand) {
this.eventStepOperand = eventStepOperand;
}
} }

View file

@ -36,6 +36,30 @@ import java.io.Serializable;
*/ */
public interface EventStep extends Serializable { public interface EventStep extends Serializable {
public enum EventStepOperand {
AND,NAND,
OR,NOR,XOR;
public boolean execute(boolean A,boolean B) {
if (this==AND) {
return A&B;
}
if (this==NAND) {
return !A&!B;
}
if (this==OR) {
return A|B;
}
if (this==NOR) {
return !A|!B;
}
if (this==XOR) {
return A^B;
}
throw new IllegalStateException("Can execute unknow EventStepOperand: "+this.name());
}
}
/** /**
* Process an object and gives it back. * Process an object and gives it back.
* *
@ -43,4 +67,8 @@ public interface EventStep extends Serializable {
* @returns An object or null if not succesfull. * @returns An object or null if not succesfull.
*/ */
public Object processObject(Object object) throws ClassCastException; public Object processObject(Object object) throws ClassCastException;
public void setEventStepOperand(EventStepOperand operand);
public EventStepOperand getEventStepOperand();
} }