org.ow2.jonas.versioning.contexts
Class VirtualJNDIBinding

java.lang.Object
  extended by org.ow2.jonas.versioning.contexts.VirtualJNDIBinding
All Implemented Interfaces:
VirtualJNDIBindingMBean, VirtualContextJMXInterface

public class VirtualJNDIBinding
extends Object
implements VirtualJNDIBindingMBean

Handles virtual JNDI binding management.

Author:
S. Ali Tokmen

Constructor Summary
protected VirtualJNDIBinding(String appName, String prefix)
          Creates and registers a virtual JNDI binding.
 
Method Summary
 void addContext(String prefix, String policy)
          Adds a JNDI prefix to this virtual JNDI naming manager using a policy.
 void checkJNDIBindings()
          Checks that the default JNDI binding is still present.
static void createJNDIBindingMBeans(String appName, String prefix)
          Creates or adds into an existing binding a prefix.
static void garbageCollectJNDIBindingMBeans()
          Removes JNDI binding management beans that are not in the JNDI directory anymore.
 Map<String,String> getContexts()
           
 String[] getejbs()
           
 Map<String,List<String>> getNames()
           
 URL geturl()
           
 boolean hasContext(String prefix)
          Checks whether a given prefix has been registered.
static void initialize(JmxService jmx, RegistryService registry, VersioningService versioning)
          Saves static server information.
 boolean rebindContext(String prefix, String policy)
          Rebinds a prefix.
 boolean removePrefix(String prefix)
          Removes a prefix, including all VirtualJNDIBindingMBean#DEFAULT bindings for this prefix.
 boolean removeVirtualContext()
          Removes this virtual JNDI binding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VirtualJNDIBinding

protected VirtualJNDIBinding(String appName,
                             String prefix)
Creates and registers a virtual JNDI binding.

Parameters:
appName - J2EE application name.
prefix - The first context prefix, will be mapped as default.
Method Detail

initialize

public static void initialize(JmxService jmx,
                              RegistryService registry,
                              VersioningService versioning)
Saves static server information.

Parameters:
jmx - JMX service.
registry - Registry service.
versioning - Versioning service.

addContext

public void addContext(String prefix,
                       String policy)
                throws IllegalArgumentException
Adds a JNDI prefix to this virtual JNDI naming manager using a policy.

Parameters:
prefix - Prefix instance to add.
policy - Prefix' policy.
Throws:
IllegalArgumentException - Policy is invalid.

rebindContext

public boolean rebindContext(String prefix,
                             String policy)
                      throws IllegalArgumentException
Rebinds a prefix.

Specified by:
rebindContext in interface VirtualContextJMXInterface
Parameters:
prefix - Prefix to rebind.
policy - New policy.
Returns:
true if succeeded, false otherwise.
Throws:
IllegalArgumentException - Policy is invalid.

hasContext

public boolean hasContext(String prefix)
Checks whether a given prefix has been registered.

Specified by:
hasContext in interface VirtualContextJMXInterface
Parameters:
prefix - Prefix to check.
Returns:
true if found, false otherwise.

removePrefix

public boolean removePrefix(String prefix)
Removes a prefix, including all VirtualJNDIBindingMBean#DEFAULT bindings for this prefix. If no more JNDI prefixes left, will also remove the JNDI binding management bean.

Parameters:
prefix - Prefix to remove.
Returns:
true if succeeded, false otherwise.

removeVirtualContext

public boolean removeVirtualContext()
Removes this virtual JNDI binding.

Specified by:
removeVirtualContext in interface VirtualContextJMXInterface
Returns:
true if succeeded, false otherwise.

createJNDIBindingMBeans

public static void createJNDIBindingMBeans(String appName,
                                           String prefix)
Creates or adds into an existing binding a prefix.

Parameters:
appName - J2EE application name.
prefix - Prefix to add.

garbageCollectJNDIBindingMBeans

public static void garbageCollectJNDIBindingMBeans()
Removes JNDI binding management beans that are not in the JNDI directory anymore.


checkJNDIBindings

public void checkJNDIBindings()
Checks that the default JNDI binding is still present.


getContexts

public Map<String,String> getContexts()
Specified by:
getContexts in interface VirtualContextJMXInterface
Returns:
All prefixes with their policies for this virtual JNDI binding.

getNames

public Map<String,List<String>> getNames()
Specified by:
getNames in interface VirtualJNDIBindingMBean
Returns:
All JNDI names managed by this virtual JNDI binding grouped by prefix.

geturl

public URL geturl()
Specified by:
geturl in interface VirtualJNDIBindingMBean
Returns:
Unique URL for this application.

getejbs

public String[] getejbs()
Specified by:
getejbs in interface VirtualJNDIBindingMBean
Returns:
new String[0].


Copyright © 2010 OW2 Consortium. All Rights Reserved.