Permalink
Browse files

Event based structure introduced. Much cleaner.

i really need to start thinking in terms of tasks here :D
  • Loading branch information...
1 parent 126fc0c commit 4d8fb78f474e51fd73b5477becdac6d013202be2 @heinousjay committed Jun 28, 2012
Showing with 1,285 additions and 729 deletions.
  1. +0 −3 .gitmodules
  2. +1 −1 ...r-server/{JibbrJabbr-kernel/src/main/java/jj → JibbrJabbr-api/src/main/java/jj/api}/Blocking.java
  3. +47 −0 JibbrJabbr-server/JibbrJabbr-api/src/main/java/jj/api/Event.java
  4. +5 −2 ...erver/{JibbrJabbr-kernel/src/main/java/jj → JibbrJabbr-api/src/main/java/jj/api}/NonBlocking.java
  5. +16 −4 JibbrJabbr-server/JibbrJabbr-bootstrapper/src/main/java/jj/BootstrapClassLoader.java
  6. +8 −0 JibbrJabbr-server/JibbrJabbr-kernel/pom.xml
  7. +46 −1 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/Application.java
  8. +0 −60 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/DaemonKernelController.java
  9. +224 −0 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/EventMediationService.java
  10. +28 −0 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/EventPublisher.java
  11. +202 −0 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/HttpRequestHandler.java
  12. +60 −35 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/HttpServer.java
  13. +48 −0 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/JJComponentMonitor.java
  14. +15 −28 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/JJLifecycleStrategy.java
  15. +2 −42 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/JJThreadPoolExecutor.java
  16. +74 −205 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/Kernel.java
  17. +24 −0 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/KernelControl.java
  18. +6 −20 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/{KernelController.java → KernelException.java}
  19. +4 −1 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/KernelMessages.java
  20. +1 −1 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/LocLoggerProvidingAdapter.java
  21. +11 −165 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/NettyRequestBridge.java
  22. +155 −0 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/generation/EventMediationTransformer.java
  23. +1 −1 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/html/HTMLFragment.java
  24. +0 −53 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/html/HTMLFragmentCache.java
  25. +2 −2 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/html/HTMLFragmentFinder.java
  26. +2 −2 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/resource/MessageBundle.java
  27. +1 −1 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/resource/MessageConveyor.java
  28. +2 −2 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/resource/MessageConveyorCache.java
  29. +2 −2 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/jj/resource/PreloadingMessageConveyor.java
  30. +1 −1 JibbrJabbr-server/JibbrJabbr-kernel/src/main/java/logging/LoggingQueue.java
  31. BIN JibbrJabbr-server/JibbrJabbr-kernel/src/main/resources/jj/{ → builtin}/assets/favicon.ico
  32. 0 JibbrJabbr-server/JibbrJabbr-kernel/src/main/resources/jj/{ → builtin}/assets/index.html
  33. 0 JibbrJabbr-server/JibbrJabbr-kernel/src/main/resources/jj/{ → builtin}/errors/404.html
  34. 0 JibbrJabbr-server/JibbrJabbr-kernel/src/main/resources/jj/{ → builtin}/errors/405.html
  35. +1 −0 JibbrJabbr-server/JibbrJabbr-kernel/src/main/resources/jj/kernel-messages_en.properties
  36. +4 −3 JibbrJabbr-server/JibbrJabbr-kernel/src/test/java/fun/ExampleAdapter.java
  37. +60 −0 JibbrJabbr-server/JibbrJabbr-kernel/src/test/java/jj/ApplicationTest.java
  38. +226 −0 JibbrJabbr-server/JibbrJabbr-kernel/src/test/java/jj/EventMediationServiceTest.java
  39. +0 −85 JibbrJabbr-server/JibbrJabbr-kernel/src/test/java/jj/html/HTMLFragmentCacheTest.java
  40. +0 −5 JibbrJabbr-server/JibbrJabbr-kernel/src/test/java/jj/html/HTMLFragmentFinderTest.java
  41. +6 −3 JibbrJabbr-server/pom.xml
  42. +0 −1 jsoup
