<file name="activemq.xml">
<!--
##
##  activemq.xml: ActiveMQ server configuration
##
-->
<beans
  xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans.xsd
      http://activemq.apache.org/schema/core
      http://activemq.apache.org/schema/core/activemq-core.xsd">

    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <value>file:///@l_prefix@/etc/activemq/activemq.properties</value>
        </property>
    </bean>

    <bean id="logQuery" class="io.fabric8.insight.log.log4j.Log4jLogQuery"
          lazy-init="false" scope="singleton"
          init-method="start" destroy-method="stop">
    </bean>

    <broker xmlns="http://activemq.apache.org/schema/core"
        brokerName="localhost"
        dataDirectory="@l_prefix@/var/activemq/data">
        <destinationPolicy>
            <policyMap>
              <policyEntries>
                <policyEntry topic=">" >
                  <pendingMessageLimitStrategy>
                    <constantPendingMessageLimitStrategy limit="1000"/>
                  </pendingMessageLimitStrategy>
                </policyEntry>
              </policyEntries>
            </policyMap>
        </destinationPolicy>

        <managementContext>
            <managementContext createConnector="false"/>
        </managementContext>

        <persistenceAdapter>
            <kahaDB directory="@l_prefix@/var/activemq/data"/>
        </persistenceAdapter>

        <systemUsage>
            <systemUsage>
                <memoryUsage>
                    <memoryUsage percentOfJvmHeap="70" />
                </memoryUsage>
                <storeUsage>
                    <storeUsage limit="100 gb"/>
                </storeUsage>
                <tempUsage>
                    <tempUsage limit="50 gb"/>
                </tempUsage>
            </systemUsage>
        </systemUsage>

        <sslContext>
            <sslContext
                keyStore="@l_prefix@/etc/activemq/example-server.ks" keyStorePassword="example"
                trustStore="@l_prefix@/etc/activemq/example-server.ts" trustStorePassword="example"
            />
        </sslContext>

        <transportConnectors>
            <transportConnector name="openwire"  uri="tcp://localhost:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="amqp"      uri="amqp://localhost:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="stomp"     uri="stomp://localhost:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="mqtt"      uri="mqtt://localhost:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="ws"        uri="ws://localhost:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="wss"       uri="wss://localhost:61615?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        </transportConnectors>

        <shutdownHooks>
            <bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" />
        </shutdownHooks>
    </broker>

    <import resource="jetty.xml"/>
</beans>
</file>
<file name="jetty.xml">
<!--
##
##  jetty.xml: Jetty server configuration
##
-->
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="securityLoginService" class="org.eclipse.jetty.security.HashLoginService">
        <property name="name" value="ActiveMQRealm" />
        <property name="config" value="file:///@l_prefix@/etc/activemq/jetty.properties"/>
    </bean>

    <bean id="securityConstraint" class="org.eclipse.jetty.util.security.Constraint">
        <property name="name" value="BASIC" />
        <property name="roles" value="user,admin" />
        <property name="authenticate" value="true" />
    </bean>
    <bean id="adminSecurityConstraint" class="org.eclipse.jetty.util.security.Constraint">
        <property name="name" value="BASIC" />
        <property name="roles" value="admin" />
        <property name="authenticate" value="true" />
    </bean>
    <bean id="securityConstraintMapping" class="org.eclipse.jetty.security.ConstraintMapping">
        <property name="constraint" ref="securityConstraint" />
        <property name="pathSpec" value="/admin/*,*.jsp" />
    </bean>
    <bean id="adminSecurityConstraintMapping" class="org.eclipse.jetty.security.ConstraintMapping">
        <property name="constraint" ref="adminSecurityConstraint" />
        <property name="pathSpec" value="*.action" />
    </bean>
    <bean id="securityHandler" class="org.eclipse.jetty.security.ConstraintSecurityHandler">
        <property name="loginService" ref="securityLoginService" />
        <property name="authenticator">
            <bean class="org.eclipse.jetty.security.authentication.BasicAuthenticator" />
        </property>
        <property name="constraintMappings">
            <list>
                <ref bean="adminSecurityConstraintMapping" />
                <ref bean="securityConstraintMapping" />
            </list>
        </property>
        <property name="handler">
            <bean id="sec" class="org.eclipse.jetty.server.handler.HandlerCollection">
                <property name="handlers">
                    <list>
                        <bean class="org.eclipse.jetty.webapp.WebAppContext">
                            <property name="contextPath" value="/openpkg-activemq/admin" />
                            <property name="resourceBase" value="@l_prefix@/share/activemq/admin" />
                            <property name="logUrlOnStart" value="true" />
                        </bean>
                        <bean class="org.eclipse.jetty.webapp.WebAppContext">
                            <property name="contextPath" value="/openpkg-activemq/fileserver" />
                            <property name="resourceBase" value="@l_prefix@/share/activemq/fileserver" />
                            <property name="logUrlOnStart" value="true" />
                            <property name="parentLoaderPriority" value="true" />
                        </bean>
                        <bean class="org.eclipse.jetty.webapp.WebAppContext">
                            <property name="contextPath" value="/openpkg-activemq/api" />
                            <property name="resourceBase" value="@l_prefix@/share/activemq/api" />
                            <property name="logUrlOnStart" value="true" />
                        </bean>
                        <bean class="org.eclipse.jetty.server.handler.ResourceHandler">
                            <property name="directoriesListed" value="false" />
                            <property name="welcomeFiles">
                                <list>
                                    <value>index.html</value>
                                </list>
                            </property>
                            <property name="resourceBase" value="@l_prefix@/share/activemq/" />
                        </bean>
                        <bean id="defaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler">
                            <property name="serveIcon" value="false" />
                        </bean>
                    </list>
                </property>
            </bean>
        </property>
    </bean>

    <bean id="contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
    </bean>

    <bean id="jettyPort" class="org.apache.activemq.web.WebConsolePort" init-method="start">
        <property name="host" value="localhost"/>
        <property name="port" value="8161"/>
    </bean>

    <bean id="Server" depends-on="jettyPort" class="org.eclipse.jetty.server.Server" init-method="start"
        destroy-method="stop">
        <property name="connectors">
            <list>
                <bean id="Connector" class="org.eclipse.jetty.server.nio.SelectChannelConnector">
                    <property name="host" value="localhost"/>
                    <property name="port" value="8162"/>
                </bean>
            </list>
        </property>
        <property name="handler">
            <bean id="handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
                <property name="handlers">
                    <list>
                        <ref bean="contexts" />
                        <ref bean="securityHandler" />
                    </list>
                </property>
            </bean>
        </property>
    </bean>

