You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/07/09 20:08:21 UTC
svn commit: r554723 [2/2] - in
/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb:
java2idl/ util/
Modified: incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java?view=diff&rev=554723&r1=554722&r2=554723
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java Mon Jul 9 11:08:19 2007
@@ -48,6 +48,19 @@
* EJBMessageHandler
*/
public class EJBHandler {
+ private static final Map<String, Class> PRIMITIVE_TYPES = new HashMap<String, Class>();
+ static {
+ PRIMITIVE_TYPES.put("boolean", boolean.class);
+ PRIMITIVE_TYPES.put("byte", byte.class);
+ PRIMITIVE_TYPES.put("char", char.class);
+ PRIMITIVE_TYPES.put("short", short.class);
+ PRIMITIVE_TYPES.put("int", int.class);
+ PRIMITIVE_TYPES.put("long", long.class);
+ PRIMITIVE_TYPES.put("float", float.class);
+ PRIMITIVE_TYPES.put("double", double.class);
+ PRIMITIVE_TYPES.put("void", void.class);
+ }
+
private Object ejbStub;
private InterfaceInfo interfaceInfo;
@@ -64,30 +77,16 @@
this.ejbStub = EJBStubHelper.lookup(namingEndpoint);
this.interfaceInfo = ejbInterface;
} catch (Exception e) {
- Throwable b = e.getCause();
- b.printStackTrace();
throw new ServiceRuntimeException(e);
}
}
- private final static Map<String, Class> primitiveClasses = new HashMap<String, Class>();
- static {
- primitiveClasses.put("boolean", boolean.class);
- primitiveClasses.put("byte", byte.class);
- primitiveClasses.put("char", char.class);
- primitiveClasses.put("short", short.class);
- primitiveClasses.put("int", int.class);
- primitiveClasses.put("long", long.class);
- primitiveClasses.put("float", float.class);
- primitiveClasses.put("double", double.class);
- primitiveClasses.put("void", void.class);
- }
-
private static Class loadClass(final String name) {
- Class type = (Class)primitiveClasses.get(name);
- if (type != null)
+ Class type = (Class)PRIMITIVE_TYPES.get(name);
+ if (type != null) {
return type;
- return (Class)AccessController.doPrivileged(new PrivilegedAction<Class>() {
+ }
+ return AccessController.doPrivileged(new PrivilegedAction<Class>() {
public Class run() {
try {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
@@ -160,13 +159,15 @@
* @return The IDL operation name
*/
private String getOperation(String methodName) {
- if (interfaceInfo == null)
+ if (interfaceInfo == null) {
return methodName;
+ }
MethodInfo methodInfo = interfaceInfo.getMethod(methodName);
- if (methodInfo != null)
+ if (methodInfo != null) {
return methodInfo.getIDLName();
- else
+ } else {
return null;
+ }
}
/*
@@ -382,16 +383,16 @@
*/
protected Object readValue(InputStream in, Class type) {
Object value = null;
- if (type == null)
+ if (type == null) {
value = in.read_value();
- else if (type == Object.class || type == Serializable.class || type == Externalizable.class) {
+ } else if (type == Object.class || type == Serializable.class || type == Externalizable.class) {
value = Util.readAny(in);
} else if (type == Integer.TYPE) {
- value = new Integer(in.read_long());
+ value = Integer.valueOf(in.read_long());
} else if (type == Short.TYPE) {
value = new Short(in.read_short());
} else if (type == Boolean.TYPE) {
- value = new Boolean(in.read_boolean());
+ value = Boolean.valueOf(in.read_boolean());
} else if (type == Byte.TYPE) {
value = new Byte(in.read_octet());
} else if (type == Long.TYPE) {
Modified: incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java?view=diff&rev=554723&r1=554722&r2=554723
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java Mon Jul 9 11:08:19 2007
@@ -52,21 +52,22 @@
public static final String CELL_ROOT = "NameServiceCellRoot";
public static final String NODE_ROOT = "NameServiceNodeRoot";
public static final String DEFAULT_ROOT = "NameService"; // Same as
- // CELL_ROOT
-
- private static final Set ROOTS = new HashSet(Arrays.asList(new String[] {SERVER_ROOT, CELL_PERSISTENT_ROOT,
- CELL_ROOT, DEFAULT_ROOT, NODE_ROOT}));
+ // CELL_ROOT
public static final String DEFAULT_HOST = "127.0.0.1"; // Default host name
- // or IP address for
- // Websphere
+ // or IP address for
+ // Websphere
public static final int DEFAULT_NAMING_PORT = 2809; // Default port
public static final String NAMING_SERVICE = "NameService"; // The name of
- // the naming
- // service
+ // the naming
+ // service
+ private static final Set<String> ROOTS =
+ new HashSet<String>(Arrays.asList(new String[] {SERVER_ROOT, CELL_PERSISTENT_ROOT, CELL_ROOT, DEFAULT_ROOT,
+ NODE_ROOT}));
// private static final String CHARS_TO_ESCAPE = "\\/.";
- private static final String RFC2396 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789;/:?@&=+$,-_.!~*'()";
+ private static final String RFC2396 =
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789;/:?@&=+$,-_.!~*'()";
private static final String HEX = "0123456789ABCDEF";
private String hostName = DEFAULT_HOST;
@@ -80,8 +81,8 @@
public EJBLocator(boolean managed) {
this.managed = managed;
if (!managed) {
- String url = (String)AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ String url = AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
return System.getProperty(Context.PROVIDER_URL);
}
});
@@ -89,28 +90,6 @@
}
}
- private void processCorbaURL(String url) {
- if (url != null && (url.startsWith("corbaname:iiop:") || url.startsWith("corbaloc:iiop:"))) {
- /**
- * corbaname:iiop:<hostName>:<port>/<root>#name corbaloc:iiop:<hostname>:<port>/<root>
- * For exmaple,
- * "corbaname:iiop:localhost:2809/NameServiceServerRoot#ejb/MyEJBHome";
- * or "corbaloc:iiop:myhost:2809/NameServiceServerRoot"
- */
- String[] parts = url.split("(:|/|#)");
- if (parts.length > 2 && parts[2].length() > 0) {
- hostName = parts[2]; // The host name
- int index = hostName.lastIndexOf('@'); // version@hostname
- if (index != -1)
- hostName = hostName.substring(index + 1);
- }
- if (parts.length > 3 && parts[3].length() > 0)
- port = Integer.parseInt(parts[3]); // The port number
- if (parts.length > 4 && parts[4].length() > 0)
- root = parts[4]; // The root of naming
- }
- }
-
public EJBLocator(String hostName, int port) {
this.hostName = (hostName == null) ? DEFAULT_HOST : hostName;
this.port = port > 0 ? port : DEFAULT_NAMING_PORT;
@@ -119,18 +98,45 @@
public EJBLocator(String hostName, int port, String root) {
this(hostName, port);
- if (ROOTS.contains(root))
+ if (ROOTS.contains(root)) {
this.root = root;
- else
+ } else {
throw new IllegalArgumentException(root + " is not a legal root");
+ }
}
public EJBLocator(String corbaName, boolean managed) {
this.managed = managed;
if (corbaName.startsWith("corbaname:iiop:")) {
processCorbaURL(corbaName);
- } else
+ } else {
throw new IllegalArgumentException(corbaName + " is not a legal corbaname");
+ }
+ }
+
+ private void processCorbaURL(String url) {
+ if (url != null && (url.startsWith("corbaname:iiop:") || url.startsWith("corbaloc:iiop:"))) {
+ /**
+ * corbaname:iiop:<hostName>:<port>/<root>#name corbaloc:iiop:<hostname>:<port>/<root>
+ * For exmaple,
+ * "corbaname:iiop:localhost:2809/NameServiceServerRoot#ejb/MyEJBHome";
+ * or "corbaloc:iiop:myhost:2809/NameServiceServerRoot"
+ */
+ String[] parts = url.split("(:|/|#)");
+ if (parts.length > 2 && parts[2].length() > 0) {
+ hostName = parts[2]; // The host name
+ int index = hostName.lastIndexOf('@'); // version@hostname
+ if (index != -1) {
+ hostName = hostName.substring(index + 1);
+ }
+ }
+ if (parts.length > 3 && parts[3].length() > 0) {
+ port = Integer.parseInt(parts[3]); // The port number
+ }
+ if (parts.length > 4 && parts[4].length() > 0) {
+ root = parts[4]; // The root of naming
+ }
+ }
}
/**
@@ -149,10 +155,11 @@
* @return
*/
private static String getCorbaloc(String hostName, int port, String service) {
- if (service == null)
+ if (service == null) {
return "corbaloc:iiop:" + hostName + ":" + port;
- else
+ } else {
return "corbaloc:iiop:" + hostName + ":" + port + "/" + service;
+ }
}
private String getCorbaloc(String service) {
@@ -180,10 +187,11 @@
* @param name The JNDI name
*/
private static String getCorbaname(String hostName, int port, String root, String name) {
- if (name == null)
+ if (name == null) {
return "corbaname:iiop:" + hostName + ":" + port + "/" + root;
- else
+ } else {
return "corbaname:iiop:" + hostName + ":" + port + "/" + root + "#" + toCorbaname(name);
+ }
}
String getCorbaname(String name) {
@@ -199,10 +207,14 @@
public ORB connect() {
if (orb == null) {
Properties props = new Properties();
- /* This code is for IBM JVM
- props.put("org.omg.CORBA.ORBClass", "com.ibm.CORBA.iiop.ORB");
- props.put("com.ibm.CORBA.ORBInitRef.NameService", getCorbaloc(NAMING_SERVICE));
- props.put("com.ibm.CORBA.ORBInitRef.NameServiceServerRoot", getCorbaloc("NameServiceServerRoot")); */
+ /*
+ * This code is for IBM JVM props.put("org.omg.CORBA.ORBClass",
+ * "com.ibm.CORBA.iiop.ORB");
+ * props.put("com.ibm.CORBA.ORBInitRef.NameService",
+ * getCorbaloc(NAMING_SERVICE));
+ * props.put("com.ibm.CORBA.ORBInitRef.NameServiceServerRoot",
+ * getCorbaloc("NameServiceServerRoot"));
+ */
orb = ORB.init((String[])null, props);
}
return orb;
@@ -336,17 +348,19 @@
private boolean isJndiConfigured() {
if (managed)
return true;
- Boolean provided = (Boolean)AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ Boolean provided = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+ public Boolean run() {
String initCtxFactory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
if (initCtxFactory == null) {
URL file = Thread.currentThread().getContextClassLoader().getResource("jndi.properties");
- if (file != null)
+ if (file != null) {
return Boolean.TRUE;
- else
+ } else {
return Boolean.FALSE;
- } else
+ }
+ } else {
return Boolean.TRUE;
+ }
}
});
return provided.booleanValue();
@@ -367,23 +381,24 @@
* @return RFC2396-encoded stringified name
*/
static String encode2396(String s) {
- if (s == null)
+ if (s == null) {
return null;
+ }
StringBuffer encoded = new StringBuffer(s);
for (int i = 0; i < encoded.length(); i++) {
char c = encoded.charAt(i);
if (RFC2396.indexOf(c) == -1) {
encoded.setCharAt(i, '%');
char ac[] = Integer.toHexString(c).toCharArray();
- if (ac.length == 2)
+ if (ac.length == 2) {
encoded.insert(i + 1, ac);
- else if (ac.length == 1) {
+ } else if (ac.length == 1) {
encoded.insert(i + 1, '0');
encoded.insert(i + 2, ac[0]);
} else {
throw new IllegalArgumentException("Invalid character '" + c + "' in \"" + s + "\"");
}
- i += 2;
+ i += 2; // NOPMD
}
}
return encoded.toString();
@@ -396,20 +411,23 @@
* @return Plain string
*/
static String decode2396(String s) {
- if (s == null)
+ if (s == null) {
return null;
+ }
StringBuffer decoded = new StringBuffer(s);
for (int i = 0; i < decoded.length(); i++) {
char c = decoded.charAt(i);
if (c == '%') {
- if (i + 2 >= decoded.length())
+ if (i + 2 >= decoded.length()) {
throw new IllegalArgumentException("Incomplete key_string escape sequence");
+ }
int j;
j = HEX.indexOf(decoded.charAt(i + 1)) * 16 + HEX.indexOf(decoded.charAt(i + 2));
decoded.setCharAt(i, (char)j);
decoded.delete(i + 1, i + 3);
- } else if (RFC2396.indexOf(c) == -1)
+ } else if (RFC2396.indexOf(c) == -1) {
throw new IllegalArgumentException("Invalid key_string character '" + c + "'");
+ }
}
return decoded.toString();
}
@@ -440,8 +458,9 @@
}
private ObjectLocator getObjectLocator() throws NamingException {
- if (locator != null)
+ if (locator != null) {
return locator;
+ }
/*
* For managed env, jndi is assumed to be configured by default For
* unmanaged environment, jndi could have configured through
@@ -450,7 +469,7 @@
if (isJndiConfigured()) {
locator = new JndiLocator();
} else { // this is definitely JSE env without jndi configured. Use
- // Corba.
+ // Corba.
locator = new CosNamingLocator();
}
return locator;
@@ -463,10 +482,10 @@
}
private static interface ObjectLocator {
- public Object locate(String name) throws NamingException;
+ Object locate(String name) throws NamingException;
}
- private class JndiLocator implements ObjectLocator {
+ private final class JndiLocator implements ObjectLocator {
private Context context;
private JndiLocator() throws NamingException {
@@ -478,17 +497,12 @@
}
public Object locate(String name) throws NamingException {
- try {
return context.lookup(name);
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
}
}
- private class CosNamingLocator implements ObjectLocator {
- private NamingContextExt context = null;
+ private final class CosNamingLocator implements ObjectLocator {
+ private NamingContextExt context;
private CosNamingLocator() {
}
@@ -498,10 +512,11 @@
}
public Object locate(String name) throws NamingException {
- if (context != null)
+ if (context != null) {
return resovleString(context, name);
- else
+ } else {
return stringToObject(name);
+ }
}
}
Modified: incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBObjectFactory.java?view=diff&rev=554723&r1=554722&r2=554723
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBObjectFactory.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBObjectFactory.java Mon Jul 9 11:08:19 2007
@@ -34,7 +34,7 @@
import org.omg.CORBA.portable.RemarshalException;
import org.osoa.sca.ServiceRuntimeException;
-public class EJBObjectFactory {
+public final class EJBObjectFactory {
private EJBObjectFactory() {
}
Modified: incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBStubHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBStubHelper.java?view=diff&rev=554723&r1=554722&r2=554723
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBStubHelper.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBStubHelper.java Mon Jul 9 11:08:19 2007
@@ -26,7 +26,7 @@
import org.osoa.sca.ServiceRuntimeException;
import org.osoa.sca.ServiceUnavailableException;
-public class EJBStubHelper {
+public final class EJBStubHelper {
private static Object stub;
private static ServiceRuntimeException exception;
Modified: incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/InterfaceInfo.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/InterfaceInfo.java?view=diff&rev=554723&r1=554722&r2=554723
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/InterfaceInfo.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/InterfaceInfo.java Mon Jul 9 11:08:19 2007
@@ -38,34 +38,27 @@
*/
public class InterfaceInfo implements Serializable {
- private static final Map interfaces = Collections.synchronizedMap(new WeakHashMap());
+ private static final Map<Class, InterfaceInfo> INTERFACES =
+ Collections.synchronizedMap(new WeakHashMap<Class, InterfaceInfo>());
private static final long serialVersionUID = 2314533906465094860L;
private String name;
- private Map methods = new HashMap();
-
- public synchronized final static InterfaceInfo getInstance(final Class iface) {
- InterfaceInfo info = (InterfaceInfo)interfaces.get(iface);
- if (info == null) {
- info = new InterfaceInfo(iface);
- interfaces.put(iface, info);
- }
- return info;
- }
+ private Map<String, MethodInfo> methods = new HashMap<String, MethodInfo>();
public InterfaceInfo(final Class iface) {
super();
- if (iface == null)
+ if (iface == null) {
throw new IllegalArgumentException("The interface cannot be null");
+ }
this.name = iface.getName();
// SECURITY
/*
* Permission: accessDeclaredMembers : Access denied
* (java.lang.RuntimePermission accessDeclaredMembers)
*/
- Map idlNames = (Map)AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ Map idlNames = AccessController.doPrivileged(new PrivilegedAction<Map>() {
+ public Map run() {
return Java2IDL.getIDLMapping(iface);
}
});
@@ -80,20 +73,19 @@
}
}
- /*
- * public InterfaceInfo(String portType, String wsdlOperationName) {
- * super(); this.name = portType; // <DataObject> operation(<DataObject>)
- * throws RemoteException MethodInfo method = new
- * MethodInfo(wsdlOperationName, DataObject.class.getName(), new
- * String[]{DataObject.class.getName()}, new
- * String[]{RemoteException.class.getName()}); methods.put(method.getName(),
- * method); }
- */
+ public static synchronized final InterfaceInfo getInstance(final Class iface) {
+ InterfaceInfo info = (InterfaceInfo)INTERFACES.get(iface);
+ if (info == null) {
+ info = new InterfaceInfo(iface);
+ INTERFACES.put(iface, info);
+ }
+ return info;
+ }
/**
* @return
*/
- public Map getMethods() {
+ public Map<String, MethodInfo> getMethods() {
return methods;
}
Modified: incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/JavaReflectionAdapter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/JavaReflectionAdapter.java?view=diff&rev=554723&r1=554722&r2=554723
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/JavaReflectionAdapter.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/JavaReflectionAdapter.java Mon Jul 9 11:08:19 2007
@@ -34,26 +34,26 @@
* An adapter for java classes, indexes the methods by name and provides an
* invoke method that takes a method name.
*/
-public class JavaReflectionAdapter {
+public final class JavaReflectionAdapter {
- private static Map adapters = Collections.synchronizedMap(new WeakHashMap());
+ private static Map<Class, JavaReflectionAdapter> adapters =
+ Collections.synchronizedMap(new WeakHashMap<Class, JavaReflectionAdapter>());
+
+ private static final Map<Class, Object> DEFAULT_VALUES = new HashMap<Class, Object>();
+ static {
+ DEFAULT_VALUES.put(boolean.class, Boolean.FALSE);
+ DEFAULT_VALUES.put(byte.class, new Byte((byte)0));
+ DEFAULT_VALUES.put(char.class, new Character((char)0));
+ DEFAULT_VALUES.put(short.class, new Short((short)0));
+ DEFAULT_VALUES.put(int.class, Integer.valueOf(0));
+ DEFAULT_VALUES.put(long.class, new Long(0));
+ DEFAULT_VALUES.put(float.class, new Float(0.0));
+ DEFAULT_VALUES.put(double.class, new Double(0.0));
+ }
private Class clazz;
- private Map methodMap = new HashMap();
- /**
- * Create a java reflection adapter
- *
- * @param clazz
- */
- public synchronized static JavaReflectionAdapter createJavaReflectionAdapter(Class clazz) {
- JavaReflectionAdapter adapter = (JavaReflectionAdapter)adapters.get(clazz);
- if (adapter == null) {
- adapter = new JavaReflectionAdapter(clazz);
- adapters.put(clazz, adapter);
- }
- return adapter;
- }
+ private Map<String, Method> methodMap = new HashMap<String, Method>();
/**
* Constructor
@@ -64,23 +64,28 @@
this.clazz = clazz;
// Index the methods on the implementation class
- Method[] methods = (Method[])AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ Method[] methods = AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
+ public Method[] run() {
return clazz.getMethods();
}
});
- for (int i = 0, n = methods.length; i < n; i++) {
+ for (int i = 0; i < methods.length; i++) {
methodMap.put(methods[i].getName(), methods[i]);
}
}
/**
- * Returns a map containing the methods on the class, keyed by name
+ * Create a java reflection adapter
*
- * @return
+ * @param clazz
*/
- public Map getMethods() {
- return methodMap;
+ public static synchronized JavaReflectionAdapter createJavaReflectionAdapter(Class clazz) {
+ JavaReflectionAdapter adapter = (JavaReflectionAdapter)adapters.get(clazz);
+ if (adapter == null) {
+ adapter = new JavaReflectionAdapter(clazz);
+ adapters.put(clazz, adapter);
+ }
+ return adapter;
}
/**
@@ -93,21 +98,19 @@
public Method getMethod(String methodName) throws NoSuchMethodException {
Method method = (Method)methodMap.get(methodName);
- if (method == null)
+ if (method == null) {
throw new NoSuchMethodException(methodName);
+ }
return method;
}
- private final static Map DEFAULT_PRIMITIVE_VALUES = new HashMap();
- static {
- DEFAULT_PRIMITIVE_VALUES.put(boolean.class, Boolean.FALSE);
- DEFAULT_PRIMITIVE_VALUES.put(byte.class, new Byte((byte)0));
- DEFAULT_PRIMITIVE_VALUES.put(char.class, new Character((char)0));
- DEFAULT_PRIMITIVE_VALUES.put(short.class, new Short((short)0));
- DEFAULT_PRIMITIVE_VALUES.put(int.class, new Integer(0));
- DEFAULT_PRIMITIVE_VALUES.put(long.class, new Long(0));
- DEFAULT_PRIMITIVE_VALUES.put(float.class, new Float(0.0));
- DEFAULT_PRIMITIVE_VALUES.put(double.class, new Double(0.0));
+ /**
+ * Returns a map containing the methods on the class, keyed by name
+ *
+ * @return
+ */
+ public Map getMethods() {
+ return methodMap;
}
/**
@@ -126,7 +129,7 @@
for (int i = 0; i < parameterTypes.length; i++) {
Class parameterType = parameterTypes[i];
if (args[i] == null && parameterType.isPrimitive()) {
- args[i] = DEFAULT_PRIMITIVE_VALUES.get(parameterType);
+ args[i] = DEFAULT_VALUES.get(parameterType);
}
}
return method.invoke(object, args);
Modified: incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/NamingEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/NamingEndpoint.java?view=diff&rev=554723&r1=554722&r2=554723
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/NamingEndpoint.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/util/NamingEndpoint.java Mon Jul 9 11:08:19 2007
@@ -34,17 +34,19 @@
public NamingEndpoint(String name) {
/**
- * by default it's a managed environment means SCA composite with ref binding is running on
- * an AppServer. If running on J2SE, pass -Dmanaged=false for the VM
- */
- String managedEnv = (String)AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ * by default it's a managed environment means SCA composite with ref
+ * binding is running on an AppServer. If running on J2SE, pass
+ * -Dmanaged=false for the VM
+ */
+ final String managedEnv = AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
return System.getProperty("managed");
}
});
- if (managedEnv != null)
- managed = new Boolean(managedEnv);
+ if (managedEnv != null) {
+ managed = Boolean.valueOf(managedEnv);
+ }
if ((!managed) && name.startsWith("corbaname:iiop:")) {
/**
@@ -54,8 +56,9 @@
*/
String[] parts = split(name, '#');
- if (parts.length != 2)
+ if (parts.length != 2) {
throw new IllegalArgumentException("Invalid corbaname: " + name);
+ }
this.jndiName = parts[1]; // The logical jndi name
this.locator = new EJBLocator(parts[0], managed);
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org