Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Added profiles section and resource filtering to pom.xml

- agent name and endpoint information can be now configured in pom.xml
- database information can be now configured in pom.xml
- Modified generated test to actually inform a fact to the agent
  • Loading branch information...
commit 4a5a00863f30319cd09a07a66dd8199952c21d9b 1 parent 3a80888
@esteban-aliverti esteban-aliverti authored
View
63 drools-mas-agent-web-archetype/src/main/resources/archetype-resources/pom.xml
@@ -28,6 +28,51 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
+
+ <profiles>
+ <profile>
+ <id>dev</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <properties>
+ <db.driverClass>org.h2.Driver</db.driverClass>
+ <db.connectionURL>jdbc:h2:tcp://localhost/~/mydb</db.connectionURL>
+ <db.username>sa</db.username>
+ <db.password>sasa</db.password>
+ <db.dialect>org.hibernate.dialect.H2Dialect</db.dialect>
+
+ <agent.name>${agent-name}</agent.name>
+ <agent.node>${agent-name}-localnode</agent.node>
+ <agent.port>8000</agent.port>
+ <agent.endpoint.ip>localhost</agent.endpoint.ip>
+ <agent.endpoint.port>8081</agent.endpoint.port>
+ </properties>
+ </profile>
+ <profile>
+ <id>local</id>
+ <properties>
+ <db.driverClass>com.mysql.jdbc.Driver</db.driverClass>
+ <db.connectionURL>jdbc:mysql://localhost:3306/drools-grid-ra</db.connectionURL>
+ <db.username>root</db.username>
+ <db.password>root</db.password>
+ <db.dialect>org.hibernate.dialect.MySQL5Dialect</db.dialect>
+
+ <agent.name>${agent-name}</agent.name>
+ <agent.node>${agent-name}-localnode</agent.node>
+ <agent.port>8000</agent.port>
+ <agent.endpoint.ip>localhost</agent.endpoint.ip>
+ <agent.endpoint.port>8081</agent.endpoint.port>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.25</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
<dependencies>
<dependency>
@@ -90,6 +135,12 @@
<version>1.3.162</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.drools.mas</groupId>
+ <artifactId>drools-mas-generic-client</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<finalName>${agent-name}</finalName>
@@ -104,5 +155,17 @@
</configuration>
</plugin>
</plugins>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ <resource>
+ <directory>src/test/java</directory>
+ <filtering>true</filtering>
+ <targetPath>../filtered-sources/test/java</targetPath>
+ </resource>
+ </resources>
+ <testSourceDirectory>target/filtered-sources/test/java</testSourceDirectory>
</build>
</project>
View
20 ...-web-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/applicationContext.xml
@@ -10,11 +10,11 @@ http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<jaxws:endpoint id="agent-ws"
- address="http://localhost:8080/${agent-name}/services/SyncAgentService"
+ address="http://${agent.endpoint.ip}:${agent.endpoint.port}/${agent.name}/services/SyncAgentService"
implementor="#agent-service">
</jaxws:endpoint>
<jaxws:endpoint id="async-agent-ws"
- address="http://localhost:8080/${agent-name}/services/AsyncAgentService"
+ address="http://${agent.endpoint.ip}:${agent.endpoint.port}/${agent.name}/services/AsyncAgentService"
implementor="#async-agent-service">
</jaxws:endpoint>
@@ -26,21 +26,21 @@ http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<property name="agent" ref="agent"/>
</bean>
- <bean id="agent1-session1" class="org.drools.mas.core.DroolsAgentConfiguration$SubSessionDescriptor">
+ <bean id="${agent.name}-session1" class="org.drools.mas.core.DroolsAgentConfiguration$SubSessionDescriptor">
<constructor-arg value="session1"/>
<constructor-arg value="agent_defSession_changeset.xml"/>
- <constructor-arg value="local-agent1"/>
+ <constructor-arg value="${agent.node}"/>
</bean>
- <bean id="agent1-configuration" class="org.drools.mas.core.DroolsAgentConfiguration">
- <property name="agentId" value="Agent 1"/>
+ <bean id="${agent.name}-configuration" class="org.drools.mas.core.DroolsAgentConfiguration">
+ <property name="agentId" value="${agent.name}"/>
<property name="changeset" value="agent_changeset.xml" />
<!-- by default the mindNodeLocation is local -->
- <property name="mindNodeLocation" value="local-agent1"/>
- <property name="port" value="7000"/>
+ <property name="mindNodeLocation" value="${agent.node}"/>
+ <property name="port" value="${agent.port}"/>
<property name="subSessions">
<list>
- <ref local="agent1-session1"/>
+ <ref local="${agent.name}-session1"/>
</list>
</property>
@@ -49,7 +49,7 @@ http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<bean id="agent-factory" class="org.drools.mas.core.DroolsAgentFactory" factory-method="getInstance"/>
<bean id="agent" class="org.drools.mas.core.DroolsAgent" factory-bean="agent-factory" factory-method="spawn">
- <constructor-arg ref="agent1-configuration"/>
+ <constructor-arg ref="${agent.name}-configuration"/>
</bean>
View
40 drools-mas-agent-web-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/orm.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
+ version="1.0">
+ <entity class="org.drools.grid.service.directory.impl.AddressImpl" access="FIELD">
+ <table name="Address"/>
+
+ <attributes>
+ <id name="addressId">
+ </id>
+ <many-to-one name="gridServiceDescription" target-entity="org.drools.grid.service.directory.impl.GridServiceDescriptionImpl" />
+ </attributes>
+ </entity>
+
+ <entity class="org.drools.grid.service.directory.impl.GridServiceDescriptionImpl" access="FIELD">
+ <table name="GridServiceDescription"/>
+
+ <attributes>
+ <id name="descId" />
+ <basic name="ownerGridId"/>
+ <one-to-many name="addresses" mapped-by="gridServiceDescription" target-entity="org.drools.grid.service.directory.impl.AddressImpl" fetch="EAGER" >
+ <map-key name="transport" />
+ <cascade>
+ <cascade-all/>
+ </cascade>
+ </one-to-many>
+
+ </attributes>
+ </entity>
+
+ <entity class="org.drools.grid.timer.impl.ScheduledJob" access="FIELD">
+ <table name="ScheduledJob"/>
+
+ <attributes>
+ <id name="jobId" />
+ <transient name="jobHandle" />
+ </attributes>
+ </entity>
+</entity-mappings>
View
22 ...s-agent-web-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:orm="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd">
+ <persistence-unit name="org.drools.grid">
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+ <class>org.drools.grid.service.directory.impl.GridServiceDescriptionImpl</class>
+ <class>org.drools.grid.service.directory.impl.AddressImpl</class>
+ <class>org.drools.grid.timer.impl.ScheduledJob</class>
+ <class>java.lang.String</class>
+
+ <properties>
+ <property name="hibernate.dialect" value="${db.dialect}"/>
+ <property name="hibernate.connection.driver_class" value="${db.driverClass}"/>
+ <property name="hibernate.connection.url" value="${db.connectionURL}"/>
+ <property name="hibernate.connection.username" value="${db.username}"/>
+ <property name="hibernate.connection.password" value="${db.password}"/>
+ <property name="hibernate.connection.autocommit" value="false"/>
+ <property name="hibernate.max_fetch_depth" value="3"/>
+ <property name="hibernate.hbm2ddl.auto" value="update"/>
+ <property name="hibernate.show_sql" value="false"/>
+ </properties>
+ </persistence-unit>
+</persistence>
View
9 ...eb-archetype/src/main/resources/archetype-resources/src/test/java/KnowledgeResourcesCompilationTest.java
@@ -6,6 +6,7 @@
import java.sql.SQLException;
import org.drools.mas.core.DroolsAgent;
+import org.drools.mas.helpers.DialogueHelper;
import org.h2.tools.DeleteDbFiles;
import org.h2.tools.Server;
import org.junit.*;
@@ -59,13 +60,19 @@ public void tearDown() {
* initialized correctly
*/
@Test
- public void compilationTest() {
+ public void compilationTest() throws InterruptedException {
ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/applicationContext.xml");
DroolsAgent agent = (DroolsAgent) context.getBean("agent");
assertNotNull(agent);
+ DialogueHelper helper = new DialogueHelper("http://${agent.endpoint.ip}:${agent.endpoint.port}/${agent.name}/services/AsyncAgentService?wsdl");
+
+ helper.invokeInform("me", "you", "Hello World!", null);
+
+ Thread.sleep(3000);
+
agent.dispose();
}
Please sign in to comment.
Something went wrong with that request. Please try again.