What’s up yall? I got this crazy programming requirement that has been killing me for the past couple of days. I need a way of serializing my streams. Now before you go cross eyed and start wagging your finger at me let me explain.
- I know a stream already represents serialized data.
- What I’m asking may sound like, “How do I wet my water?” but bear with me because I’m not as dumb as my picture looks.
- I know that when I get into situations like this that require a lot of extra coding and thinking that I’m most likely doing something else wrong but in this case I really think I’m onto something big.
Here’s the big idea. I want an interface that I can thro into my code that relieves me from the burdens/limitations of Java serialization. The interface must work with streams, readers, and writers and must do so remotely without letting the caller know or care about remoting issues. The idea is really a generic repository abstraction that allows me to easily throw junk in it and read the same junk back later on. I’ve implemented a Filesystem version of the interface that maps all stuff thrown at it to the file system and I can easily bang out an in-memory version of the same thing that uses a HashMap or the equivalent. I now want to spread remoting over top as a layer of icing on my repository cake. (Mmmmm… cake…!) I’d like to be able to do such things as chain a RemoteHttpRepository to a RemoteSocketRepository to a RepositoryFarm containing a FileSystemRepository and an WriteOnlyArchivedRepository for backup purposes. I’d like to be able to change my mind later on and snap in a DBRepository inplace of the RemoteSocketRepository in the same example.
So now we come back to my initial Repository interface. It’s a really cool thing that allows you to pas arbitrary stuff into it and get that stuff back out of it. That stuff can be anything from a File object to a Reader or an inputStream. Passing Readers or streams causes it to slurp the contents of the stream and record it all for later retrieval. That brings me back to my above dillemma, what happens when the repository is remote? I have some initial code I threw together to try to address the problem but it’s getting big and ugly. Sure the idea started simple (as most off the cuff brilliant ideas we all have start off) but it quickly exploded into an array of classes, interfaces, and unit tests on my hard drive. That’s one of the downsides to intentional programming with a powerful editor like Idea. You can hammer away for a minute or so and create a few dozen files orchestrating a complicated object and dependancy graph without even knowing it. Now I’m stuck, partly because I thought it would be a lot simpler than it is and partly because with all the development I’ve done I only see a small piece of the picture as implemented. The RemoteRepository spun off an entire abstract remoting package complete with its own set of drama. While it’s being developed specifically for my repository needs it’s showing a whole other barrel of complexity that I’m avoiding by focusing on my specific needs. That scares me because I don’t want to limit its usage to repository access but I’m not ready to swallow the entire elephant either.
In short, I feel like I’m in over my head. If you’re browsing my site and of reasonable intellect I ask, no, I plead for your insight. What’s the best way to stream a stream? Am I crazy for doing what I’m doing? Is there something obvious that I’m missing? I’ve been Googling around and I can’t find much help. I don’t have anywhere else to turn to, so I ask you my loyal reader for guidance. Hit me off with the right stuff…