[jboss-cvs] JBossAS SVN: r85730 - in branches/Branch_5_x/system/src: main/org/jboss/system/server/profileservice/persistence/xml and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Mar 11 06:57:14 EDT 2009
Author: emuckenhuber
Date: 2009-03-11 06:57:14 -0400 (Wed, 11 Mar 2009)
New Revision: 85730
Added:
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/NullValue.java
branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/persistence/support/ObjectNameMetaData.java
branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/persistence/test/ObjectNameUnitTestCase.java
Modified:
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/AttachmentPropertyPopulator.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectOverride.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectPeristenceHandler.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRecreation.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedCollectionValue.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedCompositeValue.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedPair.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedProperty.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/JAXBAttachmentSerializer.java
Log:
[JBAS-6596] fix propertiesValue namespace and handle null values separate
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/AttachmentPropertyPopulator.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/AttachmentPropertyPopulator.java 2009-03-11 10:01:09 UTC (rev 85729)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/AttachmentPropertyPopulator.java 2009-03-11 10:57:14 UTC (rev 85730)
@@ -23,6 +23,8 @@
import java.lang.reflect.Proxy;
+import javax.management.ObjectName;
+
import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.beans.info.spi.PropertyInfo;
import org.jboss.logging.Logger;
@@ -90,11 +92,13 @@
// FIXME skip CompositeValueInvocationHandler
if (metaType.isComposite())
{
- // unwrap
- Object unwrapped = metaValueFactory.unwrap(value, propertyInfo.getType());
- if (Proxy.isProxyClass(unwrapped.getClass()))
- return;
-
+ if(metaType.getTypeName().equals(ObjectName.class.getName()) == false)
+ {
+ // unwrap
+ Object unwrapped = metaValueFactory.unwrap(value, propertyInfo.getType());
+ if (Proxy.isProxyClass(unwrapped.getClass()))
+ return;
+ }
}
// Set value
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectOverride.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectOverride.java 2009-03-11 10:01:09 UTC (rev 85729)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectOverride.java 2009-03-11 10:57:14 UTC (rev 85730)
@@ -112,6 +112,7 @@
{
// TODO
}
+
// Recreate the metaValue
MetaValue override = createMetaValue(valueElement, metaType);
@@ -147,14 +148,6 @@
if (original.getMetaType() == null)
throw new IllegalStateException("Original meta value is null " + original);
-
-// if (original.getMetaType().getTypeName().equals(override.getMetaType().getTypeName()) == false)
-// {
-// // On generic values the restored is different from the original
-// if(original.getMetaType().isGeneric() == false)
-// throw new RuntimeException("Cannot merge two different types original: " + original.getMetaType()
-// + " override: " + override.getMetaType());
-// }
// Now try to merge
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectPeristenceHandler.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectPeristenceHandler.java 2009-03-11 10:01:09 UTC (rev 85729)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectPeristenceHandler.java 2009-03-11 10:57:14 UTC (rev 85730)
@@ -46,6 +46,7 @@
import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.metatype.api.values.TableValue;
import org.jboss.system.server.profileservice.persistence.xml.ModificationInfo;
+import org.jboss.system.server.profileservice.persistence.xml.NullValue;
import org.jboss.system.server.profileservice.persistence.xml.PersistedArrayValue;
import org.jboss.system.server.profileservice.persistence.xml.PersistedCollectionValue;
import org.jboss.system.server.profileservice.persistence.xml.PersistedCompositeValue;
@@ -201,7 +202,7 @@
log.trace("creating persisted value for : " + value + " with metaType " + metaType);
if(value == null)
- return emtpyPersistedValue(metaType);
+ return new NullValue();
// Override the metaType e.g. the MapCompositeValueSupport
metaType = value.getMetaType();
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRecreation.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRecreation.java 2009-03-11 10:01:09 UTC (rev 85729)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRecreation.java 2009-03-11 10:57:14 UTC (rev 85730)
@@ -67,6 +67,7 @@
import org.jboss.metatype.api.values.TableValueSupport;
import org.jboss.metatype.plugins.types.StringName;
import org.jboss.reflect.plugins.ValueConvertor;
+import org.jboss.system.server.profileservice.persistence.xml.NullValue;
import org.jboss.system.server.profileservice.persistence.xml.PersistedArrayValue;
import org.jboss.system.server.profileservice.persistence.xml.PersistedCollectionValue;
import org.jboss.system.server.profileservice.persistence.xml.PersistedCompositeValue;
@@ -270,6 +271,9 @@
log.trace("processing value " + valueElement + " type: " + metaType);
}
+ if(valueElement instanceof NullValue)
+ return null;
+
if(valueElement == null)
return null;
Added: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/NullValue.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/NullValue.java (rev 0)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/NullValue.java 2009-03-11 10:57:14 UTC (rev 85730)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.server.profileservice.persistence.xml;
+
+/**
+ * A <null/> value.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class NullValue extends AbstractPersisitedValue implements PersistedValue
+{
+
+}
+
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedCollectionValue.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedCollectionValue.java 2009-03-11 10:01:09 UTC (rev 85729)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedCollectionValue.java 2009-03-11 10:57:14 UTC (rev 85730)
@@ -38,12 +38,14 @@
/** The values. */
private List<PersistedValue> values = new ArrayList<PersistedValue>();
- @XmlElements( value = {
+ @XmlElements( value = {
+ @XmlElement(name = "null", type = NullValue.class),
@XmlElement(name = "simple", type = PersistedSimpleValue.class),
@XmlElement(name = "enum", type = PersistedEnumValue.class),
@XmlElement(name = "generic", type = PersistedGenericValue.class),
@XmlElement(name = "collection", type = PersistedCollectionValue.class),
@XmlElement(name = "composite", type = PersistedCompositeValue.class),
+ @XmlElement(name = "properties", type = PersistedPropertiesValue.class),
@XmlElement(name = "table", type = PersistedTableValue.class),
@XmlElement(name = "array", type = PersistedArrayValue.class)
})
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedCompositeValue.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedCompositeValue.java 2009-03-11 10:01:09 UTC (rev 85729)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedCompositeValue.java 2009-03-11 10:57:14 UTC (rev 85730)
@@ -39,11 +39,13 @@
List<PersistedValue> values;
@XmlElements( value = {
+ @XmlElement(name = "null", type = NullValue.class),
@XmlElement(name = "simple", type = PersistedSimpleValue.class),
@XmlElement(name = "enum", type = PersistedEnumValue.class),
@XmlElement(name = "generic", type = PersistedGenericValue.class),
@XmlElement(name = "collection", type = PersistedCollectionValue.class),
@XmlElement(name = "composite", type = PersistedCompositeValue.class),
+ @XmlElement(name = "properties", type = PersistedPropertiesValue.class),
@XmlElement(name = "table", type = PersistedTableValue.class),
@XmlElement(name = "array", type = PersistedArrayValue.class)
})
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedPair.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedPair.java 2009-03-11 10:01:09 UTC (rev 85729)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedPair.java 2009-03-11 10:57:14 UTC (rev 85730)
@@ -22,7 +22,6 @@
package org.jboss.system.server.profileservice.persistence.xml;
import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlValue;
/**
* The SimpleValue/SimpleMetaType.
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedProperty.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedProperty.java 2009-03-11 10:01:09 UTC (rev 85729)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedProperty.java 2009-03-11 10:57:14 UTC (rev 85730)
@@ -54,11 +54,13 @@
}
@XmlElements( value = {
+ @XmlElement(name = "null", type = NullValue.class),
@XmlElement(name = "simple", type = PersistedSimpleValue.class),
@XmlElement(name = "enum", type = PersistedEnumValue.class),
@XmlElement(name = "composite", type = PersistedCompositeValue.class),
@XmlElement(name = "generic", type = PersistedGenericValue.class),
@XmlElement(name = "collection", type = PersistedCollectionValue.class),
+ @XmlElement(name = "properties", type = PersistedPropertiesValue.class),
@XmlElement(name = "table", type = PersistedTableValue.class),
@XmlElement(name = "array", type = PersistedArrayValue.class)
})
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/JAXBAttachmentSerializer.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/JAXBAttachmentSerializer.java 2009-03-11 10:01:09 UTC (rev 85729)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/JAXBAttachmentSerializer.java 2009-03-11 10:57:14 UTC (rev 85730)
@@ -22,6 +22,8 @@
package org.jboss.system.server.profileservice.repository;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
@@ -69,14 +71,18 @@
protected <T> T loadAttachment(File attachmentsStore, Class<T> expected) throws Exception
{
// JBoss XB
+ log.trace("loadAttachment, attachmentsStore="+attachmentsStore);
Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- return (T) unmarshaller.unmarshal(attachmentsStore.toURL().openStream(), resolver);
+ unmarshaller.setValidation(false);
+ unmarshaller.setSchemaValidation(false);
+ InputStream is = new FileInputStream(attachmentsStore);
+ return (T) unmarshaller.unmarshal(is, resolver);
}
protected void saveAttachment(File attachmentsStore, Object attachment) throws Exception
{
// JAXB
- log.trace("saveAttachments, attachmentsStore="+attachmentsStore+ ", attachment="+attachment);
+ log.trace("saveAttachment, attachmentsStore="+attachmentsStore+ ", attachment="+attachment);
JAXBContext ctx = JAXBContext.newInstance(attachment.getClass());
Marshaller marshaller = ctx.createMarshaller();
marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);
Added: branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/persistence/support/ObjectNameMetaData.java
===================================================================
--- branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/persistence/support/ObjectNameMetaData.java (rev 0)
+++ branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/persistence/support/ObjectNameMetaData.java 2009-03-11 10:57:14 UTC (rev 85730)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.server.profileservice.persistence.support;
+
+import javax.management.ObjectName;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperty;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at ManagementObject
+public class ObjectNameMetaData
+{
+
+ ObjectName name;
+
+ @ManagementProperty
+ public ObjectName getName()
+ {
+ return name;
+ }
+
+ public void setName(ObjectName name)
+ {
+ this.name = name;
+ }
+}
+
Added: branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/persistence/test/ObjectNameUnitTestCase.java
===================================================================
--- branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/persistence/test/ObjectNameUnitTestCase.java (rev 0)
+++ branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/persistence/test/ObjectNameUnitTestCase.java 2009-03-11 10:57:14 UTC (rev 85730)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.server.profileservice.persistence.test;
+
+import javax.management.ObjectName;
+
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.system.server.profileservice.persistence.ManagedGenericOverrideHandler;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedCompositeValue;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedPropertiesValue;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedProperty;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedSimpleValue;
+import org.jboss.test.server.profileservice.persistence.support.ObjectNameMetaData;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ObjectNameUnitTestCase extends AbstractPersistenceFormatTest
+{
+
+ public ObjectNameUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void test() throws Throwable
+ {
+ ManagedObject mo = getMOF().initManagedObject(createMD(), null);
+ assertNotNull(mo);
+
+ ManagedProperty p = mo.getProperty("name");
+ CompositeValue c = (CompositeValue) p.getValue();
+ assertNotNull(c);
+
+ // Assert xml information
+ PersistedManagedObject restoredElement = restore(mo);
+ assertNotNull(restoredElement);
+
+ PersistedProperty pp = restoredElement.getProperties().get(0);
+ assertNotNull(pp);
+
+ PersistedCompositeValue pcv = (PersistedCompositeValue) pp.getValue();
+ assertNotNull(pcv);
+
+ PersistedSimpleValue psv = (PersistedSimpleValue) pcv.getValues().get(0);
+ assertEquals("domain", psv.getName());
+ assertEquals("org.jboss", psv.getValue());
+
+ PersistedPropertiesValue ppv = (PersistedPropertiesValue) pcv.getValues().get(1);
+ assertEquals("keyPropertyList", ppv.getName());
+ assertEquals(1, ppv.getEntries().size());
+
+ //
+ ManagedGenericOverrideHandler handler = new ManagedGenericOverrideHandler();
+ ManagedObject restored = handler.update(createMD(), restoredElement);
+ assertNotNull(restored);
+ }
+
+
+ protected ObjectNameMetaData createMD() throws Exception
+ {
+ ObjectNameMetaData md = new ObjectNameMetaData();
+ // Set objectName
+ md.setName(createObjectName());
+
+ return md;
+ }
+
+ protected ObjectName createObjectName() throws Exception
+ {
+ return new ObjectName("org.jboss:test=test");
+ }
+}
+
More information about the jboss-cvs-commits
mailing list