Author: chris.laprun(a)jboss.com
Date: 2009-05-07 08:04:35 -0400 (Thu, 07 May 2009)
New Revision: 13318
Modified:
branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceWrapper.java
Log:
- Added timeout on WS operations so that we don't deadlock anymore when trying to
access a service that's not answering.
Modified:
branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceWrapper.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceWrapper.java 2009-05-07
11:54:24 UTC (rev 13317)
+++
branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal/wsrp/services/ServiceWrapper.java 2009-05-07
12:04:35 UTC (rev 13318)
@@ -1,24 +1,25 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
package org.jboss.portal.wsrp.services;
@@ -27,6 +28,7 @@
import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
import org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType;
+import javax.xml.rpc.Stub;
import javax.xml.rpc.soap.SOAPFaultException;
import java.lang.reflect.ParameterizedType;
import java.rmi.Remote;
@@ -43,6 +45,7 @@
{
protected T service;
protected ManageableServiceFactory parentFactory;
+ private static final String TIMEOUT_MS = "3000"; //todo: expose timeout so
that it can be changed from the GUI
protected ServiceWrapper(Object service, ManageableServiceFactory parentFactory)
{
@@ -52,6 +55,9 @@
}
Class serviceClass = service.getClass();
+
+ // org.jboss.ws.timeout corresponds to StubExt.PROPERTY_CLIENT_TIMEOUT, not using
it here to not be tied to implementation
+ ((Stub)service)._setProperty("org.jboss.ws.timeout", TIMEOUT_MS);
Class tClass =
(Class)((ParameterizedType)getClass().getGenericSuperclass()).getActualTypeArguments()[0];
if (tClass.isAssignableFrom(serviceClass))
{
@@ -88,7 +94,7 @@
throw new IllegalArgumentException("Unknow endpoint interface " +
expectedServiceInterface);
}
- return (T)wrapper;
+ return expectedServiceInterface.cast(wrapper);
}
protected void handleRemoteException(RemoteException e) throws RemoteException