Download presentation
Presentation is loading. Please wait.
Published byAnnice Neal Modified over 9 years ago
1
javaONE 2007 - Kjartan Aanestad (Objectware)1 JavaONE 2007
2
2javaONE 2007 - Kjartan Aanestad (Objectware) Agenda Reverse Ajax - DWR GlassFish V3 Effective Java Reloaded: This Time it's NOT for Real
3
3javaONE 2007 - Kjartan Aanestad (Objectware) Reverse Ajax - DWR Joe Walker/Geert Bevin (TS-6410) New feature in DWR 2.0 CommunityOne: ICEfaces and Ajax Push
4
4javaONE 2007 - Kjartan Aanestad (Objectware) Reversed Ajax – DWR: Overview The ability to asynchronously send data from a web-server to a browser
5
5javaONE 2007 - Kjartan Aanestad (Objectware) Reversed Ajax – DWR: Overview Supports 3 methods of pushing the data to the browser: Polling – Browser makes regular request to the server Piggyback – Puts the response with the next request Comet (aka Long lived http) – Keeps the communication channel open to pass down information when time comes.
6
6javaONE 2007 - Kjartan Aanestad (Objectware) Reversed Ajax – DWR: ”live” coding demo
7
7javaONE 2007 - Kjartan Aanestad (Objectware) GlassFish V3 Jerome Dochez (TS-6503) Loosely based on the work for JSR 277 (Java Module System ) Due in Java SE 7 Architecture based on IoC, modules and maven 2
8
8javaONE 2007 - Kjartan Aanestad (Objectware) GlassFish V3: Module subsystem The module subsystem is called HK2 (Hundred Kb Kernel) Module system based on maven Identified by name and version One classloader per module of 1 to n jars Exports a subset of its content (Service Provider Interface) Imports other modules (listed in manifest file)
9
9javaONE 2007 - Kjartan Aanestad (Objectware) GlassFish V3: Module instances Modules identified by module instances at runtime 2 classloaders (public/private) Runtime network of class loaders
10
10javaONE 2007 - Kjartan Aanestad (Objectware) GlassFish V3: Repository Repositories hold modules Add and remove at runtime Different types supported Directory based Maven Modules can be added/removed/updated from repositories
11
11javaONE 2007 - Kjartan Aanestad (Objectware) GlassFish V3: Bootstrapping Module subsystems can bootstrap itself No need to define a classpath at invocation Packaged in a jar Implement the ApplicationStartup interface Declare dependencies in manifest
12
12javaONE 2007 - Kjartan Aanestad (Objectware) GlassFish V3: Build System: Maven Each module is build from a maven project (pom.xml) com.sun.enterprise.glassfish gf-web-connector 1.2.1 hk2-jar Running GlassFish retrieves the modules from the maven repository $ mvn gf:run
13
13javaONE 2007 - Kjartan Aanestad (Objectware) GlassFish V3: Services GlassFish V3 use extensively Services to identify extension points like Application containers like web-app, Jruby, Phobos..) Administrative commands Services in V3: Interfaces are declared with @Contract Implementations are declared with @Service @Contract public interface AdminCommand {...} @Service(name=”deploy”) public class DeployCommand implements AdminCommand {...}
14
14javaONE 2007 - Kjartan Aanestad (Objectware) Effective Java Reloaded: This Time it's NOT for Real Joshua Bloch (TS-2689) Effective Java still hasn’t been reloaded - It will be done later this year for sure.. Object creation Generics
15
15javaONE 2007 - Kjartan Aanestad (Objectware) Effective Java Reloaded: Object creation Static factories Map > m = new HashMap >(); Map > m = HashMap.newInstance(); Regrettably HashMap has no such method (yet) write your own, your generic classes can and should: public static HashMap newInstance() { return new HashMap (); }
16
16javaONE 2007 - Kjartan Aanestad (Objectware) Effective Java Reloaded: Object creation Builder pattern Ugly when constructors have many optional parameters new NutritionFacts(int servingSize, int servings, int calories, int fat, int sodium, int carbohydrate, 15 more optional params!); Builder constructor takes all required params One setter for each optional parameter Setter returns the builder to allow for chaining NutritionFacts locoCola = new NutritionFacts.Builder(240, 8).sodium(30).carbohydrate(28).build();
17
17javaONE 2007 - Kjartan Aanestad (Objectware) Effective Java Reloaded: Object creation public class NutritionFacts { public static class Builder { public Builder(int servingSize, int servings) { this.servingSize = servingSize; this.servings = servings; } public Builder calories(int val) { calories = val; return this; }... // 15 more setters public NutritionFacts build() { return new NutritionFacts(this); } private NutritionFacts(Builder builder) {.. } }
18
18javaONE 2007 - Kjartan Aanestad (Objectware) Effective Java Reloaded: Generics – bounded wildcards Use bounded wildcards to increase applicability of APIs public interface Shop { void buy(int numToBuy, Collection myColl); void sell(Collection myLot); } Collection subtyping doesn’t work! public interface Shop { void buy(int numToBuy, Collection myColl); void sell(Collection myLot); } Use when parameterized instance is a T producer (“for read/input”) Use when parameterized instance is a T consumer (“for write/output”)
19
19javaONE 2007 - Kjartan Aanestad (Objectware) Effective Java Reloaded: Generics – wildcard capture Control Wildcard-Capture Type system doesn’t know captured types are identical public static void rotate(List list) { if (list.size() == 0) return; list.add(list.remove(0)); } Solution: public static void rotate(List list) { rotateHelper(list); } // Generic helper method captures wildcard once private static void rotateHelper(List list) { if (list.size() == 0) return; list.add(list.remove(0)); }
20
20javaONE 2007 - Kjartan Aanestad (Objectware) Effective Java Reloaded: Generics – miscellania final is the new private Minimizes mutability Clearly thread-safe—one less thing to worry about Use the @Override annotation every time you want to override Avoid overriding my mistake
21
javaONE 2007 - Kjartan Aanestad (Objectware)21 JavaONE 2007 Kjartan Aanestad - Objectware
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.