donderdag 6 mei 2010

New version! Focus on Java Reflection

Hello young ,and less young, padawans

I was gathering stuff to put in my next release, but it was nothing mind-boggling.
Until a couple of days ago...

I was trying to create a method that would be able to call an SBO (Documentum Service-Based Business Object) without having to import the SBO-interface and having to add the jar to my classpath.

I know this can easily be done using Java Reflection, but the problem was: I wanted to create one method to call any SBO.

Something like this:

public Object callSBO(String sboName, String methodName, Object... args){...}

Now, that isn't such a hard thing to do.
  1. Get the SBO-service
  2. use Reflection to get the method and invoke it
That is, when all your arguments are Objects!


I came across the problem of calling an SBO that takes an int value + some Objects.
The problem is that Java reflection wraps an int-value into an Integer to be able to put it in a Object-array.
Since we don't want to pass both an Object[] array and the corresponding Class[] array, we have to create the Class-array on the fly.
So we start with 2 ints, and unwillingly end up with 2 Integers.


Now I don't know if you have ever tried calling a function that takes int-values with Integer values through reflection, but I can assure you, it results in nice NoSuchMethodExceptions.

As a possible solution I tried to replace all primitive-wrappers-classes in the Class-array with primitive-classes, but what if you ever come across a method like this:
public void foo(int i, String s, Double d){...}

Ye, I know, functions that mix primitives with wrappers are rare, but exist nonetheless!  So ignoring that possibility would be a bad choice.
That left me with 2 options:
  1. Also pass an array with the corresponding classes to the method (no way!)
  2. Work some MAGIC 
I obviously decided to choose the latter, and I'll present it soon!

It's easy to use, just pass a Class/Object, methodName and an array of Objects to the method (as varArgs), and let SennMagic decide which values should be primitive and which should be wrappers.

I created the method to able to use in any case, and I also added a specific method callService(...) to DFCUtils.  

Now you can call any SBO without having to add the jar to the classpath of the (web)application.

Till soon...

Cheers,
Bart

dinsdag 13 april 2010

DFC with multiple dfc.properties files

UPDATED: I have called quits on this little sideproject.  It was working ok-ish, but it was not performant enough and I just couldn't bring myself to make this work.
Source code can be handed out if you'd like to give it a try.

For now I'll just focus (lol) on the SennMagic library

I developed a small Java package that allows you to code a DFC based application that uses multiple dfc.properties files.

I'm still in the testing phase, but if you want to try it out (and help me test it) you can contact me and ask for the package.

It has to be tested in
- various OS's
- different Documentum setups (Oracle, SQL Server)
- single- & multithreaded DFC apps (this might show us a few bugs)
- webapps


You can contact me through
- replying here
- mail
- twitter
- EMC Community Forums

Use "SennMagic DFC" as subject.

Bart


EDIT: to avoid confusion: this jar cannot be found on our SourceForge page yet!

woensdag 31 maart 2010

Bugfix

I fixed the bug in CountryUtils!

You can find the updated version of SennMagic at SourceFourge!


Cheers!

donderdag 25 maart 2010

Bug in CountryUtils

Hello all,

I discovered that a there's a bug in CountryUtils.
It can't find the country_codes.xml file.

I'll fix this asap!

For the time being, if you want to use CountryUtils, place the resources-folder (found in senn-magic-3.2-src.zip/com/senn/magic/util/resources) in the root of your application.

My apologies!

Bart

woensdag 3 maart 2010

SM 3.2 released! And how!!!

Hi everybody,

it's been a while since the last version, but here it is!

SENNMAGIC 3.2!

A whole lot has been added since 3.1!

  • com.senn.magic.util.WebUtils
  • com.senn.magic.util.CountryUtils
  • com.senn.magic.util.DSUtils
  • com.senn.magic.io.Directory
And ofcourse, many methods added to the existing classes!

Check out the javadoc and release notes for more info!

As always you can find it @ our sourceforge page

Cheers,
Bart

vrijdag 12 februari 2010

Next version of SennMagic in the making!

Hi everybody!

I'm glad to announce that if I've got alot of new stuff for the new version of SennMagic!
Some new Util-classes, some methods updated or improved and even a special dedicated POJO class for working with Filesystem directories (as opposed to using java.io.File which is not very straightforward for directories).

So how's that for a sneakpeak!

I don't know yet when I'll release it, but it won't be long!

Stay tuned!

Bart

woensdag 27 januari 2010

SennMagic 3.1 = 3.0 fixed + extras!

I fixed the compile-issue with SennMagic 3.0 and as an apology, I added some new methods that I was saving for a future release.

GeneralUtils.canBeBoolean(String):boolean
GeneralUtils.canBeByte(String):boolean
GeneralUtils.canBeDouble(String):boolean
GeneralUtils.canBeFloat(String):boolean
GeneralUtils.canBeInteger(String):boolean
GeneralUtils.canBeLong(String):boolean
GeneralUtils.canBeShort(String):boolean


These methods check if a String vaue can be converted to the respective type.
It saves you the trouble of having to catch NumberFormatException everytime you want to convert a String to something.

I also added

StringUtils.isValid(String):boolean

Which is a pretty simple and straightforward check. I use it all the time to check my string values.
It checks if a String value is not null and the length is > 0.

So, SennMagic 3.1 is available for download!

Only one place: http://sourceforge.net/projects/sennmagic

maandag 25 januari 2010

Bug in SennMagic 3.0

Hi,

I just noticed that SennMagic 3.0 is compiled to 1.6.
I have no idea why my Ant build decided to build it in 6 all of a sudden...

I will fix this tonight when I get back from work, so expect a small update soon!

My apologies,

Bart

vrijdag 22 januari 2010

SennMagic 3.0!

Hi everybody,

I know it has been a while since I last updated SennMagic, but that's because I decided to wait till I had enough new material.

So here it is, the new version, and yes it's another MAJOR release.

There's been some serious changes since 2.0 so I decided to bump it up to 3.0 instead of 2.1 or whatever.

So, what's new...
  1. I changed the classnames to reflect their purpose better:
    • LogMagic => SimpleLogger
    • FileMagic => FileUtils
    • TextMagic => StringUtils
    • UtilMagic => GeneralUtils
  2. I added DFCUtils, which contains some handy methods for DFC actions (more info below)
  3. I added ignoreCase support to StringUtils.getOccurrencesCount(...)
  4. I decided to split the jar, source and javadoc into 3 packages
    1. package: senn-magic-3.0.jar
    2. source: senn-magic-3.0-src.zip
    3. docs: senn-magic-3.0-javadoc.zip
  5. Last but no least, I refactored some methods and reformatted the code + javadoc


So what is DFCUtils...?

I've been busy doing alot of development on Documentum projects.
Documentum is an enterprise content management platform by EMC² (www.emc.com).

To access the Documentum content and metadata from Java, DFC is used.
DFC, or Documentum Foundation Classes, is an extensive API that allows you to do almost anything in Documentum.

DFCUtils is a helper class that contains methods to create sessions and execute DQL (Documentum Query Language).
So it saves me (and hopefully some other people too) some time.


So that's it, check out the new version at: http://sourceforge.net/projects/sennmagic

Cheers,
Bart