View
@@ -1,3 +0,0 @@
-[submodule "jsoup"]
- path = jsoup
- url = git://github.com/jhy/jsoup.git
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package jj;
+package jj.api;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2012 Jason Miller
+ *
+ * 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.
+ */
+package jj.api;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Marks a type as being an event. Instances of that type can automatically participate in
+ * event mediation. Any component with a public void method of any name that takes a single
+ * parameter of an event type will be registered as a listener, and whenever an event is published,
+ * that method will be invoked.
+ *
+ * use the {@link Blocking}/{@link NonBlocking} annotations to indicate if the event listener method might block. if
+ * no annotation is supplied, it will be assumed that blocking is possible. at this point it is not
+ * clear what impacts this will have but it is likely that nonblocking methods will execute more quickly
+ *
+ * static methods will be ignored.
+ *
+ * event objects should almost certainly be immutable. this may be enforced
+ *
+ * @author jason
+ *
+ */
+@Retention(RUNTIME)
+@Target(TYPE)
+@Documented
+@Inherited
+public @interface Event {}
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package jj;
+package jj.api;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
@@ -22,11 +22,14 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+
/**
* <p>
* Documents that a method will never block, and so is suitable for use in
* the asynchronous executor. Methods decorated with this annotation must never
- * call methods decorated with {@link Blocking}.
+ * call methods decorated with {@link Blocking}. Note that all logging is currently
+ * potentially blocking, so there can be no logging from a method decorated
+ * with this annotation.
* </p>
*
* <p>
@@ -19,9 +19,14 @@
* @author jason
*
*/
-final class BootstrapClassLoader
+public final class BootstrapClassLoader
extends ClassLoader{
+ public interface ClassEmitter {
+ public String name();
+ public byte[] emit();
+ }
+
private static final String JAR_GLOB = "*.jar";
private static final String CLASS_FILE_FORMAT = "/%s.class";
private static final String RESOURCE_FORMAT = "/%s";
@@ -32,6 +37,10 @@
private final Path libPath;
+ private DirectoryStream<Path> libJarsStream() throws IOException {
+ return Files.newDirectoryStream(libPath, JAR_GLOB);
+ }
+
BootstrapClassLoader(Path libPath) {
// whatever loaded this class is the root of all classloaders in the system
super(BootstrapClassLoader.class.getClassLoader());
@@ -40,9 +49,12 @@
// and we want them enabled
setDefaultAssertionStatus(true);
}
-
- private DirectoryStream<Path> libJarsStream() throws IOException {
- return Files.newDirectoryStream(libPath, JAR_GLOB);
+
+ public Class<?> loadClass(ClassEmitter emitter) {
+ byte[] bytes = emitter.emit();
+ Class<?> result = defineClass(emitter.name(), bytes, 0, bytes.length);
+ resolveClass(result);
+ return result;
}
@Override
@@ -40,6 +40,14 @@
<groupId>net.jcip</groupId>
<artifactId>jcip-annotations</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm-util</artifactId>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
@@ -15,7 +15,17 @@
*/
package jj;
+import java.io.Closeable;
+import java.net.URL;
+
+import jj.api.Blocking;
+import jj.api.NonBlocking;
+
+import net.jcip.annotations.ThreadSafe;
+
/**
+ * Should this be immutable, with new instances created when things change?
+ *
* Represents some level of Application containment,
* coordinating the set of resources that make it up
* - picocontainer
@@ -37,6 +47,41 @@
* @author Jason Miller
*
*/
-public class Application {
+@ThreadSafe
+public class Application implements Closeable {
+
+ protected final URL baseURL;
+ private volatile boolean closed = false;
+ private volatile boolean loaded = false;
+
+ public Application(URL baseURL) throws Exception {
+ assert (baseURL != null) : "baseURL is required";
+
+ this.baseURL = baseURL;
+ load();
+ }
+
+ protected void load() throws Exception {
+ ;
+ }
+
+ @NonBlocking
+ public boolean loaded() {
+ return loaded;
+ }
+
+ @Blocking
+ public boolean respond(String path) {
+ return true;
+ }
+ @Override
+ public void close() {
+ this.closed = true;
+ }
+
+ public boolean closed() {
+ return closed;
+ }
+
}
@@ -1,60 +0,0 @@
-/*
- * Copyright 2012 Jason Miller
- *
- * 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.
- */
-package jj;
-
-/**
- * @author jason
- *
- */
-public class DaemonKernelController implements KernelController {
-
- /* (non-Javadoc)
- * @see jj.KernelController#awaitPrivilegedOperationsComplete()
- */
- @Override
- public void awaitPrivilegedOperationsComplete() {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see jj.KernelController#notifyPrivilegedOperationsComplete()
- */
- @Override
- public void notifyPrivilegedOperationsComplete() {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see jj.KernelController#awaitHttpServerStart()
- */
- @Override
- public void awaitHttpServerStart() {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see jj.KernelController#notifyHttpServerStarted()
- */
- @Override
- public void notifyHttpServerStarted() {
- // TODO Auto-generated method stub
-
- }
-
-}
Oops, something went wrong.

0 comments on commit 4d8fb78

Please sign in to comment.