1 / 21

JavaONE 2007

JavaONE 2007. Agenda. Reverse Ajax - DWR GlassFish V3 Effective Java Reloaded: This Time it's NOT for Real. Reverse Ajax - DWR. Joe Walker/Geert Bevin (TS-6410) New feature in DWR 2.0 CommunityOne: ICEfaces and Ajax Push. Reversed Ajax – DWR: Overview.

verda
Download Presentation

JavaONE 2007

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JavaONE 2007 javaONE 2007 - Kjartan Aanestad (Objectware)

  2. Agenda • Reverse Ajax - DWR • GlassFish V3 • Effective Java Reloaded: This Time it's NOT for Real javaONE 2007 - Kjartan Aanestad (Objectware)

  3. Reverse Ajax - DWR • Joe Walker/Geert Bevin (TS-6410) • New feature in DWR 2.0 • CommunityOne: ICEfaces and Ajax Push javaONE 2007 - Kjartan Aanestad (Objectware)

  4. Reversed Ajax – DWR:Overview • The ability to asynchronously send data from a web-server to a browser javaONE 2007 - Kjartan Aanestad (Objectware)

  5. 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. javaONE 2007 - Kjartan Aanestad (Objectware)

  6. Reversed Ajax – DWR:”live” coding demo javaONE 2007 - Kjartan Aanestad (Objectware)

  7. 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 javaONE 2007 - Kjartan Aanestad (Objectware)

  8. 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) javaONE 2007 - Kjartan Aanestad (Objectware)

  9. GlassFish V3:Module instances • Modules identified by module instances at runtime • 2 classloaders (public/private) • Runtime network of class loaders javaONE 2007 - Kjartan Aanestad (Objectware)

  10. 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 javaONE 2007 - Kjartan Aanestad (Objectware)

  11. 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 javaONE 2007 - Kjartan Aanestad (Objectware)

  12. GlassFish V3:Build System: Maven • Each module is build from a maven project (pom.xml)<groupId>com.sun.enterprise.glassfish</groupId><artifactId>gf-web-connector</artifactId><version>1.2.1</version><packaging>hk2-jar</packaging> • Running GlassFish retrieves the modules from the maven repository$ mvn gf:run javaONE 2007 - Kjartan Aanestad (Objectware)

  13. 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 {...} javaONE 2007 - Kjartan Aanestad (Objectware)

  14. 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 javaONE 2007 - Kjartan Aanestad (Objectware)

  15. Effective Java Reloaded:Object creation • Static factories Map<String, List<String>> m = new HashMap<String, List<String>>(); Map<String, List<String>> m = HashMap.newInstance(); • Regrettably HashMaphas no such method (yet) • write your own, your generic classes can and should: public static <K, V> HashMap<K, V> newInstance() { return new HashMap<K, V>(); } javaONE 2007 - Kjartan Aanestad (Objectware)

  16. Effective Java Reloaded:Object creation • Builder pattern • Ugly when constructors have many optional parametersnew 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(); javaONE 2007 - Kjartan Aanestad (Objectware)

  17. 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) { .. } } javaONE 2007 - Kjartan Aanestad (Objectware)

  18. Effective Java Reloaded:Generics – bounded wildcards • Use bounded wildcards to increase applicability of APIs public interface Shop<T> { void buy(int numToBuy, Collection<T> myColl); void sell(Collection<T> myLot); } • Collection subtyping doesn’t work! public interface Shop<T> { void buy(int numToBuy, Collection<? super T> myColl); void sell(Collection<? extends T> myLot); } • Use <? extends T> when parameterized instance is a T producer (“for read/input”) • Use <? super T> when parameterized instance is a T consumer (“for write/output”) javaONE 2007 - Kjartan Aanestad (Objectware)

  19. 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 <E> void rotateHelper(List<E> list) { if (list.size() == 0) return; list.add(list.remove(0)); } javaONE 2007 - Kjartan Aanestad (Objectware)

  20. 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 javaONE 2007 - Kjartan Aanestad (Objectware)

  21. JavaONE 2007 Kjartan Aanestad - Objectware javaONE 2007 - Kjartan Aanestad (Objectware)

More Related