Skip to main content

Home/ SoftwareEngineering/ Group items tagged dependencies

Rss Feed Group items tagged

kuni katsuya

3 ways to serialize Java Enums | Vineet Manohar's blog - 0 views

  • Mapping enum to database column using JPA/Hibernate You can use any of the 3 approaches discussed above. Map the enum to an integer column. The persistence implementation should automatically convert enum to ordinal() and back for you. Map the enum to a String column. The persistence implementation should automatically convert the enum value to String value via the name() function. Map the enum using a business value. You should mark the enum field as @Transient, and create another String field which you can map to a String column in your database table. Here’s an example code snippet. view plaincopy to clipboardprint?@Entity  public class Product {   @Column   private String colorValue;     @Transient   public Color getColor() {    return Color.fromValue(colorValue);   }     public void setColor(Color color) {    this.colorValue = color.toValue();   }  }  
  • Approach 3: Using a user defined business value – Recommended approach! This approach involves assigning a an explicit user defined value to each enum constant and defining a toValue() and fromValue() methods on the enum to do the serialization and deserialization.
  • public enum Color {   RED("RED"), GREEN("GREEN"), BLUE("BLUE"), UNKNOWN("UNKNOWN");     private final String value;     Color(String value) {     this.value = value;   }     public static Color fromValue(String value) {     if (value != null) {       for (Color color : values()) {         if (color.value.equals(value)) {           return color;         }       }     }       // you may return a default value     return getDefault();     // or throw an exception     // throw new IllegalArgumentException("Invalid color: " + value);   }     public String toValue() {     return value;   }     public static Color getDefault() {     return UNKNOWN;   }  }  public enum Color { RED("RED"), GREEN("GREEN"), BLUE("BLUE"), UNKNOWN("UNKNOWN"); private final String value; Color(String value) { this.value = value; } public static Color fromValue(String value) { if (value != null) { for (Color color : values()) { if (color.value.equals(value)) { return color; } } } // you may return a default value return getDefault(); // or throw an exception // throw new IllegalArgumentException("Invalid color: " + value); } public String toValue() { return value; } public static Color getDefault() { return UNKNOWN; } } This approach is better than approach 1 and approach 2 above. It neither depends on the order in which the enum constants are declared nor on the constant names.
kuni katsuya

Chapter 5. AS3 Code Generator - 0 views

  • 5.2. Generated ActionScript 3 Classes
  • Gas3 uses the principle of "Base" and customizable inherited classes that let you add methods to generated classes without facing the risk of losing them when a new generation process is executed
  • 5.3. Java Classes and Corresponding Templates
  • ...13 more annotations...
  • summary of templates used by the generator depending on the kind of Java class it encounters:
  • these templates are bundled in the granite-generator.jar archive, in the org.granite.generator.template package and accessible as resources via the class loader
  • class: protocol is used because all standard templates are available in the classpath
  • Alternatively, you may use the file: protocol to load your template from the filesystem. These templates can be specified either by using absolute paths (eg. file:/absolute/path/to/mytemplate.gsp) or paths relative to your current Eclipse project root directory (eg. path/to/mytemplate.gsp).
  • ActionScript 3 generator is able to write AS3 typed client proxies for exposed remote services
  • Compared to the usual Flex RemoteObject, this can greatly help development by bringing
  • auto-completion
  • improved type-safety
  • in Flex when using remote services.
  • replicate validation annotations in order to use the Flex side validation framework
  •  Known Limitations
  • Gas3 does not support inner classes
  • must declare your classes in separated source files if you want them to be correctly handled by the generator
kuni katsuya

Frequently Answered Questions (FAQ) - 0 views

  • 1.3.What Java and Spring Framework versions are required?
  • Spring Security 3.0 and 3.1 require at least JDK 1.5
  • and also require Spring 3.0.3 as a minimum
kuni katsuya

Enterprise JavaBeans 3.1 with Contexts and Dependency Injection: The Perfect Synergy - 0 views

  • EJB beans cannot be directly exposed to JSF or JSP without a little help from CDI
  • CDI doesn't provide any transactional, monitoring, or concurrency aspect out of the box
  • stateless EJB 3.1 bean as boundary (Facade)
  • ...1 more annotation...
  • injected managed beans (controls) results in the simplest possible architecture
kuni katsuya

Chapter 10. Integration with CDI - 0 views

  • 10.3.5. Security GraniteDS provides a client-side component named identity that ensures the integration between the client RemoteObject credentials and the server-side container security. It additionally includes an easy-to-use API to define runtime authorization checks on the Flex UI.
  • CDI identity component (of class org.granite.tide.cdi.Identity) predictably provides two methods login() and logout()
  • identity component is integrated with server-side role-based security and can be used to get information or show/hide UI depending on the user access rights:
  • ...2 more annotations...
  •  enabled="{identity.hasRole('admin')}"
  • button labeled Delete will be enabled only if the user has the role admin
kuni katsuya

HTTP Authentication and Security with Apache Shiro | Xebia Blog - 0 views

  • Spring Security
  • However, it is tied to the Spring technology and the size of the library — more than 10 JAR of dependencies
  •  
    "its "
kuni katsuya

Comparison - 0 views

  • TomEE is a superset of OpenEJB
  • Tomcat
  • TomEE
  • ...5 more annotations...
  • TomEE+
  • OpenEJB
  • Java API for XML Web Services (JAX-WS) Java API for RESTful Web Services (JAX-RS) Java EE Connector Architecture Java Messaging Service (JMS)
  • Java Servlets Java ServerPages (JSP) Java ServerFaces (JSF) Java Transaction API (JTA)
  • Java Persistence API (JPA) Java Contexts and Dependency Injection (CDI) Java Authentication and Authorization Service (JAAS) Java Authorization Contract for Containers (JACC) JavaMail API Bean Validation Enterprise JavaBeans
« First ‹ Previous 61 - 67 of 67
Showing 20 items per page