sk.baka.tools.javaee
Enum JeeServer

java.lang.Object
  extended by java.lang.Enum<JeeServer>
      extended by sk.baka.tools.javaee.JeeServer
All Implemented Interfaces:
Serializable, Comparable<JeeServer>

public enum JeeServer
extends Enum<JeeServer>

Enumerates JavaEE servers and provides several information such as remote EJB endpoint name, transaction manager location etc. Provides running JavaEE application server auto-detection mechanism.

Author:
Martin Vysny

Enum Constant Summary
Glassfish
          The Glassfish application server.
JBoss
          The JBoss server.
Oc4j
          The OC4J application server.
OpenEJB
          OpenEJB.
WebLogic
          WebLogic.
WebSphere
          WebSphere.
 
Method Summary
protected static boolean existsClass(String className)
           
abstract  String getHibernateTransactionManagerFactory()
          Returns a correct Hibernate org.hibernate.transaction.TransactionManagerLookup instance class name.
abstract  Properties getJNDIProperties(boolean local)
          Returns JNDI properties for instantiating correct instance of InitialContext.
 String getLocalhostRemoteURL()
          A localhost sample of how the connection URL should look like when connecting to remote EJBs.
abstract  String getRemoteURL(String host, Integer port)
          Returns the connection URL for connecting to remote EJBs.
static JeeServer getRuntime()
          Returns the server we are running on.
static JeeServer getRuntimeNull()
          Returns the server we are running on.
abstract  String getServerName()
          Returns the displayable name of the application server.
abstract  String getTransactionManagerJndi()
          Returns a JNDI name of the TransactionManager implementation.
abstract  String getUserTransactionJndi()
          Returns a JNDI name of the UserTransaction implementation.
protected abstract  boolean isRunningOn()
          Checks if we are running on a particular kind of a server.
static JeeServer valueOf(String name)
          Returns the enum constant of this type with the specified name.
static JeeServer[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

JBoss

public static final JeeServer JBoss
The JBoss server.


WebSphere

public static final JeeServer WebSphere
WebSphere.


WebLogic

public static final JeeServer WebLogic
WebLogic.


OpenEJB

public static final JeeServer OpenEJB
OpenEJB.


Glassfish

public static final JeeServer Glassfish
The Glassfish application server.


Oc4j

public static final JeeServer Oc4j
The OC4J application server.

Method Detail

values

public static JeeServer[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (JeeServer c : JeeServer.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static JeeServer valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

isRunningOn

protected abstract boolean isRunningOn()
Checks if we are running on a particular kind of a server.

Returns:
true if we are running on this server, false otherwise.

getRuntimeNull

public static JeeServer getRuntimeNull()
Returns the server we are running on.

Returns:
the server environment. If null then no known server is running in this VM.

existsClass

protected static boolean existsClass(String className)

getRuntime

public static JeeServer getRuntime()
Returns the server we are running on.

Returns:
the server environment.

getHibernateTransactionManagerFactory

public abstract String getHibernateTransactionManagerFactory()
Returns a correct Hibernate org.hibernate.transaction.TransactionManagerLookup instance class name.

Returns:
the classname.

getTransactionManagerJndi

public abstract String getTransactionManagerJndi()
Returns a JNDI name of the TransactionManager implementation.

Returns:
non-null TransactionManager JNDI name.
Throws:
UnsupportedOperationException - if the TransactionManager cannot be simply looked up in JNDI.

getUserTransactionJndi

public abstract String getUserTransactionJndi()
Returns a JNDI name of the UserTransaction implementation.

Returns:
non-null UserTransaction JNDI name.

getServerName

public abstract String getServerName()
Returns the displayable name of the application server.

Returns:
the name.

getLocalhostRemoteURL

public final String getLocalhostRemoteURL()
A localhost sample of how the connection URL should look like when connecting to remote EJBs.

Returns:
non-null sample URL.

getRemoteURL

public abstract String getRemoteURL(String host,
                                    Integer port)
Returns the connection URL for connecting to remote EJBs. Use the returned value as a value for Context.PROVIDER_URL.

Parameters:
host - the host name, must not be null.
port - optional port. If null then use the default port.
Returns:
the URL to connect to, never null.

getJNDIProperties

public abstract Properties getJNDIProperties(boolean local)
Returns JNDI properties for instantiating correct instance of InitialContext. Note that in properly configured JavaEE environment there should be no need to set JNDI parameters to InitialContext, therefore this method should be used in special environments only:

Parameters:
local - if true then JNDI is configured to invoke local beans; if false then remote beans are invoked.
Returns:
properties. May be null if the server requires a JavaEE environment and thus a correct Context instance can be obtained simply by invoking new InitialContext().
Throws:
UnsupportedOperationException - if this type of connectivity is not supported.


Copyright © 2009-2010. All Rights Reserved.