diff options
| author | Robert Godfrey <rgodfrey@apache.org> | 2012-01-30 09:38:45 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org> | 2012-01-30 09:38:45 +0000 |
| commit | a0604bb40650c78bb072ae6b0c02e98fcb4a6c93 (patch) | |
| tree | 57a5c308e5be13d853b82d39b1e30a6a44ee9371 /java | |
| parent | 948bfbdc46e09ea02808724760d03de51b8abb7f (diff) | |
| download | qpid-python-a0604bb40650c78bb072ae6b0c02e98fcb4a6c93.tar.gz | |
QPID-3789 : [Java] Remove dead code and empty directories
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1237577 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
8 files changed, 0 insertions, 1384 deletions
diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeaderKey.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeaderKey.java deleted file mode 100644 index 8fdb91cbef..0000000000 --- a/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeaderKey.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.apache.qpid.server.exchange.headers; - -import org.apache.qpid.framing.AMQShortString; - -/* -* -* 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. -* -*/ -public class HeaderKey -{ - public static final HeaderKey UNKNOWN = new HeaderKey(new AMQShortString("<< UNKNOWN >>")); - private AMQShortString _key; - - public HeaderKey(final AMQShortString key) - { - _key = key; - } - - public String toString() - { - return _key.toString(); - } - -} diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeaderKeyDictionary.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeaderKeyDictionary.java deleted file mode 100644 index 7d5953b581..0000000000 --- a/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeaderKeyDictionary.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.apache.qpid.server.exchange.headers; - -import org.apache.qpid.framing.AMQShortString; - -import java.util.HashMap; -import java.util.Map; - -/* -* -* 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. -* -*/ -public class HeaderKeyDictionary -{ - - private final Map<AMQShortString, HeaderKey> _dictionary = new HashMap<AMQShortString, HeaderKey>(); - - - public HeaderKey get(final AMQShortString key) - { - HeaderKey headerKey = _dictionary.get(key); - return headerKey == null ? HeaderKey.UNKNOWN : headerKey; - } - - public HeaderKey getOrCreate(final AMQShortString key) - { - HeaderKey headerKey = _dictionary.get(key); - if(headerKey == null) - { - headerKey = new HeaderKey(key); - _dictionary.put(key, headerKey); - } - return headerKey; - } -} diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeaderMatcherResult.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeaderMatcherResult.java deleted file mode 100644 index 518064bb29..0000000000 --- a/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeaderMatcherResult.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.apache.qpid.server.exchange.headers; - -/* -* -* 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. -* -*/ -public class HeaderMatcherResult -{ -} diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeadersMatcherDFAState.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeadersMatcherDFAState.java deleted file mode 100644 index 6701ce3e54..0000000000 --- a/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeadersMatcherDFAState.java +++ /dev/null @@ -1,343 +0,0 @@ -package org.apache.qpid.server.exchange.headers; - -import org.apache.qpid.framing.AMQShortString; -import org.apache.qpid.framing.AMQTypedValue; -import org.apache.qpid.framing.FieldTable; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -/* -* -* 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. -* -*/ -public class HeadersMatcherDFAState -{ - - - private final Collection<HeaderMatcherResult> _results; - private final Map<HeaderKey, Map<AMQTypedValue,HeadersMatcherDFAState>> _nextStateMap; - private final HeaderKeyDictionary _dictionary; - - public HeadersMatcherDFAState(Map<HeaderKey, Map<AMQTypedValue,HeadersMatcherDFAState>> nextStateMap, - Collection<HeaderMatcherResult> results, - HeaderKeyDictionary dictionary) - { - _nextStateMap = nextStateMap; - _results = results; - _dictionary = dictionary; - } - - - public Collection<HeaderMatcherResult> match(final FieldTable table) - { - return match(table.iterator()); - } - - - - public Collection<HeaderMatcherResult> match(Iterator<Map.Entry<AMQShortString,AMQTypedValue>> fieldTableIterator) - { - - if(_nextStateMap.isEmpty()) - { - return _results; - } - - while(fieldTableIterator.hasNext()) - { - - Map.Entry<AMQShortString, AMQTypedValue> fieldTableEntry = fieldTableIterator.next(); - HeaderKey key = _dictionary.get(fieldTableEntry.getKey()); - if(key != HeaderKey.UNKNOWN) - { - Map<AMQTypedValue, HeadersMatcherDFAState> valueToStateMap = _nextStateMap.get(key); - - if(valueToStateMap != null) - { - HeadersMatcherDFAState nextState = valueToStateMap.get(fieldTableEntry.getValue()); - - if(nextState == null) - { - nextState = valueToStateMap.get(null); - } - if(nextState != null && nextState != this) - { - return nextState.match(fieldTableIterator); - } - } - - } - } - - return _results; - - } - - - HeadersMatcherDFAState mergeStateMachines(HeadersMatcherDFAState otherStateMachine) - { - - assert(otherStateMachine._dictionary == _dictionary); - - Map<Set<HeadersMatcherDFAState>, HeadersMatcherDFAState> newStateMap= new HashMap<Set<HeadersMatcherDFAState>, HeadersMatcherDFAState>(); - - Collection<HeaderMatcherResult> results; - - if(_results.isEmpty()) - { - results = otherStateMachine._results; - } - else if(otherStateMachine._results.isEmpty()) - { - results = _results; - } - else - { - results = new HashSet<HeaderMatcherResult>(_results); - results.addAll(otherStateMachine._results); - } - - - final Map<HeaderKey, Map<AMQTypedValue, HeadersMatcherDFAState>> newNextStateMap = new HashMap<HeaderKey, Map<AMQTypedValue, HeadersMatcherDFAState>>(); - - HeadersMatcherDFAState newState = new HeadersMatcherDFAState(newNextStateMap, results, _dictionary); - - - Set<HeadersMatcherDFAState> oldStates = new HashSet<HeadersMatcherDFAState>(); - oldStates.add(this); - oldStates.add(otherStateMachine); - - newStateMap.put(oldStates, newState); - - mergeStateMachines(oldStates, newNextStateMap, newStateMap); - - return newState; - - - } - - private void mergeStateMachines(final Set<HeadersMatcherDFAState> oldStates, - final Map<HeaderKey, Map<AMQTypedValue, HeadersMatcherDFAState>> newNextStateMap, - final Map<Set<HeadersMatcherDFAState>, HeadersMatcherDFAState> newStateMap) - { - Map<HeaderKey, Map<AMQTypedValue, Set<HeadersMatcherDFAState>>> nfaMap = new HashMap<HeaderKey, Map<AMQTypedValue, Set<HeadersMatcherDFAState>>>(); - - Set<HeaderKey> distinctKeys = new HashSet<HeaderKey>(); - - for(HeadersMatcherDFAState state : oldStates) - { - Map<HeaderKey, Map<AMQTypedValue, HeadersMatcherDFAState>> map = state._nextStateMap; - - for(Map.Entry<HeaderKey, Map<AMQTypedValue, HeadersMatcherDFAState>> entry : map.entrySet()) - { - Map<AMQTypedValue, Set<HeadersMatcherDFAState>> valueToStatesMap = nfaMap.get(entry.getKey()); - - if(valueToStatesMap == null) - { - valueToStatesMap = new HashMap<AMQTypedValue, Set<HeadersMatcherDFAState>>(); - nfaMap.put(entry.getKey(), valueToStatesMap); - } - - for(Map.Entry<AMQTypedValue, HeadersMatcherDFAState> valueToStateEntry : entry.getValue().entrySet()) - { - Set<HeadersMatcherDFAState> states = valueToStatesMap.get(valueToStateEntry.getKey()); - if(states == null) - { - states = new HashSet<HeadersMatcherDFAState>(); - valueToStatesMap.put(valueToStateEntry.getKey(),states); - } - states.add(valueToStateEntry.getValue()); - } - - distinctKeys.add(entry.getKey()); - } - } - - Map<HeaderKey, Set<HeadersMatcherDFAState>> anyValueStates = new HashMap<HeaderKey, Set<HeadersMatcherDFAState>>(); - - for(HeaderKey distinctKey : distinctKeys) - { - Map<AMQTypedValue, Set<HeadersMatcherDFAState>> valueToStateMap = nfaMap.get(distinctKey); - if(valueToStateMap != null) - { - Set<HeadersMatcherDFAState> statesForKeyDefault = valueToStateMap.get(null); - if(statesForKeyDefault != null) - { - anyValueStates.put(distinctKey, statesForKeyDefault); - } - } - } - - // add the defaults for "null" to all other specified values of a given header key - - for( Map.Entry<HeaderKey,Map<AMQTypedValue,Set<HeadersMatcherDFAState>>> entry : nfaMap.entrySet()) - { - Map<AMQTypedValue, Set<HeadersMatcherDFAState>> valueToStatesMap = entry.getValue(); - for(Map.Entry<AMQTypedValue, Set<HeadersMatcherDFAState>> valueToStates : valueToStatesMap.entrySet()) - { - if(valueToStates.getKey() != null) - { - - - Set<HeadersMatcherDFAState> defaults = anyValueStates.get(entry.getKey()); - if(defaults != null) - { - valueToStates.getValue().addAll(defaults); - } - } - } - } - - // if a given header key is not mentioned in the map of a machine; then that machine would stay at the same state - // for that key. - for(HeaderKey distinctKey : distinctKeys) - { - Map<AMQTypedValue, Set<HeadersMatcherDFAState>> valueToStatesMap = nfaMap.get(distinctKey); - for(HeadersMatcherDFAState oldState : oldStates) - { - if(!oldState._nextStateMap.containsKey(distinctKey)) - { - for(Set<HeadersMatcherDFAState> endStates : valueToStatesMap.values()) - { - endStates.add(oldState); - } - } - } - } - - - - - for(Map.Entry<HeaderKey,Map<AMQTypedValue,Set<HeadersMatcherDFAState>>> transitionClass : nfaMap.entrySet()) - { - Map<AMQTypedValue, HeadersMatcherDFAState> valueToDFAState = newNextStateMap.get(transitionClass.getKey()); - if(valueToDFAState == null) - { - valueToDFAState = new HashMap<AMQTypedValue, HeadersMatcherDFAState>(); - newNextStateMap.put(transitionClass.getKey(), valueToDFAState); - } - - for(Map.Entry<AMQTypedValue,Set<HeadersMatcherDFAState>> transition : transitionClass.getValue().entrySet()) - { - Set<HeadersMatcherDFAState> destinations = transition.getValue(); - - - HeadersMatcherDFAState nextState = newStateMap.get(destinations); - - if(nextState == null) - { - - if(destinations.size() == 1) - { - nextState = destinations.iterator().next(); - newStateMap.put(destinations, nextState); - } - else - { - Collection<HeaderMatcherResult> results; - - Set<Collection<HeaderMatcherResult>> resultSets = new HashSet<Collection<HeaderMatcherResult>>(); - for(HeadersMatcherDFAState destination : destinations) - { - resultSets.add(destination._results); - } - resultSets.remove(Collections.EMPTY_SET); - if(resultSets.size() == 0) - { - results = Collections.EMPTY_SET; - } - else if(resultSets.size() == 1) - { - results = resultSets.iterator().next(); - } - else - { - results = new HashSet<HeaderMatcherResult>(); - for(Collection<HeaderMatcherResult> oldResult : resultSets) - { - results.addAll(oldResult); - } - } - - final Map<HeaderKey, Map<AMQTypedValue, HeadersMatcherDFAState>> nextStateMap = new HashMap<HeaderKey, Map<AMQTypedValue, HeadersMatcherDFAState>>(); - - nextState = new HeadersMatcherDFAState(nextStateMap, results, _dictionary); - newStateMap.put(destinations, nextState); - - mergeStateMachines( - destinations, - nextStateMap, - newStateMap); - - - } - - - } - valueToDFAState.put(transition.getKey(),nextState); - } - } - - - - final ArrayList<HeaderKey> removeKeyList = new ArrayList<HeaderKey>(); - - for(Map.Entry<HeaderKey,Map<AMQTypedValue,HeadersMatcherDFAState>> entry : _nextStateMap.entrySet()) - { - final ArrayList<AMQTypedValue> removeValueList = new ArrayList<AMQTypedValue>(); - - for(Map.Entry<AMQTypedValue,HeadersMatcherDFAState> valueToDFAState : entry.getValue().entrySet()) - { - if(valueToDFAState.getValue() == this) - { - HeadersMatcherDFAState defaultState = entry.getValue().get(null); - if(defaultState == null || defaultState == this) - { - removeValueList.add(valueToDFAState.getKey()); - } - } - } - - for(AMQTypedValue removeValue : removeValueList) - { - entry.getValue().remove(removeValue); - } - - if(entry.getValue().isEmpty()) - { - removeKeyList.add(entry.getKey()); - } - - } - - for(HeaderKey removeKey : removeKeyList) - { - _nextStateMap.remove(removeKey); - } - - } - -} diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeadersParser.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeadersParser.java deleted file mode 100644 index 4bd0e8d272..0000000000 --- a/java/broker/src/main/java/org/apache/qpid/server/exchange/headers/HeadersParser.java +++ /dev/null @@ -1,325 +0,0 @@ -package org.apache.qpid.server.exchange.headers; - -import org.apache.qpid.framing.AMQShortString; -import org.apache.qpid.framing.AMQType; -import org.apache.qpid.framing.AMQTypedValue; -import org.apache.qpid.framing.FieldTable; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/* -* -* 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. -* -*/ -public class HeadersParser -{ - - private final HeaderKeyDictionary _dictionary = new HeaderKeyDictionary(); - private static final AMQShortString MATCHING_TYPE_KEY = new AMQShortString("x-match"); - private static final String ANY_MATCHING = "any"; - private static final AMQShortString RESERVED_KEY_PREFIX = new AMQShortString("x-"); - - - HeadersMatcherDFAState createStateMachine(FieldTable bindingArguments, HeaderMatcherResult result) - { - String matchingType = bindingArguments.getString(MATCHING_TYPE_KEY); - boolean matchAny = matchingType.equalsIgnoreCase(ANY_MATCHING); - if(matchAny) - { - return createStateMachineForAnyMatch(bindingArguments, result); - } - else - { - return createStateMachineForAllMatch(bindingArguments, result); - } - - - } - - - private HeadersMatcherDFAState createStateMachineForAnyMatch(final FieldTable bindingArguments, - final HeaderMatcherResult result) - { - - // DFAs for "any" matches have only two states, "not-matched" and "matched"... they start in the former - // and upon meeting any of the criteria they move to the latter - - //noinspection unchecked - final HeadersMatcherDFAState successState = - new HeadersMatcherDFAState(Collections.EMPTY_MAP,Collections.singleton(result),_dictionary); - - Map<HeaderKey, Map<AMQTypedValue, HeadersMatcherDFAState>> nextStateMap = - new HashMap<HeaderKey, Map<AMQTypedValue, HeadersMatcherDFAState>>(); - - Set<AMQShortString> seenKeys = new HashSet<AMQShortString>(); - - Iterator<Map.Entry<AMQShortString, AMQTypedValue>> tableIterator = bindingArguments.iterator(); - - while(tableIterator.hasNext()) - { - final Map.Entry<AMQShortString, AMQTypedValue> entry = tableIterator.next(); - final AMQShortString key = entry.getKey(); - final AMQTypedValue value = entry.getValue(); - - - if(seenKeys.add(key) && !key.startsWith(RESERVED_KEY_PREFIX)) - { - final AMQType type = value.getType(); - - final HeaderKey headerKey = _dictionary.getOrCreate(key); - final Map<AMQTypedValue, HeadersMatcherDFAState> valueMap; - - if(type == AMQType.VOID || - ((type == AMQType.ASCII_STRING || type == AMQType.WIDE_STRING) && ((CharSequence)value.getValue()).length() == 0)) - { - valueMap = Collections.singletonMap(null,successState); - - } - else - { - valueMap = Collections.singletonMap(value,successState); - } - nextStateMap.put(headerKey,valueMap); - - } - - } - - if(seenKeys.size() == 0) - { - return successState; - } - else - { - return new HeadersMatcherDFAState(nextStateMap,Collections.EMPTY_SET,_dictionary); - } - - - } - - - private HeadersMatcherDFAState createStateMachineForAllMatch(final FieldTable bindingArguments, - final HeaderMatcherResult result) - { - // DFAs for "all" matches have a "success" state, a "fail" state, and states for every subset of - // matches which are possible, starting with the empty subset. For example if we have a binding - // x-match="all" - // a=1 - // b=1 - // c=1 - // d=1 - // Then we would have the following states - // (1) Seen none of a, b, c, or d - // (2) Seen a=1 ; none of b,c, or d - // (3) Seen b=1 ; none of a,c, or d - // (4) Seen c=1 ; none of a,b, or d - // (5) Seen d=1 ; none of a,b, or c - // (6) Seen a=1,b=1 ; none of c,d - // (7) Seen a=1,c=1 ; none of b,d - // (8) Seen a=1,d=1 ; none of b,c - // (9) Seen b=1,c=1 ; none of a,d - //(10) Seen b=1,d=1 ; none of c,d - //(11) Seen c=1,d=1 ; none of a,b - //(12) Seen a=1,b=1,c=1 ; not d - //(13) Seen a=1,b=1,d=1 ; not c - //(14) Seen a=1,c=1,d=1 ; not b - //(15) Seen b=1,c=1,d=1 ; not a - //(16) success - //(17) fail - // - // All states but (16) can transition to (17); additionally: - // (1) can transition to (2),(3),(4),(5) - // (2) can transition to (6),(7),(8) - // (3) can transition to (6),(9),(10) - // (4) can transition to (7),(9),(11) - // (5) can transition to (8),(10),(11) - // (6) can transition to (12),(13) - // (7) can transition to (12),(14) - // (8) can transition to (13),(14) - // (9) can transition to (12),(15) - //(10) can transition to (13),(15) - //(11) can transition to (14),(15) - //(12)-(15) can transition to (16) - - Set<AMQShortString> seenKeys = new HashSet<AMQShortString>(); - List<KeyValuePair> requiredTerms = new ArrayList<KeyValuePair>(bindingArguments.size()); - - Iterator<Map.Entry<AMQShortString, AMQTypedValue>> tableIterator = bindingArguments.iterator(); - - - - while(tableIterator.hasNext()) - { - final Map.Entry<AMQShortString, AMQTypedValue> entry = tableIterator.next(); - final AMQShortString key = entry.getKey(); - final AMQTypedValue value = entry.getValue(); - - - if(seenKeys.add(key) && !key.startsWith(RESERVED_KEY_PREFIX)) - { - final AMQType type = value.getType(); - - if(type == AMQType.VOID || - ((type == AMQType.ASCII_STRING || type == AMQType.WIDE_STRING) && ((CharSequence)value.getValue()).length() == 0)) - { - requiredTerms.add(new KeyValuePair(_dictionary.getOrCreate(key),null)); - } - else - { - requiredTerms.add(new KeyValuePair(_dictionary.getOrCreate(key),value)); - } - } - - } - - final HeadersMatcherDFAState successState = - new HeadersMatcherDFAState(Collections.EMPTY_MAP,Collections.singleton(result),_dictionary); - - final HeadersMatcherDFAState failState = - new HeadersMatcherDFAState(Collections.EMPTY_MAP,Collections.EMPTY_SET,_dictionary); - - Map<Set<KeyValuePair>, HeadersMatcherDFAState> notSeenTermsToStateMap = - new HashMap<Set<KeyValuePair>, HeadersMatcherDFAState>(); - - notSeenTermsToStateMap.put(Collections.EMPTY_SET, successState); - - - final int numberOfTerms = requiredTerms.size(); - - for(int numMissingTerms = 1; numMissingTerms <= numberOfTerms; numMissingTerms++) - { - int[] pos = new int[numMissingTerms]; - for(int i = 0; i < numMissingTerms; i++) - { - pos[i] = i; - } - - final int maxTermValue = (numberOfTerms - (numMissingTerms - 1)); - - while(pos[0] < maxTermValue) - { - - Set<KeyValuePair> stateSet = new HashSet<KeyValuePair>(); - for(int posIndex = 0; posIndex < pos.length; posIndex++) - { - stateSet.add(requiredTerms.get(pos[posIndex])); - } - - final Map<HeaderKey, Map<AMQTypedValue,HeadersMatcherDFAState>> nextStateMap = - new HashMap<HeaderKey, Map<AMQTypedValue,HeadersMatcherDFAState>>(); - - - for(int posIndex = 0; posIndex < pos.length; posIndex++) - { - KeyValuePair nextTerm = requiredTerms.get(pos[posIndex]); - HashSet<KeyValuePair> nextStateSet = - new HashSet<KeyValuePair>(stateSet); - nextStateSet.remove(nextTerm); - - Map<AMQTypedValue, HeadersMatcherDFAState> valueToStateMap = - new HashMap<AMQTypedValue, HeadersMatcherDFAState>(); - nextStateMap.put(nextTerm._key, valueToStateMap); - - valueToStateMap.put( nextTerm._value,notSeenTermsToStateMap.get(nextStateSet)); - if(nextTerm._value != null) - { - valueToStateMap.put(null, failState); - } - - - } - - - HeadersMatcherDFAState newState = new HeadersMatcherDFAState(nextStateMap, Collections.EMPTY_SET, _dictionary); - - notSeenTermsToStateMap.put(stateSet, newState); - - int i = numMissingTerms; - while(i-- != 0) - { - if(++pos[i] <= numberOfTerms -(numMissingTerms-i)) - { - int k = pos[i]; - for(int j = i+1; j < numMissingTerms; j++) - { - pos[j] = ++k; - } - break; - } - } - } - - - - - } - - - return notSeenTermsToStateMap.get(new HashSet<KeyValuePair>(requiredTerms)); - - - - } - - public final static class KeyValuePair - { - private final HeaderKey _key; - private final AMQTypedValue _value; - private final int _hashCode; - - public KeyValuePair(final HeaderKey key, final AMQTypedValue value) - { - _key = key; - _value = value; - int hash = (1 + 31 * _key.hashCode()); - if(_value != null) - { - hash+=_value.hashCode(); - } - _hashCode = hash; - } - - public int hashCode() - { - return _hashCode; - } - - public boolean equals(Object o) - { - assert o != null; - assert o instanceof KeyValuePair; - KeyValuePair other = (KeyValuePair)o; - return (_key == other._key) && (_value == null ? other._value == null : _value.equals(other._value)); - } - - - public String toString() - { - return "{" + _key + " -> " + _value + "}"; - } - - } -} diff --git a/java/client/src/main/java/org/apache/qpid/client/DispatcherCallback.java b/java/client/src/main/java/org/apache/qpid/client/DispatcherCallback.java deleted file mode 100644 index 1cd8df6e4a..0000000000 --- a/java/client/src/main/java/org/apache/qpid/client/DispatcherCallback.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.qpid.client; - -import java.util.Queue; - -public abstract class DispatcherCallback -{ - private BasicMessageConsumer _consumer; - - public DispatcherCallback(BasicMessageConsumer mc) - { - _consumer = mc; - } - - abstract public void whilePaused(Queue<MessageConsumerPair> reprocessQueue); - -} diff --git a/java/client/src/main/java/org/apache/qpid/naming/ReadOnlyContext.java b/java/client/src/main/java/org/apache/qpid/naming/ReadOnlyContext.java deleted file mode 100644 index 62e6672289..0000000000 --- a/java/client/src/main/java/org/apache/qpid/naming/ReadOnlyContext.java +++ /dev/null @@ -1,525 +0,0 @@ -/* 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.qpid.naming; - -import org.apache.qpid.jndi.NameParserImpl; - -import javax.naming.Binding; -import javax.naming.CompositeName; -import javax.naming.Context; -import javax.naming.LinkRef; -import javax.naming.Name; -import javax.naming.NameClassPair; -import javax.naming.NameNotFoundException; -import javax.naming.NameParser; -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.NotContextException; -import javax.naming.OperationNotSupportedException; -import javax.naming.Reference; -import javax.naming.spi.NamingManager; -import java.io.Serializable; -import java.util.Collections; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Map; - -/** - * Based on class from ActiveMQ. - * A read-only Context - * <p/> - * This version assumes it and all its subcontext are read-only and any attempt - * to modify (e.g. through bind) will result in an OperationNotSupportedException. - * Each Context in the tree builds a cache of the entries in all sub-contexts - * to optimise the performance of lookup. - * </p> - * <p>This implementation is intended to optimise the performance of lookup(String) - * to about the level of a HashMap get. It has been observed that the scheme - * resolution phase performed by the JVM takes considerably longer, so for - * optimum performance lookups should be coded like:</p> - * <code> - * Context componentContext = (Context)new InitialContext().lookup("java:comp"); - * String envEntry = (String) componentContext.lookup("env/myEntry"); - * String envEntry2 = (String) componentContext.lookup("env/myEntry2"); - * </code> - */ -public class ReadOnlyContext implements Context, Serializable -{ - private static final long serialVersionUID = -5754338187296859149L; - protected static final NameParser nameParser = new NameParserImpl(); - - private final Hashtable environment; // environment for this context - private final Map bindings; // bindings at my level - private final Map treeBindings; // all bindings under me - - private boolean frozen = false; - private String nameInNamespace = ""; - public static final String SEPARATOR = "/"; - - public ReadOnlyContext() - { - environment = new Hashtable(); - bindings = new HashMap(); - treeBindings = new HashMap(); - } - - public ReadOnlyContext(Hashtable env) - { - if (env == null) - { - this.environment = new Hashtable(); - } - else - { - this.environment = new Hashtable(env); - } - - this.bindings = Collections.EMPTY_MAP; - this.treeBindings = Collections.EMPTY_MAP; - } - - public ReadOnlyContext(Hashtable environment, Map bindings) - { - if (environment == null) - { - this.environment = new Hashtable(); - } - else - { - this.environment = new Hashtable(environment); - } - - this.bindings = bindings; - treeBindings = new HashMap(); - frozen = true; - } - - public ReadOnlyContext(Hashtable environment, Map bindings, String nameInNamespace) - { - this(environment, bindings); - this.nameInNamespace = nameInNamespace; - } - - protected ReadOnlyContext(ReadOnlyContext clone, Hashtable env) - { - this.bindings = clone.bindings; - this.treeBindings = clone.treeBindings; - this.environment = new Hashtable(env); - } - - protected ReadOnlyContext(ReadOnlyContext clone, Hashtable env, String nameInNamespace) - { - this(clone, env); - this.nameInNamespace = nameInNamespace; - } - - public void freeze() - { - frozen = true; - } - - boolean isFrozen() - { - return frozen; - } - - /** - * internalBind is intended for use only during setup or possibly by suitably synchronized superclasses. - * It binds every possible lookup into a map in each context. To do this, each context - * strips off one name segment and if necessary creates a new context for it. Then it asks that context - * to bind the remaining name. It returns a map containing all the bindings from the next context, plus - * the context it just created (if it in fact created it). (the names are suitably extended by the segment - * originally lopped off). - * - * @param name - * @param value - * @return - * @throws javax.naming.NamingException - */ - protected Map internalBind(String name, Object value) throws NamingException - { - assert (name != null) && (name.length() > 0); - assert !frozen; - - Map newBindings = new HashMap(); - int pos = name.indexOf('/'); - if (pos == -1) - { - if (treeBindings.put(name, value) != null) - { - throw new NamingException("Something already bound at " + name); - } - - bindings.put(name, value); - newBindings.put(name, value); - } - else - { - String segment = name.substring(0, pos); - assert segment != null; - assert !segment.equals(""); - Object o = treeBindings.get(segment); - if (o == null) - { - o = newContext(); - treeBindings.put(segment, o); - bindings.put(segment, o); - newBindings.put(segment, o); - } - else if (!(o instanceof ReadOnlyContext)) - { - throw new NamingException("Something already bound where a subcontext should go"); - } - - ReadOnlyContext readOnlyContext = (ReadOnlyContext) o; - String remainder = name.substring(pos + 1); - Map subBindings = readOnlyContext.internalBind(remainder, value); - for (Iterator iterator = subBindings.entrySet().iterator(); iterator.hasNext();) - { - Map.Entry entry = (Map.Entry) iterator.next(); - String subName = segment + "/" + (String) entry.getKey(); - Object bound = entry.getValue(); - treeBindings.put(subName, bound); - newBindings.put(subName, bound); - } - } - - return newBindings; - } - - protected ReadOnlyContext newContext() - { - return new ReadOnlyContext(); - } - - public Object addToEnvironment(String propName, Object propVal) throws NamingException - { - return environment.put(propName, propVal); - } - - public Hashtable getEnvironment() throws NamingException - { - return (Hashtable) environment.clone(); - } - - public Object removeFromEnvironment(String propName) throws NamingException - { - return environment.remove(propName); - } - - public Object lookup(String name) throws NamingException - { - if (name.length() == 0) - { - return this; - } - - Object result = treeBindings.get(name); - if (result == null) - { - result = bindings.get(name); - } - - if (result == null) - { - int pos = name.indexOf(':'); - if (pos > 0) - { - String scheme = name.substring(0, pos); - Context ctx = NamingManager.getURLContext(scheme, environment); - if (ctx == null) - { - throw new NamingException("scheme " + scheme + " not recognized"); - } - - return ctx.lookup(name); - } - else - { - // Split out the first name of the path - // and look for it in the bindings map. - CompositeName path = new CompositeName(name); - - if (path.size() == 0) - { - return this; - } - else - { - String first = path.get(0); - Object obj = bindings.get(first); - if (obj == null) - { - throw new NameNotFoundException(name); - } - else if ((obj instanceof Context) && (path.size() > 1)) - { - Context subContext = (Context) obj; - obj = subContext.lookup(path.getSuffix(1)); - } - - return obj; - } - } - } - - if (result instanceof LinkRef) - { - LinkRef ref = (LinkRef) result; - result = lookup(ref.getLinkName()); - } - - if (result instanceof Reference) - { - try - { - result = NamingManager.getObjectInstance(result, null, null, this.environment); - } - catch (NamingException e) - { - throw e; - } - catch (Exception e) - { - throw (NamingException) new NamingException("could not look up : " + name).initCause(e); - } - } - - if (result instanceof ReadOnlyContext) - { - String prefix = getNameInNamespace(); - if (prefix.length() > 0) - { - prefix = prefix + SEPARATOR; - } - - result = new ReadOnlyContext((ReadOnlyContext) result, environment, prefix + name); - } - - return result; - } - - public Object lookup(Name name) throws NamingException - { - return lookup(name.toString()); - } - - public Object lookupLink(String name) throws NamingException - { - return lookup(name); - } - - public Name composeName(Name name, Name prefix) throws NamingException - { - Name result = (Name) prefix.clone(); - result.addAll(name); - - return result; - } - - public String composeName(String name, String prefix) throws NamingException - { - CompositeName result = new CompositeName(prefix); - result.addAll(new CompositeName(name)); - - return result.toString(); - } - - public NamingEnumeration list(String name) throws NamingException - { - Object o = lookup(name); - if (o == this) - { - return new ReadOnlyContext.ListEnumeration(); - } - else if (o instanceof Context) - { - return ((Context) o).list(""); - } - else - { - throw new NotContextException(); - } - } - - public NamingEnumeration listBindings(String name) throws NamingException - { - Object o = lookup(name); - if (o == this) - { - return new ReadOnlyContext.ListBindingEnumeration(); - } - else if (o instanceof Context) - { - return ((Context) o).listBindings(""); - } - else - { - throw new NotContextException(); - } - } - - public Object lookupLink(Name name) throws NamingException - { - return lookupLink(name.toString()); - } - - public NamingEnumeration list(Name name) throws NamingException - { - return list(name.toString()); - } - - public NamingEnumeration listBindings(Name name) throws NamingException - { - return listBindings(name.toString()); - } - - public void bind(Name name, Object obj) throws NamingException - { - throw new OperationNotSupportedException(); - } - - public void bind(String name, Object obj) throws NamingException - { - throw new OperationNotSupportedException(); - } - - public void close() throws NamingException - { - // ignore - } - - public Context createSubcontext(Name name) throws NamingException - { - throw new OperationNotSupportedException(); - } - - public Context createSubcontext(String name) throws NamingException - { - throw new OperationNotSupportedException(); - } - - public void destroySubcontext(Name name) throws NamingException - { - throw new OperationNotSupportedException(); - } - - public void destroySubcontext(String name) throws NamingException - { - throw new OperationNotSupportedException(); - } - - public String getNameInNamespace() throws NamingException - { - return nameInNamespace; - } - - public NameParser getNameParser(Name name) throws NamingException - { - return nameParser; - } - - public NameParser getNameParser(String name) throws NamingException - { - return nameParser; - } - - public void rebind(Name name, Object obj) throws NamingException - { - throw new OperationNotSupportedException(); - } - - public void rebind(String name, Object obj) throws NamingException - { - throw new OperationNotSupportedException(); - } - - public void rename(Name oldName, Name newName) throws NamingException - { - throw new OperationNotSupportedException(); - } - - public void rename(String oldName, String newName) throws NamingException - { - throw new OperationNotSupportedException(); - } - - public void unbind(Name name) throws NamingException - { - throw new OperationNotSupportedException(); - } - - public void unbind(String name) throws NamingException - { - throw new OperationNotSupportedException(); - } - - private abstract class LocalNamingEnumeration implements NamingEnumeration - { - private Iterator i = bindings.entrySet().iterator(); - - public boolean hasMore() throws NamingException - { - return i.hasNext(); - } - - public boolean hasMoreElements() - { - return i.hasNext(); - } - - protected Map.Entry getNext() - { - return (Map.Entry) i.next(); - } - - public void close() throws NamingException - { } - } - - private class ListEnumeration extends ReadOnlyContext.LocalNamingEnumeration - { - public Object next() throws NamingException - { - return nextElement(); - } - - public Object nextElement() - { - Map.Entry entry = getNext(); - - return new NameClassPair((String) entry.getKey(), entry.getValue().getClass().getName()); - } - } - - private class ListBindingEnumeration extends ReadOnlyContext.LocalNamingEnumeration - { - public Object next() throws NamingException - { - return nextElement(); - } - - public Object nextElement() - { - Map.Entry entry = getNext(); - - return new Binding((String) entry.getKey(), entry.getValue()); - } - } -} diff --git a/java/client/src/main/java/org/apache/qpid/naming/jndi.properties b/java/client/src/main/java/org/apache/qpid/naming/jndi.properties deleted file mode 100644 index 830de5f619..0000000000 --- a/java/client/src/main/java/org/apache/qpid/naming/jndi.properties +++ /dev/null @@ -1,40 +0,0 @@ -# -# 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. -# -java.naming.factory.initial = org.apache.qpid.naming.PropertiesFileInitialConextFactory - -# use the following property to configure the default connector -#java.naming.provider.url - ignored. - -# register some connection factories -# connectionfactory.[jndiname] = [ConnectionURL] -# qpid:username=foo;password=password;client_id=id;virtualhost=path@tpc:localhost:1556 -connectionfactory.local = qpid:tcp:localhost' - -# register some queues in JNDI using the form -# queue.[jndiName] = [physicalName] -queue.MyQueue = example.MyQueue - -# register some topics in JNDI using the form -# topic.[jndiName] = [physicalName] -topic.ibmStocks = stocks.nyse.ibm - -# Register an AMQP destination in JNDI -# NOTE: Qpid currently only supports direct,topics and headers -# destination.[jniName] = [BindingURL] -destination.direct = direct://amq.direct//directQueue |
