Author: richard.opalka(a)jboss.com
Date: 2010-10-18 08:35:54 -0400 (Mon, 18 Oct 2010)
New Revision: 13147
Added:
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinder.java
Modified:
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXRPC.java
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java
Log:
refactoring - adding new SPI methods
Added:
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinder.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinder.java
(rev 0)
+++
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinder.java 2010-10-18
12:35:54 UTC (rev 13147)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.wsf.common.serviceref;
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.Referenceable;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.naming.Util;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
+
+/**
+ * Abstract service ref binder.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+abstract class AbstractServiceRefBinder implements ServiceRefBinder
+{
+ private static final Logger log = Logger.getLogger(AbstractServiceRefBinder.class);
+
+ @Deprecated
+ public final void setupServiceRef(final Context encCtx, final String encName, final
AnnotatedElement ignored,
+ final UnifiedServiceRefMetaData serviceRef, final ClassLoader loader) throws
NamingException
+ {
+ final Referenceable jndiReferenceable = this.createReferenceable(serviceRef,
loader);
+ this.bind(encCtx, encName, jndiReferenceable);
+ }
+
+ public abstract Referenceable createReferenceable(final UnifiedServiceRefMetaData
serviceRef,
+ final ClassLoader loader);
+
+ private void bind(final Context encCtx, final String encName, final Referenceable
jndiReferenceable)
+ throws NamingException
+ {
+ final String jndiFullName = encCtx.getNameInNamespace() + "/" + encName;
+
+ log.info("binding service reference to [jndi=" + jndiFullName +
"]");
+ Util.bind(encCtx, encName, jndiReferenceable);
+ }
+}
Modified:
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXRPC.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXRPC.java 2010-10-18
12:32:46 UTC (rev 13146)
+++
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXRPC.java 2010-10-18
12:35:54 UTC (rev 13147)
@@ -21,41 +21,27 @@
*/
package org.jboss.wsf.common.serviceref;
-import java.lang.reflect.AnnotatedElement;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
import javax.naming.Referenceable;
-import org.jboss.logging.Logger;
-import org.jboss.util.naming.Util;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
/**
- * Binds a JAXRPC Service object in the client's ENC for every service-ref element in
the
- * deployment descriptor.
+ * Binds a JAXRPC service object factory to the client's ENC.
*
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
*/
-public abstract class AbstractServiceRefBinderJAXRPC implements ServiceRefBinder
+public abstract class AbstractServiceRefBinderJAXRPC extends AbstractServiceRefBinder
{
- // logging support
- private static Logger log = Logger.getLogger(AbstractServiceRefBinderJAXRPC.class);
-
- /**
- * Binds a Service into the callers ENC for every service-ref element
- */
- public void setupServiceRef(Context encCtx, String encName, AnnotatedElement ignored,
- UnifiedServiceRefMetaData serviceRef, ClassLoader loader) throws
NamingException
+ public final Referenceable createReferenceable(final UnifiedServiceRefMetaData
serviceRef, final ClassLoader ignored)
{
- String externalName = encCtx.getNameInNamespace() + "/" + encName;
- log.info("setupServiceRef [jndi=" + externalName + "]");
-
- // Do not use rebind, the binding should be unique
- Referenceable ref = this.createReferenceable(serviceRef);
- Util.bind(encCtx, encName, ref);
+ return this.createJAXRPCReferenceable(serviceRef);
}
- protected abstract Referenceable createReferenceable(UnifiedServiceRefMetaData
serviceRef);
+ /**
+ * Template method for creating stack specific JAXRPC referenceables.
+ *
+ * @param serviceRef service reference UMDM
+ * @return stack specific JAXRPC JNDI referenceable
+ */
+ protected abstract Referenceable createJAXRPCReferenceable(final
UnifiedServiceRefMetaData serviceRef);
}
Modified:
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java
===================================================================
---
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java 2010-10-18
12:32:46 UTC (rev 13146)
+++
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java 2010-10-18
12:35:54 UTC (rev 13147)
@@ -31,8 +31,6 @@
import java.util.List;
import javax.jws.HandlerChain;
-import javax.naming.Context;
-import javax.naming.NamingException;
import javax.naming.Referenceable;
import javax.xml.namespace.QName;
import javax.xml.ws.RespectBinding;
@@ -43,23 +41,18 @@
import javax.xml.ws.soap.Addressing;
import javax.xml.ws.soap.MTOM;
-import org.jboss.logging.Logger;
-import org.jboss.util.naming.Util;
import org.jboss.wsf.spi.WSFException;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
/**
- * Binds a JAXWS Service object in the client's ENC.
+ * Binds a JAXWS service object factory to the client's ENC.
*
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
*/
-public abstract class AbstractServiceRefBinderJAXWS implements ServiceRefBinder
+public abstract class AbstractServiceRefBinderJAXWS extends AbstractServiceRefBinder
{
- private static Logger log = Logger.getLogger(AbstractServiceRefBinderJAXWS.class);
-
- public void setupServiceRef(Context encCtx, String encName, AnnotatedElement ignored,
- UnifiedServiceRefMetaData serviceRef, ClassLoader loader) throws
NamingException
+ public final Referenceable createReferenceable(final UnifiedServiceRefMetaData
serviceRef, final ClassLoader loader)
{
WebServiceRef wsref = null;
@@ -119,7 +112,7 @@
{
for (WebServiceRef aux : wsrefList)
{
- if (encName.endsWith("/" + aux.name()))
+ if (serviceRef.getServiceRefName().endsWith("/" + aux.name()))
{
wsref = aux;
break;
@@ -127,7 +120,7 @@
}
}
- Class targetClass = null;
+ Class<?> targetClass = null;
if (anElement instanceof Field)
{
targetClass = ((Field) anElement).getType();
@@ -143,9 +136,6 @@
}
String targetClassName = (targetClass != null ? targetClass.getName() : null);
- String externalName = encCtx.getNameInNamespace() + "/" + encName;
- if (log.isDebugEnabled())
- log.debug("setupServiceRef [jndi=" + externalName +
",target=" + targetClassName + "]");
String serviceImplClass = null;
@@ -195,13 +185,13 @@
}
catch (MalformedURLException ex)
{
- Class declaringClass = null;
+ Class<?> declaringClass = null;
if (anElement instanceof Field)
declaringClass = ((Field) anElement).getDeclaringClass();
else if (anElement instanceof Method)
declaringClass = ((Method) anElement).getDeclaringClass();
else if (anElement instanceof Class)
- declaringClass = (Class) anElement;
+ declaringClass = (Class<?>) anElement;
handlerChain = declaringClass.getPackage().getName().replace('.',
'/') + "/" + handlerChain;
}
@@ -214,7 +204,7 @@
{
try
{
- Class serviceClass = loader.loadClass(serviceImplClass);
+ Class<?> serviceClass = loader.loadClass(serviceImplClass);
if (serviceClass.getAnnotation(WebServiceClient.class) != null)
{
WebServiceClient clientDecl = (WebServiceClient)
serviceClass.getAnnotation(WebServiceClient.class);
@@ -250,11 +240,17 @@
serviceRef.setRespectBindingEnabled(respectBindingAnnotation.enabled());
}
- Referenceable serviceReferenceable = this.createReferenceable(serviceImplClass,
targetClassName, serviceRef);
- Util.bind(encCtx, encName, serviceReferenceable);
-
+ return this.createJAXWSReferenceable(serviceImplClass, targetClassName,
serviceRef);
}
- protected abstract Referenceable createReferenceable(String serviceImplClass, String
targetClassName,
- UnifiedServiceRefMetaData serviceRef);
+ /**
+ * Template method for creating stack specific JAXWS referenceables.
+ *
+ * @param serviceImplClass service implementation class name
+ * @param targetClassName target class name
+ * @param serviceRef service reference UMDM
+ * @return stack specific JAXWS JNDI referenceable
+ */
+ protected abstract Referenceable createJAXWSReferenceable(final String
serviceImplClass,
+ final String targetClassName, final UnifiedServiceRefMetaData serviceRef);
}