You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by de...@apache.org on 2007/07/12 17:52:41 UTC
svn commit: r555674 -
/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/POJODeployer.java
Author: deepal
Date: Thu Jul 12 08:52:40 2007
New Revision: 555674
URL: http://svn.apache.org/viewvc?view=rev&rev=555674
Log:
Annotated POJO can deploy even when we do not have jax-ws in class path
Modified:
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/POJODeployer.java
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/POJODeployer.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/POJODeployer.java?view=diff&rev=555674&r1=555673&r2=555674
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/POJODeployer.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/POJODeployer.java Thu Jul 12 08:52:40 2007
@@ -98,44 +98,14 @@
JAnnotation annotation =
jclass.getAnnotation(AnnotationConstants.WEB_SERVICE);
if (annotation != null) {
- Class claxx = Class.forName(
- "org.apache.axis2.jaxws.description.DescriptionFactory");
- Method mthod = claxx.getMethod(
- "createAxisService",
- new Class[]{Class.class});
- Class pojoClass = Loader.loadClass(classLoader, className);
- AxisService axisService =
- (AxisService) mthod.invoke(claxx, new Object[]{pojoClass});
- Utils.fillAxisService(axisService,
- configCtx.getAxisConfiguration(),
- new ArrayList(),
- new ArrayList());
- setMessageReceivers(axisService);
+ // try to see whether JAX-WS jars in the class path , if so use them
+ // to process annotated pojo else use annogen to process the pojo class
+ AxisService axisService;
+ axisService = createAxisService(classLoader, className);
configCtx.getAxisConfiguration().addService(axisService);
} else {
- HashMap messageReciverMap = new HashMap();
- Class inOnlyMessageReceiver = Loader.loadClass(
- "org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver");
- MessageReceiver messageReceiver =
- (MessageReceiver) inOnlyMessageReceiver.newInstance();
- messageReciverMap.put(
- WSDL2Constants.MEP_URI_IN_ONLY,
- messageReceiver);
- Class inoutMessageReceiver = Loader.loadClass(
- "org.apache.axis2.rpc.receivers.RPCMessageReceiver");
- MessageReceiver inOutmessageReceiver =
- (MessageReceiver) inoutMessageReceiver.newInstance();
- messageReciverMap.put(
- WSDL2Constants.MEP_URI_IN_OUT,
- inOutmessageReceiver);
- messageReciverMap.put(WSDL2Constants.MEP_URI_ROBUST_IN_ONLY,
- inOutmessageReceiver);
- AxisService axisService =
- AxisService.createService(className,
- configCtx.getAxisConfiguration(),
- messageReciverMap,
- null, null,
- classLoader);
+ AxisService axisService = createAxisServiceUsingAnnogen(className,
+ classLoader);
configCtx.getAxisConfiguration().addService(axisService);
}
}
@@ -201,20 +171,8 @@
JAnnotation annotation =
jclass.getAnnotation(AnnotationConstants.WEB_SERVICE);
if (annotation != null) {
- Class claxx = Class.forName(
- "org.apache.axis2.jaxws.description.DescriptionFactory");
- Method mthod = claxx.getMethod(
- "createAxisService",
- new Class[]{Class.class});
- Class pojoClass = Loader.loadClass(classLoader, className);
- AxisService axisService =
- (AxisService) mthod.invoke(claxx, new Object[]{pojoClass});
- Utils.fillAxisService(axisService,
- configCtx.getAxisConfiguration(),
- new ArrayList(),
- new ArrayList());
- axisService.setName(className);
- setMessageReceivers(axisService);
+ AxisService axisService;
+ axisService = createAxisService(classLoader, className);
axisServiceList.add(axisService);
}
}
@@ -235,6 +193,65 @@
Thread.currentThread().setContextClassLoader(threadClassLoader);
}
}
+ }
+
+ private AxisService createAxisService(ClassLoader classLoader,
+ String className) throws ClassNotFoundException,
+ InstantiationException,
+ IllegalAccessException,
+ AxisFault {
+ AxisService axisService;
+ try {
+ Class claxx = Class.forName(
+ "org.apache.axis2.jaxws.description.DescriptionFactory");
+ Method mthod = claxx.getMethod(
+ "createAxisService",
+ new Class[]{Class.class});
+ Class pojoClass = Loader.loadClass(classLoader, className);
+ axisService =
+ (AxisService) mthod.invoke(claxx, new Object[]{pojoClass});
+ Utils.fillAxisService(axisService,
+ configCtx.getAxisConfiguration(),
+ new ArrayList(),
+ new ArrayList());
+ setMessageReceivers(axisService);
+
+ } catch (Exception e) {
+ // Seems like the jax-ws jars missin in the class path .
+ // lets tryu annogen
+ axisService = createAxisServiceUsingAnnogen(className,
+ classLoader);
+ }
+ return axisService;
+ }
+
+ private AxisService createAxisServiceUsingAnnogen(String className, ClassLoader classLoader)
+ throws ClassNotFoundException,
+ InstantiationException,
+ IllegalAccessException,
+ AxisFault {
+ HashMap messageReciverMap = new HashMap();
+ Class inOnlyMessageReceiver = Loader.loadClass(
+ "org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver");
+ MessageReceiver messageReceiver =
+ (MessageReceiver) inOnlyMessageReceiver.newInstance();
+ messageReciverMap.put( WSDL2Constants.MEP_URI_IN_ONLY,
+ messageReceiver);
+ Class inoutMessageReceiver = Loader.loadClass(
+ "org.apache.axis2.rpc.receivers.RPCMessageReceiver");
+ MessageReceiver inOutmessageReceiver =
+ (MessageReceiver) inoutMessageReceiver.newInstance();
+ messageReciverMap.put(WSDL2Constants.MEP_URI_IN_OUT,
+ inOutmessageReceiver);
+ messageReciverMap.put(WSDL2Constants.MEP_URI_ROBUST_IN_ONLY,
+ inOutmessageReceiver);
+ AxisService axisService =
+ AxisService.createService(className,
+ configCtx.getAxisConfiguration(),
+ messageReciverMap,
+ null, null,
+ classLoader);
+ return axisService;
}
public void setMessageReceivers(AxisService service) {
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org