Author: ruwan
Date: Sun Oct 14 02:44:32 2007
New Revision: 584521
URL: http://svn.apache.org/viewvc?rev=584521&view=rev
Log:
Fixing an issue with the CacheMediatorSerializer.java
Modified:
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CacheMediatorSerializer.java
Modified:
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CacheMediatorSerializer.java
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CacheMediatorSerializer.java?rev=584521&r1=584520&r2=584521&view=diff
==============================================================================
---
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CacheMediatorSerializer.java
(original)
+++
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CacheMediatorSerializer.java
Sun Oct 14 02:44:32 2007
@@ -1,99 +1,103 @@
-/*
- * 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.synapse.config.xml;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.synapse.Mediator;
-import org.apache.synapse.mediators.builtin.CacheMediator;
-
-/**
- * Serializes the Cache mediator to the XML configuration specified
- *
- * <cache (id="string")? hashGenerator="class" scope="string"
timeout="mili-seconds">
- * <onCacheHit (sequence="key")?>
- * (mediator)+
- * </onCacheHit>
- * <implementation type=(memory | disk) maxSize="int"/>
- * </cache>
- */
-public class CacheMediatorSerializer extends AbstractMediatorSerializer {
-
- public OMElement serializeMediator(OMElement parent, Mediator m) {
-
- if (!(m instanceof CacheMediator)) {
- handleException("Unsupported mediator passed in for serialization
: " + m.getType());
- }
- CacheMediator mediator = (CacheMediator) m;
- OMElement cache = fac.createOMElement("cache", synNS);
- saveTracingState(cache, mediator);
-
- if (mediator.getId() != null) {
- cache.addAttribute(fac.createOMAttribute("id", nullNS,
mediator.getId()));
- }
-
- if (mediator.getDigestGenerator() != null) {
- cache.addAttribute(fac.createOMAttribute("hashGenerator", nullNS,
- mediator.getDigestGenerator().getClass().getName()));
- }
-
- if (mediator.getScope() != null) {
- cache.addAttribute(fac.createOMAttribute("scope", nullNS,
mediator.getScope()));
- }
-
- if (mediator.getTimeout() != 0) {
- cache.addAttribute(
- fac.createOMAttribute("timeout", nullNS,
Long.toString(mediator.getTimeout())));
- }
-
- if (mediator.getOnCacheHitRef() != null) {
- OMElement onCacheHit = fac.createOMElement("onCacheHit", synNS);
- onCacheHit.addAttribute(
- fac.createOMAttribute("sequence", nullNS,
mediator.getOnCacheHitRef()));
- cache.addChild(onCacheHit);
- } else if (mediator.getOnCacheHitSequence() != null) {
- OMElement onCacheHit = fac.createOMElement("onCacheHit", synNS);
- new SequenceMediatorSerializer().serializeChildren(
- onCacheHit, mediator.getOnCacheHitSequence().getList());
- cache.addChild(onCacheHit);
- }
-
- if (mediator.getInMemoryCacheSize() != 0) {
- OMElement implElem = fac.createOMElement("implementation", synNS);
- implElem.addAttribute(fac.createOMAttribute("type", nullNS,
"memory"));
- implElem.addAttribute(fac.createOMAttribute(
- "maxSize", nullNS,
Integer.toString(mediator.getInMemoryCacheSize())));
- cache.addChild(implElem);
- }
-
- if (mediator.getDiskCacheSize() != 0) {
- OMElement implElem = fac.createOMElement("implementation", synNS);
- implElem.addAttribute(fac.createOMAttribute("type", nullNS,
"disk"));
- implElem.addAttribute(fac.createOMAttribute(
- "maxSize", nullNS,
Integer.toString(mediator.getDiskCacheSize())));
- cache.addChild(implElem);
- }
-
- return cache;
- }
-
- public String getMediatorClassName() {
- return CacheMediator.class.getName();
- }
-}
+/*
+ * 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.synapse.config.xml;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.synapse.Mediator;
+import org.apache.synapse.mediators.builtin.CacheMediator;
+
+/**
+ * Serializes the Cache mediator to the XML configuration specified
+ *
+ * <cache (id="string")? hashGenerator="class" scope="string"
timeout="mili-seconds">
+ * <onCacheHit (sequence="key")?>
+ * (mediator)+
+ * </onCacheHit>
+ * <implementation type=(memory | disk) maxSize="int"/>
+ * </cache>
+ */
+public class CacheMediatorSerializer extends AbstractMediatorSerializer {
+
+ public OMElement serializeMediator(OMElement parent, Mediator m) {
+
+ if (!(m instanceof CacheMediator)) {
+ handleException("Unsupported mediator passed in for serialization
: " + m.getType());
+ }
+ CacheMediator mediator = (CacheMediator) m;
+ OMElement cache = fac.createOMElement("cache", synNS);
+ saveTracingState(cache, mediator);
+
+ if (mediator.getId() != null) {
+ cache.addAttribute(fac.createOMAttribute("id", nullNS,
mediator.getId()));
+ }
+
+ if (mediator.getDigestGenerator() != null) {
+ cache.addAttribute(fac.createOMAttribute("hashGenerator", nullNS,
+ mediator.getDigestGenerator().getClass().getName()));
+ }
+
+ if (mediator.getScope() != null) {
+ cache.addAttribute(fac.createOMAttribute("scope", nullNS,
mediator.getScope()));
+ }
+
+ if (mediator.getTimeout() != 0) {
+ cache.addAttribute(
+ fac.createOMAttribute("timeout", nullNS,
Long.toString(mediator.getTimeout())));
+ }
+
+ if (mediator.getOnCacheHitRef() != null) {
+ OMElement onCacheHit = fac.createOMElement("onCacheHit", synNS);
+ onCacheHit.addAttribute(
+ fac.createOMAttribute("sequence", nullNS,
mediator.getOnCacheHitRef()));
+ cache.addChild(onCacheHit);
+ } else if (mediator.getOnCacheHitSequence() != null) {
+ OMElement onCacheHit = fac.createOMElement("onCacheHit", synNS);
+ new SequenceMediatorSerializer().serializeChildren(
+ onCacheHit, mediator.getOnCacheHitSequence().getList());
+ cache.addChild(onCacheHit);
+ }
+
+ if (mediator.getInMemoryCacheSize() != 0) {
+ OMElement implElem = fac.createOMElement("implementation", synNS);
+ implElem.addAttribute(fac.createOMAttribute("type", nullNS,
"memory"));
+ implElem.addAttribute(fac.createOMAttribute(
+ "maxSize", nullNS,
Integer.toString(mediator.getInMemoryCacheSize())));
+ cache.addChild(implElem);
+ }
+
+ if (mediator.getDiskCacheSize() != 0) {
+ OMElement implElem = fac.createOMElement("implementation", synNS);
+ implElem.addAttribute(fac.createOMAttribute("type", nullNS,
"disk"));
+ implElem.addAttribute(fac.createOMAttribute(
+ "maxSize", nullNS,
Integer.toString(mediator.getDiskCacheSize())));
+ cache.addChild(implElem);
+ }
+
+ if (parent != null) {
+ parent.addChild(cache);
+ }
+
+ return cache;
+ }
+
+ public String getMediatorClassName() {
+ return CacheMediator.class.getName();
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]