[jboss-cvs] JBossAS SVN: r62208 - projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Apr 10 07:51:52 EDT 2007
Author: alesj
Date: 2007-04-10 07:51:51 -0400 (Tue, 10 Apr 2007)
New Revision: 62208
Added:
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractValueCreator.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/IntegerValueCreator.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/StringListValueCreator.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/StringValueCreator.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/URLValueCreator.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ValueCreatorUtil.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/VersionValueCreator.java
Modified:
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractOSGiMetaData.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ListValueCreator.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/PackageAttributeListValueCreator.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ParameterizedAttributeListValueCreator.java
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ParameterizedAttributeValueCreator.java
Log:
Separate ValueCreator impl; package protected. Helper utils for header values.
Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractOSGiMetaData.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractOSGiMetaData.java 2007-04-10 11:34:49 UTC (rev 62207)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractOSGiMetaData.java 2007-04-10 11:51:51 UTC (rev 62208)
@@ -21,7 +21,6 @@
*/
package org.jboss.osgi.plugins.metadata;
-import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.HashMap;
@@ -30,7 +29,7 @@
import java.util.jar.Manifest;
import org.jboss.deployers.plugins.metadata.AbstractManifestMetaData;
-import org.jboss.logging.Logger;
+import static org.jboss.osgi.plugins.metadata.ValueCreatorUtil.*;
import org.jboss.osgi.spi.metadata.OSGiMetaData;
import org.jboss.osgi.spi.metadata.PackageAttribute;
import org.jboss.osgi.spi.metadata.ParameterizedAttribute;
@@ -45,17 +44,7 @@
public class AbstractOSGiMetaData extends AbstractManifestMetaData implements OSGiMetaData
{
private static final long serialVersionUID = 1L;
- private static Logger log = Logger.getLogger(AbstractOSGiMetaData.class);
- protected static StringValueCreator STRING_VC = new StringValueCreator();
- protected static IntegerValueCreator INTEGER_VC = new IntegerValueCreator();
- protected static VersionValueCreator VERSION_VC = new VersionValueCreator();
- protected static URLValueCreator URL_VC = new URLValueCreator();
- protected static ParameterizedAttributeValueCreator PARAM_ATTRIB_VC = new ParameterizedAttributeValueCreator();
- protected static StringListValueCreator STRING_LIST_VC = new StringListValueCreator();
- protected static ParameterizedAttributeListValueCreator PARAM_ATTRIB_LIST_VC = new ParameterizedAttributeListValueCreator();
- protected static PackageAttributeListValueCreator PACKAGE_LIST_VC = new PackageAttributeListValueCreator();
-
protected Map<String, Object> cachedAttributes = new HashMap<String, Object>();
public AbstractOSGiMetaData()
@@ -174,52 +163,4 @@
return value;
}
- private static class StringValueCreator implements ValueCreator<String>
- {
- public String createValue(String attribute)
- {
- return attribute;
- }
- }
-
- private static class IntegerValueCreator implements ValueCreator<Integer>
- {
- public Integer createValue(String attribute)
- {
- return Integer.valueOf(attribute);
- }
- }
-
- private static class VersionValueCreator implements ValueCreator<Version>
- {
- public Version createValue(String attribute)
- {
- return new Version(attribute);
- }
- }
-
- private static class URLValueCreator implements ValueCreator<URL>
- {
- public URL createValue(String attribute)
- {
- try
- {
- return new URL(attribute);
- }
- catch (MalformedURLException e)
- {
- log.warn("Exception while creating URL.", e);
- return null;
- }
- }
- }
-
- private static class StringListValueCreator extends ListValueCreator<String>
- {
- public List<String> createValue(String attribute)
- {
- return Arrays.asList(attribute.split(","));
- }
- }
-
}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractValueCreator.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractValueCreator.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractValueCreator.java 2007-04-10 11:51:51 UTC (rev 62208)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.osgi.plugins.metadata;
+
+/**
+ * Abstract value creator.
+ * Extend this one for safe string usage.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+*/
+abstract class AbstractValueCreator<T> implements ValueCreator<T>
+{
+ private boolean trim;
+
+ protected AbstractValueCreator()
+ {
+ this(false);
+ }
+
+ protected AbstractValueCreator(boolean trim)
+ {
+ this.trim = trim;
+ }
+
+ public T createValue(String attribute)
+ {
+ if (attribute == null)
+ return null;
+ if (trim)
+ attribute = attribute.trim();
+ return useString(attribute);
+ }
+
+ /**
+ * Use this method on non-null trimmed string.
+ * @param attibute non-null trimmed string
+ * @return expected value
+ */
+ protected abstract T useString(String attibute);
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/IntegerValueCreator.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/IntegerValueCreator.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/IntegerValueCreator.java 2007-04-10 11:51:51 UTC (rev 62208)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.osgi.plugins.metadata;
+
+/**
+ * Parse int from string.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+*/
+class IntegerValueCreator extends AbstractValueCreator<Integer>
+{
+ public IntegerValueCreator()
+ {
+ super();
+ }
+
+ public IntegerValueCreator(boolean trim)
+ {
+ super(trim);
+ }
+
+ public Integer useString(String attribute)
+ {
+ return Integer.valueOf(attribute);
+ }
+}
Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ListValueCreator.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ListValueCreator.java 2007-04-10 11:34:49 UTC (rev 62207)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ListValueCreator.java 2007-04-10 11:51:51 UTC (rev 62208)
@@ -29,6 +29,15 @@
* @param <T> expected component type
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public abstract class ListValueCreator<T> implements ValueCreator<List<T>>
+abstract class ListValueCreator<T> extends AbstractValueCreator<List<T>>
{
+ protected ListValueCreator()
+ {
+ super();
+ }
+
+ protected ListValueCreator(boolean trim)
+ {
+ super(trim);
+ }
}
Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/PackageAttributeListValueCreator.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/PackageAttributeListValueCreator.java 2007-04-10 11:34:49 UTC (rev 62207)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/PackageAttributeListValueCreator.java 2007-04-10 11:51:51 UTC (rev 62208)
@@ -30,9 +30,9 @@
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public class PackageAttributeListValueCreator extends ListValueCreator<PackageAttribute>
+class PackageAttributeListValueCreator extends ListValueCreator<PackageAttribute>
{
- public List<PackageAttribute> createValue(String attibute)
+ public List<PackageAttribute> useString(String attibute)
{
return null; // todo
}
Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ParameterizedAttributeListValueCreator.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ParameterizedAttributeListValueCreator.java 2007-04-10 11:34:49 UTC (rev 62207)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ParameterizedAttributeListValueCreator.java 2007-04-10 11:51:51 UTC (rev 62208)
@@ -30,9 +30,9 @@
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public class ParameterizedAttributeListValueCreator extends ListValueCreator<ParameterizedAttribute>
+class ParameterizedAttributeListValueCreator extends ListValueCreator<ParameterizedAttribute>
{
- public List<ParameterizedAttribute> createValue(String attribute)
+ public List<ParameterizedAttribute> useString(String attribute)
{
return null; //Todo
}
Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ParameterizedAttributeValueCreator.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ParameterizedAttributeValueCreator.java 2007-04-10 11:34:49 UTC (rev 62207)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ParameterizedAttributeValueCreator.java 2007-04-10 11:51:51 UTC (rev 62208)
@@ -28,9 +28,9 @@
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public class ParameterizedAttributeValueCreator implements ValueCreator<ParameterizedAttribute>
+class ParameterizedAttributeValueCreator extends AbstractValueCreator<ParameterizedAttribute>
{
- public ParameterizedAttribute createValue(String attribute)
+ public ParameterizedAttribute useString(String attribute)
{
return null; //todo
}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/StringListValueCreator.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/StringListValueCreator.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/StringListValueCreator.java 2007-04-10 11:51:51 UTC (rev 62208)
@@ -0,0 +1,38 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.osgi.plugins.metadata;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Split string into list of strings.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+*/
+class StringListValueCreator extends ListValueCreator<String>
+{
+ public List<String> useString(String attribute)
+ {
+ return Arrays.asList(attribute.split(","));
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/StringValueCreator.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/StringValueCreator.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/StringValueCreator.java 2007-04-10 11:51:51 UTC (rev 62208)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.osgi.plugins.metadata;
+
+/**
+ * Plain string forwarding - no conversion.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+*/
+class StringValueCreator extends AbstractValueCreator<String>
+{
+ public StringValueCreator()
+ {
+ super();
+ }
+
+ public StringValueCreator(boolean trim)
+ {
+ super(trim);
+ }
+
+ protected String useString(String attibute)
+ {
+ return attibute;
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/URLValueCreator.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/URLValueCreator.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/URLValueCreator.java 2007-04-10 11:51:51 UTC (rev 62208)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.osgi.plugins.metadata;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Create URL from string.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+*/
+class URLValueCreator extends AbstractValueCreator<URL>
+{
+ private static Logger log = Logger.getLogger(URLValueCreator.class);
+
+ public URLValueCreator()
+ {
+ super();
+ }
+
+ public URLValueCreator(boolean trim)
+ {
+ super(trim);
+ }
+
+ public URL useString(String attribute)
+ {
+ try
+ {
+ return new URL(attribute);
+ }
+ catch (MalformedURLException e)
+ {
+ log.warn("Exception while creating URL.", e);
+ return null;
+ }
+ }
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ValueCreatorUtil.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ValueCreatorUtil.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ValueCreatorUtil.java 2007-04-10 11:51:51 UTC (rev 62208)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.osgi.plugins.metadata;
+
+/**
+ * ValueCreator holder.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ValueCreatorUtil
+{
+ static StringValueCreator STRING_VC = new StringValueCreator();
+ static IntegerValueCreator INTEGER_VC = new IntegerValueCreator();
+ static VersionValueCreator VERSION_VC = new VersionValueCreator();
+ static URLValueCreator URL_VC = new URLValueCreator();
+ static ParameterizedAttributeValueCreator PARAM_ATTRIB_VC = new ParameterizedAttributeValueCreator();
+ static StringListValueCreator STRING_LIST_VC = new StringListValueCreator();
+ static ParameterizedAttributeListValueCreator PARAM_ATTRIB_LIST_VC = new ParameterizedAttributeListValueCreator();
+ static PackageAttributeListValueCreator PACKAGE_LIST_VC = new PackageAttributeListValueCreator();
+}
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/VersionValueCreator.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/VersionValueCreator.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/VersionValueCreator.java 2007-04-10 11:51:51 UTC (rev 62208)
@@ -0,0 +1,47 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.osgi.plugins.metadata;
+
+import org.osgi.framework.Version;
+
+/**
+ * Parse Version from string.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+*/
+class VersionValueCreator extends AbstractValueCreator<Version>
+{
+ public VersionValueCreator()
+ {
+ super();
+ }
+
+ public VersionValueCreator(boolean trim)
+ {
+ super(trim);
+ }
+
+ public Version useString(String attribute)
+ {
+ return new Version(attribute);
+ }
+}
More information about the jboss-cvs-commits
mailing list