You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2010/07/07 05:53:30 UTC
svn commit: r961098 - in /activemq/sandbox/activemq-apollo-actor:
activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/ activemq-web/
activemq-web/src/main/scala/org/apache/
activemq-web/src/main/scala/org/apache/activemq/ activemq-web/src/main/...
Author: chirino
Date: Wed Jul 7 03:53:30 2010
New Revision: 961098
URL: http://svn.apache.org/viewvc?rev=961098&view=rev
Log:
Starting to customize for amq
Added:
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/BrokerRegistry.scala
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/ServletContextListener.scala
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/Root.scala
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/org/apache/
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/org/apache/activemq/
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/web/
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/web/resources/
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/web/resources/Root.index.scaml
activemq/sandbox/activemq-apollo-actor/activemq-web/src/test/scala/org/apache/
activemq/sandbox/activemq-apollo-actor/activemq-web/src/test/scala/org/apache/activemq/
activemq/sandbox/activemq-apollo-actor/activemq-web/src/test/scala/org/apache/activemq/apollo/
activemq/sandbox/activemq-apollo-actor/activemq-web/src/test/scala/org/apache/activemq/apollo/web/
activemq/sandbox/activemq-apollo-actor/activemq-web/src/test/scala/org/apache/activemq/apollo/web/ResourcesTest.scala
Removed:
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/fusesource/scalate/samples/bookstore/ServletContextListener.scala
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/fusesource/scalate/samples/bookstore/model/Book.scala
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/fusesource/scalate/samples/bookstore/resources/BookResource.scala
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/fusesource/scalate/samples/bookstore/resources/Bookstore.scala
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/fusesource/scalate/samples/bookstore/resources/DefaultRepresentations.scala
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/org/fusesource/scalate/samples/bookstore/resources/BookResource.index.ssp
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/org/fusesource/scalate/samples/bookstore/resources/Bookstore.index.ssp
activemq/sandbox/activemq-apollo-actor/activemq-web/src/test/scala/org/fusesource/scalate/sample/SampleTest.scala
Modified:
activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/BrokerXml.java
activemq/sandbox/activemq-apollo-actor/activemq-web/pom.xml
activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/web.xml
Modified: activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/BrokerXml.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/BrokerXml.java?rev=961098&r1=961097&r2=961098&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/BrokerXml.java (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/BrokerXml.java Wed Jul 7 03:53:30 2010
@@ -42,8 +42,15 @@ public class BrokerXml {
private List<String> transportServers = new ArrayList<String>();
@XmlElement(name="connect-uri")
private List<String> connectUris = new ArrayList<String>();
-
-
+
+
+ public BrokerXml() {
+ }
+
+ public BrokerXml(Broker broker) {
+ }
+
+
public Broker createMessageBroker() throws Exception {
Broker rc = new Broker();
for (VirtualHostXml element : virtualHosts) {
Modified: activemq/sandbox/activemq-apollo-actor/activemq-web/pom.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-web/pom.xml?rev=961098&r1=961097&r2=961098&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-web/pom.xml (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-web/pom.xml Wed Jul 7 03:53:30 2010
@@ -17,8 +17,8 @@
<properties>
<jetty-port>8080</jetty-port>
- <scalate-editor>${env.SCALATE_EDITOR}</scalate-editor>
- <scalate-workdir>${basedir}/target/_scalate</scalate-workdir>
+ <scalate.editor>${env.SCALATE_EDITOR}</scalate.editor>
+ <scalate.workdir>${basedir}/target/_scalate</scalate.workdir>
<netbeans.hint.deploy.server>Tomcat60</netbeans.hint.deploy.server>
</properties>
@@ -35,6 +35,16 @@
<artifactId>activemq-jaxb</artifactId>
<version>6.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-stomp</artifactId>
+ <version>6.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-tcp</artifactId>
+ <version>6.0-SNAPSHOT</version>
+ </dependency>
<!-- Web Framework APIs -->
<dependency>
@@ -97,7 +107,6 @@
<include>**/*Test.*</include>
</includes>
<excludes>
- <exclude>**/QueuesTest.*</exclude>
<exclude>**/htmlunit/**.*</exclude>
</excludes>
</configuration>
@@ -115,15 +124,11 @@
<systemProperties>
<systemProperty>
<name>scalate.editor</name>
- <value>${scalate-editor}</value>
- </systemProperty>
- <systemProperty>
- <name>scalate.temp.workingdir</name>
- <value>true</value>
+ <value>${scalate.editor}</value>
</systemProperty>
<systemProperty>
- <name>scalate-workdir</name>
- <value>${scalate-workdir}</value>
+ <name>scalate.workdir</name>
+ <value>${scalate.workdir}</value>
</systemProperty>
</systemProperties>
<scanIntervalSeconds>0</scanIntervalSeconds>
Added: activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/BrokerRegistry.scala
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/BrokerRegistry.scala?rev=961098&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/BrokerRegistry.scala (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/BrokerRegistry.scala Wed Jul 7 03:53:30 2010
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.activemq.apollo
+
+import java.util.HashMap
+import org.apache.activemq.apollo.broker.Broker
+
+/**
+ * <p>
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+object BrokerRegistry {
+
+ private val _brokers = new HashMap[String, Broker]()
+
+ def get(id:String) = _brokers.synchronized {
+ _brokers.get(id)
+ }
+
+ def add(broker:Broker) = _brokers.synchronized {
+ _brokers.put(broker.name, broker)
+ }
+
+ def remove(id:String) = _brokers.synchronized {
+ _brokers.remove(id)
+ }
+}
\ No newline at end of file
Added: activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/ServletContextListener.scala
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/ServletContextListener.scala?rev=961098&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/ServletContextListener.scala (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/ServletContextListener.scala Wed Jul 7 03:53:30 2010
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.activemq.apollo.web
+
+import com.google.inject.servlet.GuiceServletContextListener
+import org.fusesource.scalate.guice.ScalateModule
+import com.google.inject.Guice
+import javax.servlet.ServletContextEvent
+import org.apache.activemq.transport.TransportFactory
+import org.apache.activemq.apollo.BrokerRegistry
+import org.apache.activemq.apollo.broker.{CompletionTracker, Broker}
+
+/**
+ * A servlet context listener which registers
+ * <a href="http://code.google.com/p/google-guice/wiki/Servlets">Guice Servlet</a>
+ *
+ * @version $Revision : 1.1 $
+ */
+class ServletContextListener extends GuiceServletContextListener {
+
+ var broker:Broker = null
+
+ override def contextInitialized(servletContextEvent: ServletContextEvent) = {
+
+ // todo: replace this with info accessed from a configuration store.
+ // register/start brokers we are managing.
+ try {
+ broker = createBroker();
+ BrokerRegistry.add(broker);
+ broker.start
+ }
+ catch {
+ case e:Exception =>
+ broker = null
+ e.printStackTrace
+ }
+
+ super.contextInitialized(servletContextEvent);
+ }
+
+ def createBroker(): Broker = {
+ val broker = new Broker()
+ broker.name = "default"
+ broker.transportServers.add(TransportFactory.bind("tcp://localhost:10000?wireFormat=multi"))
+ broker.connectUris.add("tcp://localhost:10000")
+ broker
+ }
+
+ override def contextDestroyed(servletContextEvent: ServletContextEvent) = {
+ super.contextDestroyed(servletContextEvent);
+
+ // un-register/stop brokers we are managing.
+ if( broker!=null ) {
+ val tracker = new CompletionTracker("broker shutdown")
+ BrokerRegistry.remove(broker.name);
+ broker.stop(tracker.task(broker.name))
+ tracker.await()
+ }
+ }
+
+ def getInjector = Guice.createInjector(new ScalateModule() {
+
+ // TODO add some custom provider methods here
+ // which can then be injected into resources or templates
+ //
+ // @Provides def createSomething = new MyThing()
+
+ // lets add any package names which contain JAXRS resources
+ // https://jersey.dev.java.net/issues/show_bug.cgi?id=485
+ override def resourcePackageNames =
+ "org.apache.activemq.apollo.web.resources" ::
+ "org.codehaus.jackson.jaxrs" ::
+ super.resourcePackageNames
+ })
+
+
+}
\ No newline at end of file
Added: activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/Root.scala
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/Root.scala?rev=961098&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/Root.scala (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/Root.scala Wed Jul 7 03:53:30 2010
@@ -0,0 +1,115 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.activemq.apollo.web.resources
+
+import java.lang.String
+import org.fusesource.scalate.rest.{Container, ContainerResource}
+import com.sun.jersey.api.NotFoundException
+import javax.ws.rs._
+import core.MediaType
+import org.fusesource.scalate.util.Logging
+import reflect.{BeanProperty, BeanInfo}
+
+/**
+ * Defines the default representations to be used on resources
+ */
+//@ImplicitProduces(Array("text/html;qs=5"))
+//@Produces(Array("application/json", "application/xml","text/xml"))
+@Consumes(Array(MediaType.APPLICATION_JSON))
+@Produces(Array(MediaType.APPLICATION_JSON))
+trait Resource extends Logging
+
+@Path("/")
+class Root() extends Resource {
+
+ @BeanProperty
+ var brokers: Array[Broker] = List(
+ new Broker(this, "default"),
+ new Broker(this, "example")
+ ).toArray[Broker]
+
+ @Path("{id}")
+ def broker(@PathParam("id") id : String): Broker = {
+ if( id == "default" ) {
+ new Broker(this, id)
+ } else {
+ throw new NotFoundException("Broker " + id + " not found")
+ }
+ }
+}
+
+case class Broker(parent:Root, @BeanProperty id: String) extends Resource {
+ @Path("config")
+ def config = BrokerConfig(this, id)
+ @Path("status")
+ def status = BrokerStatus(this, id)
+}
+
+case class BrokerConfig(parent:Broker, @BeanProperty id:String) extends Resource {
+
+ @Path("virtual-hosts")
+ def virtualHosts :List[VirtualHostConfig] = List(
+ new VirtualHostConfig(this, "host1"),
+ new VirtualHostConfig(this, "host2")
+ )
+ @Path("virtual-hosts/{id}")
+ def virtualHost(@PathParam("id") id : String):VirtualHostConfig = null
+
+ @Path("connectors")
+ def connectors :List[ConnectorConfig] = null
+ @Path("connectors/{id}")
+ def connector(@PathParam("id") id : String):ConnectorConfig = null
+}
+
+case class BrokerStatus(parent:Broker, @BeanProperty id:String) extends Resource {
+ @Path("virtual-hosts")
+ def virtualHosts :List[VirtualHostStatus] = null
+ @Path("virtual-host/{id}")
+ def virtualHost(@PathParam("id") id : String):VirtualHostStatus = null
+
+ @Path("connectors")
+ def connectors :List[ConnectorStatus] = null
+ @Path("connectors/{id}")
+ def connector(@PathParam("id") id : String):ConnectorStatus = null
+
+ @Path("connections")
+ def connections :List[ConnectionStatus] = null
+ @Path("connections/{id}")
+ def connection(@PathParam("id") id : String):ConnectionStatus = null
+}
+
+case class VirtualHostConfig(parent:BrokerConfig, @BeanProperty id: String) extends Resource {
+ var names:List[String] = null
+}
+case class VirtualHostStatus(parent:BrokerStatus, @BeanProperty id: String) extends Resource {
+ var state:String = null
+}
+
+case class ConnectorConfig(parent:BrokerConfig, @BeanProperty id:String) extends Resource {
+ var uri:String = null;
+ var connect:String = null;
+}
+case class ConnectorStatus(parent:BrokerStatus, @BeanProperty id: String) extends Resource {
+ var state:String = "unknown";
+ var accepted:Long = 0;
+}
+
+case class ConnectionStatus(parent:BrokerStatus, @BeanProperty id:String) extends Resource {
+ var state:String = "unknown";
+ var readCounter:Long = 0;
+ var writeCounter:Long = 0;
+}
Added: activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/web/resources/Root.index.scaml
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/web/resources/Root.index.scaml?rev=961098&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/web/resources/Root.index.scaml (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/web/resources/Root.index.scaml Wed Jul 7 03:53:30 2010
@@ -0,0 +1,10 @@
+!!!
+-@ import val it: org.apache.activemq.apollo.web.resources.Root
+%html
+ %body
+ %h1 Brokers
+
+ %ul
+ - for( broker <- brokers )
+ %li
+ %a(href="#{broker.id}") #{broker.id}
Modified: activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/web.xml?rev=961098&r1=961097&r2=961098&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/web.xml (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/web.xml Wed Jul 7 03:53:30 2010
@@ -11,7 +11,7 @@
</description>
<listener>
- <listener-class>org.fusesource.scalate.samples.bookstore.ServletContextListener</listener-class>
+ <listener-class>org.apache.activemq.apollo.web.ServletContextListener</listener-class>
</listener>
<filter>
Added: activemq/sandbox/activemq-apollo-actor/activemq-web/src/test/scala/org/apache/activemq/apollo/web/ResourcesTest.scala
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-web/src/test/scala/org/apache/activemq/apollo/web/ResourcesTest.scala?rev=961098&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-web/src/test/scala/org/apache/activemq/apollo/web/ResourcesTest.scala (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-web/src/test/scala/org/apache/activemq/apollo/web/ResourcesTest.scala Wed Jul 7 03:53:30 2010
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.activemq.apollo.web
+
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+import org.scalatest.{FunSuite}
+
+import org.fusesource.scalate.test._
+
+/**
+ */
+@RunWith(classOf[JUnitRunner])
+class ResourcesTest extends FunSuite with WebServerMixin with WebDriverMixin {
+
+ test("home page") {
+ webDriver.get(rootUrl)
+// pageContains("Bookstore")
+ }
+
+// testPageContains("id/item1", "Title1", "Author1", "item1")
+// testPageContains("id/item2", "Title2", "Author2", "item2")
+
+}
\ No newline at end of file