Skip to content

Commit

Permalink
Merge pull request #22 from aandryashin/multiple-contexts
Browse files Browse the repository at this point in the history
Separate application contexts
  • Loading branch information
smecsia committed Mar 5, 2015
2 parents 2cca154 + e02994a commit d643aa8
Show file tree
Hide file tree
Showing 14 changed files with 257 additions and 205 deletions.
5 changes: 5 additions & 0 deletions camelot-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
<artifactId>hazelcast</artifactId>
<version>${hazelcast.version}</version>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-client</artifactId>
<version>${hazelcast.version}</version>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-spring</artifactId>
Expand Down
37 changes: 37 additions & 0 deletions camelot-core/src/main/resources/camelot-amq-context.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="failover:${jms.broker.list}"/>
</bean>

<bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory"
depends-on="camelotCamelContext" init-method="start" destroy-method="stop">
<property name="timeBetweenExpirationCheckMillis" value="${activemq.pool.timeBetweenExpirationCheckMillis}"/>
<property name="idleTimeout" value="${activemq.pool.idleTimeout}"/>
<property name="maxConnections" value="${activemq.pool.maxConnections}"/>
<property name="maximumActiveSessionPerConnection" value="${activemq.pool.maximumActiveSessionPerConnection}"/>
<property name="connectionFactory" ref="jmsConnectionFactory"/>
</bean>

<bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="pooledConnectionFactory"/>
<property name="transacted" value="false"/>
<property name="testConnectionOnStartup" value="true"/>
</bean>

<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="configuration" ref="jmsConfig"/>
<property name="testConnectionOnStartup" value="true"/>
</bean>

</beans>
26 changes: 26 additions & 0 deletions camelot-core/src/main/resources/camelot-camel-context.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<!-- Routes -->
<camelContext id="camelotCamelContext" xmlns="http://camel.apache.org/schema/spring">
<jmxAgent id="agent" disabled="true"/>

<endpoint id="events.input" uri="${camelot.input.uri}"/>
<endpoint id="events.output" uri="${camelot.output.uri}"/>

<route id="stopped">
<from ref="events.output"/>
<stop/>
</route>
</camelContext>

</beans>
145 changes: 5 additions & 140 deletions camelot-core/src/main/resources/camelot-core-context.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:hz="http://www.hazelcast.com/schema/spring"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.hazelcast.com/schema/spring
http://www.hazelcast.com/schema/spring/hazelcast-spring-3.2.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

Expand All @@ -27,140 +22,10 @@
<context:annotation-config/>
<context:component-scan base-package="ru.yandex.qatools.camelot.web,ru.yandex.qatools.camelot.core"/>

<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="failover:${jms.broker.list}"/>
</bean>

<bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory"
depends-on="camelotCamelContext" init-method="start" destroy-method="stop">
<property name="timeBetweenExpirationCheckMillis" value="${activemq.pool.timeBetweenExpirationCheckMillis}"/>
<property name="idleTimeout" value="${activemq.pool.idleTimeout}"/>
<property name="maxConnections" value="${activemq.pool.maxConnections}"/>
<property name="maximumActiveSessionPerConnection" value="${activemq.pool.maximumActiveSessionPerConnection}"/>
<property name="connectionFactory" ref="jmsConnectionFactory"/>
</bean>

<bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="pooledConnectionFactory"/>
<property name="transacted" value="false"/>
<property name="testConnectionOnStartup" value="true"/>
</bean>

<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="configuration" ref="jmsConfig"/>
<property name="testConnectionOnStartup" value="true"/>
</bean>

<hz:hazelcast id="hazelcastInstance">
<hz:config>
<hz:group name="${hazelcast.group.name}" password="${hazelcast.group.password}"/>
<hz:properties>
<hz:property name="hazelcast.merge.first.run.delay.seconds">${hazelcast.merge.first.run.delay.seconds}
</hz:property>
<hz:property name="hazelcast.merge.next.run.delay.seconds">${hazelcast.merge.next.run.delay.seconds}
</hz:property>
<hz:property name="hazelcast.max.no.heartbeat.seconds">${hazelcast.max.no.heartbeat.seconds}
</hz:property>
<hz:property name="hazelcast.logging.type">${hazelcast.logging.type}</hz:property>
</hz:properties>
<hz:network port="${hazelcast.port}" port-auto-increment="${hazelcast.port.auto.increment}">
<hz:join>
<hz:multicast enabled="false" multicast-group="224.2.2.3" multicast-port="54327"/>
<hz:tcp-ip enabled="${hazelcast.tcp-ip.enabled}">
<hz:members>${hazelcast.hosts}</hz:members>
</hz:tcp-ip>
</hz:join>
<hz:interfaces>
<hz:interface>${hazelcast.interface}</hz:interface>
</hz:interfaces>
</hz:network>

