[Design the new POJO MicroContainer] - Abstractions, reuse and bad examples
by adrian@jboss.org
Here's an example of a bad abstraction I found by accident.
This is actually from the tests so its not too bad, but see below.
This could obviously be made more useful to others with the following changes;
| public class SearchDeployer extends AbstractDeployer
| {
| private URL[] urls;
|
| + private String prefix;
|
| + private String suffix;
|
| public SearchDeployer()
| {
| setStage(DeploymentStages.REAL);
| }
|
| public String getPrefix()
| {
| return prefix;
| }
|
| public void setPrefix(String prefix)
| {
| this.prefix = prefix;
| }
|
| public String getSuffix()
| {
| return suffix;
| }
|
| public void setSuffix(String suffix)
| {
| this.suffix = suffix;
| }
|
| public void deploy(DeploymentUnit unit) throws DeploymentException
| {
| try
| {
| - urls = Classpath.search(unit.getClassLoader(), "META-INF/", ".taglib.xml");
| + urls = Classpath.search(unit.getClassLoader(), prefix, suffix);
| }
| catch (IOException e)
| {
| - DeploymentException.rethrowAsDeploymentException("Error doing facelets search", e);
| + DeploymentException.rethrowAsDeploymentException("Error doing search prefix=" + prefix + " suffix=" + suffix, e);
| }
| }
|
| public void undeploy(DeploymentUnit unit)
| {
| urls = null;
| }
|
| public URL[] getUrls()
| {
| return urls;
| }
| }
|
That way the facelets deployer (which is obviously where this comes from?)
can extend this SearchDeployer and reuse generic tested code.
This argument is further enhanced because if you look at what
ClassPath.search() it is wrong,
it isn't making reference to the ClassLoadingMetaData/Module
so it will ignore any filters.
Has this code been copied somewhere else?
It's generally a bad idea to show the wrong way to do things in tests
because people copy what they find thinking that's the way it is supposed to work. :-)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4180248#4180248
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4180248
15 years, 7 months
[Design of Messaging on JBoss (Messaging/JBoss)] - Re: Some thoughts on large messages and message chunking
by clebert.suconic@jboss.com
"Tim Fox" wrote : When sending a message, we simply check if message size is greater than ml. If false then message sending and delivery proceeds exactly as normal. If true, then we send a standard SendMessage packet, followed by n MessageContinuation packets which contains the rest of the message split into each packet.
|
I'm doing this with a slightly variant.
SessionSendMessage creates the ServerMessageImpl, and decode/encodes directly from the Buffer to avoid copy and get some performance.
As SessionSendMessage is the class responsible for creating the MessageImpl, I was have a little difficult on instantiating the ServerMessage that will store the body on a file.
Because of that, when using LargeMessages I'm using another PacketType to deal with Large Messages. With that the regular use case would be optimized avoiding extra non necessary copies.
I will commit it tomorrow (on trunk or another branch) and it will be easier to talk about this later when I have some code to show the differences.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4180171#4180171
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4180171
15 years, 7 months