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 2005/09/17 05:43:00 UTC
svn commit: r289696 - in /webservices/axis2/trunk/java/modules/core:
src/org/apache/axis2/context/
src/org/apache/axis2/deployment/repository/util/
src/org/apache/axis2/engine/ test-resources/deployment/ServiceGroup/
test-resources/deployment/ServiceGr...
Author: deepal
Date: Fri Sep 16 20:42:39 2005
New Revision: 289696
URL: http://svn.apache.org/viewcvs?rev=289696&view=rev
Log:
added ServiceGroup test cases , and changed code to make the service name unique across the system
Added:
webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/
webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/axis2.xml
webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/services/
webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/services/service1/
webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/services/service1/META-INF/
webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/services/service1/META-INF/services.xml
webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/services/service2/
webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/services/service2/META-INF/
webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/services/service2/META-INF/services.xml
webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/deployment/SameServiceAddingTest.java
Modified:
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceGroupContext.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfiguration.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfigurationImpl.java
webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/deployment/ServiceGroupTest.java
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java?rev=289696&r1=289695&r2=289696&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java Fri Sep 16 20:42:39 2005
@@ -229,8 +229,8 @@
public ServiceGroupContext fillServiceContextAndServiceGroupContext(MessageContext messageContext) throws AxisFault {
String serviceGroupContextId = messageContext.getServiceGroupContextId();
- ServiceGroupContext serviceGroupContext = null;
- ServiceContext serviceContext = null;
+ ServiceGroupContext serviceGroupContext;
+ ServiceContext serviceContext ;
if (!isNull(serviceGroupContextId) && serviceGroupContextMap.get(serviceGroupContextId) != null) {
// SGC is already there
serviceGroupContext = (ServiceGroupContext) serviceGroupContextMap.get(serviceGroupContextId);
@@ -253,9 +253,11 @@
messageContext.setServiceGroupContextId(serviceGroupContextId);
}
if(messageContext.getServiceDescription() !=null){
- String servicName = messageContext.getServiceDescription().getName().getLocalPart();
+// String servicName = messageContext.getServiceDescription().getName().getLocalPart();
ServiceGroupDescription servicGroupDescription =
- this.getAxisConfiguration().getServiceGroup(servicName);
+ messageContext.getServiceDescription().getParent();
+// ServiceGroupDescription servicGroupDescription =
+// this.getAxisConfiguration().getServiceGroup(servicName);
serviceGroupContext = servicGroupDescription.getServiceGroupContext(this);
serviceContext = serviceGroupContext.getServiceContext(
messageContext.getServiceDescription().getName().
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceGroupContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceGroupContext.java?rev=289696&r1=289695&r2=289696&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceGroupContext.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceGroupContext.java Fri Sep 16 20:42:39 2005
@@ -35,31 +35,31 @@
private Map serviceContextMap;
private transient ServiceGroupDescription description;
private String serviceGroupDescName=null;
-
- public void init(AxisConfiguration axisConfiguration) throws AxisFault {
- if (serviceGroupDescName!=null)
- description = axisConfiguration.getServiceGroup(serviceGroupDescName);
- }
-
+
+ public void init(AxisConfiguration axisConfiguration) throws AxisFault {
+ if (serviceGroupDescName!=null)
+ description = axisConfiguration.getServiceGroup(serviceGroupDescName);
+ }
+
private void writeObject(ObjectOutputStream out) throws IOException {
- if (description!=null)
- this.serviceGroupDescName = description.getServiceGroupName();
-
- out.defaultWriteObject();
+ if (description!=null)
+ this.serviceGroupDescName = description.getServiceGroupName();
+
+ out.defaultWriteObject();
}
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
- in.defaultReadObject();
- nonPersistentMap = new HashMap ();
+ in.defaultReadObject();
+ nonPersistentMap = new HashMap ();
}
public ServiceGroupContext(ConfigurationContext parent ,ServiceGroupDescription description) {
super(parent);
this.description = description;
serviceContextMap = new HashMap();
-
+
if (description!=null)
- this.serviceGroupDescName = description.getServiceGroupName();
+ this.serviceGroupDescName = description.getServiceGroupName();
fillServiceContexts();
}
@@ -86,9 +86,8 @@
while (services.hasNext()) {
ServiceDescription serviceDescription = (ServiceDescription) services.next();
ServiceContext serviceContext = new ServiceContext(serviceDescription,this);
- String [] servicNams = AxisConfigurationImpl.splitServiceName(
- serviceDescription.getName().getLocalPart());
- serviceContextMap.put(servicNams[1],serviceContext);
+ String servicNams = serviceDescription.getName().getLocalPart();
+ serviceContextMap.put(servicNams,serviceContext);
}
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java?rev=289696&r1=289695&r2=289696&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java Fri Sep 16 20:42:39 2005
@@ -224,7 +224,7 @@
} else {
File file = new File(filename, SERVICEXML);
if (file.exists()) {
- InputStream in = null;
+ InputStream in ;
try {
in = new FileInputStream(file);
buildServiceGroup(in,engine,serviceGroupDesc);
@@ -251,11 +251,11 @@
rootelementName = services.getLocalName();
if(SERVICE_ELEMENT.equals(rootelementName)){
ServiceDescription serviceDesc = engine.getCurrentFileItem().
- getService(new QName(builder.getShortFileName(
+ getService(new QName(DescriptionBuilder.getShortFileName(
engine.getCurrentFileItem().getName())));
if(serviceDesc == null){
serviceDesc = new ServiceDescription(
- new QName(builder.getShortFileName(
+ new QName(DescriptionBuilder.getShortFileName(
engine.getCurrentFileItem().getName())));
engine.getCurrentFileItem().addService(serviceDesc);
}
@@ -298,7 +298,7 @@
} else {
File file = new File(filename, MODULEXML);
if (file.exists()) {
- InputStream in = null;
+ InputStream in;
try {
in = new FileInputStream(file);
ModuleBuilder builder = new ModuleBuilder(in, engine, module);
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfiguration.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfiguration.java?rev=289696&r1=289695&r2=289696&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfiguration.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfiguration.java Fri Sep 16 20:42:39 2005
@@ -73,7 +73,7 @@
public void addService(ServiceDescription service) throws AxisFault;
//to Add service Groups
- public void addServiceGroup(ServiceGroupDescription serviceGroup);
+ public void addServiceGroup(ServiceGroupDescription serviceGroup) throws AxisFault;
/**
* Method removeService
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfigurationImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfigurationImpl.java?rev=289696&r1=289695&r2=289696&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfigurationImpl.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfigurationImpl.java Fri Sep 16 20:42:39 2005
@@ -255,13 +255,23 @@
addServiceGroup(serviceGroup);
}
- public void addServiceGroup(ServiceGroupDescription serviceGroup){
- serviceGroups.put(serviceGroup.getServiceGroupName(),serviceGroup);
+ public void addServiceGroup(ServiceGroupDescription serviceGroup) throws AxisFault {
Iterator services = serviceGroup.getServices();
+ ServiceDescription description ;
+ while (services.hasNext()) {
+ description = (ServiceDescription) services.next();
+ if(allservices.get(description.getName().getLocalPart()) !=null){
+ throw new AxisFault("Two service can not have same name, a service with " +
+ description.getName().getLocalPart() + " alredy exist in the system");
+ }
+ }
+ services = serviceGroup.getServices();
while (services.hasNext()) {
- ServiceDescription description = (ServiceDescription) services.next();
+ description = (ServiceDescription) services.next();
+ allservices.put(description.getName().getLocalPart(),description);
notifyObservers(AxisEvent.SERVICE_DEPLOY ,description);
}
+ serviceGroups.put(serviceGroup.getServiceGroupName(),serviceGroup);
}
/**
@@ -288,19 +298,7 @@
* @throws AxisFault
*/
public ServiceDescription getService(String name) throws AxisFault {
- String [] nameParts = splitServiceName(name);
- ServiceGroupDescription sg = getServiceGroup(nameParts[0]);
- if(sg == null){
- return null;
- } else {
- String servicName = nameParts[1];
- ServiceDescription service = sg.getService(new QName(servicName));
- if(service == null){
- return null;
- } else {
- return service;
- }
- }
+ return (ServiceDescription)allservices.get(name);
}
/**
@@ -310,11 +308,7 @@
* @throws AxisFault
*/
public synchronized void removeService(String name) throws AxisFault {
- String [] nameParts = splitServiceName(name);
- ServiceGroupDescription sg = getServiceGroup(nameParts[0]);
- if(sg != null){
- sg.removeService(new QName(nameParts[1]));
- }
+ allservices.remove(name);
}
public TransportInDescription getTransportIn(QName name) throws AxisFault {
@@ -371,8 +365,7 @@
}
public ServiceGroupDescription getServiceGroup(String serviceNameAndGroupString) {
- String serviceGroup [] = splitServiceName(serviceNameAndGroupString);
- return (ServiceGroupDescription)serviceGroups.get(serviceGroup[0]);
+ return (ServiceGroupDescription)serviceGroups.get(serviceNameAndGroupString);
}
public Iterator getServiceGroups() {
@@ -517,7 +510,7 @@
allservices.put(serviceDescription.getName().getLocalPart(),serviceDescription);
}
}
- return allservices;
+ return allservices;
}
public boolean isEngaged(QName moduleName) {
@@ -569,26 +562,26 @@
}
- /**
- * To split a given service name into it serviceGroupName and Service Name
- * if the service Name is foo:bar then serviceGroupName ="foo" and ServiceName ="bar"
- * but if the service name is only the foo we asume ServiceGroupName="foo" ans ServiceName="foo"
- * meaning foo := foo:foo
- * @param serviceName
- * @return String [] <code>String</code>
- */
- public static String [] splitServiceName(String serviceName){
- String namePart [] = new String[2];
- int index = serviceName.indexOf(Constants.SERVICE_NAME_SPLIT_CHAR);
- if(index > 0){
- namePart[0] = serviceName.substring(0,index);
- namePart[1] = serviceName.substring(index +1 ,serviceName.length());
- } else {
- namePart[0] = serviceName;
- namePart[1] = serviceName;
- }
- return namePart;
- }
+// /**
+// * To split a given service name into it serviceGroupName and Service Name
+// * if the service Name is foo:bar then serviceGroupName ="foo" and ServiceName ="bar"
+// * but if the service name is only the foo we asume ServiceGroupName="foo" ans ServiceName="foo"
+// * meaning foo := foo:foo
+// * @param serviceName
+// * @return String [] <code>String</code>
+// */
+// public static String [] splitServiceName(String serviceName){
+// String namePart [] = new String[2];
+// int index = serviceName.indexOf(Constants.SERVICE_NAME_SPLIT_CHAR);
+// if(index > 0){
+// namePart[0] = serviceName.substring(0,index);
+// namePart[1] = serviceName.substring(index +1 ,serviceName.length());
+// } else {
+// namePart[0] = serviceName;
+// namePart[1] = serviceName;
+// }
+// return namePart;
+// }
}
Added: webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/axis2.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/axis2.xml?rev=289696&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/axis2.xml (added)
+++ webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/axis2.xml Fri Sep 16 20:42:39 2005
@@ -0,0 +1,84 @@
+<axisconfig name="AxisJava2.0">
+ <!-- ================================================= -->
+ <!-- Parameters -->
+ <!-- ================================================= -->
+ <parameter name="hotdeployment" locked="false">true</parameter>
+ <parameter name="hotupdate" locked="false">false</parameter>
+ <parameter name="enableMTOM" locked="false">true</parameter>
+ <!-- Uncomment this to enable REST support -->
+ <!-- <parameter name="enableREST" locked="false">true</parameter>-->
+
+
+ <parameter name="userName" locked="false">admin</parameter>
+ <parameter name="password" locked="false">axis2</parameter>
+
+
+
+
+
+ <!-- ================================================= -->
+ <!-- Message Receivers -->
+ <!-- ================================================= -->
+ <!-- This is the Deafult Message Receiver for the Request Response style Operations -->
+ <messageReceiver mep="INOUT" class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+
+ <!-- ================================================= -->
+ <!-- Transport Ins -->
+ <!-- ================================================= -->
+ <transportReceiver name="http" class="org.apache.axis2.transport.http.SimpleHTTPServer">
+ <parameter name="port" locked="false">6060</parameter>
+ </transportReceiver>
+
+ <parameter name="extractServiceArchive" locked="false">true</parameter>
+
+ <!-- Uncomment this one with the appropriate papameters to enable the SMTP transport Receiver
+ <transportReceiver name="mail" class="org.apache.axis2.transport.mail.SimpleMailListener">
+ <parameter name="transport.mail.pop3.host" locked="false">127.0.0.1</parameter>
+ <parameter name="transport.mail.pop3.user" locked="false">axis2</parameter>
+ <parameter name="transport.mail.pop3.password" locked="false">axis2</parameter>
+ <parameter name="transport.mail.pop3.port" locked="false">110</parameter>
+ <parameter name="transport.mail.replyToAddress" locked="false">axis2@127.0.0.1</parameter>
+ </transportReceiver> -->
+
+ <transportReceiver name="tcp" class="org.apache.axis2.transport.tcp.TCPServer">
+ <parameter name="port" locked="false">6060</parameter>
+ </transportReceiver>
+
+ <!-- ================================================= -->
+ <!-- Transport Outs -->
+ <!-- ================================================= -->
+
+ <transportSender name="tcp" class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
+ <transportSender name="local" class="org.apache.axis2.transport.local.LocalTransportSender"/>
+ <transportSender name="http" class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL" locked="false">HTTP/1.0</parameter>
+ </transportSender>
+ <transportSender name="https" class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+ </transportSender>
+
+
+ <phaseOrder type="inflow">
+ <!-- System pre defined phases -->
+ <phase name="TransportIn"/>
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch"/>
+ <phase name="PostDispatch"/>
+ <!-- System pre defined phases -->
+ <!-- After Postdispatch phase module author or or service author can add any phase he want -->
+ <phase name="userphase1"/>
+ </phaseOrder>
+ <phaseOrder type="outflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="userphase1"/>
+ </phaseOrder>
+ <phaseOrder type="INfaultflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="userphase1"/>
+ </phaseOrder>
+ <phaseOrder type="Outfaultflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="userphase1"/>
+ </phaseOrder>
+</axisconfig>
+
Added: webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/services/service1/META-INF/services.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/services/service1/META-INF/services.xml?rev=289696&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/services/service1/META-INF/services.xml (added)
+++ webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/services/service1/META-INF/services.xml Fri Sep 16 20:42:39 2005
@@ -0,0 +1,7 @@
+<serviceGroup>
+ <service name="serevice1">
+ </service>
+
+ <service name="serevice4">
+ </service>
+</serviceGroup>
Added: webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/services/service2/META-INF/services.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/services/service2/META-INF/services.xml?rev=289696&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/services/service2/META-INF/services.xml (added)
+++ webservices/axis2/trunk/java/modules/core/test-resources/deployment/ServiceGroup/services/service2/META-INF/services.xml Fri Sep 16 20:42:39 2005
@@ -0,0 +1,7 @@
+<serviceGroup>
+ <service name="serevice1">
+ </service>
+
+ <service name="serevice2">
+ </service>
+</serviceGroup>
Added: webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/deployment/SameServiceAddingTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/deployment/SameServiceAddingTest.java?rev=289696&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/deployment/SameServiceAddingTest.java (added)
+++ webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/deployment/SameServiceAddingTest.java Fri Sep 16 20:42:39 2005
@@ -0,0 +1,50 @@
+package org.apache.axis2.deployment;
+
+import junit.framework.TestCase;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.ServiceGroupDescription;
+import org.apache.axis2.description.ServiceDescription;
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*
+*/
+
+/**
+ * Author: Deepal Jayasinghe
+ * Date: Sep 16, 2005
+ * Time: 11:29:06 PM
+ */
+public class SameServiceAddingTest extends TestCase {
+ AxisConfiguration ar;
+ String repo ="./test-resources/deployment/ServiceGroup";
+
+
+ public void testServiceGroup() throws AxisFault {
+ ConfigurationContextFactory builder = new ConfigurationContextFactory();
+ ar = builder.buildConfigurationContext(repo).getAxisConfiguration();
+ ServiceDescription servie = ar.getService("serevice1");
+ assertNotNull(servie);
+ servie = ar.getService("serevice4");
+ assertNotNull(servie);
+
+ servie = ar.getService("serevice2");
+ assertEquals(null,servie);
+ assertEquals(null,ar.getServiceGroup("service2"));
+ }
+
+}
Modified: webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/deployment/ServiceGroupTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/deployment/ServiceGroupTest.java?rev=289696&r1=289695&r2=289696&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/deployment/ServiceGroupTest.java (original)
+++ webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/deployment/ServiceGroupTest.java Fri Sep 16 20:42:39 2005
@@ -36,9 +36,9 @@
public void testServiceGroup() throws AxisFault {
ServiceGroupDescription sgd = ar.getServiceGroup("serviceGroup");
assertNotNull(sgd);
- ServiceDescription service1 = ar.getService("serviceGroup:service1");
+ ServiceDescription service1 = ar.getService("service1");
assertNotNull(service1);
- ServiceDescription service2 = ar.getService("serviceGroup:service2");
+ ServiceDescription service2 = ar.getService("service2");
assertNotNull(service2);
}