<hz:map name="${hazelcast.map.name}"
backup-count="${hazelcast.backup.count}"
async-backup-count="${hazelcast.async.backup.count}"
max-size="${hazelcast.map.max-size}"
eviction-percentage="${hazelcast.map.eviction-percentage}"
read-backup-data="${hazelcast.map.read-backup-data}"
eviction-policy="${hazelcast.map.eviction-policy}"
merge-policy="${hazelcast.map.merge-policy}">
</hz:map>
</hz:config>
</hz:hazelcast>

<!-- Beans -->
<bean id="LOADER-MAVEN" class="ru.yandex.qatools.camelot.core.impl.MavenRepositoryPluginLoader">
<constructor-arg name="localRepository" value="${plugins.local.repository}"/>
<constructor-arg name="remoteRepositories" value="${plugins.remote.repositories}"/>
<constructor-arg name="updatePolicy" value="${plugins.config.updatePolicy}"/>
<constructor-arg name="checksumPolicy" value="${plugins.config.checksumPolicy}"/>
</bean>
<bean id="LOADER-CLASSPATH" class="ru.yandex.qatools.camelot.core.impl.SameClasspathPluginLoader"/>

<bean id="schedulerFactory" class="org.quartz.impl.StdSchedulerFactory"/>
<bean id="scheduler" factory-bean="schedulerFactory" factory-method="getScheduler"/>

<!-- Builders Factories -->
<bean id="FACTORY-HZ" class="ru.yandex.qatools.camelot.core.builders.BuildersFactoryWithHazelcastImpl">
<constructor-arg name="hazelcastInstance" ref="hazelcastInstance"/>
<property name="waitForLockSec" value="${camelot.hazelcast.waitForLockSec}"/>
</bean>
<bean id="FACTORY-MEM" class="ru.yandex.qatools.camelot.core.builders.BuildersFactoryImpl">
<property name="waitForLockSec" value="${camelot.mem.waitForLockSec}"/>
</bean>

<bean id="processingEngine" class="ru.yandex.qatools.camelot.core.impl.ProcessingEngineImpl" init-method="init">
<constructor-arg name="configResources" value="${plugins.config.path}"/>
<constructor-arg name="camelContext" ref="camelotCamelContext"/>
<constructor-arg name="pluginLoader" ref="${camelot.pluginLoader}"/>
<constructor-arg name="inputUri" value="ref:events.input"/>
<constructor-arg name="outputUri" value="ref:events.output"/>
<property name="scheduler" ref="scheduler"/>
<property name="buildersFactory" ref="${camelot.factory}"/>
<property name="contextInjector">
<bean class="ru.yandex.qatools.camelot.core.impl.PluginContextInjectorImpl"/>
</property>
<property name="resourceBuilder">
<bean class="ru.yandex.qatools.camelot.core.builders.SpringPluginResourceBuilder"/>
</property>
<property name="appConfig">
<bean class="ru.yandex.qatools.camelot.core.impl.AppConfigSpringProperties"/>
</property>
<property name="pluginInitializer">
<bean class="ru.yandex.qatools.camelot.core.impl.PluginInitializerWithHazelcastImpl">
<constructor-arg name="hazelcastInstance" ref="hazelcastInstance"/>
</bean>
</property>
</bean>

<!-- ThreadPool profiles -->
<bean id="camelotDefaultProfile" class="org.apache.camel.spi.ThreadPoolProfile">
<property name="id" value="camelotDefaultProfile"/>
<property name="defaultProfile" value="true"/>
<property name="timeUnit" value="MILLISECONDS"/>
<property name="keepAliveTime" value="${camelot.threadpool.default.keepAliveMillis}"/>
<property name="poolSize" value="${camelot.threadpool.default.size}"/>
<property name="maxPoolSize" value="${camelot.threadpool.default.maxSize}"/>
</bean>

<bean id="camelotMulticastProfile" class="org.apache.camel.spi.ThreadPoolProfile">
<property name="id" value="camelotMulticastProfile"/>
<property name="defaultProfile" value="false"/>
<property name="timeUnit" value="MILLISECONDS"/>
<property name="keepAliveTime" value="${camelot.threadpool.multicast.keepAliveMillis}"/>
<property name="poolSize" value="${camelot.threadpool.multicast.size}"/>
<property name="maxPoolSize" value="${camelot.threadpool.multicast.maxSize}"/>
</bean>

