[Design the new POJO MicroContainer] - Re: enums, generics and other animals
by alesj
"adrian(a)jboss.org" wrote :
| You don't need to code this yourself. Just add @XmlEnumValues to the enum class.
| JBoss/AXB already knows how to parse enums.
Does this include the old JBossXB handlers?
e.g.
| public class InjectionHandler extends DefaultElementHandler
| {
| ...
|
| public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
| {
| AbstractInjectionValueMetaData injection = (AbstractInjectionValueMetaData) o;
| for (int i = 0; i < attrs.getLength(); ++i)
| {
| String localName = attrs.getLocalName(i);
| ...
| else if ("type".equals(localName))
| injection.setInjectionType(AutowireType.getInstance(attrs.getValue(i)));
| else if ("option".equals(localName))
| injection.setInjectionOption(InjectOption.getInstance(attrs.getValue(i)));
| else if ("fromContext".equals(localName))
| injection.setFromContext(FromContext.getInstance(attrs.getValue(i)));
| }
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134872#4134872
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4134872
18 years, 1 month
[Design the new POJO MicroContainer] - Re: enums, generics and other animals
by adrian@jboss.org
"alesj" wrote : Another refactoring question. :-)
| Since for xml handling I still need to get the right enum by matching the underlying strings.
| The thing is that on enums there is already a valueOf method which does similar thing, matching enum's name with input string parameter.
| But in our case the names do not match exactly the underlying strings, resulting in needing something like getInstance method which iterates over the enums and does a string match.
| Should I just use the valueOf and fix the strings in our tests?
| Probably not, since it will break quite some things. :-)
RTFM :-)
You can actually do some pretty weird stuff, so don't overuse it ;-)
| @XmlEnum(Integer.class)
| public enum OldEnglishMoney
| {
| @XmlEnumValue("D")
| PENNY(1),
| @XmlEnumValue("S")
| SHILLING(12)
| @XmlEnumValue("L")
| POUND(240)
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134855#4134855
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4134855
18 years, 1 month
[Design the new POJO MicroContainer] - Maven dependencies - trimming
by adrian@jboss.org
One thing I'm doing while doing the refactoring of the projects
is to "trim" the dependencies.
e.g. using optional and exclude such that consuming projects
don't pick up unnecessary dependencies.
javaassist is optional when using jboss-reflect
| <dependency>
| <groupId>org.jboss</groupId>
| <artifactId>javassist</artifactId>
| <version>3.6.0.GA</version>
| <!-- HERE -->
| <optional>true</optional>
| </dependency>
|
Don't let jboss-common-core add unnecessary dependencies
(or choose an old logging-spi version ;-).
| <dependency>
| <groupId>org.jboss</groupId>
| <artifactId>jboss-common-core</artifactId>
| <version>2.2.3.GA</version>
| <exclusions>
| <exclusion>
| <groupId>jboss</groupId>
| <artifactId>jboss-common-logging-spi</artifactId>
| </exclusion>
| <exclusion>
| <groupId>apache-httpclient</groupId>
| <artifactId>commons-httpclient</artifactId>
| </exclusion>
| <exclusion>
| <groupId>apache-slide</groupId>
| <artifactId>webdavlib</artifactId>
| </exclusion>
| <exclusion>
| <groupId>apache-xerces</groupId>
| <artifactId>xml-apis</artifactId>
| </exclusion>
| </exclusions>
|
This kind of thing needs doing throughout the MC.
e.g. there is a JIRA task about making junit and jboss-test an optional
dependency since not everybody will want to use the MicrocontainerTest.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134853#4134853
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4134853
18 years, 1 month