You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by sc...@apache.org on 2006/06/02 19:33:13 UTC
svn commit: r411218 [12/34] - in /webservices/muse: branches/1.0/
branches/1.0/src/examples/broker/ branches/1.0/src/examples/broker/WEB-INF/
branches/1.0/src/examples/consumer/ branches/1.0/src/examples/consumer/epr/
branches/1.0/src/examples/consumer...
Added: webservices/muse/branches/1.0/src/java/org/apache/ws/resource/i18n/Keys.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/java/org/apache/ws/resource/i18n/Keys.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/java/org/apache/ws/resource/i18n/Keys.java (added)
+++ webservices/muse/branches/1.0/src/java/org/apache/ws/resource/i18n/Keys.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,719 @@
+/*=============================================================================*
+ * Copyright 2004 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.
+ *=============================================================================*/
+package org.apache.ws.resource.i18n;
+
+
+/**
+ * I18n message keys and messages for the {@link org.apache.ws.resource}
+ * package and all its subpackages.
+ */
+public interface Keys
+{
+ /**
+ * @msg Creating ResourcePropertySet from XmlBean whose factory is: {0} ...
+ */
+ String CREATING_PROPSET = "CREATING_PROPSET";
+
+ /**
+ * @msg Received request to {0} resource with Id {1}
+ */
+ String PORTTYPE_RECEIVED_REQUEST = "PORTTYPE_RECEIVED_REQUEST";
+
+ /**
+ * @msg Resource Id {0} not found for service {1}
+ */
+ String RESOURCE_NOT_FOUND = "RESOURCE_NOT_FOUND";
+
+ /**
+ * @msg Output directory for generated files.
+ */
+ String OPT_OUTPUT_DIR_FOR_GEN_SRC = "OPT_OUTPUT_DIR_FOR_GEN_SRC";
+
+ /**
+ * @msg output directory for generated jar files.
+ */
+ String OPT_OUTPUT_DIR_FOR_GEN_JAR = "OPT_OUTPUT_DIR_FOR_GEN_JAR";
+
+ /**
+ * @msg enable verbose output.
+ */
+ String OPT_ENABLE_VERBOSE = "OPT_ENABLE_VERBOSE";
+
+ /**
+ * @msg enable debug output.
+ */
+ String OPT_ENABLE_DEBUG = "OPT_ENABLE_DEBUG";
+
+ /**
+ * @msg classpath to be passed to XMLBeans schema compiler.
+ */
+ String OPT_CLASSPATH_SENT_TO_XMLBEANS = "OPT_CLASSPATH_SENT_TO_XMLBEANS";
+
+ /**
+ * @msg No WSDL files were specified. Nothing to do.
+ */
+ String WARN_EMPTY_WSDLS = "WARN_EMPTY_WSDLS";
+
+ /**
+ * @msg Calling Wsdl2Java with: {0} wsdl files, {1} output dir.
+ */
+ String WSDL4J_PASSED_ARGUMENTS = "WSDL4J_PASSED_ARGUMENTS";
+
+ /**
+ * @msg {0} is a required option.
+ */
+ String OPT_REQUIRED = "OPT_REQUIRED";
+
+ /**
+ * @msg Expected WS-Addressing SOAP header: {0}
+ */
+ String EXPECTED_ADDRESSING_HEADER = "EXPECTED_ADDRESSING_HEADER";
+
+ /**
+ * @msg Dialect: {0}
+ */
+ String DIALECT = "DIALECT";
+
+ /**
+ * @msg content
+ */
+ String CONTENT = "CONTENT";
+
+ /**
+ * @msg name
+ */
+ String NAME = "NAME";
+
+ /**
+ * @msg faultCode
+ */
+ String FAULTCODE = "FAULTCODE";
+
+ /**
+ * @msg description
+ */
+ String DESCRIPTION = "DESCRIPTION";
+
+ /**
+ * @msg faultCause
+ */
+ String FAULTCAUSE = "FAULTCAUSE";
+
+ /**
+ * @msg faultString
+ */
+ String FAULTSTRING = "FAULTSTRING";
+
+ /**
+ * @msg errorCode
+ */
+ String ERRORCODE = "ERRORCODE";
+
+ /**
+ * @msg MessageContext was null.
+ */
+ String MESSAGECONTEXT_NULL = "MESSAGECONTEXT_NULL";
+
+ /**
+ * @msg An Exception Occurred when retrieving the ResourceHome. Cause: {0}
+ */
+ String EXCEPTION_GETTING_HOME = "EXCEPTION_GETTING_HOME";
+
+ /**
+ * @msg An Exception Occurred when Creating an instance of the Class: {0} , Cause: {1}
+ */
+ String EXCEPTION_CREATING_CLASS = "EXCEPTION_CREATING_CLASS";
+
+ /**
+ * @msg Expected type: {0}, but got: {1}
+ */
+ String EXCEPTION_EXPECTED_TYPE = "EXCEPTION_EXPECTED_TYPE";
+
+ /**
+ * @msg Received ?WSDL request for service: {0}
+ */
+ String RECEIVED_WSDL_REQUEST = "RECEIVED_WSDL_REQUEST";
+
+ /**
+ * @msg Populating WSRF JNDI context - reading JNDI configuration off classpath from {0}...
+ */
+ String POPULATING_JNDI = "POPULATING_JNDI";
+
+ /**
+ * @msg {0} is initialized.
+ */
+ String CLASS_IS_INITIALIZED = "CLASS_IS_INITIALIZED";
+
+ /**
+ * @msg Received request.
+ */
+ String RECEIVED_REQUEST = "RECEIVED_REQUEST";
+
+ /**
+ * @msg The {0} method on service class {1} threw an exception.
+ */
+ String ERROR_INVOKING_METHOD_ON_SERVICE = "ERROR_INVOKING_METHOD_ON_SERVICE";
+
+ /**
+ * @msg Internal server error occurred.
+ */
+ String INTERNAL_SERVER_ERROR = "INTERNAL_SERVER_ERROR";
+
+ /**
+ * @msg Handling response...
+ */
+ String HANDLING_RESPONSE = "HANDLING_RESPONSE";
+
+ /**
+ * @msg Found {0} response body elements.
+ */
+ String FOUND_RESP_ELEMS = "FOUND_RESP_ELEMS";
+
+ /**
+ * @msg Retrieved service classname: {0} from resource home.
+ */
+ String RETRIEVED_SERVICE_CLASSNAME = "RETRIEVED_SERVICE_CLASSNAME";
+
+ /**
+ * @msg Required parameter {0} not defined in resource home.
+ */
+ String SERVICE_OPT_UNDEFINED_IN_HOME = "SERVICE_OPT_UNDEFINED_IN_HOME";
+
+ /**
+ * @msg Deriving the service method name from the request body element name ({0})...
+ */
+ String DERIVE_SERVICE_NAME_FROM_REQ = "DERIVE_SERVICE_NAME_FROM_REQ";
+
+ /**
+ * @msg Unrecognized request body element: {0}
+ */
+ String BAD_REQUEST_BODY_ELEMENT = "BAD_REQUEST_BODY_ELEMENT";
+
+ /**
+ * @msg Found service method: {0}
+ */
+ String FOUND_SERVICE_METHOD = "FOUND_SERVICE_METHOD";
+
+ /**
+ * @msg Failed to create SOAPMessage via MessageFactory.
+ */
+ String FAILED_TO_CREATE_SOAPMESSAGE = "FAILED_TO_CREATE_SOAPMESSAGE";
+
+ /**
+ * @msg Creating an instance of service class: {0}
+ */
+ String CREATING_INSTANCE_OF_SERVICE = "CREATING_INSTANCE_OF_SERVICE";
+
+ /**
+ * @msg Cleaning expired resources.
+ */
+ String CLEANING_EXPIRED_RESOURCES = "CLEANING_EXPIRED_RESOURCES";
+
+ /**
+ * @msg Finding resource with key {0} ...
+ */
+ String FINDING_RESOURCE_WITH_KEY = "FINDING_RESOURCE_WITH_KEY";
+
+ /**
+ * @msg ResourceKey was null.
+ */
+ String NULL_KEY = "NULL_KEY";
+
+ /**
+ * @msg Initializing Home
+ */
+ String INIT_HOME = "INIT_HOME";
+
+ /**
+ * @msg The ResourceKey name was null, please check the jndi-config.xml file.
+ */
+ String RESOURCE_KEYNAME_NULL = "RESOURCE_KEYNAME_NULL";
+
+ /**
+ * @msg The Resource Class name was null, please check the jndi-config.xml file.
+ */
+ String RESOURCE_CLASSNAME_NULL = "RESOURCE_CLASSNAME_NULL";
+
+ /**
+ * @msg Failed to destroy resource: {0} Cause: {1}
+ */
+ String FAILED_TO_DESTROY_RESOURCE = "FAILED_TO_DESTROY_RESOURCE";
+
+ /**
+ * @msg Removed the resource {0} with key: {1}
+ */
+ String REMOVED_RESOURCE_WITH_KEY = "REMOVED_RESOURCE_WITH_KEY";
+
+ /**
+ * @msg Creating instance for ResourceKey: {0}
+ */
+ String CREATING_INSTANCE_WITH_KEY = "CREATING_INSTANCE_WITH_KEY";
+
+ /**
+ * @msg Calling init() in the Resource Instance: {0}
+ */
+ String INIT_RESOURCE_LIFECYCLE_INSTANCE = "INIT_RESOURCE_LIFECYCLE_INSTANCE";
+
+ /**
+ * @msg Failed to initialize resource: {0} Cause: {1}
+ */
+ String FAILED_TO_INIT_RESOURCE = "FAILED_TO_INIT_RESOURCE";
+
+ /**
+ * @msg Loading Resource from persistence for ResourceKey: {0}
+ */
+ String LOADING_RESOURCE_FROM_PERSISTENCE = "LOADING_RESOURCE_FROM_PERSISTENCE";
+
+ /**
+ * @msg The Resource class {0} was not found. Please check your classpath and WSRF JNDI config.
+ */
+ String RESOURCE_CLASS_NOT_FOUND = "RESOURCE_CLASS_NOT_FOUND";
+
+ /**
+ * @msg Adding resource with identifier {0} to {1} ...
+ */
+ String ADDING_RESOURCE_WITH_ID = "ADDING_RESOURCE_WITH_ID";
+
+ /**
+ * @msg Attempting to lookup resource with identifier {0} from {1} ...
+ */
+ String GETTING_RESOURCE_WITH_ID = "GETTING_RESOURCE_WITH_ID";
+
+ /**
+ * @msg Looking up default timer using JNDI name {0} ...
+ */
+ String TIMER_LOOKUP_WITH_JNDI_NAME = "TIMER_LOOKUP_WITH_JNDI_NAME";
+
+ /**
+ * @msg Scheduling resource sweeper ...
+ */
+ String SCHEDULE_RESOURCE_SWEEPER = "SCHEDULE_RESOURCE_SWEEPER";
+
+ /**
+ * @msg Cancelling resource sweeper ...
+ */
+ String CANCEL_RESOURCE_SWEEPER = "CANCEL_RESOURCE_SWEEPER";
+
+ /**
+ * @msg The SOAPMessageContext was null.
+ */
+ String NULL_SOAPMSGCTX = "NULL_SOAPMSGCTX";
+
+ /**
+ * @msg Looking up resource with key: {0} ...
+ */
+ String LOOKUP_RESOURCE_FOR_KEY = "LOOKUP_RESOURCE_FOR_KEY";
+
+ /**
+ * @msg Found resource: {0}
+ */
+ String FOUND_RESOURCE = "FOUND_RESOURCE";
+
+ /**
+ * @msg The JNDI home location is: {0}
+ */
+ String JNDI_HOME_LOCATION = "JNDI_HOME_LOCATION";
+
+ /**
+ * @msg The ResourceKey is: {0}
+ */
+ String RESOURCE_KEY = "RESOURCE_KEY";
+
+ /**
+ * @msg Resource key name is null.
+ */
+ String NULL_RESOURCE_NAME = "NULL_RESOURCE_NAME";
+
+ /**
+ * @msg Attempting to retrieve ResourceKeyHeader for ResourceKey name: {0}
+ */
+ String GET_RESOURCEKEY_HEADER = "GET_RESOURCEKEY_HEADER";
+
+ /**
+ * @msg The ResourceKey Name was null.
+ */
+ String NULL_RESOURCEKEY_QNAME = "NULL_RESOURCEKEY_QNAME";
+
+ /**
+ * @msg Retrieving the ServiceURL from the Addressing Headers. Service URL is: {0}
+ */
+ String GET_SERVICE_URL_FROM_ADDR_HDR = "GET_SERVICE_URL_FROM_ADDR_HDR";
+
+ /**
+ * @msg Destroying {0} resource with Id {1}
+ */
+ String DESTROYING_RESOURCE = "DESTROYING_RESOURCE";
+
+ /**
+ * @msg Unable to set termination time for {0} resource with Id {1}
+ */
+ String UNABLE_TO_SET_TERM_TIME = "UNABLE_TO_SET_TERM_TIME";
+
+ /**
+ * @msg {0} resource with Id {1} could not be destroyed.
+ */
+ String UNABLE_TO_DESTROY_RESOURCE = "UNABLE_TO_DESTROY_RESOURCE";
+
+ /**
+ * @msg Resource Id {0} not found for service {1}
+ */
+ String RESOURCEID_NOT_FOUND_FOR_SERVICE = "RESOURCEID_NOT_FOUND_FOR_SERVICE";
+
+ /**
+ * @msg Setting property: {0} with time: {1}
+ */
+ String SET_PROP_TIME = "SET_PROP_TIME";
+
+ /**
+ * @msg Read-only property: {0}
+ */
+ String READ_ONLY_PROP = "READ_ONLY_PROP";
+
+ /**
+ * @msg Invalid expression: {0}
+ */
+ String INVALID_EXPRESSION = "INVALID_EXPRESSION";
+
+ /**
+ * @msg Invalid property name: {0}
+ */
+ String INVALID_PROP_NAME = "INVALID_PROP_NAME";
+
+ /**
+ * @msg The {0} property cannot be cleared - its schema requires it to contain at least {1} elements.
+ */
+ String CANNOT_CLEAR_SCHEMA_CONSTRAINT = "CANNOT_CLEAR_SCHEMA_CONSTRAINT";
+
+ /**
+ * @msg This resource property already contains {0} elements, which is the maximum allowed by its schema.
+ */
+ String MAX_ALLOWED_BY_SCHEMA = "MAX_ALLOWED_BY_SCHEMA";
+
+ /**
+ * @msg Property element to add must be named {0}
+ */
+ String PROP_MUST_BE_NAMED = "PROP_MUST_BE_NAMED";
+
+ /**
+ * @msg Unable to convert specified object to an XmlObject.
+ */
+ String UNABLE_TO_CONVERT_TO_XMLOBJECT = "UNABLE_TO_CONVERT_TO_XMLOBJECT";
+
+ /**
+ * @msg Property element to remove must be named {0}
+ */
+ String PROP_ELEM_TO_REMOVE_MST_B_NAMED = "PROP_ELEM_TO_REMOVE_MST_B_NAMED";
+
+ /**
+ * @msg Property element to set must be named {0}
+ */
+ String PROP_SET_MST_B_NAMED = "PROP_SET_MST_B_NAMED";
+
+ /**
+ * @msg Specified index must be >=0 and < {0}
+ */
+ String INDEX_MST_B_GTR0 = "INDEX_MST_B_GTR0";
+
+ /**
+ * @msg Specified schema type must be of document type.
+ */
+ String SCHEMA_MUST_BE_DOC = "SCHEMA_MUST_BE_DOC";
+
+ /**
+ * @msg Specified XMLBean ({0}) is not a document type.
+ */
+ String XMLOBJECT_DOC = "XMLOBJECT_DOC";
+
+ /**
+ * @msg Properties that are explicitly defined in the RP doc schema cannot be removed from the property set.
+ */
+ String NON_ANY_PROP_CANNOT_BE_REMOVED = "NON_ANY_PROP_CANNOT_BE_REMOVED";
+
+ /**
+ * @msg The resource properties document already contains a resource property named {0}
+ */
+ String PROP_DOC_ALREADY_CONTAINS_PROPERTY = "PROP_DOC_ALREADY_CONTAINS_PROPERTY";
+
+ /**
+ * @msg Clearing the PropertSet.
+ */
+ String CLEAR_PROP_SET = "CLEAR_PROP_SET";
+
+ /**
+ * @msg Removing property from ResourcePropertySet, property: {0}
+ */
+ String REMOVING_PROP = "REMOVING_PROP";
+
+ /**
+ * @msg Adding property to ResourcePropertySet, property: {0}
+ */
+ String ADDING_PROP = "ADDING_PROP";
+
+ /**
+ * @msg Processing SetResourceProperties request: {0} ...
+ */
+ String SET_RP_REQ = "SET_RP_REQ";
+
+ /**
+ * @msg Deleting resource property: {0} ...
+ */
+ String DEL_RP_REQ = "DEL_RP_REQ";
+
+ /**
+ * @msg wsrp:Delete element is missing the required ResourceProperty attribute.
+ */
+ String DEL_MISSING_RP_ATTRIB = "DEL_MISSING_RP_ATTRIB";
+
+ /**
+ * @msg Inserting resource property...
+ */
+ String INSERT_RP_REQ = "INSERT_RP_REQ";
+
+ /**
+ * @msg Property {0} cannot be deleted because its minOccurs is greater than zero.
+ */
+ String ERROR_PROPERTY_DELETE_VIOLATES_SCHEMA = "ERROR_PROPERTY_DELETE_VIOLATES_SCHEMA";
+
+ /**
+ * @msg Element {0} cannot be inserted because maxOccurs for property {1} would be exceeded.
+ */
+ String ERROR_PROPERTY_INSERT_VIOLATES_SCHEMA = "ERROR_PROPERTY_INSERT_VIOLATES_SCHEMA";
+
+ /**
+ * @msg Updating resource property...
+ */
+ String UPDATE_RP_REQ = "UPDATE_RP_REQ";
+
+ /**
+ * @msg Elements cannot be inserted because maxOccurs for property {0} would be exceeded.
+ */
+ String ERROR_PROPERTY_UPDATE_VIOLATES_SCHEMA = "ERROR_PROPERTY_UPDATE_VIOLATES_SCHEMA";
+
+ /**
+ * @msg Getting Resource Property with name: {0}
+ */
+ String GET_RP_WITH_NAME = "GET_RP_WITH_NAME";
+
+ /**
+ * @msg Query ResourceProperties request: {0}
+ */
+ String QUERY_RP_REQ = "QUERY_RP_REQ";
+
+ /**
+ * @msg Failed to extract SOAP envelope from resource context. Cause: {0}
+ */
+ String FAILED_TO_EXTRACT_SOAP_ENV = "FAILED_TO_EXTRACT_SOAP_ENV";
+
+ /**
+ * @msg Attempting to get resource property: {0} ...
+ */
+ String GET_RP_REQ = "GET_RP_REQ";
+
+ /**
+ * @msg GetMultipleResourceProperties request: {0}
+ */
+ String GET_MULTI_RP_REQ = "GET_MULTI_RP_REQ";
+
+ /**
+ * @msg Attempt to call a WSRP operation on a WS-Resource that has no properties.
+ */
+ String CALL_WSRP_OP_ON_NOPROP = "CALL_WSRP_OP_ON_NOPROP";
+
+ /**
+ * @msg Unsupported dialect: {0}
+ */
+ String UNSUPP_DIALECT = "UNSUPP_DIALECT";
+
+ /**
+ * @msg value
+ */
+ String VALUE = "VALUE";
+
+ /**
+ * @msg namespaceContext
+ */
+ String NMSPCECTX = "NMSPCECTX";
+
+ /**
+ * @msg Constructed XPathExpression: {0}
+ */
+ String CONSTR_XPATH_EXPR = "CONSTR_XPATH_EXPR";
+
+ /**
+ * @msg XPath expression: {0}
+ */
+ String XPATH = "XPATH";
+
+ /**
+ * @msg Properties document: {0}
+ */
+ String PROP_DOC = "PROP_DOC";
+
+ /**
+ * @msg Xalan XPath expression evaluator (Xalan version is {0})
+ */
+ String XALAN_EVALUATOR = "XALAN_EVALUATOR";
+
+ /**
+ * @msg Jaxen XPath expression evaluator
+ */
+ String JAXEN_EVALUATOR = "JAXEN_EVALUATOR";
+
+ /**
+ * @msg XPath Expression was null.
+ */
+ String NULL_XPATH = "NULL_XPATH";
+
+ /**
+ * @msg Evaluating XPath expression [{0}] over context [{1}]
+ */
+ String EVAL_XPATH = "EVAL_XPATH";
+
+ /**
+ * @msg XPath query failed: {0} Cause: {1}
+ */
+ String XPATH_FAILED = "XPATH_FAILED";
+
+ /**
+ * @msg Namespace context on XPathExpression is null or is not a DomNamespaceContext.
+ */
+ String BAD_XPATH_NAMESPACE_CONTEXT = "BAD_XPATH_NAMESPACE_CONTEXT";
+
+ /**
+ * @msg QueryEngine encountered an error during a refresh. Cause: {0}
+ */
+ String QUERY_ENG_INIT_ERROR = "QUERY_ENG_INIT_ERROR";
+
+ /**
+ * @msg Executing Query
+ */
+ String EXEC_QUERY = "EXEC_QUERY";
+
+ /**
+ * @msg on ResourcePropertySet:
+ */
+ String ON_RP_SET = "ON_RP_SET";
+
+ /**
+ * @msg All property elements in Insert request must have the same name.
+ */
+ String ERROR_INSERT_ELEMS_NOT_HOMOGENOUS = "ERROR_INSERT_ELEMS_NOT_HOMOGENOUS";
+
+ /**
+ * @msg All property elements in Update request must have the same name.
+ */
+ String ERROR_UPDATE_ELEMS_NOT_HOMOGENOUS = "ERROR_UPDATE_ELEMS_NOT_HOMOGENOUS";
+
+ /**
+ * @msg XML Beans XPath expression evaluator
+ */
+ String XMLBEANS_XPATH_EVAL = "XMLBEANS_XPATH_EVAL";
+
+ /**
+ * @msg The XMLBeanXPathExpressionEvaluator#evaluate() requires that the specified ResourcePropertySet be an instance of XmlBeansResourcePropertySet. Cause: {0}
+ */
+ String ERROR_XPATH_EXPR_REQ_XMLBEANRPSET = "ERROR_XPATH_EXPR_REQ_XMLBEANRPSET";
+
+ /**
+ * @msg Query failed: {0} Cause: {1}
+ */
+ String QUERY_FAILED = "QUERY_FAILED";
+
+ /**
+ * @msg Failed to initialize query expression dialect. Cause: {0}
+ */
+ String FAILED_INIT_DIALECT = "FAILED_INIT_DIALECT";
+
+ /**
+ * @msg As per the WS-RP schema, a query expression element can only have up to one child node.
+ */
+ String QUERY_ONLY_ONE_NODE = "QUERY_ONLY_ONE_NODE";
+
+ /**
+ * @msg As per the WS-RP schema, a query expression element must contain either one element or one text node.
+ */
+ String QUERY_MUST_HAVE_ELEM_OR_TXT = "QUERY_MUST_HAVE_ELEM_OR_TXT";
+
+ /**
+ * @msg The QueryExpression is: {0}
+ */
+ String QUERY_EXPR = "QUERY_EXPR";
+
+ /**
+ * @msg Invoking service method: {0}
+ */
+ String INVOKING_SERVICE_METHOD = "INVOKING_SERVICE_METHOD";
+
+ /**
+ * @msg for Dialect:
+ */
+ String FOR_DIALECT = "FOR_DIALECT";
+
+ /**
+ * @msg Wsdl2Java expects the WSDL files to have the extension .wsdl the passed-in file was named: {0}
+ */
+ String ERROR_ONLY_WSDLS = "ERROR_ONLY_WSDLS";
+
+ /**
+ * @msg Retrieving the Action from the Addressing Headers. Action is: {0}
+ */
+ String GET_ACTION_FROM_ADDR_HDR = "GET_ACTION_FROM_ADDR_HDR";
+
+ /**
+ * @msg Received request with no WS-Addressing Action header.
+ */
+ String NO_WSA_ACTION = "NO_WSA_ACTION";
+
+ /**
+ * @msg Received request with no WS-Addressing headers.
+ */
+ String NO_WSA_HEADERS = "NO_WSA_HEADERS";
+
+ /**
+ * @msg There was an error when calling the insertProperty operation on the callback {0}
+ */
+ String ERROR_DURING_INSERT_CALLBACK = "ERROR_DURING_INSERT_CALLBACK";
+
+ /**
+ * @msg There was an error when calling the updateProperty operation on the callback {0}
+ */
+ String ERROR_DURING_UPDATE_CALLBACK = "ERROR_DURING_UPDATE_CALLBACK";
+
+ /**
+ * @msg There was an error when calling the deleteProperty operation on the callback {0}
+ */
+ String ERROR_DURING_DELETE_CALLBACK = "ERROR_DURING_DELETE_CALLBACK";
+
+ /**
+ * @msg Error occurred during delete property operation.
+ */
+ String ERROR_DURING_DELETE = "ERROR_DURING_DELETE";
+
+ /**
+ * @msg Error occurred during insert property operation.
+ */
+ String ERROR_DURING_INSERT = "ERROR_DURING_INSERT";
+
+ /**
+ * @msg Error occurred during update property operation.
+ */
+ String ERROR_DURING_UPDATE = "ERROR_DURING_UPDATE";
+
+ /**
+ * @msg Unrecognized request body element.
+ */
+ String BAD_REQUEST_BODY_ELEMENT_NOPARAM = "BAD_REQUEST_BODY_ELEMENT_NOPARAM";
+}
\ No newline at end of file
Added: webservices/muse/branches/1.0/src/java/org/apache/ws/resource/i18n/MessagesImpl.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/java/org/apache/ws/resource/i18n/MessagesImpl.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/java/org/apache/ws/resource/i18n/MessagesImpl.java (added)
+++ webservices/muse/branches/1.0/src/java/org/apache/ws/resource/i18n/MessagesImpl.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,66 @@
+/*=============================================================================*
+ * Copyright 2004 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.
+ *=============================================================================*/
+package org.apache.ws.resource.i18n;
+
+import org.apache.ws.util.i18n.AbstractMessages;
+import org.apache.ws.util.i18n.Messages;
+
+/**
+ * Singleton used by all classes below the {@link org.apache.ws.resource} package
+ * for retrieving i18n messages.
+ *
+ * @author Ian P. Springer
+ */
+public class MessagesImpl
+ extends AbstractMessages
+{
+ /** DOCUMENT_ME */
+ public static final String PROJECT_PACKAGE_NAME = "org.apache.ws.resource";
+
+ /** DOCUMENT_ME */
+ public static final String RESOURCE_PACKAGE_NAME = "org.apache.ws.resource.i18n";
+ private static Messages s_ourInstance = new MessagesImpl( );
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public static Messages getInstance( )
+ {
+ return s_ourInstance;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ protected String getProjectPackageName( )
+ {
+ return PROJECT_PACKAGE_NAME;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ protected String getResourcePackageName( )
+ {
+ return RESOURCE_PACKAGE_NAME;
+ }
+}
\ No newline at end of file
Added: webservices/muse/branches/1.0/src/java/org/apache/ws/resource/impl/AbstractResourceContext.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/java/org/apache/ws/resource/impl/AbstractResourceContext.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/java/org/apache/ws/resource/impl/AbstractResourceContext.java (added)
+++ webservices/muse/branches/1.0/src/java/org/apache/ws/resource/impl/AbstractResourceContext.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,368 @@
+/*=============================================================================*
+ * Copyright 2004 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.
+ *=============================================================================*/
+package org.apache.ws.resource.impl;
+
+import org.apache.axis.message.addressing.Action;
+import org.apache.axis.message.addressing.AddressingHeaders;
+import org.apache.axis.message.addressing.util.AddressingUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.Soap1_1Constants;
+import org.apache.ws.resource.JndiConstants;
+import org.apache.ws.resource.Resource;
+import org.apache.ws.resource.ResourceContext;
+import org.apache.ws.resource.ResourceContextException;
+import org.apache.ws.resource.ResourceException;
+import org.apache.ws.resource.ResourceHome;
+import org.apache.ws.resource.faults.FaultException;
+import org.apache.ws.resource.i18n.Keys;
+import org.apache.ws.resource.i18n.MessagesImpl;
+import org.apache.ws.util.i18n.Messages;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.xml.rpc.handler.MessageContext;
+import javax.xml.rpc.handler.soap.SOAPMessageContext;
+import javax.xml.soap.SOAPMessage;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * An abstract implementation of a resource context.
+ */
+public abstract class AbstractResourceContext
+ implements ResourceContext
+{
+ private static final Log LOG = LogFactory.getLog( AbstractResourceContext.class.getName( ) );
+ private static final Messages MSG = MessagesImpl.getInstance( );
+ private SOAPMessage m_msg;
+ private ResourceHome m_home;
+ private String m_serviceName;
+ private URL m_serviceURL;
+ private Map m_propsMap = Collections.synchronizedMap( new HashMap( ) );
+ private String m_baseURL;
+ private String m_action;
+ private SOAPMessageContext m_msgContext;
+
+ /**
+ * Creates a new {@link AbstractResourceContext} object.
+ *
+ * @param soapMsgContext DOCUMENT_ME
+ */
+ public AbstractResourceContext( SOAPMessageContext soapMsgContext )
+ throws Exception
+ {
+ if ( soapMsgContext == null )
+ {
+ throw new IllegalArgumentException( MSG.getMessage( Keys.NULL_SOAPMSGCTX ) );
+ }
+
+ m_msgContext = soapMsgContext;
+ m_msg = soapMsgContext.getMessage( );
+ extractFields( soapMsgContext );
+ try
+ {
+ m_home = (ResourceHome) new InitialContext( ).lookup( getResourceHomeLocation( ) );
+ }
+ catch ( NamingException ne )
+ {
+ ne.printStackTrace( );
+ throw new ResourceContextException( ne );
+ }
+
+ if ( m_home instanceof AbstractResourceHome )
+ {
+ AbstractResourceHome abstractResourceHome = ( (AbstractResourceHome) m_home );
+
+ //check if home has been initialized
+ synchronized ( abstractResourceHome )
+ {
+ if ( !abstractResourceHome.isInitialized( ) )
+ {
+ abstractResourceHome.init( );
+ }
+ }
+ }
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public String getBaseURL( )
+ {
+ return m_baseURL;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param name DOCUMENT_ME
+ * @param value DOCUMENT_ME
+ */
+ public void setProperty( String name,
+ Object value )
+ {
+ m_propsMap.put( name, value );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param name DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public Object getProperty( String name )
+ {
+ return this.m_propsMap.get( name );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public Iterator getPropertyNames( )
+ {
+ return this.m_propsMap.keySet( ).iterator( );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public String getRequestAction( )
+ {
+ return m_action;
+ }
+
+ /**
+ * @see org.apache.ws.resource.ResourceContext#getResource()
+ */
+ public Resource getResource( )
+ throws ResourceException
+ {
+ ResourceHome home = getResourceHome( );
+ Object id = home.extractResourceIdentifier( this );
+ return home.find( id );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public ResourceHome getResourceHome( )
+ {
+ return m_home;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public synchronized String getResourceHomeLocation( )
+ {
+ String homeLocation =
+ JndiConstants.CONTEXT_NAME_SERVICES + "/" + getServiceName( ) + "/" + JndiConstants.ATOMIC_NAME_HOME;
+ LOG.debug( MSG.getMessage( Keys.JNDI_HOME_LOCATION, homeLocation ) );
+ return homeLocation;
+ }
+
+ /**
+ * @see ResourceContext#setResponseAction(java.net.URI)
+ */
+ public void setResponseAction( URI action )
+ {
+ if ( action != null )
+ {
+ AddressingHeaders responseAddrHeaders = AddressingUtils.getResponseHeaders( m_msgContext );
+ try
+ {
+ responseAddrHeaders.setAction( action.toString( ) );
+ }
+ catch ( Exception e )
+ {
+ throw new RuntimeException( "Failed to set wsa:Action for response.", e );
+ }
+ }
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public SOAPMessage getSOAPMessage( )
+ {
+ return m_msg;
+ }
+
+ /**
+ * Returns target m_serviceName associated with this context.
+ *
+ * @return the target m_serviceName that was set with {@link #setServiceName(String) setService()}. If set to
+ * <code>null</code> or not set at all, by default it returns the target m_serviceName associated with the
+ * underlying SOAP m_msg context.
+ */
+ public String getServiceName( )
+ {
+ return m_serviceName;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public URL getServiceURL( )
+ {
+ return m_serviceURL;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param name DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public boolean containsProperty( String name )
+ {
+ return this.m_propsMap.containsKey( name );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param name DOCUMENT_ME
+ */
+ public void removeProperty( String name )
+ {
+ this.m_propsMap.remove( name );
+ }
+
+ /**
+ * Returns the WS-Addressing Action Header
+ *
+ * @param msgContext SAAJ message context; may not be null
+ *
+ * @return
+ */
+ protected String getAddressingAction( MessageContext msgContext )
+ {
+ AddressingHeaders addrHeaders =
+ (AddressingHeaders) msgContext.getProperty( org.apache.axis.message.addressing.Constants.ENV_ADDRESSING_REQUEST_HEADERS );
+ if ( addrHeaders == null )
+ {
+ LOG.debug( MSG.getMessage( Keys.NO_WSA_HEADERS ) );
+ throw new FaultException( Soap1_1Constants.FAULT_CLIENT, "This endpoint requires WS-Addressing headers." );
+ }
+
+ Action wsaAction = addrHeaders.getAction( );
+ if ( wsaAction == null )
+ {
+ LOG.debug( MSG.getMessage( Keys.NO_WSA_ACTION ) );
+ throw new FaultException( Soap1_1Constants.FAULT_CLIENT,
+ "The WS-Addressing Action header is required by this endpoint." );
+ }
+
+ LOG.debug( MSG.getMessage( Keys.GET_ACTION_FROM_ADDR_HDR, wsaAction ) );
+ return wsaAction.toString( );
+ }
+
+ /**
+ * Sets the target m_serviceName of this context.
+ *
+ * @param serviceName m_serviceName name.
+ */
+ protected void setServiceName( String serviceName )
+ {
+ m_serviceName = serviceName;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param msgContext DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ protected String getServiceName( MessageContext msgContext )
+ {
+ URL serviceURL = ( m_serviceURL != null ) ? m_serviceURL : getServiceURL( );
+ return serviceURL.getFile( );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param msgContext SAAJ message context; may not be null
+ *
+ * @return DOCUMENT_ME
+ */
+ protected URL getServiceURL( MessageContext msgContext )
+ {
+ AddressingHeaders wsaHeaders =
+ (AddressingHeaders) msgContext.getProperty( org.apache.axis.message.addressing.Constants.ENV_ADDRESSING_REQUEST_HEADERS );
+ try
+ {
+ String serviceUrl = wsaHeaders.getTo( ).toString( );
+ LOG.debug( MSG.getMessage( Keys.GET_SERVICE_URL_FROM_ADDR_HDR, serviceUrl ) );
+ return new URL( serviceUrl );
+ }
+ catch ( MalformedURLException murle )
+ {
+ throw new RuntimeException( "Value of wsa:To SOAP header element is not a valid URL.", murle );
+ }
+ }
+
+ private String getBaseURL( URL serviceURL )
+ {
+ String s = serviceURL.toString( );
+ s = s.substring( 0,
+ s.lastIndexOf( "/" ) );
+ return s;
+ }
+
+ private void extractFields( MessageContext msgContext )
+ {
+ m_serviceURL = getServiceURL( msgContext );
+ m_serviceName = getServiceName( msgContext );
+ m_baseURL = getBaseURL( m_serviceURL );
+ m_action = getAddressingAction( msgContext );
+ extractProperties( msgContext );
+ }
+
+ private void extractProperties( MessageContext msgContext )
+ {
+ Iterator propertyNames = msgContext.getPropertyNames( );
+ while ( propertyNames.hasNext( ) )
+ {
+ String keyName = (String) propertyNames.next( );
+ m_propsMap.put( keyName,
+ msgContext.getProperty( keyName ) );
+ }
+ }
+}
\ No newline at end of file
Added: webservices/muse/branches/1.0/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java (added)
+++ webservices/muse/branches/1.0/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,1035 @@
+/*=============================================================================*
+ * Copyright 2004 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.
+ *=============================================================================*/
+package org.apache.ws.resource.impl;
+
+import commonj.timers.Timer;
+import commonj.timers.TimerManager;
+import org.apache.commons.collections.map.ReferenceMap;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.Soap1_1Constants;
+import org.apache.ws.addressing.EndpointReference;
+import org.apache.ws.addressing.XmlBeansEndpointReference;
+import org.apache.ws.resource.IllegalResourceTypeException;
+import org.apache.ws.resource.JndiConstants;
+import org.apache.ws.resource.PersistentResource;
+import org.apache.ws.resource.PropertiesResource;
+import org.apache.ws.resource.Resource;
+import org.apache.ws.resource.ResourceContext;
+import org.apache.ws.resource.ResourceCreationEvent;
+import org.apache.ws.resource.ResourceCreationListener;
+import org.apache.ws.resource.ResourceDestructionEvent;
+import org.apache.ws.resource.ResourceDestructionListener;
+import org.apache.ws.resource.ResourceException;
+import org.apache.ws.resource.ResourceHome;
+import org.apache.ws.resource.ResourceUnknownException;
+import org.apache.ws.resource.faults.FaultException;
+import org.apache.ws.resource.i18n.Keys;
+import org.apache.ws.resource.i18n.MessagesImpl;
+import org.apache.ws.resource.lifetime.ScheduledResourceTerminationResource;
+import org.apache.ws.util.Cache;
+import org.apache.ws.util.NameUtils;
+import org.apache.ws.util.i18n.Messages;
+import org.apache.ws.util.jndi.Initializable;
+import org.apache.ws.util.jndi.JNDIUtils;
+import org.apache.ws.util.lock.Lock;
+import org.apache.ws.util.lock.LockManager;
+import org.apache.ws.util.platform.JaxRpcPlatform;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.xml.namespace.QName;
+import javax.xml.rpc.JAXRPCException;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPHeaderElement;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * TODO: Update these Javadocs
+ * <p/>
+ * LOG-DONE An implementation of the <code>ResourceHome</code> interface. This implementation was designed to work with
+ * resources that implement the {@link PersistentResource PersistenceCallback} interface as well as memory resident
+ * resources. If the resource class implements the {@link PersistentResource PersistenceCallback} interface
+ * <code>SoftReference</code>s will be used to recycle resource objects. The resource class implementation is
+ * responsible for saving its state to disk. This implementation will <b>not</b> call {@link PersistentResource#store()
+ * PersistenceCallback.store()}. The resource implementation must have a default constructor. <br><br> Configuration
+ * options: <ul> <li> sweeperDelay - configures how often the resource sweeper runs in msec. By default the resource
+ * sweeper runs every minute. For example:
+ * <pre>
+ * <parameter>
+ * <name>sweeperDelay</name>
+ * <value>60000</value>
+ * </parameter>
+ * </pre>
+ * <li> resourceClass - configures the name of the resource class. For example:
+ * <pre>
+ * <parameter>
+ * <name>resourceClass</name>
+ * <value>org.globus.wsrf.samples.counter.PersistentCounter</value>
+ * </parameter>
+ * </pre>
+ * <li> resourceKeyType - configures the key type class. By default <code>java.lang.String</code> is used. For example:
+ * <pre>
+ * <parameter>
+ * <name>resourceKeyType</name>
+ * <value>java.lang.Integer</value>
+ * </parameter>
+ * </pre>
+ * <li> resourceKeyName - configures the key name. For example:
+ * <pre>
+ * <parameter>
+ * <name>resourceKeyName</name>
+ * <value>{http://counter.com}CounterKey</value>
+ * </parameter>
+ * </pre>
+ * </ul> <br> <b>Note:</b> Must be deployed with <code>org.globus.wsrf.jndi.BeanFactory</code> in JNDI or user must
+ * first call {@link #init() initialize()} method. Also when overriding the {@link #init() initialize()} method make
+ * sure to call <code>super.initialize();</code>.
+ *
+ * @author Globus, Ian Springer
+ */
+public abstract class AbstractResourceHome
+ implements ResourceHome,
+ Initializable
+{
+ private static final int DEFAULT_SWEEPER_DELAY = 60000;
+ private static final Log LOG = LogFactory.getLog( AbstractResourceHome.class );
+
+ /** DOCUMENT_ME */
+ public static final Messages MSG = MessagesImpl.getInstance( );
+
+ /**
+ * A static key used only for registering Singleton Resources
+ */
+ private static final Object SINGLETON_KEY = new Object( );
+ private static final String PLACEHOLDER_IPADDRESS = "$IP_ADDRESS$";
+ private static final String PLACEHOLDER_HOSTNAME = "$HOST_NAME$";
+
+ /**
+ * DOCUMENT_ME
+ */
+ protected Map m_resources;
+
+ /**
+ * DOCUMENT_ME
+ */
+ protected String m_resourceClassName;
+
+ /** DOCUMENT_ME */
+ protected boolean m_resourceIsPersistent;
+ private QName m_resourceIdRefParamName;
+ private String m_wsdlTargetNamespace;
+ private String m_serviceClassName;
+
+ /**
+ * The baseURL obtained via JNDI config, used as the basis for the endpoint URL.
+ */
+ private String m_baseWebappUrl;
+
+ /**
+ * DOCUMENT_ME
+ */
+ protected LockManager m_lockManager;
+ private String m_cacheLocation;
+ private Cache m_cache;
+ private long m_sweeperDelay = DEFAULT_SWEEPER_DELAY;
+ private Sweeper m_sweeper;
+ private boolean m_initialized;
+ private Class m_resourceClass;
+ private List m_creationListeners = new ArrayList( );
+ private List m_destructionListeners = new ArrayList( );
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param jndiLocation DOCUMENT_ME
+ */
+ public void setCacheLocation( String jndiLocation )
+ {
+ m_cacheLocation = jndiLocation;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public String getCacheLocation( )
+ {
+ return m_cacheLocation;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public abstract org.apache.ws.resource.properties.NamespaceVersionHolder getNamespaceVersionHolder( );
+
+ /**
+ * Returns the EndpointReference associated with this Resource. Only the required fields will be filled in (i.e.
+ * Address) AND the ReferenceProperty for the ResourceKey (if not a singleton)
+ * <p/>
+ * If the resourceKey is not equal to null ( not a singleton ), the reference properties will contain the key.
+ *
+ * @param resourceId the resource identifier, or null if the resource is a singleton
+ * @return an EndpointReference (EPR) for the resource
+ */
+ public EndpointReference getEndpointReference( Object resourceId )
+ {
+ String endpointAddress =
+ JaxRpcPlatform.getJaxRpcPlatform( ).getEndpointUrl( getBaseWebappUrl( ),
+ getServiceName( ).getLocalPart( ) );
+ String wsAddressingURI = getNamespaceVersionHolder( ).getAddressingNamespace( );
+
+ XmlBeansEndpointReference xmlBeansEndpointReference =
+ new XmlBeansEndpointReference( endpointAddress, wsAddressingURI );
+ xmlBeansEndpointReference.setResourceIdentifierReferenceParameterName( getResourceIdentifierReferenceParameterQName( ) );
+ xmlBeansEndpointReference.setResourceIdentifier( resourceId );
+ xmlBeansEndpointReference.setPortTypeQName( getPortType( ) );
+ xmlBeansEndpointReference.setServicePortName( getServicePortName( ) );
+ xmlBeansEndpointReference.setServiceQName( getServiceName( ) );
+ return xmlBeansEndpointReference;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public abstract QName getPortType( );
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param resourceClass DOCUMENT_ME
+ */
+ public void setResourceClassName( String resourceClass )
+ {
+ m_resourceClassName = resourceClass;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public String getResourceClassName( )
+ {
+ return m_resourceClassName;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param className DOCUMENT_ME
+ */
+ public void setServiceClassName( String className )
+ {
+ m_serviceClassName = className;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public String getServiceClassName( )
+ {
+ return m_serviceClassName;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public abstract QName getServiceName( );
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public abstract String getServicePortName( );
+
+ /**
+ * Sets the base webapp url.
+ * <p/>
+ * The URL should contin the webapp context name. (i.e. http://127.0.0.1:8080/wsrf)
+ * <p/>
+ * The URL may contain one of the following:
+ * <p/>
+ * <ol>
+ * <li>the marker <IP_ADDRESS> in which case we will attempt to determine the IP address at runtime.
+ * i.e. http://<IP_ADDRESS>:8080/wsrf (Do not use on multi-homed systems)</li>
+ * <li>the marker <HOST_NAME> in which case we will attempt to determine the host name at runtime
+ * i.e. http://<HOST_NAME>:8080/wsrf </li>
+ * <li>NO Marker in which case whatever value you add will be static and used.
+ * i.e. http://myhostname:8080/wsrf </li>
+ * </ol>
+ *
+ * @param baseWebappUrl The base webapp url containing the webapp context. (i.e. http://127.0.0.1:8080/wsrf)
+ */
+ public void setBaseWebappUrl( String baseWebappUrl )
+ { //todo we may need to figure out a way to stop everything if this method fails.
+ //the url is nonexistant
+ if ( ( baseWebappUrl == null ) || baseWebappUrl.equals( "" ) )
+ {
+ try
+ {
+ m_baseWebappUrl = getDefaultUrl( );
+ LOG.fatal( "The baseWebappUrl from the jndi-config.xml file was invalid! Defaulting to: "
+ + m_baseWebappUrl );
+ }
+ catch ( java.net.UnknownHostException e )
+ {
+ m_baseWebappUrl = "http://127.0.0.1:8080/wsrf";
+ LOG.fatal( "The baseWebappUrl from the jndi-config.xml file was invalid! Unable to determine host IP address using java.net.InetAddress.getLocalHost().getHostAddress() defaulting to: "
+ + m_baseWebappUrl, e );
+ return;
+ }
+ }
+
+ //the url is not to be modified
+ else if ( ( baseWebappUrl.indexOf( PLACEHOLDER_IPADDRESS ) == -1 )
+ && ( baseWebappUrl.indexOf( PLACEHOLDER_HOSTNAME ) == -1 ) )
+ {
+ m_baseWebappUrl = baseWebappUrl;
+ return;
+ }
+
+ //url will need to be built
+ //define localhost to be used
+ java.net.InetAddress localHost = null;
+
+ try
+ {
+ localHost = java.net.InetAddress.getLocalHost( );
+ }
+ catch ( java.net.UnknownHostException e )
+ {
+ LOG.fatal( "Unable to get the InetAddress for localhost using InetAddress.getLocalHost(). Defaults will be used. This may cause problems with EndpointReferences in Resources." );
+ }
+
+ if ( baseWebappUrl.indexOf( PLACEHOLDER_IPADDRESS ) > -1 )
+ {
+ String ipaddress = null;
+ if ( localHost == null )
+ {
+ ipaddress = "127.0.0.1";
+ }
+ else
+ {
+ ipaddress = localHost.getHostAddress( );
+ }
+
+ m_baseWebappUrl =
+ baseWebappUrl.substring( 0,
+ baseWebappUrl.indexOf( PLACEHOLDER_IPADDRESS ) ) + ipaddress
+ + baseWebappUrl.substring( baseWebappUrl.indexOf( PLACEHOLDER_IPADDRESS )
+ + PLACEHOLDER_IPADDRESS.length( ) );
+ return;
+ } //end if
+
+ else if ( baseWebappUrl.indexOf( PLACEHOLDER_HOSTNAME ) > -1 )
+ {
+ String hostname = null;
+ if ( localHost == null )
+ {
+ hostname = "127.0.0.1";
+ }
+ else
+ {
+ hostname = localHost.getHostName( );
+ }
+
+ m_baseWebappUrl =
+ baseWebappUrl.substring( 0,
+ baseWebappUrl.indexOf( PLACEHOLDER_HOSTNAME ) ) + hostname
+ + baseWebappUrl.substring( baseWebappUrl.indexOf( PLACEHOLDER_HOSTNAME )
+ + PLACEHOLDER_HOSTNAME.length( ) );
+ return;
+ } //end else if
+ }
+
+ /**
+ * Returns the base webapp url which includes the webapp context. (i.e. http://127.0.0.1:8080/wsrf)
+ *
+ * @return base webapp url
+ */
+ public String getBaseWebappUrl( )
+ {
+ return m_baseWebappUrl;
+ }
+
+ /**
+ * Returns true if the home has been initialized, else false
+ *
+ * @return true if the home has been initialized, else false
+ */
+ public boolean isInitialized( )
+ {
+ return m_initialized;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param name DOCUMENT_ME
+ */
+ public void setResourceIdentifierReferenceParameterName( String name )
+ {
+ m_resourceIdRefParamName = QName.valueOf( name );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public String getResourceIdentifierReferenceParameterName( )
+ {
+ //case of singleton...
+ if ( m_resourceIdRefParamName == null )
+ {
+ return null;
+ }
+
+ return m_resourceIdRefParamName.toString( );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public QName getResourceIdentifierReferenceParameterQName( )
+ {
+ return m_resourceIdRefParamName;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param delay DOCUMENT_ME
+ */
+ public void setSweeperDelay( long delay )
+ {
+ m_sweeperDelay = delay;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public long getSweeperDelay( )
+ {
+ return m_sweeperDelay;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param targetNamespace DOCUMENT_ME
+ */
+ public void setWsdlTargetNamespace( String targetNamespace )
+ {
+ m_wsdlTargetNamespace = targetNamespace;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public String getWsdlTargetNamespace( )
+ {
+ return m_wsdlTargetNamespace;
+ }
+
+ /**
+ * @see ResourceHome#add(org.apache.ws.resource.Resource)
+ */
+ public boolean add( Resource resource )
+ throws IllegalResourceTypeException
+ {
+ boolean resourceWasAdded = false;
+ if ( !m_resourceClass.isAssignableFrom( resource.getClass( ) ) )
+ {
+ throw new IllegalResourceTypeException( "This home only supports resources of type "
+ + m_resourceClassName );
+ }
+
+ synchronized ( m_resources )
+ {
+ Object key = getNonNullKey( resource.getID( ) );
+ if ( resource.getEndpointReference( ) == null )
+ {
+ resource.setEndpointReference( getEndpointReference( key ) );
+ }
+
+ if ( !m_resources.containsKey( key ) )
+ {
+ LOG.debug( MSG.getMessage( Keys.ADDING_RESOURCE_WITH_ID,
+ resource.getID( ),
+ getClass( ).getName( ) ) );
+ m_resources.put( key, resource );
+ scheduleSweeperTask( );
+ notifyResourceCreatedListeners( resource );
+ updateCache( resource );
+ resourceWasAdded = true;
+ }
+ }
+
+ return resourceWasAdded;
+ }
+
+ /**
+ * Adds a listener for ResourceCreationEvents
+ *
+ * @param listener
+ */
+ public void addResourceCreationListener( ResourceCreationListener listener )
+ {
+ m_creationListeners.add( listener );
+ }
+
+ /**
+ * Adds a listener for ResourceDestructionEvents
+ *
+ * @param listener
+ */
+ public void addResourceDestructionListener( ResourceDestructionListener listener )
+ {
+ m_destructionListeners.add( listener );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param context DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public Object extractResourceIdentifier( ResourceContext context )
+ {
+ if ( getResourceIdentifierReferenceParameterName( ) == null )
+ {
+ return null;
+ }
+
+ try
+ {
+ SOAPHeader soapHeader = context.getSOAPMessage( ).getSOAPHeader( );
+ Iterator resourceIdElemsIter =
+ soapHeader.getChildElements( NameUtils.toName( getResourceIdentifierReferenceParameterQName( ) ) );
+ if ( !resourceIdElemsIter.hasNext( ) )
+ {
+ throw new FaultException( Soap1_1Constants.FAULT_CLIENT,
+ "The expected resource identifier reference parameter named "
+ + getResourceIdentifierReferenceParameterName( )
+ + " was not found in the SOAP header." );
+ }
+
+ SOAPHeaderElement resourceIdElem = (SOAPHeaderElement) resourceIdElemsIter.next( );
+ if ( resourceIdElemsIter.hasNext( ) )
+ {
+ throw new FaultException( Soap1_1Constants.FAULT_CLIENT,
+ "More than one resource identifier reference parameter named "
+ + getResourceIdentifierReferenceParameterName( )
+ + " was found in the SOAP header. Exactly one is expected." );
+ }
+
+ return resourceIdElem.getValue( );
+ }
+ catch ( SOAPException soape )
+ {
+ throw new JAXRPCException( soape );
+ }
+ }
+
+ /**
+ * @see ResourceHome#find(Object)
+ */
+ public Resource find( Object resourceId )
+ throws ResourceUnknownException,
+ ResourceException
+ {
+ LOG.debug( MSG.getMessage( Keys.FINDING_RESOURCE_WITH_KEY,
+ String.valueOf( resourceId ) ) );
+ Resource resource = null;
+ synchronized ( m_resources )
+ {
+ //Lock lock = acquireLock( resourceId );
+ //try
+ //{
+ resource = get( resourceId );
+ updateCache( resource );
+
+ //}
+ //finally
+ //{
+ // lock.release();
+ //}
+ }
+
+ return resource;
+ }
+
+ /**
+ * Initializes this home. Should be called <em>after</em> setters have been called on all bean properties.
+ *
+ * @throws Exception on error
+ */
+ public void init( )
+ throws Exception
+ {
+ synchronized ( this )
+ {
+ if ( m_initialized )
+ {
+ return;
+ }
+
+ LOG.debug( MSG.getMessage( Keys.INIT_HOME ) );
+ Class resourceClass = getResourceClass( );
+ if ( PersistentResource.class.isAssignableFrom( resourceClass ) )
+ {
+ m_resourceIsPersistent = true;
+ }
+
+ Context initialContext = new InitialContext( );
+ m_resources = getResourceMap( );
+ m_lockManager = new LockManager( );
+ if ( ScheduledResourceTerminationResource.class.isAssignableFrom( getResourceClass( ) ) )
+ {
+ initSweeper( initialContext );
+ }
+
+ initCachePolicy( new InitialContext( ) );
+ m_initialized = true;
+ }
+ }
+
+ /**
+ * @see ResourceHome#remove(Object)
+ */
+ public void remove( Object resourceId )
+ throws ResourceUnknownException,
+ ResourceException
+ {
+ Resource resource = null;
+ Lock lock = acquireLock( resourceId );
+ try
+ {
+ resource = get( resourceId );
+
+ try
+ {
+ resource.destroy( );
+ }
+ catch ( RuntimeException re )
+ {
+ throw new ResourceException( MSG.getMessage( Keys.FAILED_TO_DESTROY_RESOURCE, resource, re ) );
+ }
+
+ Resource removedResource = (Resource) m_resources.remove( getNonNullKey( resourceId ) );
+ if ( removedResource instanceof PropertiesResource )
+ {
+ notifyResourceDeletedListeners( removedResource );
+ }
+
+ LOG.debug( MSG.getMessage( Keys.REMOVED_RESOURCE_WITH_KEY,
+ resource.getClass( ).getName( ),
+ String.valueOf( resourceId ) ) );
+ if ( m_cache != null )
+ {
+ m_cache.remove( resource );
+ }
+ }
+ finally
+ {
+ lock.release( );
+ }
+ }
+
+ /**
+ * Removes a listener for ResourceCreationEvents
+ *
+ * @param listener
+ * @return true if the listener was removed, else false
+ */
+ public boolean removeResourceCreationListener( ResourceCreationListener listener )
+ {
+ return m_creationListeners.remove( listener );
+ }
+
+ /**
+ * Removes a listener for ResourceDestructionEvents
+ *
+ * @param listener
+ * @return true if the listener was removed, else false
+ */
+ public boolean removeResourceDestructionListener( ResourceDestructionListener listener )
+ {
+ return m_destructionListeners.remove( listener );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ *
+ * @throws NamingException DOCUMENT_ME
+ */
+ protected abstract Map getResourceMap( )
+ throws NamingException;
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ *
+ * @throws java.net.UnknownHostException DOCUMENT_ME
+ */
+ protected String getDefaultUrl( )
+ throws java.net.UnknownHostException
+ {
+ return "http://" + java.net.InetAddress.getLocalHost( ).getHostAddress( ) + ":8080/wsrf";
+ }
+
+ /**
+ * This method uses reflection to create an instance of a Resource which contains an empty constructor. It will not
+ * work with Resources which do not have an empty constructor.
+ * <p/>
+ * Note: the returned Resource will an EndpointReference associated with it.
+ *
+ * @param id the resource identifier
+ * @return a resource of the type associated with this home
+ * @throws ResourceException
+ * @throws IllegalStateException
+ */
+ protected Resource createInstance( Object id )
+ throws ResourceException
+ {
+ LOG.debug( MSG.getMessage( Keys.CREATING_INSTANCE_WITH_KEY,
+ String.valueOf( id ) ) );
+ Resource resource;
+ try
+ {
+ resource = (Resource) getResourceClass( ).newInstance( );
+ }
+ catch ( Exception e )
+ {
+ throw new ResourceException( e );
+ }
+
+ resource.setID( id );
+ try
+ {
+ LOG.debug( MSG.getMessage( Keys.INIT_RESOURCE_LIFECYCLE_INSTANCE,
+ resource.getClass( ).getName( ) ) );
+ if ( resource.getEndpointReference( ) == null ) //also checked in add(..) in case they sidestep this
+ {
+ resource.setEndpointReference( getEndpointReference( id ) );
+ }
+
+ resource.init( );
+ }
+ catch ( RuntimeException re )
+ {
+ throw new ResourceException( MSG.getMessage( Keys.FAILED_TO_INIT_RESOURCE, resource, re ), re );
+ }
+
+ return resource;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param id DOCUMENT_ME
+ * @return DOCUMENT_ME
+ * @throws ResourceException DOCUMENT_ME
+ */
+ protected Resource createNewInstanceAndLoad( Object id )
+ throws ResourceException
+ {
+ Resource resource = createInstance( id );
+ LOG.debug( MSG.getMessage( Keys.LOADING_RESOURCE_FROM_PERSISTENCE,
+ String.valueOf( id ) ) );
+ ( (PersistentResource) resource ).load( );
+ if ( ResourceSweeper.isExpired( resource ) )
+ {
+ throw new ResourceUnknownException( getNonNullKey( id ),
+ getServicePortName( ) );
+ }
+
+ return resource;
+ }
+
+ /**
+ * Creates a synschronized map for storing {@link Resource}s. If the resource is persistent, a {@link ReferenceMap}
+ * is used, otherwise a {@link HashMap} is used. Provided for the convenience of subclasses, which are responsible
+ * for creating a map of resources and maintaining a static reference to that map.
+ *
+ * @param isPersistent if the resource is persistent
+ * @return a synschronized map for storing {@link Resource}s
+ */
+ protected static Map createResourceMap( boolean isPersistent )
+ {
+ Map resourceMap;
+ if ( isPersistent )
+ {
+ resourceMap = new ReferenceMap( ReferenceMap.HARD, ReferenceMap.SOFT, true );
+ }
+ else
+ {
+ resourceMap = new HashMap( );
+ }
+
+ return Collections.synchronizedMap( resourceMap );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param initialContext DOCUMENT_ME
+ *
+ * @throws NamingException DOCUMENT_ME
+ */
+ protected void initCachePolicy( Context initialContext )
+ throws NamingException
+ {
+ if ( m_cacheLocation != null )
+ {
+ m_cache = (Cache) JNDIUtils.lookup( initialContext, m_cacheLocation, Cache.class );
+ }
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param obj DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ Object getNonNullKey( Object obj )
+ {
+ return ( obj != null ) ? obj : SINGLETON_KEY;
+ }
+
+ private Class getResourceClass( )
+ throws ResourceException
+ {
+ if ( m_resourceClass == null )
+ {
+ if ( m_resourceClassName == null )
+ {
+ throw new IllegalStateException( MSG.getMessage( Keys.RESOURCE_CLASSNAME_NULL ) );
+ }
+
+ try
+ {
+ m_resourceClass = Class.forName( m_resourceClassName );
+ }
+ catch ( ClassNotFoundException cnfe )
+ {
+ throw new ResourceException( MSG.getMessage( Keys.RESOURCE_CLASS_NOT_FOUND, m_resourceClassName ) );
+ }
+
+ if ( !Resource.class.isAssignableFrom( m_resourceClass ) )
+ {
+ throw new ResourceException( "Specified resource class '" + m_resourceClassName
+ + "' does not implement the " + Resource.class.getName( )
+ + " interface." );
+ }
+ }
+
+ return m_resourceClass;
+ }
+
+ private Lock acquireLock( Object resourceId )
+ throws ResourceException
+ {
+ Lock lock = m_lockManager.getLock( getNonNullKey( resourceId ) );
+ try
+ {
+ lock.acquire( );
+ }
+ catch ( InterruptedException ie )
+ {
+ throw new ResourceException( ie );
+ }
+
+ return lock;
+ }
+
+ private Resource get( Object resourceId )
+ throws ResourceException
+ {
+ LOG.debug( MSG.getMessage( Keys.GETTING_RESOURCE_WITH_ID,
+ resourceId,
+ getClass( ).getName( ) ) );
+ Resource resource = (Resource) m_resources.get( getNonNullKey( resourceId ) );
+ if ( resource == null )
+ {
+ if ( !m_resourceIsPersistent )
+ {
+ throw new ResourceUnknownException( resourceId,
+ getServicePortName( ) );
+ }
+
+ add( createNewInstanceAndLoad( resourceId ) );
+ }
+
+ return resource;
+ }
+
+ private void initSweeper( Context initialContext )
+ throws NamingException
+ {
+ LOG.debug( MSG.getMessage( Keys.TIMER_LOOKUP_WITH_JNDI_NAME, JndiConstants.KEY_NAME_DEFAULT_TIMER ) );
+ TimerManager timerManager = (TimerManager) initialContext.lookup( JndiConstants.KEY_NAME_DEFAULT_TIMER );
+
+ // TimerManager timerManager = new TimerManagerImpl();
+ m_sweeper = new Sweeper( this, m_resources, timerManager, m_sweeperDelay );
+ }
+
+ /**
+ * This method is used to notify listeners a resource has been created.
+ *
+ * @param resource The Resource which was created
+ */
+ private void notifyResourceCreatedListeners( Resource resource )
+ {
+ for ( int i = 0; i < m_creationListeners.size( ); i++ )
+ {
+ ResourceCreationListener resourceCreationListener =
+ (ResourceCreationListener) m_creationListeners.get( i );
+ resourceCreationListener.creationOccurred( new ResourceCreationEvent( resource ) );
+ }
+ }
+
+ /**
+ * This method is used to notify listeners a resource has been deleted.
+ *
+ * @param resource The EndpointReference for the Resource which was created
+ */
+ private void notifyResourceDeletedListeners( Resource resource )
+ {
+ for ( int i = 0; i < m_destructionListeners.size( ); i++ )
+ {
+ ResourceDestructionListener resourceDestructionListener =
+ (ResourceDestructionListener) m_destructionListeners.get( i );
+ ResourceDestructionEvent event = new ResourceDestructionEvent( resource );
+ resourceDestructionListener.destructionOccurred( event );
+ }
+ }
+
+ private void scheduleSweeperTask( )
+ {
+ if ( m_sweeper != null )
+ {
+ m_sweeper.schedule( );
+ }
+ }
+
+ private void updateCache( Resource resource )
+ {
+ if ( m_cache != null )
+ {
+ m_cache.update( resource );
+ }
+ }
+
+ /**
+ * This ResourceSweeper implementation just returns the resources currently stored in the map. The reason is that
+ * the sweeper doesn't have to reactivate/reload a persistent resource if the resource object was reclaimed. So
+ * lifetime checks are not done on reclained resources. Lifetime checks have to be done on resource load.
+ */
+ private static class Sweeper
+ extends ResourceSweeper
+ {
+ private TimerManager m_timerManager;
+ private Timer m_timer;
+ private long m_delay;
+
+ /**
+ * Creates a new {@link Sweeper} object.
+ *
+ * @param home DOCUMENT_ME
+ * @param resources DOCUMENT_ME
+ * @param timerManager DOCUMENT_ME
+ * @param delay DOCUMENT_ME
+ */
+ public Sweeper( ResourceHome home,
+ Map resources,
+ TimerManager timerManager,
+ long delay )
+ {
+ super( home, resources );
+ m_timerManager = timerManager;
+ m_delay = delay;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param timer DOCUMENT_ME
+ */
+ public void timerExpired( Timer timer )
+ {
+ super.timerExpired( timer );
+ cancel( );
+ if ( !m_resources.isEmpty( ) )
+ {
+ schedule( );
+ }
+ }
+
+ /**
+ * Schedules this resource sweeper.
+ */
+ synchronized void schedule( )
+ {
+ if ( m_timer == null )
+ {
+ LOG.debug( MSG.getMessage( Keys.SCHEDULE_RESOURCE_SWEEPER ) );
+ m_timer = m_timerManager.schedule( this, m_delay );
+ }
+ }
+
+ /**
+ * Cancels this resource sweeper.
+ */
+ private synchronized void cancel( )
+ {
+ if ( m_timer != null )
+ {
+ LOG.debug( MSG.getMessage( Keys.CANCEL_RESOURCE_SWEEPER ) );
+ m_timer = null;
+ }
+ }
+ }
+}
\ No newline at end of file
Added: webservices/muse/branches/1.0/src/java/org/apache/ws/resource/impl/ResourceCapabilityImpl.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/java/org/apache/ws/resource/impl/ResourceCapabilityImpl.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/java/org/apache/ws/resource/impl/ResourceCapabilityImpl.java (added)
+++ webservices/muse/branches/1.0/src/java/org/apache/ws/resource/impl/ResourceCapabilityImpl.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,577 @@
+/*=============================================================================*
+ * Copyright 2004 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.
+ *=============================================================================*/
+package org.apache.ws.resource.impl;
+
+import org.apache.ws.resource.InvalidWsrfWsdlException;
+import org.apache.ws.resource.ResourceCapability;
+import org.apache.ws.util.WsdlUtils;
+import org.apache.ws.util.WsrfWsdlUtils;
+import javax.wsdl.Definition;
+import javax.wsdl.Import;
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A {@link ResourceCapability} implementation.
+ *
+ * @author Ian Springer (ian DOT springer AT hp DOT com)
+ */
+public class ResourceCapabilityImpl
+ implements ResourceCapability
+{
+ private Definition m_def;
+ private PortType m_portType;
+ private Map m_implementedResourceDefs;
+ private QName[] m_propNames;
+ private String[] m_customOpNames;
+ private QName[] m_customPropNames;
+ private QName m_propsDocName;
+ private String m_metadataDescLocation;
+ private QName m_metadataDescName;
+ private URL m_baseUrl;
+
+ /**
+ * Creates a new {@link ResourceCapabilityImpl} based on the specified JWSDL definition and portType.
+ *
+ * @param def a JWSDL definition
+ * @param baseURL
+ */
+ public ResourceCapabilityImpl( Definition def,
+ PortType portType,
+ URL baseURL )
+ throws InvalidWsrfWsdlException
+ {
+ m_def = def;
+ m_portType = portType;
+ m_baseUrl = baseURL;
+ initImplementedPortTypes( );
+ initCustomOperations( );
+ initPropertyNames( );
+ m_metadataDescName = WsrfWsdlUtils.getMetadataDescriptorName( m_portType );
+ m_metadataDescLocation = WsrfWsdlUtils.getMetadataDescriptorLocation( m_portType );
+ if ( !m_def.getTargetNamespace( ).startsWith( "http://docs.oasis-open.org/" ) )
+ {
+ validateOperations( );
+ validateProperties( );
+ }
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public String[] getCustomOperationNames( )
+ {
+ return m_customOpNames;
+ }
+
+ /**
+ * @return
+ */
+ public QName[] getCustomPropertyNames( )
+ {
+ return m_customPropNames;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public Definition getDefinition( )
+ {
+ return m_def;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public Map getImplementedResourceCapabilities( )
+ {
+ return m_implementedResourceDefs;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public PortType getPortType( )
+ {
+ return m_portType;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public QName[] getPropertyNames( )
+ {
+ return m_propNames;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public boolean hasProperties( )
+ {
+ return m_propNames != null;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param args DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public static void main( String[] args )
+ throws Exception
+ {
+ WSDLReader wsdlReader = WSDLFactory.newInstance( ).newWSDLReader( );
+ String wsdlPath = "C:\\opt\\pubscribe-1.0-beta1\\webapps\\pubscribe\\wsdl\\FileSystem.wsdl";
+ Definition def = wsdlReader.readWSDL( wsdlPath );
+ PortType portType = (PortType) def.getPortTypes( ).values( ).toArray( )[0];
+ ResourceCapability wsResourceDef = null;
+ try
+ {
+ wsResourceDef = new ResourceCapabilityImpl( def, portType, null );
+ }
+ catch ( InvalidWsrfWsdlException iwwe )
+ {
+ System.err.println( iwwe );
+ System.exit( 1 );
+ }
+
+ System.out.println( wsResourceDef );
+
+ Map implementedResourceDefs = wsResourceDef.getImplementedResourceCapabilities( );
+ Iterator specDefs = implementedResourceDefs.values( ).iterator( );
+ while ( specDefs.hasNext( ) )
+ {
+ System.out.println( (ResourceCapability) specDefs.next( ) );
+ }
+
+ System.out.println( wsResourceDef.getMetadataDescriptorName( ) );
+ System.out.println( wsResourceDef.getMetadataDescriptorLocation( ) );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public String getMetadataDescriptorLocation( )
+ {
+ return m_metadataDescLocation;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public QName getMetadataDescriptorName( )
+ {
+ return m_metadataDescName;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public QName getPropertiesDocumentName( )
+ {
+ return m_propsDocName;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param capabilityName DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public boolean implementsResourceCapability( QName capabilityName )
+ {
+ return m_implementedResourceDefs.containsKey( capabilityName );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public String toString( )
+ {
+ StringBuffer strBuf = new StringBuffer( );
+ strBuf.append( "=== WS-Resource Definition defined via portType " + m_portType.getQName( ) + " ===\n" );
+ strBuf.append( "Implemented PortTypes:\n" );
+ if ( m_implementedResourceDefs.isEmpty( ) )
+ {
+ strBuf.append( "\t<NONE>\n" );
+ }
+ else
+ {
+ Iterator implementedPortTypeNameIter = m_implementedResourceDefs.keySet( ).iterator( );
+ while ( implementedPortTypeNameIter.hasNext( ) )
+ {
+ QName portTypeName = (QName) implementedPortTypeNameIter.next( );
+ strBuf.append( "\t" + portTypeName + "\n" );
+ }
+ }
+
+ strBuf.append( "Custom Operations:\n" );
+ if ( m_customOpNames.length == 0 )
+ {
+ strBuf.append( "\t<NONE>\n" );
+ }
+ else
+ {
+ for ( int i = 0; i < m_customOpNames.length; i++ )
+ {
+ strBuf.append( "\t" + m_customOpNames[i] + "\n" );
+ }
+ }
+
+ strBuf.append( "Custom Properties:\n" );
+ if ( !hasProperties( ) )
+ {
+ strBuf.append( "\t<NONE>\n" );
+ }
+ else
+ {
+ for ( int i = 0; i < m_customPropNames.length; i++ )
+ {
+ strBuf.append( "\t" + m_customPropNames[i] + "\n" );
+ }
+ }
+
+ return strBuf.toString( );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws InvalidWsrfWsdlException DOCUMENT_ME
+ */
+ protected void validateOperations( )
+ throws InvalidWsrfWsdlException
+ {
+ if ( hasProperties( ) )
+ {
+ if ( !m_implementedResourceDefs.containsKey( org.apache.ws.resource.properties.v2004_11.porttype.GetResourcePropertyPortType.NAME )
+ && !m_implementedResourceDefs.containsKey( org.apache.ws.resource.properties.v2004_06.porttype.GetResourcePropertyPortType.NAME ) )
+ {
+ throw new InvalidWsrfWsdlException( "PortType " + m_portType.getQName( )
+ + " defines a wsrp:ResourceProperties attribute but does not implement the WSRF-RP GetResourceProperty portType." );
+ }
+ }
+ else
+ {
+ Iterator resourceDefNames = m_implementedResourceDefs.keySet( ).iterator( );
+ while ( resourceDefNames.hasNext( ) )
+ {
+ QName resourceDefName = (QName) resourceDefNames.next( );
+ if ( resourceDefName.getNamespaceURI( ).equals( org.apache.ws.resource.properties.v2004_11.ResourcePropertiesConstants.NSURI_WSRP_WSDL )
+ || resourceDefName.getNamespaceURI( ).equals( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_WSDL ) )
+ {
+ throw new InvalidWsrfWsdlException( "PortType " + m_portType.getQName( )
+ + " does not define a wsrp:ResourceProperties attribute but implements one or more WSRF-RP portTypes." );
+ }
+ }
+ }
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws InvalidWsrfWsdlException DOCUMENT_ME
+ */
+ protected void validateProperties( )
+ throws InvalidWsrfWsdlException
+ {
+ boolean isValid = true;
+ List propNameList;
+ if ( m_propNames != null ) //avoid a null pointer if m_propNames are null (i.e. no props defined)
+ {
+ propNameList = Arrays.asList( m_propNames );
+ }
+ else
+ {
+ propNameList = new ArrayList( ); //no properties were defined....
+ } //continue checking if implemented defs had props that the user didn't implement
+
+ Iterator defIter = m_implementedResourceDefs.values( ).iterator( );
+ while ( defIter.hasNext( ) )
+ {
+ ResourceCapability def = (ResourceCapability) defIter.next( );
+ if ( def.hasProperties( ) )
+ {
+ QName[] propNames = def.getPropertyNames( );
+ Set missingPropNames = new HashSet( );
+ for ( int i = 0; i < propNames.length; i++ )
+ {
+ if ( !propNameList.contains( propNames[i] ) )
+ {
+ missingPropNames.add( propNames[i] );
+ }
+ }
+
+ if ( !missingPropNames.isEmpty( ) )
+ {
+ System.err.println( "PortType implements the operations from the "
+ + def.getPortType( ).getQName( )
+ + " portType but does not define the following required properties: "
+ + missingPropNames );
+ isValid = false;
+ }
+ }
+ }
+
+ if ( !isValid )
+ {
+ throw new InvalidWsrfWsdlException( "PortType " + m_portType.getQName( )
+ + " does not define one or more properties required by the portTypes it implements." );
+ }
+ }
+
+ private ResourceCapability[] getImportedResourceDefinitions( )
+ throws InvalidWsrfWsdlException
+ {
+ List importedResourceDefs = new ArrayList( );
+ Import[] imports = getImports( m_def );
+ for ( int i = 0; i < imports.length; i++ )
+ {
+ Definition def = imports[i].getDefinition( );
+ Map portTypes = def.getPortTypes( );
+ Iterator portTypeIter = portTypes.values( ).iterator( );
+ while ( portTypeIter.hasNext( ) )
+ {
+ PortType portType = (PortType) portTypeIter.next( );
+ URL baseUrl = null;
+ try
+ {
+ baseUrl = new URL( m_baseUrl,
+ imports[i].getLocationURI( ) );
+ }
+ catch ( MalformedURLException e )
+ {
+ throw new InvalidWsrfWsdlException( "Invalid import location " + imports[i].getLocationURI( ) );
+ }
+
+ importedResourceDefs.add( new ResourceCapabilityImpl( def, portType, baseUrl ) );
+ }
+ }
+
+ return (ResourceCapability[]) importedResourceDefs.toArray( new ResourceCapability[0] );
+ }
+
+ private Import[] getImports( Definition def )
+ {
+ Set importSet = new HashSet( );
+ Map importMap = def.getImports( );
+ Iterator iter = importMap.keySet( ).iterator( );
+ while ( iter.hasNext( ) )
+ {
+ String nsURI = (String) iter.next( );
+ Iterator importsIter = ( (List) importMap.get( nsURI ) ).iterator( );
+ while ( importsIter.hasNext( ) )
+ {
+ Import anImport = (Import) importsIter.next( );
+ Import[] importDefImports = getImports( anImport.getDefinition( ) );
+ List imports = new ArrayList( );
+ imports.add( anImport );
+ imports.addAll( Arrays.asList( importDefImports ) );
+ for ( int i = 0; i < imports.size( ); i++ )
+ {
+ Import importToCheck = (Import) imports.get( i );
+ if ( !importIsRedundant( importSet, importToCheck ) )
+ {
+ importSet.add( anImport );
+ }
+ }
+ }
+ }
+
+ return (Import[]) importSet.toArray( new Import[0] );
+ }
+
+ private boolean isInheritedOperation( Set inheritedOps,
+ Operation op )
+ {
+ boolean isInheritedOp = false;
+ Iterator inheritedOpIter = inheritedOps.iterator( );
+ while ( inheritedOpIter.hasNext( ) )
+ {
+ Operation inheritedOp = (Operation) inheritedOpIter.next( );
+ if ( WsdlUtils.equals( op, inheritedOp ) )
+ {
+ isInheritedOp = true;
+ break;
+ }
+ }
+
+ return isInheritedOp;
+ }
+
+ private Set getInheritedOperations( )
+ {
+ Set specOps = new HashSet( );
+ Iterator defIter = m_implementedResourceDefs.values( ).iterator( );
+ while ( defIter.hasNext( ) )
+ {
+ ResourceCapability def = (ResourceCapability) defIter.next( );
+ List ops = def.getPortType( ).getOperations( );
+ for ( int i = 0; i < ops.size( ); i++ )
+ {
+ specOps.add( (Operation) ops.get( i ) );
+ }
+ }
+
+ return specOps;
+ }
+
+ private boolean isInheritedProperty( Set inheritedPropNames,
+ QName propName )
+ {
+ boolean isInheritedProp = false;
+ Iterator inheritedPropNameIter = inheritedPropNames.iterator( );
+ while ( inheritedPropNameIter.hasNext( ) )
+ {
+ QName inheritedPropName = (QName) inheritedPropNameIter.next( );
+ if ( inheritedPropName.equals( propName ) )
+ {
+ isInheritedProp = true;
+ break;
+ }
+ }
+
+ return isInheritedProp;
+ }
+
+ private Set getInheritedPropertyNames( )
+ {
+ Set inheritedPropNames = new HashSet( );
+ Iterator defIter = m_implementedResourceDefs.values( ).iterator( );
+ while ( defIter.hasNext( ) )
+ {
+ ResourceCapability def = (ResourceCapability) defIter.next( );
+ if ( def.hasProperties( ) )
+ {
+ QName[] propNames = def.getPropertyNames( );
+ for ( int i = 0; i < propNames.length; i++ )
+ {
+ inheritedPropNames.add( propNames[i] );
+ }
+ }
+ }
+
+ return inheritedPropNames;
+ }
+
+ private boolean importIsRedundant( Set imports,
+ Import anImport )
+ {
+ boolean importIsRedundant = false;
+ Iterator importIter = imports.iterator( );
+ while ( importIter.hasNext( ) )
+ {
+ Import anotherImport = (Import) importIter.next( );
+ if ( WsdlUtils.equals( anImport, anotherImport ) )
+ {
+ importIsRedundant = true;
+ break;
+ }
+ }
+
+ return importIsRedundant;
+ }
+
+ private void initCustomOperations( )
+ {
+ Set customOpNames = new HashSet( );
+ Set inheritedOps = getInheritedOperations( );
+ List ops = m_portType.getOperations( );
+ for ( int i = 0; i < ops.size( ); i++ )
+ {
+ Operation op = (Operation) ops.get( i );
+ if ( !isInheritedOperation( inheritedOps, op ) )
+ {
+ customOpNames.add( op.getName( ) );
+ }
+ }
+
+ m_customOpNames = (String[]) customOpNames.toArray( new String[0] );
+ }
+
+ private void initImplementedPortTypes( )
+ throws InvalidWsrfWsdlException
+ {
+ m_implementedResourceDefs = new HashMap( );
+ ResourceCapability[] importedResourceDefs = getImportedResourceDefinitions( );
+ for ( int i = 0; i < importedResourceDefs.length; i++ )
+ {
+ PortType importedPortType = importedResourceDefs[i].getPortType( );
+ if ( WsrfWsdlUtils.implementsPortType( m_portType, importedPortType ) )
+ {
+ m_implementedResourceDefs.put( importedPortType.getQName( ),
+ importedResourceDefs[i] );
+ }
+ }
+ }
+
+ private void initPropertyNames( )
+ throws InvalidWsrfWsdlException
+ {
+ m_propsDocName = WsrfWsdlUtils.getResourcePropertiesDocumentName( m_portType );
+ m_propNames = WsrfWsdlUtils.getResourcePropertyNames( m_propsDocName, m_def, m_baseUrl );
+ Set customPropNames = new HashSet( );
+ if ( hasProperties( ) )
+ {
+ Set inheritedPropNames = getInheritedPropertyNames( );
+ for ( int i = 0; i < m_propNames.length; i++ )
+ {
+ if ( !isInheritedProperty( inheritedPropNames, m_propNames[i] ) )
+ {
+ customPropNames.add( m_propNames[i] );
+ }
+ }
+ }
+
+ m_customPropNames = (QName[]) customPropNames.toArray( new QName[0] );
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org