<!-- Routes -->
<camelContext id="camelotCamelContext" xmlns="http://camel.apache.org/schema/spring">
<jmxAgent id="agent" disabled="true"/>

<endpoint id="events.input" uri="${camelot.input.uri}"/>
<endpoint id="events.output" uri="${camelot.output.uri}"/>
<import resource="classpath*:camelot-amq-context.xml"/>
<import resource="classpath*:camelot-hz-context.xml"/>
<import resource="classpath*:camelot-loaders-context.xml"/>
<import resource="classpath*:camelot-camel-context.xml"/>
<import resource="classpath*:camelot-processing-context.xml"/>

<route id="stopped">
<from ref="events.output"/>
<stop/>
</route>
</camelContext>
</beans>
56 changes: 56 additions & 0 deletions camelot-core/src/main/resources/camelot-hz-context.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:hz="http://www.hazelcast.com/schema/spring"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.hazelcast.com/schema/spring
http://www.hazelcast.com/schema/spring/hazelcast-spring-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<hz:hazelcast id="hazelcastInstance">
<hz:config>
<hz:group name="${hazelcast.group.name}" password="${hazelcast.group.password}"/>
<hz:properties>
<hz:property name="hazelcast.merge.first.run.delay.seconds">${hazelcast.merge.first.run.delay.seconds}
</hz:property>
<hz:property name="hazelcast.merge.next.run.delay.seconds">${hazelcast.merge.next.run.delay.seconds}
</hz:property>
<hz:property name="hazelcast.max.no.heartbeat.seconds">${hazelcast.max.no.heartbeat.seconds}
</hz:property>
<hz:property name="hazelcast.logging.type">${hazelcast.logging.type}</hz:property>
</hz:properties>
<hz:network port="${hazelcast.port}" port-auto-increment="${hazelcast.port.auto.increment}">
<hz:join>
<hz:multicast enabled="false" multicast-group="224.2.2.3" multicast-port="54327"/>
<hz:tcp-ip enabled="${hazelcast.tcp-ip.enabled}">
<hz:members>${hazelcast.hosts}</hz:members>
</hz:tcp-ip>
</hz:join>
<hz:interfaces>
<hz:interface>${hazelcast.interface}</hz:interface>
</hz:interfaces>
</hz:network>

<hz:map name="${hazelcast.map.name}"
backup-count="${hazelcast.backup.count}"
async-backup-count="${hazelcast.async.backup.count}"
max-size="${hazelcast.map.max-size}"
eviction-percentage="${hazelcast.map.eviction-percentage}"
read-backup-data="${hazelcast.map.read-backup-data}"
eviction-policy="${hazelcast.map.eviction-policy}"
merge-policy="${hazelcast.map.merge-policy}">
</hz:map>
</hz:config>
</hz:hazelcast>

<!-- Builders Factories -->
<bean id="FACTORY-HZ" class="ru.yandex.qatools.camelot.core.builders.BuildersFactoryWithHazelcastImpl">
<constructor-arg name="hazelcastInstance" ref="hazelcastInstance"/>
<property name="waitForLockSec" value="${camelot.hazelcast.waitForLockSec}"/>
</bean>

</beans>
28 changes: 28 additions & 0 deletions camelot-core/src/main/resources/camelot-loaders-context.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<bean id="LOADER-MAVEN" class="ru.yandex.qatools.camelot.core.impl.MavenRepositoryPluginLoader">
<constructor-arg name="localRepository" value="${plugins.local.repository}"/>
<constructor-arg name="remoteRepositories" value="${plugins.remote.repositories}"/>
<constructor-arg name="updatePolicy" value="${plugins.config.updatePolicy}"/>
<constructor-arg name="checksumPolicy" value="${plugins.config.checksumPolicy}"/>
</bean>
<bean id="LOADER-CLASSPATH" class="ru.yandex.qatools.camelot.core.impl.SameClasspathPluginLoader"/>

<bean id="schedulerFactory" class="org.quartz.impl.StdSchedulerFactory"/>
<bean id="scheduler" factory-bean="schedulerFactory" factory-method="getScheduler"/>

<bean id="FACTORY-MEM" class="ru.yandex.qatools.camelot.core.builders.BuildersFactoryImpl">
<property name="waitForLockSec" value="${camelot.mem.waitForLockSec}"/>
</bean>

</beans>
Loading

0 comments on commit d643aa8

Please sign in to comment.