Methods Summary |
---|
private static java.util.Map | extractRABeanProps(java.lang.String raClassName, java.lang.ClassLoader classLoader)Extracts RA Bean properties via reflection.
Map hMap = new HashMap();
//Only if RA is a 1.5 RAR, we need to get RA JavaBean properties, else
//return an empty map.
if(raClassName.trim().length() != 0) {
Class c = classLoader.loadClass(raClassName);
if(_logger.isLoggable(Level.FINER)) printClassDetails(c);
hMap = getJavaBeanProperties(c);
}
return hMap;
|
private static java.util.Map | getJavaBeanProperties(java.lang.Class c)
Method[] m = c.getMethods();
Map hMap = new HashMap();
for (int i = 0; i < m.length; i++) {
_logger.finer(m[i].getName());
if(m[i].getName().startsWith("get")
&& isValidRABeanConfigProperty(m[i].getReturnType())) {
hMap.put(m[i].getName().substring(3), m[i].getReturnType());
}
}
//remove Object's Class attribute.
hMap.remove("Class");
return hMap;
|
public static java.util.Set | getMergedActivationConfigProperties(com.sun.enterprise.deployment.EjbMessageBeanDescriptor msgDesc)Prepares the name/value pairs for ActivationSpec.
Rule:
1. The name/value pairs are the union of activation-config on
standard DD (message-driven) and runtime DD (mdb-resource-adapter)
2. If there are duplicate property settings, the value in runtime
activation-config will overwrite the one in the standard
activation-config.
Set mergedProps = new HashSet();
Set runtimePropNames = new HashSet();
Set runtimeProps = msgDesc.getRuntimeActivationConfigProperties();
if(runtimeProps != null){
Iterator iter = runtimeProps.iterator();
while (iter.hasNext()) {
EnvironmentProperty entry = (EnvironmentProperty) iter.next();
mergedProps.add(entry);
String propName = (String) entry.getName();
runtimePropNames.add(propName);
}
}
Set standardProps = msgDesc.getActivationConfigProperties();
if(standardProps != null){
Iterator iter = standardProps.iterator();
while (iter.hasNext()) {
EnvironmentProperty entry = (EnvironmentProperty) iter.next();
String propName = (String) entry.getName();
if (runtimePropNames.contains(propName))
continue;
mergedProps.add(entry);
}
}
return mergedProps;
|
public static java.util.Map | getRABeanProperties(java.lang.String pathToDeployableUnit)Finds the properties of a RA JavaBean bundled in a RAR
without exploding the RAR
File f = new File(pathToDeployableUnit);
if (!f.exists()){
String i18nMsg = localStrings.getString(
"rar_archive_not_found", pathToDeployableUnit);
throw new ConnectorRuntimeException( i18nMsg );
}
if(f.isDirectory()) {
return getRABeanPropertiesForDirectoryBasedDeployment(pathToDeployableUnit);
} else {
return getRABeanPropertiesForRARBasedDeployment(pathToDeployableUnit);
}
|
private static java.util.Map | getRABeanPropertiesForDirectoryBasedDeployment(java.lang.String directoryLocation)
Map hMap = new HashMap();
//Use the deployment APIs to get the name of the resourceadapter
//class through the connector descriptor
try {
ConnectorDescriptor cd = ConnectorDDTransformUtils.
getConnectorDescriptor(directoryLocation);
String raClassName = cd.getResourceAdapterClass();
File f = new File(directoryLocation);
URLClassLoader ucl = new URLClassLoader(new URL[]{f.toURI().toURL()},
RARUtils.class.getClassLoader());
hMap = extractRABeanProps(raClassName, ucl);
} catch (IOException e) {
_logger.info(e.getMessage());
_logger.log(Level.FINE, "IO Error while trying to read connector" +
"descriptor to get resource-adapter properties", e);
} catch (ClassNotFoundException e) {
_logger.info(e.getMessage());
_logger.log(Level.FINE, "Unable to find class while trying to read connector" +
"descriptor to get resource-adapter properties", e);
} catch (ConnectorRuntimeException e) {
_logger.info(e.getMessage());
_logger.log(Level.FINE, "Error while trying to read connector" +
"descriptor to get resource-adapter properties", e);
} catch (Exception e) {
_logger.info(e.getMessage());
_logger.log(Level.FINE, "Error while trying to read connector" +
"descriptor to get resource-adapter properties", e);
}
return hMap;
|
private static java.util.Map | getRABeanPropertiesForRARBasedDeployment(java.lang.String rarLocation)
ConnectorRARClassLoader jarCL =
(new ConnectorRARClassLoader(rarLocation, RARUtils.class.getClassLoader()));
String raClassName = ConnectorDDTransformUtils.
getResourceAdapterClassName(rarLocation);
_logger.finer("RA class : " + raClassName);
Map hMap = new HashMap();
try {
hMap = extractRABeanProps(raClassName, jarCL);
} catch (ClassNotFoundException e) {
_logger.info(e.getMessage());
_logger.log(Level.FINE, "Error while trying to find class "
+ raClassName + "in RAR at " + rarLocation, e);
}
return hMap;
|
private static boolean | isPrimitiveWrapper(java.lang.Class clz)Determines if a class is one of the eight java primitive wrapper classes
return (clz.equals(Boolean.class) || clz.equals(Character.class)
|| clz.equals(Byte.class) || clz.equals(Short.class)
|| clz.equals(Integer.class) || clz.equals(Long.class)
|| clz.equals(Float.class) || clz.equals(Double.class));
|
public static boolean | isValidRABeanConfigProperty(java.lang.Class clz)A valid resource adapter java bean property should either be one of the
following
1. A Java primitive or a primitve wrapper
2. A String
return (clz.isPrimitive() || clz.equals(String.class)
|| isPrimitiveWrapper(clz));
|
public static void | main(java.lang.String[] args)
if(!(args.length >= 1)){
System.out.println("<Usage> java RARUtils directory-path ");
return;
}
Map hMap = RARUtils.getRABeanPropertiesForDirectoryBasedDeployment(args[0]);
System.out.println("RA JavaBean Properties");
System.out.println(hMap);
|
private static void | printClassDetails(java.lang.Class c)
Method[] m = c.getMethods();
_logger.finer("Methods in " + c.getName());
for (int i = 0; i < m.length; i++) {
_logger.finer(m[i].toString());
}
|