Skip to content

Instantly share code, notes, and snippets.

View imageaid's full-sized avatar

Craig Kaminsky imageaid

View GitHub Profile
@imageaid
imageaid / Railo Web XML Bits
Created December 4, 2010 16:31
The necessary/required Railo elements to add to Tomcat's web.xml
<!-- BEGIN: RAILO SERVLET SHTUFF -->
<servlet>
<servlet-name>GlobalCFMLServlet</servlet-name>
<description>CFML runtime Engine</description>
<servlet-class>railo.loader.servlet.CFMLServlet</servlet-class>
<init-param>
<param-name>configuration</param-name>
<param-value>{web-root-directory}/WEB-INF/railo/</param-value>
<description>Configuraton directory</description>
</init-param>
@imageaid
imageaid / Railo-Tomcat-HTTPD Virtual Host
Created December 4, 2010 16:32
A virtual host declaration for Railo running on Tomcat and Apache HTTPD
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@mydomain.com
DocumentRoot "C:/dev/Clients/mydomain.com/"
ServerName mydomain.com
ErrorLog "logs/app.local-error.log"
CustomLog "logs/app.local-access.log" common
DirectoryIndex index.html, index.cfm
<Proxy *>
Order deny,allow
@imageaid
imageaid / Tomcat Host Declaration
Created December 4, 2010 16:33
A basic Tomcat host declaration in server.xml
<Host name="mydomain.com" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Alias>www.domain.com</Alias>
<Context path="" docBase="C:/dev/Clients/mydomain.com" />
</Host>
@imageaid
imageaid / ActiveMQ Resources for Tomcat
Created December 4, 2010 23:26
The context.xml file in Tomcat/conf that sets up the resources for ActiveMQ
<Context privileged="true" antiResourceLocking="false" antiJARLocking="false" reloadable="true">
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource name="jms/flex/TopicConnectionFactory" type="org.apache.activemq.ActiveMQConnectionFactory" description="JMS Connection Factory" factory="org.apache.activemq.jndi.JNDIReferenceFactory" brokerURL="tcp://localhost:61616" brokerName="myBroker"/>
<Resource name="jms/announcements" type="org.apache.activemq.command.ActiveMQTopic" description="Announcements" factory="org.apache.activemq.jndi.JNDIReferenceFactory" physicalName="amq-client-announcements"/>
<Resource name="jms/messages" type="org.apache.activemq.command.ActiveMQTopic" description="Messages" factory="org.apache.activemq.jndi.JNDIReferenceFactory" physicalName="amq-client-messages"/>
<Resource name="jms/simplequeue" type="org.apache.activemq.command.ActiveMQQueue" description="my Queue" factory="org.apache.activemq.jndi.JNDIRe
@imageaid
imageaid / Railo-BlazeDS-ActiveMQ Messaging Config
Created December 4, 2010 23:39
Messaging configuration file for communicating from Railo, via BlazeDS to ActiveMQ
<?xml version="1.0" encoding="UTF-8"?>
<service id="message-service" class="flex.messaging.services.MessageService" messageTypes="flex.messaging.messages.AsyncMessage">
<adapters>
<adapter-definition id="actionscript" class="flex.messaging.services.messaging.adapters.ActionScriptAdapter"/>
<adapter-definition id="jms" class="flex.messaging.services.messaging.adapters.JMSAdapter"/>
</adapters>
<default-channels>
<channel ref="my-amf"/>
@imageaid
imageaid / MXML for Messaging
Created December 13, 2010 20:19
A very simple MXML Application component to handle server-side messaging
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="initSubscribers()"
layout="absolute"
minWidth="640"
minHeight="480">
<!-- The two consumer tags setup the connection to our ActiveMQ topics -->
<!-- Note how the value of the destination attribute matches our messaging-config.xml destinations -->
<!-- The selector attribute is used to filter messages in a topic for a specific client. For the purpose of this example, I've hard-coded the value whereas in a real application, we set the .NUMBER dynamically -->
<!-- The last important attribute are your handlers, of course. Don't forget those :) -->
@imageaid
imageaid / Java Message Object
Created December 13, 2010 20:45
A POJO that we send from the server to a Flex (or other front-end) client
package com.pojo.messages;
import java.io.Serializable;
public class MessageBody implements Serializable {
/*
* Nothing much to this POJO ... just a few properties with getters and setters
* In my real-world application, these properties are used in the Flash client
*/
private static final long serialVersionUID = 1L;
@imageaid
imageaid / JMS Publisher Object
Created December 13, 2010 20:46
A Java object that handles sending/publishing a message from the server to ActiveMQ
package com.gateways.adapters;
import java.util.*;
import javax.jms.*;
import javax.naming.*;
import com.pojo.messages.MessageBody;
public class JMSPublisher {
// we start by setting up our properties for the object, including the basic connection values for
// the messaging service -- you'll note that the _providerURL and _contextFactory properties match the
@imageaid
imageaid / JMS Example Application.cfc
Created December 14, 2010 15:55
The CFML Application.cfc file ... basic!
<cfcomponent output="false">
<cfset this.name = "JMSTest">
<cfset this.applicationTimeout = createTimeSpan(0,2,0,0)>
<cfset this.clientManagement = false>
<cfset this.sessionManagement = false>
<cfset this.setClientCookies = true>
<cfset this.setDomainCookies = false>
<!--- Run when application starts up --->
@imageaid
imageaid / JMS: test_announcements.cfm
Created December 14, 2010 15:58
A CFML script that, when the form is submitted, calls the Java objects to send a message
<cfscript>
if(lcase(trim(cgi.request_method)) == 'post'){
broadcastAnnouncement();
}
</cfscript>
<cfoutput>
<html>
<head>
<title>General Announcements</title>
</head>