<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright 2015 Red Hat, Inc. and/or its affiliates
    and other contributors as indicated by the @author tags.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.hawkular.bus</groupId>
    <artifactId>hawkular-bus-parent</artifactId>
    <version>0.7.2.Final</version>
  </parent>

  <artifactId>hawkular-bus-ra-wf-module</artifactId>
  <packaging>pom</packaging>
  <name>Hawkular Bus: Resource Adapter WildFly Module</name>

  <dependencies>
    <dependency>
      <groupId>org.apache.activemq</groupId>
      <artifactId>activemq-rar</artifactId>
      <type>rar</type>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <descriptors>
            <descriptor>src/main/scripts/module-assembly.xml</descriptor>
          </descriptors>
        </configuration>
        <executions>
          <execution>
            <id>module</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <!-- configures a wildfly container so devs can use it -->
    <profile>
      <id>dev</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <id>config-wf</id>
                <phase>install</phase>
                <configuration>
                  <target>
                    <property name="org.hawkular.wildfly.home" value="${basedir}/../../hawkular-agent/hawkular-agent-distro/target/wildfly-${version.org.wildfly}" />
                    <property name="org.hawkular.broker.bus.uri" value="vm://org.hawkular.bus.broker.${jboss.node.name}?create=false" />
                    <unzip src="${project.build.directory}/${project.build.finalName}-module.zip" dest="${org.hawkular.wildfly.home}/modules/system/layers/base" />
                    <replaceregexp file="${org.hawkular.wildfly.home}/standalone/configuration/standalone.xml" flags="gis" match="&lt;/session-bean&gt;&#xA;" replace="&lt;/session-bean&gt;&#xA;&lt;mdb&gt;&#xA; &lt;resource-adapter-ref resource-adapter-name=&quot;activemq-rar&quot; /&gt;&#xA; &lt;bean-instance-pool-ref pool-name=&quot;mdb-strict-max-pool&quot; /&gt;&#xA;&lt;/mdb&gt;&#xA;" />
                    <replaceregexp file="${org.hawkular.wildfly.home}/standalone/configuration/standalone.xml" flags="gis" match="&lt;subsystem xmlns=&quot;urn:jboss:domain:resource-adapters:2.0&quot; /&gt;&#xA;" replace="&lt;subsystem xmlns=&quot;urn:jboss:domain:resource-adapters:2.0&quot;&gt;&#xA;&lt;resource-adapters&gt;&#xA; &lt;resource-adapter id=&quot;activemq-rar&quot;&gt;&#xA; &lt;module slot=&quot;main&quot; id=&quot;org.apache.activemq.ra&quot; /&gt;&#xA; &lt;transaction-support&gt;XATransaction&lt;/transaction-support&gt;&#xA; &lt;config-property name=&quot;UseInboundSession&quot;&gt;&#xA; false&#xA; &lt;/config-property&gt;&#xA; &lt;!--&lt;config-property name=&quot;Password&quot;&gt;&#xA; defaultPassword&#xA; &lt;/config-property&gt;&#xA; &lt;config-property name=&quot;UserName&quot;&gt;&#xA; defaultUser&#xA; &lt;/config-property&gt;--&gt;&#xA; &lt;config-property name=&quot;ServerUrl&quot;&gt;&#xA; ${org.hawkular.broker.bus.uri}&#xA; &lt;/config-property&gt;&#xA; &lt;connection-definitions&gt;&#xA; &lt;connection-definition class-name=&quot;org.apache.activemq.ra.ActiveMQManagedConnectionFactory&quot; jndi-name=&quot;java:/HawkularBusConnectionFactory&quot; enabled=&quot;true&quot; use-java-context=&quot;true&quot; pool-name=&quot;HawkularBusConnectionFactory&quot;&gt;&#xA; &lt;xa-pool&gt;&#xA; &lt;min-pool-size&gt;1&lt;/min-pool-size&gt;&#xA; &lt;max-pool-size&gt;20&lt;/max-pool-size&gt;&#xA; &lt;prefill&gt;false&lt;/prefill&gt;&#xA; &lt;is-same-rm-override&gt;false&lt;/is-same-rm-override&gt;&#xA; &lt;/xa-pool&gt;&#xA; &lt;/connection-definition&gt;&#xA; &lt;/connection-definitions&gt;&#xA; &lt;!-- &lt;admin-objects&gt;&#xA; &lt;admin-object class-name=&quot;org.apache.activemq.command.ActiveMQQueue&quot; jndi-name=&quot;java:/queue/QueueName&quot; enabled=&quot;true&quot; use-java-context=&quot;true&quot; pool-name=&quot;QueueName&quot;&gt;&#xA; &lt;config-property name=&quot;PhysicalName&quot;&gt;&#xA; QueueName&#xA; &lt;/config-property&gt;&#xA; &lt;/admin-object&gt;&#xA; &lt;admin-object class-name=&quot;org.apache.activemq.command.ActiveMQTopic&quot; jndi-name=&quot;java:/topic/TopicName&quot; enabled=&quot;true&quot; use-java-context=&quot;true&quot; pool-name=&quot;TopicName&quot;&gt;&#xA; &lt;config-property name=&quot;PhysicalName&quot;&gt;&#xA; TopicName&#xA; &lt;/config-property&gt;&#xA; &lt;/admin-object&gt;&#xA; &lt;/admin-objects&gt; --&gt;&#xA; &lt;/resource-adapter&gt;&#xA;&lt;/resource-adapters&gt;&#xA;&lt;/subsystem&gt;&#xA;" />
                  </target>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
