Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.webengine.jaxrs
Class Utils

java.lang.Object
  extended by org.nuxeo.ecm.webengine.jaxrs.Utils

public class Utils
extends Object

Some helper methods for parsing configuration and loading contributed servlets or filters.

Author:
Bogdan Stefanescu

Nested Class Summary
static class Utils.ClassRef
           
 
Constructor Summary
Utils()
           
 
Method Summary
static Utils.ClassRef getClassRef(String classRef)
          Get a class proxy reference for the given class reference
static Utils.ClassRef getClassRef(String classRef, org.osgi.framework.Bundle bundle)
           
static Class<?> loadClass(String classRef)
          Load a class from a class reference string.
static Class<?> loadClass(String bundleId, String className)
          Load a class given the owner bundle and the class name.
static Class<?>[] loadClasses(String classRefs)
          Load classes from a list of class references given as a comma separated string list.
static Class<?>[] loadClasses(String classRefs, char sep)
          Load classes from a list of class references given as a 'sep' separated string list.
static Object newInstance(String classRef)
          Create a new object of the given a class reference.
static Object newInstance(String bundleId, String className)
          Create a new object of the given class in the given bundle.
static
<T> T[]
newInstances(Class<T> componentType, String classRefs)
          Get class instances for the given class references string
static
<T> T[]
newInstances(Class<T> componentType, String classRefs, char sep)
          Get class instances for the given class references string
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

loadClasses

public static Class<?>[] loadClasses(String classRefs)
                              throws ClassNotFoundException,
                                     BundleNotFoundException
Load classes from a list of class references given as a comma separated string list.

Parameters:
classRefs - the string containing the list of class references
Returns:
an array of the loaded classes
Throws:
ClassNotFoundException
BundleNotFoundException

loadClasses

public static Class<?>[] loadClasses(String classRefs,
                                     char sep)
                              throws ClassNotFoundException,
                                     BundleNotFoundException
Load classes from a list of class references given as a 'sep' separated string list.

Parameters:
classRefs - the string containing the list of class references
sep - the separator character used to separate class references in the string.
Returns:
an array of the loaded classes
Throws:
ClassNotFoundException
BundleNotFoundException

newInstances

public static <T> T[] newInstances(Class<T> componentType,
                                   String classRefs)
                        throws Exception
Get class instances for the given class references string

Type Parameters:
T -
Parameters:
componentType - the type of the expected array component
classRefs -
Returns:
Throws:
Exception
See Also:
#loadClasses(String)}

newInstances

public static <T> T[] newInstances(Class<T> componentType,
                                   String classRefs,
                                   char sep)
                        throws Exception
Get class instances for the given class references string

Type Parameters:
T -
Parameters:
componentType -
classRefs -
sep -
Returns:
Throws:
Exception
See Also:
#loadClasses(String, char)}

loadClass

public static Class<?> loadClass(String classRef)
                          throws ClassNotFoundException,
                                 BundleNotFoundException
Load a class from a class reference string. The class reference string is in the format: bundleSymbolicName:className or className. If no bundle symbolic name is given the class will be loaded using the class loader of the Utils class.

The bundle will be resolved to the last version of the bundle (in case when different bundle versions are found)

Parameters:
classRef -
Returns:
Throws:
ClassNotFoundException
BundleNotFoundException

getClassRef

public static Utils.ClassRef getClassRef(String classRef)
                                  throws ClassNotFoundException,
                                         BundleNotFoundException
Get a class proxy reference for the given class reference

Parameters:
classRef -
Returns:
Throws:
Exception
ClassNotFoundException
BundleNotFoundException

getClassRef

public static Utils.ClassRef getClassRef(String classRef,
                                         org.osgi.framework.Bundle bundle)
                                  throws ClassNotFoundException,
                                         BundleNotFoundException
Throws:
ClassNotFoundException
BundleNotFoundException

loadClass

public static Class<?> loadClass(String bundleId,
                                 String className)
                          throws ClassNotFoundException,
                                 BundleNotFoundException
Load a class given the owner bundle and the class name.

The bundle will be resolved to the last version of the bundle (in case when different bundle versions are found)

Parameters:
bundleId -
className -
Returns:
Throws:
ClassNotFoundException
BundleNotFoundException

newInstance

public static Object newInstance(String bundleId,
                                 String className)
                          throws Exception
Create a new object of the given class in the given bundle. The class should provide a no-args empty constructor.

The bundle will be resolved to the last version of the bundle (in case when different bundle versions are found)

Parameters:
bundleId -
className -
Returns:
Throws:
Exception
See Also:
#loadClass(String, String)}

newInstance

public static Object newInstance(String classRef)
                          throws Exception
Create a new object of the given a class reference.

The bundle will be resolved to the last version of the bundle (in case when different bundle versions are found)

Parameters:
classRef -
Returns:
Throws:
Exception
See Also:
#loadClass(String, String)}

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.