[wise-commits] wise SVN: r483 - in webgui/branches/cdi-jsf: src/main/java/org/jboss/wise/gui and 1 other directories.

wise-commits at lists.jboss.org wise-commits at lists.jboss.org
Fri Feb 1 18:45:18 EST 2013


Author: alessio.soldano at jboss.com
Date: 2013-02-01 18:45:18 -0500 (Fri, 01 Feb 2013)
New Revision: 483

Modified:
   webgui/branches/cdi-jsf/pom.xml
   webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/CleanupHelper.java
   webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/ClientConversationBean.java
   webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/ComplexWiseTreeElement.java
   webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/EnumerationWiseTreeElement.java
   webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/ParameterizedWiseTreeElement.java
   webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/SimpleWiseTreeElement.java
   webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/WiseTreeElementBuilder.java
Log:
Fixing logging, slimming down dependencies a bit and solving a potential concurrency issue with creation of client builder


Modified: webgui/branches/cdi-jsf/pom.xml
===================================================================
--- webgui/branches/cdi-jsf/pom.xml	2013-02-01 23:42:03 UTC (rev 482)
+++ webgui/branches/cdi-jsf/pom.xml	2013-02-01 23:45:18 UTC (rev 483)
@@ -104,6 +104,38 @@
                       <groupId>wsdl4j</groupId>
                       <artifactId>wsdl4j</artifactId>
                   </exclusion>
+                  <exclusion>
+                      <groupId>log4j</groupId>
+                      <artifactId>log4j</artifactId>
+                  </exclusion>
+                  <exclusion>
+                      <groupId>org.freemarker</groupId>
+                      <artifactId>freemarker</artifactId>
+                  </exclusion>
+                  <exclusion>
+                      <groupId>javassist</groupId>
+                      <artifactId>javassist</artifactId>
+                  </exclusion>
+                  <exclusion>
+                      <groupId>org.milyn</groupId>
+                      <artifactId>milyn-smooks-javabean</artifactId>
+                  </exclusion>
+                  <exclusion>
+                      <groupId>org.milyn</groupId>
+                      <artifactId>milyn-smooks-validation</artifactId>
+                  </exclusion>
+                  <exclusion>
+                      <groupId>com.thoughtworks.xstream</groupId>
+                      <artifactId>xstream</artifactId>
+                  </exclusion>
+                  <exclusion>
+                      <groupId>org.mvel</groupId>
+                      <artifactId>mvel2</artifactId>
+                  </exclusion>
+                  <exclusion>
+                      <groupId>dtdparser</groupId>
+                      <artifactId>dtdparser</artifactId>
+                  </exclusion>
               </exclusions>
          </dependency>
 

Modified: webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/CleanupHelper.java
===================================================================
--- webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/CleanupHelper.java	2013-02-01 23:42:03 UTC (rev 482)
+++ webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/CleanupHelper.java	2013-02-01 23:45:18 UTC (rev 483)
@@ -24,6 +24,8 @@
 import javax.ejb.Singleton;
 import javax.ejb.Startup;
 
