Skip to content
Browse files

initial commit of jun 2011 presentation

  • Loading branch information...
1 parent b9bfec2 commit da0f86903128ff3e1b25e46810d287c94154f4e4 @ckirkendall committed Jun 25, 2011
View
7 .gitignore
@@ -0,0 +1,7 @@
+pom.xml
+*jar
+lib/
+classes/
+bin/
+.settings/
+.lein-deps-sum
View
BIN jun-2011/clojure-in-action-cincyfp.odp
Binary file not shown.
View
22 jun-2011/source/aleph-server/.classpath
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="test"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
+ <classpathentry kind="lib" path="lib/commons-codec-1.4.jar"/>
+ <classpathentry kind="lib" path="lib/clojure-1.2.1.jar"/>
+ <classpathentry kind="lib" path="lib/dev"/>
+ <classpathentry kind="lib" path="lib/httpcore-4.0.1.jar"/>
+ <classpathentry kind="lib" path="lib/httpclient-4.0.3.jar"/>
+ <classpathentry kind="lib" path="lib/clojure-contrib-1.2.0.jar"/>
+ <classpathentry kind="lib" path="lib/clj-http-0.1.3.jar"/>
+ <classpathentry kind="lib" path="lib/netty-3.2.4.Final.jar"/>
+ <classpathentry kind="lib" path="lib/user-agent-utils-1.2.3.jar"/>
+ <classpathentry kind="lib" path="lib/lamina-0.4.0-alpha1.jar"/>
+ <classpathentry kind="lib" path="lib/aleph-0.2.0-alpha1.jar"/>
+ <classpathentry kind="lib" path="lib/potemkin-0.1.0.jar"/>
+ <classpathentry kind="lib" path="lib/gloss-0.2.0-alpha1.jar"/>
+ <classpathentry kind="lib" path="lib/commons-io-1.4.jar"/>
+ <classpathentry kind="output" path="classes"/>
+</classpath>
View
20 jun-2011/source/aleph-server/.project
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>aleph-server</name>
+ <comment>FIXME: write description</comment>
+ <projects/>
+ <buildSpec>
+ <buildCommand>
+ <name>ccw.builder</name>
+ <arguments/>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments/>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>ccw.nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
View
13 jun-2011/source/aleph-server/README
@@ -0,0 +1,13 @@
+# org.cincyfp.log.server
+
+FIXME: write description
+
+## Usage
+
+FIXME: write
+
+## License
+
+Copyright (C) 2011 FIXME
+
+Distributed under the Eclipse Public License, the same as Clojure.
View
6 jun-2011/source/aleph-server/project.clj
@@ -0,0 +1,6 @@
+(defproject aleph-server "1.0.0-SNAPSHOT"
+ :description "FIXME: write description"
+ :dependencies [[org.clojure/clojure "1.2.1"]
+ [aleph "0.2.0-alpha1"]]
+ :dev-dependencies[[lein-eclipse "1.0.0"]]
+)
View
22 jun-2011/source/aleph-server/src/org/cincyfp/log/server/core.clj
@@ -0,0 +1,22 @@
+(ns org.cincyfp.log.server.core
+ (:import (java.io.File)))
+
+(use 'lamina.core 'aleph.tcp 'gloss.core 'gloss.io 'clojure.java.io)
+
+(def log-writer (writer "/home/creighton/cool.log" :append true))
+
+(def log-channel (channel))
+
+(defn log-handler [channel client-info]
+ (enqueue channel "ok")
+ (receive-all channel (fn [msg] (enqueue channel "ok")
+ (enqueue log-channel msg))))
+
+(def f (future
+ (doseq [msg (lazy-channel-seq log-channel)]
+ (.write log-writer (str msg))
+ (.flush log-writer))))
+
+(def msg-frame (string :utf-8 :delimiters ["_EM_"]))
+
+(start-tcp-server log-handler {:port 10000, :frame msg-frame})
View
6 jun-2011/source/aleph-server/test/org/cincyfp/log/server/test/core.clj
@@ -0,0 +1,6 @@
+(ns org.cincyfp.log.server.test.core
+ (:use [org.cincyfp.log.server.core])
+ (:use [clojure.test]))
+
+(deftest replace-me ;; FIXME: write
+ (is false "No tests have been written."))
View
7 jun-2011/source/java-test-client/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="lib" path="/log4j-appender/log4j-appender-1.0.0-SNAPSHOT-standalone.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
View
17 jun-2011/source/java-test-client/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>java-test-client</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
View
13 jun-2011/source/java-test-client/src/log4j.properties
@@ -0,0 +1,13 @@
+# Set root logger level to DEBUG and its only appender to A1.
+log4j.rootLogger=DEBUG,clj
+
+# A1 is set to be a ConsoleAppender.
+log4j.appender.clj=org.cincyfp.log4j.appender.CljAppender
+
+# A1 uses PatternLayout.
+log4j.appender.clj.layout=org.apache.log4j.PatternLayout
+log4j.appender.clj.layout.ConversionPattern=[%t] %-5p %c %x - %m%n
+
+#aleph connection
+log4j.appender.clj.host=localhost
+log4j.appender.clj.port=10000
View
25 jun-2011/source/java-test-client/src/org/cincyfp/log/TestClient.java
@@ -0,0 +1,25 @@
+package org.cincyfp.log;
+
+import org.apache.log4j.Logger;
+
+public class TestClient {
+ static Logger logger = Logger.getLogger(TestClient.class);
+
+ public static void main(String[] args) {
+
+ try {
+ logger.info("Entering application.");
+ logger.trace("testing trace");
+ logger.debug("testing debug");
+ logger.error("testing error");
+ for (int i = 0; i < 10000; i++) {
+ Thread.sleep(2000);
+ logger.info("message" + i);
+ }
+ } catch (InterruptedException e) {
+ logger.error(e.getMessage(), e);
+ e.printStackTrace();
+ }
+
+ }
+}
View
23 jun-2011/source/log4j-appender/.classpath
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="test"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
+ <classpathentry kind="lib" path="lib/commons-codec-1.4.jar"/>
+ <classpathentry kind="lib" path="lib/clojure-1.2.1.jar"/>
+ <classpathentry kind="lib" path="lib/dev"/>
+ <classpathentry kind="lib" path="lib/httpcore-4.0.1.jar"/>
+ <classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
+ <classpathentry kind="lib" path="lib/httpclient-4.0.3.jar"/>
+ <classpathentry kind="lib" path="lib/clojure-contrib-1.2.0.jar"/>
+ <classpathentry kind="lib" path="lib/clj-http-0.1.3.jar"/>
+ <classpathentry kind="lib" path="lib/netty-3.2.4.Final.jar"/>
+ <classpathentry kind="lib" path="lib/user-agent-utils-1.2.3.jar"/>
+ <classpathentry kind="lib" path="lib/lamina-0.4.0-alpha1.jar"/>
+ <classpathentry kind="lib" path="lib/aleph-0.2.0-alpha1.jar"/>
+ <classpathentry kind="lib" path="lib/potemkin-0.1.0.jar"/>
+ <classpathentry kind="lib" path="lib/gloss-0.2.0-alpha1.jar"/>
+ <classpathentry kind="lib" path="lib/commons-io-1.4.jar"/>
+ <classpathentry kind="output" path="classes"/>
+</classpath>
View
20 jun-2011/source/log4j-appender/.project
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>log4j-appender</name>
+ <comment>FIXME: write description</comment>
+ <projects/>
+ <buildSpec>
+ <buildCommand>
+ <name>ccw.builder</name>
+ <arguments/>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments/>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>ccw.nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
View
13 jun-2011/source/log4j-appender/README
@@ -0,0 +1,13 @@
+# org.cincyfp.log4j.appender
+
+FIXME: write description
+
+## Usage
+
+FIXME: write
+
+## License
+
+Copyright (C) 2011 FIXME
+
+Distributed under the Eclipse Public License, the same as Clojure.
View
12 jun-2011/source/log4j-appender/project.clj
@@ -0,0 +1,12 @@
+(defproject log4j-appender "1.0.0-SNAPSHOT"
+ :description "FIXME: write description"
+ :dependencies [[org.clojure/clojure "1.2.1"]
+ [aleph "0.2.0-alpha1"]
+ [log4j "1.2.15" :exclusions [javax.mail/mail
+ javax.jms/jms
+ com.sun.jdmk/jmxtools
+ com.sun.jmx/jmxri]]]
+ :dev-dependencies[
+ [lein-eclipse "1.0.0"]
+ [swank-clojure "1.2.1"]]
+ :main org.cincyfp.log4j.appender.core)
View
82 jun-2011/source/log4j-appender/src/org/cincyfp/log4j/appender/core.clj
@@ -0,0 +1,82 @@
+(ns org.cincyfp.log4j.appender.core
+ (:import (org.apache.log4j.AppenderSkeleton)
+ (org.apache.log4j.spi.LoggingEvent)
+ (org.apache.log4j.spi.ErrorCode)
+ (org.apache.log4j.Layout)
+ (org.apache.log4j.helpers.LogLog))
+ (:gen-class
+ :name "org.cincyfp.log4j.appender.CljAppender"
+ :extends org.apache.log4j.AppenderSkeleton
+ :state state
+ :init myinit
+ :methods [[getHost [] String]
+ [setHost [String] void]
+ [getPort [] int]
+ [setPort [int] void]
+ [createAsyncHandler [] void]
+ [getHandlerFunc [] Runnable]]))
+
+(use 'lamina.core 'aleph.tcp 'gloss.core)
+
+
+(defn -myinit []
+ (let [ch (channel)]
+ [[] (ref {:name "clj-append" :channel ch})]))
+
+
+(defn -activateOptions [this]
+ (let [state (.state this)
+ host (.getHost this)
+ port (.getPort this)
+ frame (string :utf-8 :delimiters ["_EM_"])
+ tcp (tcp-client {:host host, :port port, :frame frame})]
+ (dosync (alter state assoc :tcp-client tcp))
+ (.createAsyncHandler this)))
+
+
+(defn -append [this #^LoggingEvent event]
+ (let [message (.format (.getLayout this) event)]
+ (enqueue (:channel @(.state this)) message)))
+
+
+(defn -requiresLayout [this] true)
+
+(defn -close [this] )
+
+
+(defn -getHost [this]
+ (:host @(.state this)))
+
+(defn -setHost [this nm]
+ (let [state (.state this)]
+ (dosync (alter state assoc :host nm)) nil))
+
+(defn -getPort [this]
+ (:port @(.state this)))
+
+(defn -setPort [this port]
+ (let [state (.state this)]
+ (dosync (alter state assoc :port port)) nil))
+
+
+(defn- -createAsyncHandler [this]
+ (doto
+ (Thread. (.getHandlerFunc this))
+ (.setDaemon true)
+ (.start)))
+
+
+(defn- -getHandlerFunc [this]
+ (let [ch (:channel @(.state this))
+ tcp (:tcp-client @(.state this))]
+ (fn [] (doseq [msg (lazy-channel-seq ch)]
+ (enqueue @tcp msg)))))
+
+
+(defn -main [& args]
+ (let [tmp (new org.cincyfp.log4j.appender.CljAppender)]
+ (println "Host1:" (.getHost tmp))
+ (.setHost tmp "localhost")
+ (println "Host2:" (.getHost tmp))
+ (.setPort tmp 20000)
+ (println "Port:" (.getPort tmp))))
View
6 jun-2011/source/log4j-appender/test/org/cincyfp/log4j/appender/test/core.clj
@@ -0,0 +1,6 @@
+(ns org.cincyfp.log4j.appender.test.core
+ (:use [org.cincyfp.log4j.appender.core])
+ (:use [clojure.test]))
+
+(deftest replace-me ;; FIXME: write
+ (is false "No tests have been written."))

0 comments on commit da0f869

Please sign in to comment.
Something went wrong with that request. Please try again.