Posts

Building a Stronger Team that YOU work in

Image
Anyone who has worked in a team knows that there is no simple answer for team success. Each employee/team-member offers a unique perspective and comes from a unique background (typically). This is even true in homogeneous teams, or centers of excellence. Building and sustaining team morale can be difficult especially in homogenous teams because direct comparisons can be drawn very quickly. I recently read a general article, http://www.inc.com/jeff-haden/the-5-qualities-of-remarkable-bosses.html , this outlines a list of things bosses should do to build and sustain remarkable teams. I could not find myself agreeing more.   Develop every employee. Deal with problems immediately. Rescue your worst employee . Serve others, not yourself. Always remember where you came from. The list above outlines how to be a good boss. However if you are team member these rules apply as well. In order to help continue to build a stronger team, there may be a few more that need t...

Rolling Back Transactions

While doing a spot check on code and configuration – I noticed that the developer wasn’t throwing a runtime exception nor was he setting rollbackOnly in a CMT EJB. I was told that any exception will rollback a transaction and it is not possible to setRollbackOnly, and there are only 4 types of transaction attributes on CMT. Wrong, wrong and wrong. 1. If your code throws an application exception – the container expects the bean to handle it. However, if your bean throws a runtime exception (or subclass), like javax.ejb.Exception – the container will rollback the transaction. 2. If you don’t want to throw RTEs all around your code – and/or you have massive catch all exception code blocks, you should context.setRollbackOnly – to rollback transactions. 3. There are various transaction attributes – 6 to be exact: Requires, Requires New, Supports, Not Supported, Never & Mandatory. Never and Mandatory are opposite to one another. Requires starts a transaction if not called with one, M...

Java EE 5–No Entity Beans!

I’ve always done ORM with HIbernate –and it helped a lot with cardinality (besides ORM general features). 1:1::Married Couple (there are cultural and religious exceptions) 1:n:: Order: Line Item n:1:: Line Item: Order n:n:: Course: Student Regardless of cardinality, entities should never be non-singular from a naming convention stand point. In Bidirectional relationships – the inverse side must refer to its owning side via the mappedBy element. In n:1, the many side always owns the relationship. In n:n – it doesn’t matter. All in all the beauty of Java Persistence API is that it has all the features that Hibernate had – and then makes things a lot simpler with Annotations. I never was a fan of annotations when they first surfaced, but I have slowly come to like it. I like the encapsulation it provides. You can mix non-entity super classes with entity super classes, use polymorphic associations, queries etc. It is surprisingly flexible. Three basic strategies remained consiste...

GoF: Polymorphism, Encapsulation, Inheritance and Delegation

Polymorphism is when your client has a reference to an interface, and it’s concreate class can be one of many implementations. A different different behavior or value in a subclass can be utilized without a switch or an if. Parent class class defaults can be inherited and overridden where necessary. A method can be declared in a parent class, but each subclass can have a specialized implementation/logic of that method e.g. calculateArea(); Encapsulation is a core principal, it refers to the bundling of data with the methods that operate on that data. Basically, logic and data go together. If you have a class, with properties and logic together – it is encapsulated. Helps separation of concerns and reduces surface areas – also supports immutability – since only the object can control the data.   Inheritance is the ability of objects in an Object-Oriented language to inherit properties and methods of other objects e.g. in Java, use extends or implements keywords. Delegation is whe...

Java SE Security APIs and Frameworks

Image
  Java SE has a deep foundation for security – there are a variety of APIs and frameworks that plug on top of various security impls. JAAS: Java Authentication and Authorization Services GSS: Generic Security Services. Think Tokens. JCE: Java Cryptography Extension. Keys and Ciphers. JSSE: Java Secure Sockets Extensions. SSL and TLS. SASL: Simple Authentication and Security Layer. Layer between Client and Server – describes the how. RFC 2222   TLS (SSL) is a point-to-point, transient only solution which provides no context, discrimination to content. Authentication, confidentiality and integrity is provided. MLS (Message Layer Security) is an end-to-end security because it stays encrypted at rest and in motion. It is encrypted by the sender and can only be decrypted by the intended recipient. It does not depend on the transport layer. Realm is the complete database of users and group, a user is an individual, a group is a collection of individuals, each group or ind...

Gang of Four Patterns for Java EE developers : Cheat Sheet

Here is the list of Gang of Four patterns related with an actual implementation in Java EE. Read on – it will make sense (hopefully). Strategy: EJB interface. Defines a family of algorithms, encapsulates each one and makes them interchangeable. Strategy lets the algorithm vary independently from clients who use it. Decorator: Dependency Injection. Attach additional responsibilities to an object dynamically. Provide a flexible alternative to sub-classing for extending functionality. Factory: EJBs . Define an interface for creating an object, but let the subclasses decide which class to instantiate. Chain: Filters. Decoupled requester and handler. Chain the handlers, one of them must handle it. Singleton: JNDI Ensure a class only has one instance, and provide a global point of access Flyweight: JDBC Connection Pooling. JDN Adapter : Use the same interface, but adapt to other classes. Façade: Single point of entry for a sub-system. Template: Defer implementation to su...

Java EE 5 idiosyncrasies

In the Java Persistence API, you don’t need to provide an XML descriptor to specify the primary key, while you do need to provide a back pointer reference in a bidirectional relationship, unlike the Entity Bean specification version 2.1. Java Server Faces can act as a front controller (i.e. no GUI) and unlike Custom Tag Libraries and much like a Servlet. JSF does save view state, but cannot be previewed outside the container. JCA = Java Cryptography Architecture as well as Java Connector Architecture. Having overloaded acronyms in the same domain is confusing. Java Cryptography Extension is packaged with JCA – guess which JCA? JAAS is the Java Authentication and Authorization Service. While the former supports RSA, DSA, AES etc, the latter abstracts authentication APIs as well as permissions API. JSSE is Java Secure Socket Extension – it is primarily used for TLS, SSL, Kerberos, SASL. Weirdly enough JNLP applications that are running without their jars signed can interact with Syste...