+import org.jboss.logging.Logger;
+
 @Singleton
 @Startup
 public class CleanupHelper {
@@ -32,6 +34,7 @@
     
     @Schedule(minute = "*/3", hour = "*", persistent = false) //every 3 minutes
     public void foo() {
+	Logger.getLogger(CleanupHelper.class).debug("Periodic cleanup...");
 	synchronized (tasks) {
 	    for (CleanupTask<?> task : tasks) {
 		task.refsCleanup();

Modified: webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/ClientConversationBean.java
===================================================================
--- webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/ClientConversationBean.java	2013-02-01 23:42:03 UTC (rev 482)
+++ webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/ClientConversationBean.java	2013-02-01 23:45:18 UTC (rev 483)
@@ -16,6 +16,7 @@
  */
 package org.jboss.wise.gui;
 
+import java.io.PrintStream;
 import java.io.Serializable;
 import java.lang.reflect.Type;
 import java.util.Collection;
@@ -34,16 +35,17 @@
 import javax.inject.Named;
 import javax.jws.soap.SOAPBinding;
 
+import org.jboss.logging.Logger;
 import org.jboss.wise.core.client.InvocationResult;
 import org.jboss.wise.core.client.WSDynamicClient;
 import org.jboss.wise.core.client.WSEndpoint;
 import org.jboss.wise.core.client.WSMethod;
 import org.jboss.wise.core.client.WSService;
 import org.jboss.wise.core.client.WebParameter;
-import org.jboss.wise.core.client.builder.WSDynamicClientBuilder;
-import org.jboss.wise.core.client.factories.WSDynamicClientFactory;
+import org.jboss.wise.core.client.impl.reflection.builder.ReflectionBasedWSDynamicClientBuilder;
 import org.jboss.wise.core.exception.InvocationException;
 import org.jboss.wise.core.exception.WiseRuntimeException;
+import org.jboss.wise.core.utils.JBossLoggingOutputStream;
 import org.jboss.wise.gui.treeElement.GroupWiseTreeElement;
 import org.jboss.wise.gui.treeElement.LazyLoadWiseTreeElement;
 import org.jboss.wise.gui.treeElement.WiseTreeElement;
@@ -57,10 +59,11 @@
 public class ClientConversationBean implements Serializable {
 
     private static final long serialVersionUID = 1L;
-
+    
     private static final int CONVERSATION_TIMEOUT = 15 * 60 * 1000; //15 mins instead of default 30 mins
-    private static WSDynamicClientBuilder clientBuilder;
     private static CleanupTask<WSDynamicClient> cleanupTask = new CleanupTask<WSDynamicClient>(true);
+    private static Logger logger = Logger.getLogger(ClientConversationBean.class);
+    private static PrintStream ps = new PrintStream(new JBossLoggingOutputStream(logger, Logger.Level.DEBUG), true);
     
     @Inject Conversation conversation;
     private WSDynamicClient client;
@@ -85,7 +88,7 @@
 	conversation.end();
 	conversation.begin();
 	try {
-	    client = getClientBuilder().verbose(true).keepSource(true).wsdlURL(getWsdlUrl()).maxThreadPoolSize(1).build();
+	    client = new ReflectionBasedWSDynamicClientBuilder().verbose(true).messageStream(ps).keepSource(true).maxThreadPoolSize(1).wsdlURL(getWsdlUrl()).build();
 	    cleanupTask.addRef(client, System.currentTimeMillis() + CONVERSATION_TIMEOUT, new CleanupTask.CleanupCallback<WSDynamicClient>() {
 		@Override
 		public void cleanup(WSDynamicClient data) {
@@ -331,13 +334,6 @@
         this.error = error;
     }
 
-    private static synchronized WSDynamicClientBuilder getClientBuilder() {
-	if (clientBuilder == null) {
-	    clientBuilder = WSDynamicClientFactory.getJAXWSClientBuilder();
-	}
-	return clientBuilder;
-    }
-    
     private static String toErrorMessage(Exception e) {
 	StringBuilder sb = new StringBuilder();
 	if (e instanceof WiseRuntimeException) {
@@ -354,6 +350,6 @@
     }
     
     private static void logException(Exception e) {
-	e.printStackTrace(); //TODO!!
+	logger.error("", e);
     }
 }

Modified: webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/ComplexWiseTreeElement.java
===================================================================
--- webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/ComplexWiseTreeElement.java	2013-02-01 23:42:03 UTC (rev 482)
+++ webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/ComplexWiseTreeElement.java	2013-02-01 23:45:18 UTC (rev 483)
@@ -26,7 +26,6 @@
 import javax.xml.datatype.Duration;
 import javax.xml.datatype.XMLGregorianCalendar;
 
-import org.jboss.logging.Logger;
 import org.jboss.wise.core.exception.WiseRuntimeException;
 import org.jboss.wise.core.utils.IDGenerator;
 import org.jboss.wise.core.utils.ReflectionUtils;
@@ -84,15 +83,12 @@
 		String setter = ReflectionUtils.setterMethodName(child.getName(), child.isTypeBoolean());
 		String getter = ReflectionUtils.getterMethodName(child.getName(), child.isTypeBoolean());
 
-		Logger.getLogger(this.getClass()).debug("Setter: " + setter);
 		Method method;
 		if (child instanceof GroupWiseTreeElement) {
-		    Logger.getLogger(this.getClass()).debug("Child is a group...");
 		    method = cl.getMethod(getter, (Class[]) null);
 		    Collection<?> col = (Collection<?>) method.invoke(obj, (Object[]) null);
 		    col.addAll((List) child.toObject());
 		} else {
-		    Logger.getLogger(this.getClass()).debug("Child is not a group...");
 		    Object childObject = child.toObject();
 		    if (child instanceof ParameterizedWiseTreeElement) {
 			method = cl.getMethod(setter, (Class<?>) ((ParameterizedType) child.getClassType()).getRawType());
@@ -111,9 +107,9 @@
 
 		    }
 		    method.invoke(obj, childObject);
-		    // TODO!!! Remove the following check once we're confident
-		    method = cl.getMethod(getter, (Class[]) null);
-		    Logger.getLogger(this.getClass()).debug("[FIXME: remove check] risultato getter " + getter + ": " + method.invoke(obj, (Object[]) null));
+//		    // TODO!!! Remove the following check once we're confident
+//		    method = cl.getMethod(getter, (Class[]) null);
+//		    Logger.getLogger(this.getClass()).info("[FIXME: remove check] risultato getter " + getter + ": " + method.invoke(obj, (Object[]) null));
 		}
 	    }
 	} catch (Exception e) {

Modified: webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/EnumerationWiseTreeElement.java
===================================================================
--- webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/EnumerationWiseTreeElement.java	2013-02-01 23:42:03 UTC (rev 482)
+++ webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/EnumerationWiseTreeElement.java	2013-02-01 23:45:18 UTC (rev 483)
@@ -86,7 +86,6 @@
     public Map<String, String> getValidValue() {
 	HashMap<String, String> returnMap = new HashMap<String, String>();
 	for (Object obj : ((Class<?>) classType).getEnumConstants()) {
-	    System.out.print("class:" + obj.getClass());
 	    String valueOfEnum;
 	    try {
 		Method method = obj.getClass().getMethod("value");
@@ -108,8 +107,6 @@
 	    }
 	    Method method = cl.getMethod("fromValue", String.class);
 	    Object obj = method.invoke(null, value);
-	    System.out.print("returning:" + obj);
-	    System.out.print("returning:" + obj.getClass());
 	    return obj;
 	} catch (Exception e) {
 	    throw new WiseRuntimeException("Type format error", e);

Modified: webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/ParameterizedWiseTreeElement.java
===================================================================
--- webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/ParameterizedWiseTreeElement.java	2013-02-01 23:42:03 UTC (rev 482)
+++ webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/ParameterizedWiseTreeElement.java	2013-02-01 23:45:18 UTC (rev 483)
@@ -25,7 +25,6 @@
 import javax.xml.bind.annotation.XmlElementDecl;
 import javax.xml.ws.Holder;
 
-import org.jboss.logging.Logger;
 import org.jboss.wise.core.client.WSDynamicClient;
 import org.jboss.wise.core.exception.WiseRuntimeException;
 import org.jboss.wise.core.utils.IDGenerator;
@@ -129,7 +128,6 @@
 	    }
 	    if (methodToUse != null) {
 		Object obj = objectFactoryClass.newInstance();
-		Logger.getLogger(this.getClass()).debug(methodToUse + " with value=" + value);
 		return methodToUse.invoke(obj, new Object[] { value });
 	    } else {
 		return null;

Modified: webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/SimpleWiseTreeElement.java
===================================================================
--- webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/SimpleWiseTreeElement.java	2013-02-01 23:42:03 UTC (rev 482)
+++ webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/SimpleWiseTreeElement.java	2013-02-01 23:45:18 UTC (rev 483)
@@ -21,7 +21,6 @@
 import java.math.BigInteger;
 import java.net.URLEncoder;
 
-import org.jboss.logging.Logger;
 import org.jboss.wise.core.exception.WiseRuntimeException;
 import org.jboss.wise.core.utils.IDGenerator;
 import org.jboss.wise.core.utils.JavaUtils;
@@ -187,7 +186,6 @@
 	Class<?> cl = (Class<?>) classType;
 	if (cl.isPrimitive()) {
 	    cl = JavaUtils.getWrapperType(cl);
-	    Logger.getLogger(this.getClass()).debug("Wrapper class assigned: " + cl);
 	}
 	if ("java.lang.String".equalsIgnoreCase(cl.getName())) {
 	    return new String(value);

Modified: webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/WiseTreeElementBuilder.java
===================================================================
--- webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/WiseTreeElementBuilder.java	2013-02-01 23:42:03 UTC (rev 482)
+++ webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/WiseTreeElementBuilder.java	2013-02-01 23:45:18 UTC (rev 483)
@@ -46,12 +46,16 @@
  */
 public class WiseTreeElementBuilder {
     
-    private WSDynamicClient client;
-    private boolean request;
+    private static Logger logger = Logger.getLogger(WiseTreeElementBuilder.class);
     
+    private final WSDynamicClient client;
+    private final boolean request;
+    private final boolean trace;
+    
     public WiseTreeElementBuilder(WSDynamicClient client, boolean request) {
 	this.client = client;
 	this.request = request;
+	this.trace = logger.isTraceEnabled();
     }
     
     public WiseTreeElement buildTreeFromType(Type type, String name, Object value, boolean nillable) {
@@ -66,14 +70,11 @@
 	    				      String namespace,
 	    				      Map<Type, WiseTreeElement> typeMap,
 	    				      Set<Type> stack) {
-	Logger.getLogger(this.getClass()).debug("=> Converting parameter '" + name + "', type '" + type + "'");
+	if (trace) logger.trace("=> Converting parameter '" + name + "', type '" + type + "'");
 	if (type instanceof ParameterizedType) {
-	    Logger.getLogger(this.getClass()).debug("Parameterized type...");
 	    ParameterizedType pt = (ParameterizedType) type;
 	    return this.buildParameterizedType(pt, name, obj, scope, namespace, typeMap, stack);
 	} else {
-	    Logger.getLogger(this.getClass()).debug("Not a parameterized type... casting to Class");
-	    
 	    return this.buildFromClass((Class<?>) type, name, obj, nillable, typeMap, stack);
 
 	}
@@ -123,6 +124,7 @@
 	    				   Set<Type> stack) {
 
 	if (cl.isArray()) {
+	    if (trace) logger.trace("* array, component type: " + cl.getComponentType());
 	    if (byte.class.equals(cl.getComponentType())) {
 		ByteArrayWiseTreeElement element = new ByteArrayWiseTreeElement(cl, name, null);
 		if (obj != null) {
@@ -130,13 +132,11 @@
 		}
 		return element;
 	    }
-	    Logger.getLogger(this.getClass()).debug("* array");
-	    Logger.getLogger(this.getClass()).debug("Component type: " + cl.getComponentType());
 	    throw new WiseRuntimeException("Converter doesn't support this Object[] yet.");
 	}
 
 	if (isSimpleType(cl, client)) {
-	    Logger.getLogger(this.getClass()).debug("* simple");
+	    if (trace) logger.trace("* simple");
 	    SimpleWiseTreeElement element = SimpleWiseTreeElementFactory.create(cl, name, obj);
 	    if (!nillable) {
 		element.enforceNotNillable();
@@ -144,11 +144,11 @@
 	    return element;
 	} else { // complex
 	    if (request && stack.contains(cl)) {
-		Logger.getLogger(this.getClass()).debug("* lazy");
+		if (trace) logger.trace("* lazy");
 		return new LazyLoadWiseTreeElement(cl, name, typeMap);
 	    }
 	    
-	    Logger.getLogger(this.getClass()).debug("* complex");
+	    if (trace) logger.trace("* complex");
 	    
 	    ComplexWiseTreeElement complex = new ComplexWiseTreeElement(cl, name);
 	    if (request) {



More information about the wise-commits mailing list