</beans>
</file>
<file name="activemq.properties">
##
##  activemq.properties: ActiveMQ configuration properties
##

activemq.username=system
activemq.password=manager

</file>
<file name="jetty.properties">
##
##  jetty.properties: ActiveMQ configuration properties
##

# username: password[, rolename ...]
admin: admin, admin

</file>
<file name="log4j.properties">
##
##  log4j.properties: ActiveMQ Log4J logging configuration
##

log4j.rootLogger=INFO,logfile

log4j.logger.org.apache.activemq.spring=WARN
log4j.logger.org.apache.xbean.spring=WARN
log4j.logger.org.springframework=WARN
#log4j.logger.org.apache.activemq=WARN
#log4j.logger.org.apache.camel=WARN

log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.file=@l_prefix@/var/activemq/log/activemq.log
log4j.appender.logfile.maxFileSize=1024KB
log4j.appender.logfile.maxBackupIndex=9
log4j.appender.logfile.append=true
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n

</file>
<file name="web.xml">
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
    <display-name>ActiveMQ REST Service</display-name>
    <description>ActiveMQ REST Service</description>

    <context-param>
        <param-name>org.apache.activemq.brokerURL</param-name>
        <param-value>vm://localhost</param-value>
        <description>The URL of the Message Broker to connect to</description>
    </context-param>
    <context-param>
        <param-name>org.apache.activemq.embeddedBroker</param-name>
        <param-value>true</param-value>
        <description>Whether we should include an embedded broker or not</description>
    </context-param>

    <servlet>
        <servlet-name>MessageServlet</servlet-name>
        <servlet-class>org.apache.activemq.web.MessageServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
        <init-param>
            <param-name>destinationOptions</param-name>
            <param-value>consumer.prefetchSize=1</param-value>
        </init-param>
    </servlet>
    <servlet>
        <servlet-name>AjaxServlet</servlet-name>
        <servlet-class>org.apache.activemq.web.AjaxServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>QueueBrowseServlet</servlet-name>
        <servlet-class>org.apache.activemq.web.QueueBrowseServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>MessageServlet</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>AjaxServlet</servlet-name>
        <url-pattern>/ajax/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>QueueBrowseServlet</servlet-name>
        <url-pattern>/browse/*</url-pattern>
    </servlet-mapping>

    <filter>
        <filter-name>session</filter-name>
        <filter-class>org.apache.activemq.web.SessionFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>session</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>
</file>
<file name="activemq.conf">
##
##  activemq.conf: ActiveMQ Apache configuration
##

#   global URL integration mapping
#   (mainly to circumvent cross-browser access control checks
#   and to allow correct path mapping for JSESSIONID cookie)
ProxyPass         /openpkg-activemq/  http://localhost:8161/openpkg-activemq/
ProxyPassReverse  /openpkg-activemq/  http://localhost:8161/openpkg-activemq/

</file>
