use of org.apache.geode.cache.CacheXmlException in project geode by apache.
the class CacheXmlParser method endTransactionWriter.
/**
* Create a <code>transaction-writer</code> using the declarable interface and set the transaction
* manager with the newly instantiated writer.
*/
private void endTransactionWriter() {
Declarable d = createDeclarable();
if (!(d instanceof TransactionWriter)) {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_TRANSACTION_WRITER.toLocalizedString(d.getClass().getName()));
}
CacheTransactionManagerCreation txMgrCreation = (CacheTransactionManagerCreation) stack.peek();
txMgrCreation.setWriter((TransactionWriter) d);
}
use of org.apache.geode.cache.CacheXmlException in project geode by apache.
the class CacheXmlParser method endCompressor.
/**
* Ending the <code>compressor</code> registration should leave us with a class name on the stack.
* Pull it off and setup the {@link Compressor} on the region attributes.
*/
private void endCompressor() {
Class<?> klass = getClassFromStack();
if (!Compressor.class.isAssignableFrom(klass)) {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_COMPRESSOR.toLocalizedString(klass.getName()));
}
Compressor compressor;
try {
compressor = (Compressor) klass.newInstance();
} catch (Exception ex) {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_WHILE_INSTANTIATING_A_0.toLocalizedString(klass.getName()), ex);
}
Object a = stack.peek();
if (a instanceof RegionAttributesCreation) {
RegionAttributesCreation attrs = (RegionAttributesCreation) a;
attrs.setCompressor(compressor);
} else {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_MUST_BE_DEFINED_IN_THE_CONTEXT_OF_REGIONATTRIBUTES_OR_1.toLocalizedString(new Object[] { COMPRESSOR, DYNAMIC_REGION_FACTORY }));
}
}
use of org.apache.geode.cache.CacheXmlException in project geode by apache.
the class CacheXmlParser method endInitializer.
private void endInitializer() {
Properties props = new Properties();
Object top = stack.pop();
while (top instanceof Parameter) {
Parameter param = (Parameter) top;
props.put(param.getName(), param.getValue());
top = stack.pop();
}
Assert.assertTrue(top instanceof String);
String className = (String) top;
Object o;
try {
Class c = InternalDataSerializer.getCachedClass(className);
o = c.newInstance();
} catch (Exception ex) {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_WHILE_INSTANTIATING_A_0.toLocalizedString(className), ex);
}
if (!(o instanceof Declarable)) {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_CLASS_0_IS_NOT_AN_INSTANCE_OF_DECLARABLE.toLocalizedString(className));
}
Declarable d = (Declarable) o;
this.cache.setInitializer(d, props);
}
use of org.apache.geode.cache.CacheXmlException in project geode by apache.
the class CacheXmlParser method endElement.
public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
try {
// + "; localName = " + localName + "; qName = " + qName);
if (qName.equals(CACHE)) {
endCache();
} else if (qName.equals(CLIENT_CACHE)) {
endClientCache();
} else if (qName.equals(BRIDGE_SERVER)) {
endCacheServer();
} else if (qName.equals(CACHE_SERVER)) {
endCacheServer();
} else if (qName.equals(LOAD_PROBE)) {
endLoadProbe();
} else if (qName.equals(CLIENT_SUBSCRIPTION)) {
endClientHaQueue();
} else if (qName.equals(CONNECTION_POOL)) {
endPool();
} else if (qName.equals(DYNAMIC_REGION_FACTORY)) {
endDynamicRegionFactory();
} else if (qName.equals(GATEWAY_SENDER)) {
endSerialGatewaySender();
} else if (qName.equals(GATEWAY_RECEIVER)) {
endGatewayReceiver();
} else if (qName.equals(GATEWAY_EVENT_FILTER)) {
endGatewayEventFilter();
} else if (qName.equals(GATEWAY_EVENT_SUBSTITUTION_FILTER)) {
endGatewayEventSubstitutionFilter();
} else if (qName.equals(GATEWAY_TRANSPORT_FILTER)) {
endGatewayTransportFilter();
} else if (qName.equals(ASYNC_EVENT_QUEUE)) {
endAsyncEventQueue();
} else if (qName.equals(REGION)) {
endRegion();
} else if (qName.equals(GATEWAY_CONFLICT_RESOLVER)) {
endGatewayConflictResolver();
} else if (qName.equals(VM_ROOT_REGION)) {
endRegion();
} else if (qName.equals(REGION_ATTRIBUTES)) {
endRegionAttributes();
} else if (qName.equals(DISK_STORE)) {
endDiskStore();
} else if (qName.equals(KEY_CONSTRAINT)) {
endKeyConstraint();
} else if (qName.equals(VALUE_CONSTRAINT)) {
endValueConstraint();
} else if (qName.equals(REGION_TIME_TO_LIVE)) {
endRegionTimeToLive();
} else if (qName.equals(REGION_IDLE_TIME)) {
endRegionIdleTime();
} else if (qName.equals(ENTRY_TIME_TO_LIVE)) {
endEntryTimeToLive();
} else if (qName.equals(ENTRY_IDLE_TIME)) {
endEntryIdleTime();
} else if (qName.equals(CUSTOM_EXPIRY)) {
endCustomExpiry();
} else if (qName.equals(DISK_WRITE_ATTRIBUTES)) {
endDiskWriteAttributes();
} else if (qName.equals(SYNCHRONOUS_WRITES)) {
} else if (qName.equals(ASYNCHRONOUS_WRITES)) {
} else if (qName.equals(DISK_DIRS)) {
endDiskDirs();
} else if (qName.equals(DISK_DIR)) {
endDiskDir();
} else if (qName.equals(GROUP)) {
endGroup();
} else if (qName.equals(PARTITION_ATTRIBUTES)) {
endPartitionAttributes();
} else if (qName.equals(FIXED_PARTITION_ATTRIBUTES)) {
endFixedPartitionAttributes();
} else if (qName.equals(LOCAL_PROPERTIES)) {
endPartitionProperites(LOCAL_PROPERTIES);
} else if (qName.equals(GLOBAL_PROPERTIES)) {
endPartitionProperites(GLOBAL_PROPERTIES);
} else if (qName.equals(MEMBERSHIP_ATTRIBUTES)) {
endMembershipAttributes();
} else if (qName.equals(REQUIRED_ROLE)) {
endRequiredRole();
} else if (qName.equals(EXPIRATION_ATTRIBUTES)) {
} else if (qName.equals(CUSTOM_EXPIRY)) {
endCustomExpiry();
} else if (qName.equals(SUBSCRIPTION_ATTRIBUTES)) {
} else if (qName.equals(ENTRY)) {
endEntry();
} else if (qName.equals(CLASS_NAME)) {
endClassName();
} else if (qName.equals(PARAMETER)) {
endParameter();
} else if (qName.equals(CACHE_LOADER)) {
endCacheLoader();
} else if (qName.equals(CACHE_WRITER)) {
endCacheWriter();
} else if (qName.equals(EVICTION_ATTRIBUTES)) {
} else if (qName.equals(LRU_ENTRY_COUNT)) {
// internal to eviction-attributes
} else if (qName.equals(LRU_MEMORY_SIZE)) {
// internal to eviction-attributes
endLRUMemorySize();
} else if (qName.equals(LRU_HEAP_PERCENTAGE)) {
// internal to eviction-attributes
endLRUHeapPercentage();
} else if (qName.equals(CACHE_LISTENER)) {
endCacheListener();
} else if (qName.equals(ASYNC_EVENT_LISTENER)) {
endAsyncEventListener();
} else if (qName.equals(KEY)) {
} else if (qName.equals(VALUE)) {
} else if (qName.equals(STRING)) {
endString();
} else if (qName.equals(DECLARABLE)) {
endDeclarable();
} else if (qName.equals(FUNCTIONAL)) {
} else if (qName.equals(INDEX)) {
endIndex();
} else if (qName.equals(PRIMARY_KEY)) {
} else if (qName.equals(TRANSACTION_MANAGER)) {
endCacheTransactionManager();
} else if (qName.equals(TRANSACTION_LISTENER)) {
endTransactionListener();
} else if (qName.equals(TRANSACTION_WRITER)) {
endTransactionWriter();
} else if (qName.equals(JNDI_BINDINGS)) {
} else if (qName.equals(JNDI_BINDING)) {
// Asif Pop the BindingCreation object
BindingCreation bc = (BindingCreation) this.stack.pop();
JNDIInvoker.mapDatasource(bc.getGFSpecificMap(), bc.getVendorSpecificList());
} else if (qName.equals(CONFIG_PROPERTY_BINDING)) {
} else if (qName.equals(CONFIG_PROPERTY_NAME)) {
String name = null;
if (this.stack.peek() instanceof StringBuffer)
// Pop the config-property-name element value from the stack.
name = ((StringBuffer) this.stack.pop()).toString();
BindingCreation bc = (BindingCreation) this.stack.peek();
List vsList = bc.getVendorSpecificList();
ConfigProperty cp = (ConfigProperty) vsList.get(vsList.size() - 1);
if (name == null) {
String excep = LocalizedStrings.CacheXmlParser_EXCEPTION_IN_PARSING_ELEMENT_0_THIS_IS_A_REQUIRED_FIELD.toLocalizedString(qName);
throw new CacheXmlException(excep);
} else {
// set the name.
cp.setName(name);
}
} else if (qName.equals(CONFIG_PROPERTY_VALUE)) {
String value = null;
// Pop the config-property-value element value from the stack.
if (this.stack.peek() instanceof StringBuffer)
value = ((StringBuffer) this.stack.pop()).toString();
BindingCreation bc = (BindingCreation) this.stack.peek();
List vsList = bc.getVendorSpecificList();
ConfigProperty cp = (ConfigProperty) vsList.get(vsList.size() - 1);
// Set the value to the ConfigProperty Data Object.
cp.setValue(value);
} else if (qName.equals(CONFIG_PROPERTY_TYPE)) {
String type = null;
if (this.stack.peek() instanceof StringBuffer)
type = ((StringBuffer) this.stack.pop()).toString();
BindingCreation bc = (BindingCreation) this.stack.peek();
List vsList = bc.getVendorSpecificList();
ConfigProperty cp = (ConfigProperty) vsList.get(vsList.size() - 1);
if (type == null) {
String excep = LocalizedStrings.CacheXmlParser_EXCEPTION_IN_PARSING_ELEMENT_0_THIS_IS_A_REQUIRED_FIELD.toLocalizedString(qName);
throw new CacheXmlException(excep);
} else {
cp.setType(type);
}
} else if (qName.equals(LRU_MEMORY_SIZE)) {
// internal to eviction-attributes
// Visit startLRUMemorySize() to know the begining
// of lru-memory-size eviction configuration
endLRUMemorySize();
} else if (qName.equals(LOCATOR)) {
// nothing needed
} else if (qName.equals(SERVER)) {
// nothing needed
} else if (qName.equals(PARTITION_RESOLVER)) {
endPartitionResolver();
} else if (qName.equals(PARTITION_LISTENER)) {
endPartitionListener();
} else if (qName.equals(FUNCTION)) {
endFunctionName();
} else if (qName.equals(FUNCTION_SERVICE)) {
endFunctionService();
} else if (qName.equals(TOP_SERIALIZER_REGISTRATION)) {
endSerializerRegistration();
} else if (qName.equals(INITIALIZER)) {
endInitializer();
} else if (qName.equals(SERIALIZER_REGISTRATION)) {
endSerializer();
} else if (qName.equals(INSTANTIATOR_REGISTRATION)) {
endInstantiator();
} else if (qName.equals(RESOURCE_MANAGER)) {
endResourceManager();
} else if (qName.equals(BACKUP)) {
endBackup();
} else if (qName.equals(PDX)) {
// nothing needed
} else if (qName.equals(PDX_SERIALIZER)) {
endPdxSerializer();
} else if (qName.equals(COMPRESSOR)) {
endCompressor();
} else {
final XmlParser delegate = getDelegate(namespaceURI);
if (null == delegate) {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_UNKNOWN_XML_ELEMENT_0.toLocalizedString(qName));
}
delegate.endElement(namespaceURI, localName, qName);
}
} catch (CacheException ex) {
throw new SAXException(LocalizedStrings.CacheXmlParser_A_CACHEEXCEPTION_WAS_THROWN_WHILE_PARSING_XML.toLocalizedString(), ex);
}
}
use of org.apache.geode.cache.CacheXmlException in project geode by apache.
the class LuceneXmlParser method startIndex.
private void startIndex(Attributes atts) {
if (!(stack.peek() instanceof RegionCreation)) {
throw new CacheXmlException("lucene <index> elements must occur within <region> elements");
}
final RegionCreation region = (RegionCreation) stack.peek();
String name = atts.getValue(NAME);
LuceneIndexCreation indexCreation = new LuceneIndexCreation();
indexCreation.setName(name);
indexCreation.setRegion(region);
region.getExtensionPoint().addExtension(indexCreation);
stack.push(indexCreation);
}
Aggregations