openamf/src/java/org/openamf AdvancedGateway.java,1.7,1.8 ServiceRequest.java,1.4,1.5
[email protected] Thu, 01 May 2003 09:22:09 -0700
Newsgroups
gmane.comp.java.openamf.cvs
Message-ID
<[email protected] >
Update of /cvsroot/openamf/openamf/src/java/org/openamf
In directory sc8-pr-cvs1:/tmp/cvs-serv4930/src/java/org/openamf
Modified Files:
AdvancedGateway.java ServiceRequest.java
Log Message:
1) renamed ServiceOperationConfig to ServiceMethodConfig
2) renamed ServiceOperationParameterConfig to ServiceMethodParameterConfig
3) moved state-bean-ref from Service to Service Method
4) cached serviceConfig and serviceMethodConfig in request
Index: AdvancedGateway.java
===================================================================
RCS file: /cvsroot/openamf/openamf/src/java/org/openamf/AdvancedGateway.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** AdvancedGateway.java 30 Apr 2003 19:40:29 -0000 1.7
--- AdvancedGateway.java 1 May 2003 16:22:06 -0000 1.8
***************
*** 11,16 ****
import org.openamf.config.Config;
import org.openamf.config.ServiceConfig;
! import org.openamf.config.ServiceOperationConfig;
! import org.openamf.config.ServiceOperationParameterConfig;
import org.openamf.config.StateBeanConfig;
import org.openamf.config.TranslatorConfig;
--- 11,16 ----
import org.openamf.config.Config;
import org.openamf.config.ServiceConfig;
! import org.openamf.config.ServiceMethodConfig;
! import org.openamf.config.ServiceMethodParameterConfig;
import org.openamf.config.StateBeanConfig;
import org.openamf.config.TranslatorConfig;
***************
*** 38,54 ****
new ServiceRequest(requestBody, serviceConfig);
! for (Iterator i = serviceConfig.getStateBeanConfigs();
! i.hasNext();
! ) {
!
! StateBeanConfig stateBeanConfig = (StateBeanConfig) i.next();
! log.debug("loading " + stateBeanConfig.getClassName());
! Class stateBeanClass =
! Thread.currentThread().getContextClassLoader().loadClass(
! stateBeanConfig.getClassName());
! Object stateBean = stateBeanClass.newInstance();
! request.addParameter(stateBean);
! }
serviceInvoker =
ServiceInvoker.load(
--- 38,46 ----
new ServiceRequest(requestBody, serviceConfig);
! ServiceMethodConfig methodConfig =
! getMethodConfig(serviceConfig, request);
+ addStateBeansToParams(request, methodConfig);
+
serviceInvoker =
ServiceInvoker.load(
***************
*** 64,67 ****
--- 56,80 ----
}
+ private void addStateBeansToParams(
+ ServiceRequest request,
+ ServiceMethodConfig methodConfig)
+ throws ClassNotFoundException, InstantiationException, IllegalAccessException {
+
+ if (methodConfig != null) {
+ for (Iterator i = methodConfig.getStateBeanConfigs();
+ i.hasNext();
+ ) {
+
+ StateBeanConfig stateBeanConfig = (StateBeanConfig) i.next();
+ log.debug("loading " + stateBeanConfig.getClassName());
+ Class stateBeanClass =
+ Thread.currentThread().getContextClassLoader().loadClass(
+ stateBeanConfig.getClassName());
+ Object stateBean = stateBeanClass.newInstance();
+ request.addParameter(stateBean);
+ }
+ }
+ }
+
protected Object postInvokeService(
HttpServletRequest httpServletRequest,
***************
*** 70,84 ****
throws ServiceInvocationException {
! ServiceOperationConfig operationConfig = null;
try {
! operationConfig = getOperationConfig(serviceInvoker.getRequest());
- if (operationConfig != null
- && operationConfig.getResultTranslatorConfig() != null) {
-
serviceResult =
translateResult(
serviceResult,
! operationConfig.getResultTranslatorConfig());
}
--- 83,97 ----
throws ServiceInvocationException {
! ServiceMethodConfig methodConfig =
! serviceInvoker.getRequest().getServiceMethodConfig();
!
try {
! if (methodConfig != null
! && methodConfig.getResultTranslatorConfig() != null) {
serviceResult =
translateResult(
serviceResult,
! methodConfig.getResultTranslatorConfig());
}
***************
*** 128,132 ****
}
! private ServiceOperationConfig getOperationConfig(ServiceRequest request)
throws IOException, SAXException, ClassNotFoundException {
--- 141,147 ----
}
! private ServiceMethodConfig getMethodConfig(
! ServiceConfig serviceConfig,
! ServiceRequest request)
throws IOException, SAXException, ClassNotFoundException {
***************
*** 134,162 ****
log.debug("looking for " + request.getServiceMethodName());
! ServiceOperationConfig operationConfig = null;
ArrayList parameters = request.getParameters();
! Iterator socs =
! getServiceConfig(request.getRequestBody()).getOperationConfigs();
! socsLabel : while (socs.hasNext()) {
! ServiceOperationConfig soc = (ServiceOperationConfig) socs.next();
! log.debug("soc name: " + soc.getName());
! if (soc.getName().equals(request.getServiceMethodName())) {
log.debug("name matches, now to compare params");
//compare params
int paramIndex = -1;
! Iterator sopcs = soc.getParameterConfigs();
! sopcsLabel : while (sopcs.hasNext()) {
paramIndex++;
! ServiceOperationParameterConfig sopc =
! (ServiceOperationParameterConfig) sopcs.next();
if (sopc.getType().equals("*")) {
log.debug("matches the rest");
! operationConfig = soc;
! break socsLabel;
} else if (
sopc.getType().equals("?")
--- 149,176 ----
log.debug("looking for " + request.getServiceMethodName());
! ServiceMethodConfig methodConfig = null;
ArrayList parameters = request.getParameters();
! Iterator smcs = serviceConfig.getMethodConfigs();
! smcsLabel : while (smcs.hasNext()) {
! ServiceMethodConfig smc = (ServiceMethodConfig) smcs.next();
! log.debug("soc name: " + smc.getName());
! if (smc.getName().equals(request.getServiceMethodName())) {
log.debug("name matches, now to compare params");
//compare params
int paramIndex = -1;
! Iterator sopcs = smc.getParameterConfigs();
! smpcsLabel : while (sopcs.hasNext()) {
paramIndex++;
! ServiceMethodParameterConfig sopc =
! (ServiceMethodParameterConfig) sopcs.next();
if (sopc.getType().equals("*")) {
log.debug("matches the rest");
! methodConfig = smc;
! break smcsLabel;
} else if (
sopc.getType().equals("?")
***************
*** 164,173 ****
if (paramIndex == parameters.size()) {
log.debug("all parameters match");
! operationConfig = soc;
! break socsLabel;
} else {
log.debug(
"this parameter matches, contine checking the rest");
! continue sopcsLabel;
}
}
--- 178,187 ----
if (paramIndex == parameters.size()) {
log.debug("all parameters match");
! methodConfig = smc;
! break smcsLabel;
} else {
log.debug(
"this parameter matches, contine checking the rest");
! continue smpcsLabel;
}
}
***************
*** 176,180 ****
}
! return operationConfig;
}
--- 190,197 ----
}
! //store methodConfig in request so we don't have to get it again
! request.setServiceMethodConfig(methodConfig);
!
! return methodConfig;
}
***************
*** 182,186 ****
ArrayList parameters,
int paramIndex,
! ServiceOperationParameterConfig sopc)
throws ClassNotFoundException {
--- 199,203 ----
ArrayList parameters,
int paramIndex,
! ServiceMethodParameterConfig sopc)
throws ClassNotFoundException {
Index: ServiceRequest.java
===================================================================
RCS file: /cvsroot/openamf/openamf/src/java/org/openamf/ServiceRequest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ServiceRequest.java 30 Apr 2003 19:40:30 -0000 1.4
--- ServiceRequest.java 1 May 2003 16:22:06 -0000 1.5
***************
*** 4,11 ****
--- 4,14 ----
import org.openamf.config.ServiceConfig;
+ import org.openamf.config.ServiceMethodConfig;
public class ServiceRequest {
private AMFBody requestBody;
+ private ServiceConfig serviceConfig;
+ private ServiceMethodConfig methodConfig;
private String target;
private String serviceName;
***************
*** 19,22 ****
--- 22,26 ----
public ServiceRequest(AMFBody requestBody, ServiceConfig serviceConfig) {
this.requestBody = requestBody;
+ this.serviceConfig = serviceConfig;
this.target = requestBody.getTarget();
if (serviceConfig == null) {
***************
*** 40,44 ****
--- 44,60 ----
requestBody = body;
}
+
+ public ServiceConfig getServiceConfig() {
+ return serviceConfig;
+ }
+ public ServiceMethodConfig getServiceMethodConfig() {
+ return methodConfig;
+ }
+
+ void setServiceMethodConfig(ServiceMethodConfig methodConfig) {
+ this.methodConfig = methodConfig;
+ }
+
public String getTarget() {
return target;
***************
*** 76,79 ****
--- 92,96 ----
parameters.add(stateBean);
}
+
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf