axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ngalla...@apache.org
Subject svn commit: r469381 [1/2] - in /webservices/axis2/trunk/java/modules/jaxws: ./ src/javax/annotation/ src/org/apache/axis2/jaxws/context/ src/org/apache/axis2/jaxws/context/factory/ src/org/apache/axis2/jaxws/context/utils/ src/org/apache/axis2/jaxws/co...
Date Tue, 31 Oct 2006 05:56:21 GMT
Author: ngallardo
Date: Mon Oct 30 21:56:19 2006
New Revision: 469381

URL: http://svn.apache.org/viewvc?view=rev&rev=469381
Log:
AXIS2-1553
Contributor: Nikhil Thaker

Nikhil's patch for @Resource injection of the WebServiceContext and the endpoint lifecycle.

Added:
    webservices/axis2/trunk/java/modules/jaxws/src/javax/annotation/
    webservices/axis2/trunk/java/modules/jaxws/src/javax/annotation/PostConstruct.java
    webservices/axis2/trunk/java/modules/jaxws/src/javax/annotation/PreDestroy.java
    webservices/axis2/trunk/java/modules/jaxws/src/javax/annotation/Resource.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/WebServiceContextImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/factory/
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/factory/MessageContextFactory.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUitls.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/factory/
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/factory/EndpointDispatcherFactory.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/ResourceInjector.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/WebServiceContextInjector.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/factory/
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/factory/ResourceInjectionFactory.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/impl/
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/impl/ResourceInjectionException.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/impl/WebServiceContextInjectorImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/EndpointLifecycleException.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/EndpointLifecycleManager.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/factory/
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/factory/EndpointLifecycleManagerFactory.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/impl/
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/impl/EndpointLifecycleManagerImpl.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/injection/
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/injection/ResourceInjectionTestImpl1.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/injection/ResourceInjectionTestImpl2.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/injection/ResourceInjectionTestImpl3.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/injection/ResourceInjectionTestImpl4.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/injection/ResourceInjectionTestImpl5.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/injection/ResourceInjectionTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/lifecycle/
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/lifecycle/EndpointLifecycleTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/resourceinjection/
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/resourceinjection/META-INF/
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/resourceinjection/META-INF/resourceinjection.wsdl
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/resourceinjection/META-INF/services.xml
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/resourceinjection/ResourceInjectionPortTypeImpl.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/resourceinjection/sei/
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/resourceinjection/sei/ResourceInjectionPortType.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/resourceinjection/sei/ResourceInjectionService.java
Modified:
    webservices/axis2/trunk/java/modules/jaxws/maven.xml
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/util/MessageContextUtils.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/ProtectedMessageContext.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/SoapMessageContext.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/registry/FactoryRegistry.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaDispatcher.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java

Modified: webservices/axis2/trunk/java/modules/jaxws/maven.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/maven.xml?view=diff&rev=469381&r1=469380&r2=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/maven.xml (original)
+++ webservices/axis2/trunk/java/modules/jaxws/maven.xml Mon Oct 30 21:56:19 2006
@@ -127,6 +127,15 @@
     	            <classpath location="${compiled.classes.dir}"/>
     	            <arg line="-d ${schema.generated.src.dir} -wsdl ${wsdl.source.dir}/EchoMessage.wsdl"/>
     	        </java>
+    	<ant:echo>Generating java from resourceinjection.wsdl for javabean endpoint Resource Injection support</ant:echo>
+		<!--
+    	<java classname="com.sun.tools.xjc.Driver" fork="true"> 
+    	    <jvmarg line="${maven.junit.jvmargs}"/>
+    	    <classpath refid="maven.dependency.classpath"/>
+    	    <classpath location="${compiled.classes.dir}"/>
+    	    <arg line="-d ${schema.generated.src.dir} -quiet -wsdl ${wsdl.source.dir}/resourceinjection.wsdl"/>
+    	 </java>
+    	 -->
     	 
     	<!-- Compile the generated classes -->
     	<ant:echo>Compiling generated schema</ant:echo>
@@ -350,6 +359,17 @@
 			   <ant:include name="org/apache/axis2/jaxws/nonanonymous/complextype/**"/>
 			</ant:fileset>
 			<ant:fileset dir="test/org/apache/axis2/jaxws/nonanonymous/complextype">
+			   <ant:include name="META-INF/**"/>
+			</ant:fileset>
+			<ant:fileset dir="target/classes">
+			   <ant:include name="org/apache/axis2/jaxws/server/**"/>
+			</ant:fileset>
+		</ant:copy>
+		<ant:copy toDir="target/test-classes/services/ResourceInjectionService/">
+			<ant:fileset dir="target/test-classes">
+			   <ant:include name="org/apache/axis2/jaxws/resourceinjection/**"/>
+			</ant:fileset>
+			<ant:fileset dir="test/org/apache/axis2/jaxws/resourceinjection">
 			   <ant:include name="META-INF/**"/>
 			</ant:fileset>
 			<ant:fileset dir="target/classes">

Added: webservices/axis2/trunk/java/modules/jaxws/src/javax/annotation/PostConstruct.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/javax/annotation/PostConstruct.java?view=auto&rev=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/javax/annotation/PostConstruct.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/javax/annotation/PostConstruct.java Mon Oct 30 21:56:19 2006
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * 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.
+ */
+package javax.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface PostConstruct {
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/javax/annotation/PreDestroy.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/javax/annotation/PreDestroy.java?view=auto&rev=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/javax/annotation/PreDestroy.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/javax/annotation/PreDestroy.java Mon Oct 30 21:56:19 2006
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * 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.
+ */
+package javax.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface PreDestroy {
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/javax/annotation/Resource.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/javax/annotation/Resource.java?view=auto&rev=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/javax/annotation/Resource.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/javax/annotation/Resource.java Mon Oct 30 21:56:19 2006
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * 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.
+ */
+package javax.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Resource {
+	public enum AuthenticationType{CONTAINER, APPLICATION};
+	String name() default "";
+	
+	Class type() default Object.class;
+	AuthenticationType authenticationType() default AuthenticationType.CONTAINER;
+	
+	boolean shareable() default true;
+	String mappedName() default "";
+	String description() default "";
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/WebServiceContextImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/WebServiceContextImpl.java?view=auto&rev=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/WebServiceContextImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/WebServiceContextImpl.java Mon Oct 30 21:56:19 2006
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.axis2.jaxws.context;
+
+import java.security.Principal;
+
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
+
+
+public class WebServiceContextImpl implements WebServiceContext {
+
+	private MessageContext soapMessageContext;
+	public WebServiceContextImpl() {
+		super();
+		// TODO Auto-generated constructor stub
+	}
+
+	/* (non-Javadoc)
+	 * @see javax.xml.ws.WebServiceContext#getMessageContext()
+	 */
+	public MessageContext getMessageContext() {
+		return soapMessageContext;
+	}
+
+	/* (non-Javadoc)
+	 * @see javax.xml.ws.WebServiceContext#getUserPrincipal()
+	 */
+	public Principal getUserPrincipal() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see javax.xml.ws.WebServiceContext#isUserInRole(java.lang.String)
+	 */
+	public boolean isUserInRole(String s) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+	
+	public void setSoapMessageContext(MessageContext soapMessageContext){
+		this.soapMessageContext = soapMessageContext;
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/factory/MessageContextFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/factory/MessageContextFactory.java?view=auto&rev=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/factory/MessageContextFactory.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/factory/MessageContextFactory.java Mon Oct 30 21:56:19 2006
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.axis2.jaxws.context.factory;
+
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
+
+import org.apache.axis2.jaxws.context.WebServiceContextImpl;
+import org.apache.axis2.jaxws.handler.ProtectedMessageContext;
+import org.apache.axis2.jaxws.handler.SoapMessageContext;
+
+
+public class MessageContextFactory {
+
+	public MessageContextFactory() {
+		super();
+		
+	}
+
+	public static WebServiceContext createWebServiceContext(){
+		return new WebServiceContextImpl();
+	}
+	
+	public static MessageContext createSoapMessageContext(org.apache.axis2.jaxws.core.MessageContext jaxwsMessageContext){
+		return new SoapMessageContext(jaxwsMessageContext);
+	}
+	
+	public static MessageContext createProtectedMessageContext(org.apache.axis2.jaxws.core.MessageContext jaxwsMessageContext){
+		return new ProtectedMessageContext(jaxwsMessageContext);
+	}
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUitls.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUitls.java?view=auto&rev=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUitls.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUitls.java Mon Oct 30 21:56:19 2006
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.axis2.jaxws.context.utils;
+
+import javax.xml.ws.handler.MessageContext.Scope;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.apache.axis2.Constants;
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.description.ServiceDescription;
+import org.apache.axis2.jaxws.util.WSDLWrapper;
+import org.apache.axis2.transport.http.HTTPConstants;
+
+public class ContextUitls {
+
+	public ContextUitls() {
+		super();
+	}
+
+	public static void addProperties(SOAPMessageContext soapMessageContext, MessageContext jaxwsMessageContext){
+		
+		   org.apache.axis2.context.MessageContext axisMsgContext = jaxwsMessageContext.getAxisMessageContext();
+		   //Set wsdl related properties.
+		   ServiceDescription sd = jaxwsMessageContext.getServiceDescription();
+		   WSDLWrapper wsdlWrapper = sd.getWSDLWrapper();
+		   if(wsdlWrapper!=null){
+			   soapMessageContext.put(javax.xml.ws.handler.MessageContext.WSDL_DESCRIPTION, wsdlWrapper.getDefinition());
+			   soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.WSDL_DESCRIPTION, Scope.APPLICATION);
+		   }
+		   soapMessageContext.put(javax.xml.ws.handler.MessageContext.WSDL_OPERATION, axisMsgContext.getAxisOperation().getName());
+		   soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.WSDL_OPERATION, Scope.APPLICATION);
+			   
+		   soapMessageContext.put(javax.xml.ws.handler.MessageContext.WSDL_PORT, null);
+		   soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.WSDL_PORT, Scope.APPLICATION);
+			   
+		   soapMessageContext.put(javax.xml.ws.handler.MessageContext.WSDL_SERVICE, axisMsgContext.getAxisService().getName());
+		   soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.WSDL_SERVICE,Scope.APPLICATION );
+		   
+		   soapMessageContext.put(javax.xml.ws.handler.MessageContext.WSDL_INTERFACE, null);
+		   soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.WSDL_INTERFACE, Scope.APPLICATION);
+		  
+		   
+		   //Setup all Servlet properties
+		   
+		   soapMessageContext.put(javax.xml.ws.handler.MessageContext.SERVLET_CONTEXT, axisMsgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETCONTEXT));
+		   soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.SERVLET_CONTEXT, Scope.APPLICATION);
+		   
+		   soapMessageContext.put(javax.xml.ws.handler.MessageContext.SERVLET_REQUEST, axisMsgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST));
+		   soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.SERVLET_REQUEST, Scope.APPLICATION);
+		   
+		   soapMessageContext.put(javax.xml.ws.handler.MessageContext.SERVLET_RESPONSE, axisMsgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE));
+		   soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.SERVLET_RESPONSE, Scope.APPLICATION);
+		   
+		   //All HTTP properties
+		   soapMessageContext.put(javax.xml.ws.handler.MessageContext.HTTP_REQUEST_HEADERS, axisMsgContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS));
+		   soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.HTTP_REQUEST_HEADERS, Scope.APPLICATION);
+		   
+		   soapMessageContext.put(javax.xml.ws.handler.MessageContext.HTTP_REQUEST_METHOD, axisMsgContext.getProperty(Constants.Configuration.HTTP_METHOD));
+		   soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.HTTP_REQUEST_METHOD, Scope.APPLICATION);
+		   
+		   soapMessageContext.put(javax.xml.ws.handler.MessageContext.HTTP_RESPONSE_CODE, axisMsgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE));
+		   soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.HTTP_RESPONSE_CODE, Scope.APPLICATION);
+		   
+		   soapMessageContext.put(javax.xml.ws.handler.MessageContext.HTTP_RESPONSE_HEADERS, null);
+		   soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.HTTP_RESPONSE_HEADERS, Scope.APPLICATION);
+		   
+		   //Message Properties
+		   soapMessageContext.put(javax.xml.ws.handler.MessageContext.MESSAGE_OUTBOUND_PROPERTY, null);
+		   soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.MESSAGE_OUTBOUND_PROPERTY, Scope.APPLICATION);
+		   
+		   soapMessageContext.put(javax.xml.ws.handler.MessageContext.MESSAGE_ATTACHMENTS, null);
+		   soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.MESSAGE_ATTACHMENTS, Scope.APPLICATION);
+		  
+	}
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/util/MessageContextUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/util/MessageContextUtils.java?view=diff&rev=469381&r1=469380&r2=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/util/MessageContextUtils.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/util/MessageContextUtils.java Mon Oct 30 21:56:19 2006
@@ -21,7 +21,6 @@
 import org.apache.axis2.jaxws.core.MessageContext;
 import org.apache.axis2.jaxws.message.MessageException;
 import org.apache.axis2.util.MessageContextBuilder;
-import org.apache.axis2.util.Utils;
 
 /**
  * A utility class for handling some of the common issues related to 

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/ProtectedMessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/ProtectedMessageContext.java?view=diff&rev=469381&r1=469380&r2=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/ProtectedMessageContext.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/ProtectedMessageContext.java Mon Oct 30 21:56:19 2006
@@ -17,10 +17,12 @@
 package org.apache.axis2.jaxws.handler;
 
 import java.util.Collection;
+import java.util.Hashtable;
 import java.util.Map;
 import java.util.Set;
 
 import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.message.Message;
 
 /**
  * The <tt>ProtectedMessageContext</tt> is the version of the MessageContext
@@ -32,7 +34,7 @@
 public class ProtectedMessageContext implements javax.xml.ws.handler.MessageContext {
     
     private MessageContext msgContext;
-
+    private Map<String, Scope> scope = new Hashtable<String, Scope>();
     public ProtectedMessageContext() {
         //do nothing
     }
@@ -42,11 +44,11 @@
     }
     
     public Scope getScope(String s) {
-        return null;
+        return scope.get(s);
     }
 
     public void setScope(String s, Scope scope) {
-        
+        this.scope.put(s, scope);
     }
     
     //--------------------------------------------------
@@ -99,5 +101,12 @@
 
     public Collection values() {
         return msgContext.getProperties().values();
+    }
+    
+    protected Message getMessageObject(){
+    	if(this.msgContext!=null){
+    		return this.msgContext.getMessage();
+    	}
+    	return null;
     }
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/SoapMessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/SoapMessageContext.java?view=diff&rev=469381&r1=469380&r2=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/SoapMessageContext.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/SoapMessageContext.java Mon Oct 30 21:56:19 2006
@@ -23,7 +23,10 @@
 import javax.xml.namespace.QName;
 import javax.xml.soap.SOAPMessage;
 
+import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.message.Message;
+import org.apache.axis2.jaxws.message.MessageException;
 
 /**
  * The SOAPMessageContext is the context handed to SOAP-based application
@@ -33,7 +36,7 @@
  */
 public class SoapMessageContext extends ProtectedMessageContext 
     implements javax.xml.ws.handler.soap.SOAPMessageContext {
-
+	
 	
     public SoapMessageContext() {
 		super();
@@ -47,8 +50,13 @@
         return null;
     }
 
-    public SOAPMessage getMessage() {
-        return null;
+    public SOAPMessage getMessage(){
+    	try{
+    		Message msg = getMessageObject();
+    		return msg.getAsSOAPMessage();
+    	}catch(MessageException e){
+    		throw ExceptionFactory.makeWebServiceException(e);
+    	}
     }
 
     public Set<URI> getRoles() {

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties?view=diff&rev=469381&r1=469380&r2=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties Mon Oct 30 21:56:19 2006
@@ -64,6 +64,8 @@
 JAXWSMessageReceiverNoServiceClass=The service class cannot be found for this AxisService.
 EndpointControllerErr2=The service class is not configured for this endpoint. Processing cannot continue.
 EndpointControllerErr4=The {0} provider implementation class cannot be loaded due to an error. Processing cannot continue.
+EndpointControllerErr5=A service implementation class cannot be found.
+EndpointControllerErr6=The service is unable to load the {0} service implementation class.
 BlockImplErr1=An internal error occurred. The block for {0} is already consumed. Processing cannot continue.
 XMLPartImplErr1=An internal error occurred. The XML part is already consumed.  Processing cannot continue.
 XMLPartImplErr2=An internal error occurred. The content of the XML part cannot be determined.
@@ -114,4 +116,12 @@
 validateUserName=Error: A value must be specified when setting the javax.xml.ws.security.auth.username property.
 validatePassword=Error: A value must be specified when setting the javax.xml.ws.security.auth.password property.
 checkUsernameAndPassword=Error: The javax.xml.ws.security.auth.username user name and the javax.xml.ws.security.auth.password password must be specified.
-JAXBBlockFactoryErr1=An internal assertion error occurred.  The context parameter of JAXBBlockFactory should be a JAXBBlockContext object, but a {0} object was found.
\ No newline at end of file
+JAXBBlockFactoryErr1=An internal assertion error occurred.  The context parameter of JAXBBlockFactory should be a JAXBBlockContext object, but a {0} object was found.
+WebServiceContextInjectionImplErr1=Cannot inject Resource on a null Service Instance.
+WebServiceContextInjectionImplErr2=Injection on Private and Protected set methods not supported yet.
+WebServiceContextInjectionImplErr3=Cannot inject WebServiceContext on ServiceInstance Field, field cannot be NULL.
+WebServiceContextInjectionImplErr4=Cannot inject WebServiceContext on ServiceInstance Method, method cannot be NULL.
+WebServiceContextInjectionImplErr5=Injection on Private and Protected Service Instance Field not supported yet.
+WebServiceContextInjectionImplErr6=injection can happen using method if method name starts with \"set\" returns a void and only has one parameter and the type of this parameter must be compatible with resource.
+ResourceInjectionFactoryErr1=Unknown Resource Type, Currently only Resource of Type javax.xml.ws.WebServiceContext can be injected.
+EndpointLifecycleManagerImplErr1=Failed to create EndpointLifecycleManager, Endpoint Instance cannot be null.

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/registry/FactoryRegistry.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/registry/FactoryRegistry.java?view=diff&rev=469381&r1=469380&r2=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/registry/FactoryRegistry.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/registry/FactoryRegistry.java Mon Oct 30 21:56:19 2006
@@ -37,6 +37,7 @@
 import org.apache.axis2.jaxws.message.impl.MessageFactoryImpl;
 import org.apache.axis2.jaxws.message.impl.XMLPartFactoryImpl;
 import org.apache.axis2.jaxws.message.util.impl.SAAJConverterFactoryImpl;
+import org.apache.axis2.jaxws.server.endpoint.lifecycle.factory.EndpointLifecycleManagerFactory;
 
 /**
  * FactoryRegistry
@@ -56,6 +57,7 @@
 		table.put(XMLPartFactory.class, new XMLPartFactoryImpl());
 		table.put(SAAJConverterFactory.class, new SAAJConverterFactoryImpl());
 		table.put(MethodMarshallerFactory.class, new MethodMarshallerFactory());
+		table.put(EndpointLifecycleManagerFactory.class, new EndpointLifecycleManagerFactory());
 	}
 	/**
 	 * FactoryRegistry is currently a static singleton

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java?view=diff&rev=469381&r1=469380&r2=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java Mon Oct 30 21:56:19 2006
@@ -16,8 +16,6 @@
  */
 package org.apache.axis2.jaxws.server;
 
-import javax.xml.ws.Provider;
-
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.jaxws.ExceptionFactory;
@@ -26,12 +24,16 @@
 import org.apache.axis2.jaxws.description.DescriptionFactory;
 import org.apache.axis2.jaxws.description.ServiceDescription;
 import org.apache.axis2.jaxws.i18n.Messages;
+import org.apache.axis2.jaxws.registry.FactoryRegistry;
 import org.apache.axis2.jaxws.server.dispatcher.EndpointDispatcher;
-import org.apache.axis2.jaxws.server.dispatcher.JavaBeanDispatcher;
-import org.apache.axis2.jaxws.server.dispatcher.ProviderDispatcher;
+import org.apache.axis2.jaxws.server.dispatcher.factory.EndpointDispatcherFactory;
+import org.apache.axis2.jaxws.server.endpoint.lifecycle.EndpointLifecycleManager;
+import org.apache.axis2.jaxws.server.endpoint.lifecycle.factory.EndpointLifecycleManagerFactory;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+
+
 /**
  * The EndpointController is the server side equivalent to the
  * InvocationController on the client side.  It is an abstraction of the server
@@ -47,7 +49,6 @@
     
     private static final Log log = LogFactory.getLog(EndpointController.class);
 	private static final String PARAM_SERVICE_CLASS = "ServiceClass";
-
     public EndpointController() {}
 
     /**
@@ -57,20 +58,22 @@
      * be stored  
      */
     public InvocationContext invoke(InvocationContext ic) {
-            MessageContext requestMsgCtx = ic.getRequestMessageContext();
+        MessageContext requestMsgCtx = ic.getRequestMessageContext();
 
-            String implClassName = getServiceImplClassName(requestMsgCtx);
+        String implClassName = getServiceImplClassName(requestMsgCtx);
             
-            Class implClass = loadServiceImplClass(implClassName, 
-                    requestMsgCtx.getClassLoader());
+        Class implClass = loadServiceImplClass(implClassName, 
+                 requestMsgCtx.getClassLoader());
             
-            ServiceDescription serviceDesc = getServiceDescription(requestMsgCtx, implClass);
-            requestMsgCtx.setServiceDescription(serviceDesc);
+        ServiceDescription serviceDesc = getServiceDescription(requestMsgCtx, implClass);
+        requestMsgCtx.setServiceDescription(serviceDesc);
 
 		MessageContext responseMsgContext = null;
 		
 		try {
-			EndpointDispatcher dispatcher = getEndpointDispatcher(implClass);
+			EndpointLifecycleManager elm = createEndpointlifecycleManager();
+			Object serviceInstance = elm.createServiceInstance(requestMsgCtx, implClass);
+			EndpointDispatcher dispatcher = getEndpointDispatcher(implClass, serviceInstance);
             
 			responseMsgContext = dispatcher.invoke(requestMsgCtx);
         } catch (Exception e) {
@@ -87,17 +90,9 @@
     /*
 	 * Get the appropriate EndpointDispatcher for a given service endpoint.
 	 */
-	private EndpointDispatcher getEndpointDispatcher(Class serviceImplClass) 
+	private EndpointDispatcher getEndpointDispatcher(Class serviceImplClass, Object serviceInstance) 
         throws Exception {
-        // TODO:  This check should be based on the EndpointDescription processing of annotations
-        //        It is left this way for now because some tests have an @WebService annotation on
-        //        Provider-based endpoints as a pre-existing workaround.
-        if(Provider.class.isAssignableFrom(serviceImplClass)) {
-    		return new ProviderDispatcher(serviceImplClass);
-    	}
-        else {
-            return new JavaBeanDispatcher(serviceImplClass);
-        }
+        return EndpointDispatcherFactory.createEndpointDispatcher(serviceImplClass, serviceInstance);
     }
 	
 	/*
@@ -156,4 +151,10 @@
             return sd;
         }
     }
+    
+   private EndpointLifecycleManager createEndpointlifecycleManager(){
+	  EndpointLifecycleManagerFactory elmf =(EndpointLifecycleManagerFactory)FactoryRegistry.getFactory(EndpointLifecycleManagerFactory.class);
+	  return elmf.createEndpointLifecycleManager();
+   }
+  
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java?view=diff&rev=469381&r1=469380&r2=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java Mon Oct 30 21:56:19 2006
@@ -20,7 +20,6 @@
 
 import javax.jws.soap.SOAPBinding.ParameterStyle;
 import javax.xml.namespace.QName;
-import javax.xml.ws.Holder;
 import javax.xml.ws.soap.SOAPBinding;
 
 import org.apache.axis2.jaxws.ExceptionFactory;
@@ -51,10 +50,9 @@
     private EndpointDescription endpointDesc = null;
     private OperationDescription operationDesc = null;
     private MethodMarshaller methodMarshaller = null;
-    private Object serviceInstance;
     
-    public JavaBeanDispatcher(Class implClass) {
-        super(implClass);
+    public JavaBeanDispatcher(Class implClass, Object serviceInstance) {
+        super(implClass, serviceInstance);
     }
     
     /*
@@ -73,9 +71,8 @@
         Method target = getJavaMethod(mc, serviceImplClass);
 
         //At this point, we have the method that is going to be invoked and
-        //the parameter data to invoke it with, so create an instance and 
+        //the parameter data to invoke it with, so we use the instance and 
         //do the invoke.
-        serviceInstance = createServiceInstance();
         //Passing method input params to grab holder values, if any.
         Object response = null;
         try {

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaDispatcher.java?view=diff&rev=469381&r1=469380&r2=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaDispatcher.java Mon Oct 30 21:56:19 2006
@@ -32,9 +32,11 @@
     private static final Log log = LogFactory.getLog(JavaDispatcher.class);
     
     protected Class serviceImplClass;
+    protected Object serviceInstance;
     
-    protected JavaDispatcher(Class impl) {
-        serviceImplClass = impl;
+    protected JavaDispatcher(Class impl, Object serviceInstance){
+    	this.serviceImplClass = impl;
+    	this.serviceInstance = serviceInstance;
     }
     
     public abstract MessageContext invoke(MessageContext mc)

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java?view=diff&rev=469381&r1=469380&r2=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java Mon Oct 30 21:56:19 2006
@@ -72,15 +72,15 @@
     private Message message = null;
     private Protocol messageProtocol;
 
+	
 	/**
 	 * Constructor
-	 * 
 	 * @param _class
+	 * @param serviceInstance
 	 */
-	public ProviderDispatcher(Class _class) {
-		super(_class);
+	public ProviderDispatcher(Class _class, Object serviceInstance) {
+		super(_class, serviceInstance);
 	}
-    
     /* (non-Javadoc)
      * @see org.apache.axis2.jaxws.server.EndpointDispatcher#execute()
      */
@@ -259,16 +259,16 @@
         
         Provider provider = null;
     	if(clazz == String.class){
-    		provider = (Provider<String>) serviceImplClass.newInstance();
+    		provider = (Provider<String>) serviceInstance;
     	}
         else if(clazz == Source.class){
-    		provider = (Provider<Source>) serviceImplClass.newInstance();
+    		provider = (Provider<Source>) serviceInstance;
     	}
         else if(clazz == SOAPMessage.class){
-    		provider = (Provider<SOAPMessage>) serviceImplClass.newInstance();
+    		provider = (Provider<SOAPMessage>) serviceInstance;
     	}
         else if(clazz == JAXBContext.class){
-    		provider = (Provider<JAXBContext>) serviceImplClass.newInstance();
+    		provider = (Provider<JAXBContext>) serviceInstance;
     	}
     	
         if (provider == null) {

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/factory/EndpointDispatcherFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/factory/EndpointDispatcherFactory.java?view=auto&rev=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/factory/EndpointDispatcherFactory.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/factory/EndpointDispatcherFactory.java Mon Oct 30 21:56:19 2006
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.axis2.jaxws.server.dispatcher.factory;
+
+import javax.xml.ws.Provider;
+
+import org.apache.axis2.jaxws.server.dispatcher.EndpointDispatcher;
+import org.apache.axis2.jaxws.server.dispatcher.JavaBeanDispatcher;
+import org.apache.axis2.jaxws.server.dispatcher.ProviderDispatcher;
+
+
+public class EndpointDispatcherFactory {
+
+	public EndpointDispatcherFactory() {
+		super();
+		
+	}
+	
+	public static EndpointDispatcher createEndpointDispatcher(Class serviceImplClass, Object serviceInstance){
+		//		 TODO:  This check should be based on the EndpointDescription processing of annotations
+        //        It is left this way for now because some tests have an @WebService annotation on
+        //        Provider-based endpoints as a pre-existing workaround.
+		if(Provider.class.isAssignableFrom(serviceImplClass)) {
+	    	return new ProviderDispatcher(serviceImplClass, serviceInstance);
+	    }
+	    else {
+	        return new JavaBeanDispatcher(serviceImplClass, serviceInstance);
+	    }
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/ResourceInjector.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/ResourceInjector.java?view=auto&rev=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/ResourceInjector.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/ResourceInjector.java Mon Oct 30 21:56:19 2006
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.axis2.jaxws.server.endpoint.injection;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.apache.axis2.jaxws.server.endpoint.injection.impl.ResourceInjectionException;
+
+/*
+ * Resource Injection is responsible to Injecting Resource Object to endpoint Instance at runtime.
+ */
+public interface ResourceInjector {
+	
+	/**
+	 * Inject resource on Filed, Method or Class depending on how the @Resource annotation is defined.
+	 * @param resource
+	 * @param instance
+	 */
+	abstract void inject(Object resource, Object instance) throws ResourceInjectionException;
+	/**
+	 * Resource will be injected on the field.
+	 * @param resource
+	 * @param instance
+	 * @param field
+	 * @return
+	 */
+	abstract void injectOnField(Object resource, Object instance, Field field) throws ResourceInjectionException;
+	/**
+	 * Resource will be injected on the Method.
+	 * @param resource
+	 * @param instance
+	 * @param method
+	 * @return
+	 */
+	abstract void injectOnMethod(Object resource, Object instance, Method method) throws ResourceInjectionException;
+	/**
+	 * Resource will be injection on the class.
+	 * @param resource
+	 * @param instance
+	 * @param clazz
+	 * @return
+	 */
+	abstract void injectOnClass(Object resource, Object instance, Class clazz) throws ResourceInjectionException;
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/WebServiceContextInjector.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/WebServiceContextInjector.java?view=auto&rev=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/WebServiceContextInjector.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/WebServiceContextInjector.java Mon Oct 30 21:56:19 2006
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.axis2.jaxws.server.endpoint.injection;
+
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
+
+/*
+ * WebserviceContext Injection is responsible to Injecting WebServiceContext Object to a JAXWS endpoint Instance at runtime.
+ * Injection will happen when the Endpoint instance is first initialized.
+ * WebServiceContext methods should be invoked when one of the webservice methods is invoked.
+ * Invocation of WebServiceContext method outside of invocation of its webservice method is illigal as per jaxws spec section 5.3.
+ */
+	public interface WebServiceContextInjector extends ResourceInjector {
+	
+	/**
+	 * MessageContext is made availble to the endpoint instance via the WebServiceContext.
+	 * This method will add MessageContext to WebServiceContext that is injected in
+	 * WebService. MessageContext represents the context of Inbound message following the
+	 * Handler Execution. Only properties with Application scope will be exposed.
+	 * @param wc
+	 * @param mc
+	 */
+	public void addMessageContext(WebServiceContext wc, MessageContext mc);
+	
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/factory/ResourceInjectionFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/factory/ResourceInjectionFactory.java?view=auto&rev=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/factory/ResourceInjectionFactory.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/factory/ResourceInjectionFactory.java Mon Oct 30 21:56:19 2006
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.axis2.jaxws.server.endpoint.injection.factory;
+
+import javax.xml.ws.WebServiceContext;
+
+import org.apache.axis2.jaxws.i18n.Messages;
+import org.apache.axis2.jaxws.server.endpoint.injection.ResourceInjector;
+import org.apache.axis2.jaxws.server.endpoint.injection.impl.ResourceInjectionException;
+import org.apache.axis2.jaxws.server.endpoint.injection.impl.WebServiceContextInjectorImpl;
+
+
+public class ResourceInjectionFactory {
+
+	/**
+	 * 
+	 */
+	public ResourceInjectionFactory() {
+		super();
+		// TODO Auto-generated constructor stub
+	}
+	
+	public static ResourceInjector createResourceInjector(Class resourceType) throws ResourceInjectionException{
+		if(resourceType == WebServiceContext.class || resourceType.isAssignableFrom(WebServiceContext.class)){
+			return new WebServiceContextInjectorImpl();
+		}
+		throw new ResourceInjectionException(Messages.getMessage("ResourceInjectionFactoryErr1"));
+	}
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/impl/ResourceInjectionException.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/impl/ResourceInjectionException.java?view=auto&rev=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/impl/ResourceInjectionException.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/impl/ResourceInjectionException.java Mon Oct 30 21:56:19 2006
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.axis2.jaxws.server.endpoint.injection.impl;
+
+
+public class ResourceInjectionException extends Exception {
+
+	/**
+	 * 
+	 */
+	public ResourceInjectionException() {
+		super();
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * @param message
+	 */
+	public ResourceInjectionException(String message) {
+		super(message);
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * @param message
+	 * @param cause
+	 */
+	public ResourceInjectionException(String message, Throwable cause) {
+		super(message, cause);
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * @param cause
+	 */
+	public ResourceInjectionException(Throwable cause) {
+		super(cause);
+		// TODO Auto-generated constructor stub
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/impl/WebServiceContextInjectorImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/impl/WebServiceContextInjectorImpl.java?view=auto&rev=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/impl/WebServiceContextInjectorImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/injection/impl/WebServiceContextInjectorImpl.java Mon Oct 30 21:56:19 2006
@@ -0,0 +1,300 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.axis2.jaxws.server.endpoint.injection.impl;
+
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import javax.annotation.Resource;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
+
+import org.apache.axis2.jaxws.context.WebServiceContextImpl;
+import org.apache.axis2.jaxws.i18n.Messages;
+import org.apache.axis2.jaxws.server.endpoint.injection.WebServiceContextInjector;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+public class WebServiceContextInjectorImpl implements WebServiceContextInjector {
+	private static final Log log = LogFactory.getLog(WebServiceContextInjectorImpl.class);
+	private static String METHOD_NAME		="set";
+	private static int NUMBER_OF_PARAMETERS = 1;	
+	private static String RETURN_TYPE 		= "void";
+	public WebServiceContextInjectorImpl() {
+		super();
+		
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.server.endpoint.injection.WebServiceContextInjection#addMessageContext(javax.xml.ws.WebServiceContext, javax.xml.ws.handler.MessageContext)
+	 */
+	public void addMessageContext(WebServiceContext wc, MessageContext mc) {
+		WebServiceContextImpl wsContext = (WebServiceContextImpl)wc;
+		wsContext.setSoapMessageContext(mc);
+
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.server.endpoint.injection.ResourceInjection#inject(java.lang.Object, java.lang.Object)
+	 */
+	public void inject(Object resource, Object instance) throws ResourceInjectionException {
+		if(instance == null){
+			if(log.isDebugEnabled()){
+				log.debug("Cannot inject Resource on a null Service Instance.");
+			}
+			throw new ResourceInjectionException(Messages.getMessage("WebServiceContextInjectionImplErr1"));
+		}
+	
+		Class serviceClazz = instance.getClass();
+		
+		/*Look for @Resource annotation on Field. If found then look for type on the annotation. If found, then
+		 * if type is java.lang.Object then make sure type on declared field in javax.xml.WebServiceContext and assign the resource value
+		 * if type is javax.xml.WebServiceContext then assign the resource value
+		*/ 
+		Field resourceField = searchFieldsForResourceAnnotation(serviceClazz);
+		if(resourceField!=null){
+			if(log.isDebugEnabled()){
+				log.debug("Attempting to inject Resource on Field");
+			}
+			//Found field that has a @Resource for WebServiceContext
+			//Inject Resource.
+			injectOnField(resource, instance, resourceField);
+			if(log.isDebugEnabled()){
+				log.debug("Resource Injected on Field");
+			}
+			return;
+		}
+		
+		/* If @Resource annotation not found on declared Fileds, then look for it on Methods. If found then,
+		 * if @Resource type is java.lang.Object then,
+		 * look for PropertyDescriptor who's write Method or setter is the Method on which you found the annotation and 
+		 * make sure that the declared type of that property is javax.xml.WebServiceContext and invoke the Method with Resource.
+		 * if @Resource type is javax.xml.ws.WebServiceContext, Invoke the Method with Resource.
+		 */
+		Method method = searchMethodsResourceAnnotation(serviceClazz);
+		if(method!=null){
+			if(log.isDebugEnabled()){
+				log.debug("Attempting to inject resource on Method");
+			}
+			if(!isValidMethod(method)){
+				if(log.isDebugEnabled()){
+					log.debug("injection can happen using method if method name starts with \"set\" returns a void and only has one parameter and the type of this parameter must be compatible with resource.");
+				}
+				throw new  ResourceInjectionException(Messages.getMessage("WebServiceContextInjectionImplErr6"));
+			}
+			injectOnMethod(resource, instance, method);	
+			if(log.isDebugEnabled()){
+				log.debug("Resource Injected");
+			}
+			return;
+		}
+		
+		//Nothing to inject
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.server.endpoint.injection.ResourceInjection#injectOnClass(java.lang.Object, java.lang.Object, java.lang.Class)
+	 */
+	public void injectOnClass(Object resource, Object instance, Class clazz) throws ResourceInjectionException {
+		throw new UnsupportedOperationException("WebServiceContext Injeciton on Class not yet supported");
+		
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.server.endpoint.injection.ResourceInjection#injectOnField(java.lang.Object, java.lang.Object, java.lang.reflect.Field)
+	 */
+	public void injectOnField(Object resource, Object instance, Field field) throws ResourceInjectionException {
+		if(instance == null){
+			if(log.isDebugEnabled()){
+				log.debug("Cannot inject Resource on a null Service Instance.");
+			}
+			throw new ResourceInjectionException(Messages.getMessage("WebServiceContextInjectionImplErr1"));
+		}
+		if(field == null){
+			if(log.isDebugEnabled()){
+				log.debug("Cannot inject WebServiceContext on ServiceInstance Field, field cannot be NULL");
+			}
+			throw new ResourceInjectionException(Messages.getMessage("WebServiceContextInjectionImplErr3"));
+		}
+		try{
+			if(!Modifier.isPublic(field.getModifiers())){
+				//TODO: Do I need to put java2 Security around this calls.
+				field.setAccessible(true);
+			}
+			//Inject Resource.
+			field.set(instance, resource);
+		}catch(IllegalAccessException e){
+			throw new ResourceInjectionException(e);
+		}
+		
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.server.endpoint.injection.ResourceInjection#injectOnMethod(java.lang.Object, java.lang.Object, java.lang.reflect.Method)
+	 */
+	public void injectOnMethod(Object resource, Object instance, Method method) throws ResourceInjectionException {
+		if(instance == null){
+			if(log.isDebugEnabled()){
+				log.debug("Cannot inject Resource on a null Service Instance.");
+			}
+			throw new ResourceInjectionException(Messages.getMessage("WebServiceContextInjectionImplErr1"));
+		}
+		if(method == null){
+			if(log.isDebugEnabled()){
+				log.debug("Cannot inject WebServiceContext on ServiceInstance Method, method cannot be NULL");
+			}
+			throw new ResourceInjectionException(Messages.getMessage("WebServiceContextInjectionImplErr3"));
+		}
+		try{
+			if(!Modifier.isPublic(method.getModifiers())){
+				//TODO: Do I need to put java2 Security around this calls.
+				method.setAccessible(true);
+			}
+			method.invoke(instance, resource);
+			return;
+		}catch(IllegalAccessException e){
+			throw new ResourceInjectionException(e);
+		}catch(InvocationTargetException e){
+			throw new ResourceInjectionException(e);
+		}
+				
+		
+		
+	}
+	
+	/*
+	 * Search for Field with @Resource Annotation.
+	 */
+	private Field searchFieldsForResourceAnnotation(Class bean){
+		if(bean == null){
+			return null;
+		}
+		Field[] fields =bean.getDeclaredFields();
+		for(Field field: fields){
+			Annotation[] annotations = field.getAnnotations();
+			for(Annotation an:annotations){
+				if(Resource.class.isAssignableFrom(an.getClass())){
+					//check to make sure it is a @Resource for WebServiceContext.
+					Resource atResource = (Resource)an;
+					Class type = atResource.type();
+					if(isWebServiceContextResource(atResource, field)){
+						return field;
+					}
+				}
+			}
+		}
+		return null;
+	}
+	/*
+	 * Search for Method with @Resource Annotation
+	 */
+	private Method searchMethodsResourceAnnotation(Class bean){
+		if(bean == null){
+			return null;
+		}
+		Method[] methods = bean.getDeclaredMethods();
+		for(Method method:methods){
+			Annotation[] annotations = method.getAnnotations();
+			for(Annotation an:annotations){
+				if(Resource.class.isAssignableFrom(an.getClass())){
+					//check to make sure it is a @Resource for WebServiceContext.
+					Resource atResource = (Resource)an;
+					if(isWebServiceContextResource(atResource, method)){
+						return method;
+					}
+				}
+			}
+		}
+		return null;
+	}
+	
+	private boolean isWebServiceContextResource(Resource atResource, Field field){
+		Class type = atResource.type();
+		if(type == java.lang.Object.class){
+			if(field!=null && field.getType() == WebServiceContext.class){
+				return true;
+			}
+		}
+		else if(type == WebServiceContext.class ){
+			//TODO: Should I check if the field declared type is assignable from WebServiceContext. Spec is not clear about this.
+			return true;
+		}
+		if(log.isDebugEnabled()){
+			log.debug("Invalid Field type or Resource Type found, cannot inject WebServiceContext on this field");
+		}
+		return false;
+	}
+	
+	private boolean isWebServiceContextResource(Resource atResource, Method method){
+		//As per JSR-250 the method injection is nothing but setter based injection,
+		//Such a injection can happen if method name starts with "set" returns a void and
+		//only has one parameter and the type of this parameter must be compatible with
+		//resource.
+		
+		Class type = atResource.type();
+		Class[] paramTypes = method.getParameterTypes();
+		for(Class paramType:paramTypes)
+		if(type == java.lang.Object.class){
+			if(paramType == WebServiceContext.class || paramType.isAssignableFrom(WebServiceContext.class)){
+				return true;
+			}
+		}
+		else if(type == WebServiceContext.class){
+			//TODO: Should I check if the field declared type is assignable from WebServiceContext. Spec is not clear about this.
+			return true;
+		}
+		if(log.isDebugEnabled()){
+			log.debug("Invalid Field type or Resource Type found, cannot inject WebServiceContext on this method");
+		}
+		return false;
+	}
+	
+	private boolean isValidMethod(Method method){
+		//As per JSR-250 the method injection is nothing but setter based injection,
+		//Such a injection can happen if method name starts with "set" returns a void and
+		//only has one parameter and the type of this parameter must be compatible with
+		//resource.
+		String name = method.getName();
+		Class returnType = method.getReturnType();
+		Class[] types= method.getParameterTypes();
+		int noOfDeclaredParameter = 0;
+		if(types !=null){
+			noOfDeclaredParameter = types.length;
+		}
+		
+		if(name.startsWith(METHOD_NAME) && noOfDeclaredParameter == NUMBER_OF_PARAMETERS && returnType.getName().equals(RETURN_TYPE)){
+			return true;
+		}
+		if(log.isDebugEnabled()){
+			log.debug("Method found with @Resource annotaion and input param to set WebServiceContext Object, However method did not meet the criteria for injection as per JSR-250");
+		}
+		return false;
+		
+	}
+
+	
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/EndpointLifecycleException.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/EndpointLifecycleException.java?view=auto&rev=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/EndpointLifecycleException.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/EndpointLifecycleException.java Mon Oct 30 21:56:19 2006
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.axis2.jaxws.server.endpoint.lifecycle;
+
+
+public class EndpointLifecycleException extends Exception {
+
+	
+	public EndpointLifecycleException() {
+		super();
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * @param message
+	 */
+	public EndpointLifecycleException(String message) {
+		super(message);
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * @param message
+	 * @param cause
+	 */
+	public EndpointLifecycleException(String message, Throwable cause) {
+		super(message, cause);
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * @param cause
+	 */
+	public EndpointLifecycleException(Throwable cause) {
+		super(cause);
+		// TODO Auto-generated constructor stub
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/EndpointLifecycleManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/EndpointLifecycleManager.java?view=auto&rev=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/EndpointLifecycleManager.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/EndpointLifecycleManager.java Mon Oct 30 21:56:19 2006
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.axis2.jaxws.server.endpoint.lifecycle;
+
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.server.endpoint.injection.impl.ResourceInjectionException;
+
+/*
+ * EndpointLifecycleManager is responsible to invoke lifycycle methods on Endpoint. An Endpoint could be a 
+ * Java Bean Endpoint or Provider Endpoint. Lifecycle manager should be invoked with proper Endpoint Object.
+ */
+public interface EndpointLifecycleManager {
+	
+	/**
+	 * EndpointLifecycleManager will create a service instance. It will inject Resources and then call 
+	 * the lifecycle methods on the service instance.
+	 * @param mc
+	 * @param serviceImplClass
+	 * @return
+	 */
+	public Object createServiceInstance(MessageContext mc, Class serviceImplClass) throws EndpointLifecycleException, ResourceInjectionException;
+	/*
+	 * Invokes method on endpoint marked with @PostConstruct annotation.
+	 */
+	public void invokePostConstruct() throws EndpointLifecycleException;
+	/*
+	 * Invokes method on endpoint marked with @preDestroy annotation.
+	 */
+	public void invokePreDestroy()throws EndpointLifecycleException;
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/factory/EndpointLifecycleManagerFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/factory/EndpointLifecycleManagerFactory.java?view=auto&rev=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/factory/EndpointLifecycleManagerFactory.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/factory/EndpointLifecycleManagerFactory.java Mon Oct 30 21:56:19 2006
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.axis2.jaxws.server.endpoint.lifecycle.factory;
+
+import org.apache.axis2.jaxws.i18n.Messages;
+import org.apache.axis2.jaxws.server.endpoint.lifecycle.EndpointLifecycleException;
+import org.apache.axis2.jaxws.server.endpoint.lifecycle.EndpointLifecycleManager;
+import org.apache.axis2.jaxws.server.endpoint.lifecycle.impl.EndpointLifecycleManagerImpl;
+
+
+public class EndpointLifecycleManagerFactory {
+
+	
+	public EndpointLifecycleManagerFactory() {
+		super();
+		// TODO Auto-generated constructor stub
+	}
+	
+	public EndpointLifecycleManager createEndpointLifecycleManager(Object endpointInstance) throws EndpointLifecycleException{
+		if(endpointInstance == null){
+			throw new EndpointLifecycleException(Messages.getMessage("EndpointLifecycleManagerImplErr1"));
+		}
+		return new EndpointLifecycleManagerImpl(endpointInstance);
+	}
+	
+	public EndpointLifecycleManager createEndpointLifecycleManager(){
+		
+		return new EndpointLifecycleManagerImpl();
+	}
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/impl/EndpointLifecycleManagerImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/impl/EndpointLifecycleManagerImpl.java?view=auto&rev=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/impl/EndpointLifecycleManagerImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/impl/EndpointLifecycleManagerImpl.java Mon Oct 30 21:56:19 2006
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.axis2.jaxws.server.endpoint.lifecycle.impl;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.xml.ws.WebServiceContext;
+
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.context.WebServiceContextImpl;
+import org.apache.axis2.jaxws.context.factory.MessageContextFactory;
+import org.apache.axis2.jaxws.context.utils.ContextUitls;
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.handler.SoapMessageContext;
+import org.apache.axis2.jaxws.i18n.Messages;
+import org.apache.axis2.jaxws.server.endpoint.injection.ResourceInjector;
+import org.apache.axis2.jaxws.server.endpoint.injection.WebServiceContextInjector;
+import org.apache.axis2.jaxws.server.endpoint.injection.factory.ResourceInjectionFactory;
+import org.apache.axis2.jaxws.server.endpoint.injection.impl.ResourceInjectionException;
+import org.apache.axis2.jaxws.server.endpoint.lifecycle.EndpointLifecycleException;
+import org.apache.axis2.jaxws.server.endpoint.lifecycle.EndpointLifecycleManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+public class EndpointLifecycleManagerImpl implements EndpointLifecycleManager {
+	private static final String WEBSERVICE_MESSAGE_CONTEXT = "javax.xml.ws.WebServiceContext";
+	private static final Log log = LogFactory.getLog(EndpointLifecycleManagerImpl.class);
+	private Object endpointInstance = null;
+	private Class endpointClazz = null;
+	public EndpointLifecycleManagerImpl(Object endpointInstance) {
+		super();
+		this.endpointInstance = endpointInstance;
+		if(endpointInstance != null){
+			endpointClazz = endpointInstance.getClass();
+		}
+	}
+	
+	public EndpointLifecycleManagerImpl() {
+		super();
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.server.endpoint.lifecycle.EndpointLifecycleManager#createServiceInstance(org.apache.axis2.jaxws.core.MessageContext, java.lang.Class)
+	 */
+	public Object createServiceInstance(MessageContext mc, Class serviceImplClass) throws EndpointLifecycleException, ResourceInjectionException{
+		org.apache.axis2.context.MessageContext msgContext = mc.getAxisMessageContext();
+        ServiceContext serviceContext = msgContext.getServiceContext();
+        //Create MessageContext for current invocation.
+        javax.xml.ws.handler.MessageContext soapMessageContext = createSOAPMessageContext(mc);
+        Object serviceimpl = serviceContext.getProperty(ServiceContext.SERVICE_OBJECT);
+        if (serviceimpl != null) {
+        	if (log.isDebugEnabled()) {
+                log.debug("Service Instance found in the service context, reusing the instance");
+            }
+           //Get WebServiceContext from ServiceContext
+        	WebServiceContext ws = (WebServiceContext)serviceContext.getProperty(WEBSERVICE_MESSAGE_CONTEXT);
+        	//Add the MessageContext for current invocation
+        	if(ws !=null){
+        		updateWebServiceContext(ws, soapMessageContext);
+        	}
+        	 //since service impl is there in service context , take that from there
+            return serviceimpl;
+        } else {
+            // create a new service impl class for that service
+            serviceimpl = createServiceInstance(serviceImplClass);
+            this.endpointInstance = serviceimpl;
+            //Since Serivce Object is instantiated for the first time I will Inject any resource 
+            //and call the PostConstruct lifecycle methods here.
+            
+            //Create WebServiceContext
+            WebServiceContextImpl wsContext = new WebServiceContextImpl();
+            //Add MessageContext for this request.
+            wsContext.setSoapMessageContext(soapMessageContext);
+            //inject WebServiceContext
+            injectWebServiceContext(wsContext, serviceimpl);
+            //InvokePostConstruct
+            invokePostConstruct();
+            serviceContext.setProperty(WEBSERVICE_MESSAGE_CONTEXT, wsContext);
+            serviceContext.setProperty(ServiceContext.SERVICE_OBJECT, serviceimpl);
+            return serviceimpl;
+        }
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.server.endpoint.lifecycle.EndpointLifecycleManager#invokePostConstruct()
+	 */
+	public void invokePostConstruct() throws EndpointLifecycleException{
+		if(endpointInstance == null){
+			throw new EndpointLifecycleException(Messages.getMessage("EndpointLifecycleManagerImplErr1"));
+		}
+		Method method = getPostConstructMethod();
+		if(method != null){
+			if(log.isDebugEnabled()){
+				log.debug("Invoking Method with @PostConstruct annotation");
+			}
+			invokeMethod(method, null);
+			if(log.isDebugEnabled()){
+				log.debug("Completed invoke on Method with @PostConstruct annotation");
+			}
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.jaxws.server.endpoint.lifecycle.EndpointLifecycleManager#invokePreDestroy()
+	 */
+	public void invokePreDestroy() throws EndpointLifecycleException {
+		if(endpointInstance == null){
+			throw new EndpointLifecycleException(Messages.getMessage("EndpointLifecycleManagerImplErr1"));
+		}
+		Method method = getPreDestroyMethod();
+		if(method != null){
+			if(log.isDebugEnabled()){
+				log.debug("Invoking Method with @PostConstruct annotation");
+			}
+			invokeMethod(method, null);
+			if(log.isDebugEnabled()){
+				log.debug("Completed invoke on Method with @PreDestroy annotation");
+			}
+		}
+	}
+	
+	private void invokeMethod(Method m, Object[] params) throws EndpointLifecycleException{
+		try{
+			m.invoke(endpointInstance, params);
+		}catch(InvocationTargetException e){
+			throw new EndpointLifecycleException(e);
+		}catch(IllegalAccessException e){
+			throw new EndpointLifecycleException(e);
+		}
+	}
+	
+	private Method getPostConstructMethod(){
+		//return Method with @PostConstruct Annotation.
+		if(endpointInstance != null){
+			Class endpointClazz = endpointInstance.getClass();
+			Method[] methods = endpointClazz.getMethods();
+			
+			for(Method method:methods){
+				if(isPostConstruct(method)){
+					return method;
+				}
+			}
+		}
+		return null;
+	}
+	
+	private Method getPreDestroyMethod(){
+		//return Method with @PreDestroy Annotation
+		if(endpointInstance != null){
+			Class endpointClazz = endpointInstance.getClass();
+			Method[] methods = endpointClazz.getMethods();
+			
+			for(Method method:methods){
+				if(isPreDestroy(method)){
+					return method;
+				}
+			}
+		}
+		return null;
+	}
+	
+	private boolean isPostConstruct(Method method){
+		Annotation[] annotations = method.getDeclaredAnnotations();
+		for(Annotation annotation:annotations){
+			return PostConstruct.class.isAssignableFrom(annotation.annotationType());
+		}
+		return false;
+	}
+	
+	private boolean isPreDestroy(Method method){
+		Annotation[] annotations = method.getDeclaredAnnotations();
+		for(Annotation annotation:annotations){
+			return PreDestroy.class.isAssignableFrom(annotation.annotationType());
+		}
+		return false;
+	}
+	
+	 private Object createServiceInstance(Class serviceImplClass) {
+	        if (log.isDebugEnabled()) {
+	            log.debug("Creating new instance of service endpoint");
+	        }
+	        
+	        if (serviceImplClass == null) {
+	            throw ExceptionFactory.makeWebServiceException(Messages.getMessage(
+	                    "EndpointControllerErr5"));
+	        }
+	        
+	        Object instance = null;
+	        try {
+	            instance = serviceImplClass.newInstance();
+	        } catch (IllegalAccessException e) {
+	            throw ExceptionFactory.makeWebServiceException(Messages.getMessage(
+	                    "EndpointControllerErr6", serviceImplClass.getName()));
+	        } catch (InstantiationException e) {
+	            throw ExceptionFactory.makeWebServiceException(Messages.getMessage(
+	                    "EndpointControllerErr6", serviceImplClass.getName()));
+	        }
+	        
+	        return instance;
+	   }
+	
+	 private javax.xml.ws.handler.MessageContext createSOAPMessageContext(MessageContext mc){
+		SoapMessageContext soapMessageContext = (SoapMessageContext)MessageContextFactory.createSoapMessageContext(mc);
+		ContextUitls.addProperties(soapMessageContext, mc);
+		return soapMessageContext;
+	 }
+	 
+	private void injectWebServiceContext(WebServiceContext wsContext, Object serviceInstance) throws ResourceInjectionException{
+	   ResourceInjector ri =ResourceInjectionFactory.createResourceInjector(WebServiceContext.class);
+	   ri.inject(wsContext, serviceInstance);
+		   
+	}
+	   
+	private void updateWebServiceContext(WebServiceContext wsContext, javax.xml.ws.handler.MessageContext soapMessageContext) throws ResourceInjectionException{
+	   WebServiceContextInjector wci =(WebServiceContextInjector)ResourceInjectionFactory.createResourceInjector(WebServiceContext.class);
+	   wci.addMessageContext(wsContext, soapMessageContext);
+		   
+	}
+	   
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java?view=diff&rev=469381&r1=469380&r2=469381
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java Mon Oct 30 21:56:19 2006
@@ -36,6 +36,8 @@
 import org.apache.axis2.jaxws.exception.ExceptionFactoryTests;
 import org.apache.axis2.jaxws.handler.HandlerChainProcessorTests;
 import org.apache.axis2.jaxws.i18n.JaxwsMessageBundleTests;
+import org.apache.axis2.jaxws.injection.ResourceInjectionTests;
+import org.apache.axis2.jaxws.lifecycle.EndpointLifecycleTests;
 import org.apache.axis2.jaxws.message.BlockTests;
 import org.apache.axis2.jaxws.message.FaultTests;
 import org.apache.axis2.jaxws.message.MessageTests;
@@ -117,6 +119,8 @@
         suite.addTestSuite(NonAnonymousComplexTypeTests.class);
         suite.addTestSuite(AddNumbersTests.class);
         suite.addTestSuite(FaultyWebServiceTests.class);
+        suite.addTestSuite(EndpointLifecycleTests.class);
+        suite.addTestSuite(ResourceInjectionTests.class);
         
         // Start (and stop) the server only once for all the tests
         TestSetup testSetup = new TestSetup(suite) {



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message