import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import java.util.List;
public class GenericDao extends HibernateDaoSupport{
@SuppressWarnings("unchecked")
publicList getObject(T object){
return getHibernateTemplate().findByExample(object);
}
@SuppressWarnings("unchecked")
publicList getAllObjects(Class thisClass){
return getHibernateTemplate().loadAll(thisClass);
}
@SuppressWarnings("unchecked")
publicObject addObject(T object){
return getHibernateTemplate().save(object);
}
@SuppressWarnings("unchecked")
publicvoid updateObject(T object){
getHibernateTemplate().update(object);
}
}
Thursday, February 19, 2009
A neat little DAO for hibernate I came up with
No need to create new DAOs for each project if you use this little gem. Its not in groovy because GMaven has some problems with generics but this has seemed to remove the need to have multiple DAOs for annotated classes that just do basic crud functionality. Check it out and feel free to comment(Not that anyone reads these anyway :-)).
Tuesday, February 17, 2009
WTF is up with native in BPEL
To anyone that has tried to play around with BPEL they quickly realize that if a partnerlink has a schema of type "Native" than the payload must be in a Base64Binary string. This means that without a schema you can't just assign a string to a native payload. This is so that non-text content (such as pictures or audio) can be sent to a partnerlink, however, it creates extra work and aggravation 99% of the time.
So the easiest way to remedy this problem is to create a embedded java in your BPEL to convert your variable to a string. This post is designed to walk you through that.
First we need to import the Binary encoder so right before all of the partnerlinks in our BPEL document we will want to add this import (This is for Oracle BPEL and the class maybe different for other flavors)
or
Depending on the direction you want to go.
Ok now we have our import now we need to create a variable to house our encoded string, I used...
Finally we will create our embedded Java, here is what mine looks like I encoded my string decoding would be similar.
String input = (String)getVariableData();
Base64Encoder Encoder = new Base64Encoder();
try
{
String encoded = Base64Encoder.encode(input);
setVariableData("EncodedMessage",encoded);
}
catch(Exception ex)
{
ex.printStackTrace();
}
my is "ReceiveAddToDb_Dequeue_InputVariable","genericMessage","/ns6:genericMessage/ns6:payload"
Then I use an assign to assign the variable to the native payload.
So the easiest way to remedy this problem is to create a embedded java in your BPEL to convert your variable to a string. This post is designed to walk you through that.
First we need to import the Binary encoder so right before all of the partnerlinks in our BPEL document we will want to add this import (This is for Oracle BPEL and the class maybe different for other flavors)
or
Depending on the direction you want to go.
Ok now we have our import now we need to create a variable to house our encoded string, I used...
Finally we will create our embedded Java, here is what mine looks like I encoded my string decoding would be similar.
String input = (String)getVariableData(
Base64Encoder Encoder = new Base64Encoder();
try
{
String encoded = Base64Encoder.encode(input);
setVariableData("EncodedMessage",encoded);
}
catch(Exception ex)
{
ex.printStackTrace();
}
my
Then I use an assign to assign the variable to the native payload.
Wednesday, January 28, 2009
One last step for the trojan
One last thing there are two exes in the system 32 directory. They look a lot like svchost but they are small variations and have an exe ending. Start in safe mode and delete these then use CCleaner to clean up the problems with the registry.
Finally looks like I beat this virus!
Finally looks like I beat this virus!
BEWARE of Spyware Protect 2009
The name of the malicious program I got today was Something like spyware protector 2009
This site helped alot
http://www.spywarevoid.com/spyware-protect-2009.html
Steps I took to resolve
1.) open regedit and find currentuser>software you should find two new entries one should begin with like a A(Sorry already deleted it) and another one is like protection suite
also look in currentuser>software>microsoft>windows>run and there should be an entry for a exe that begins with s. Note the location of the file and delete
2.) Open Task manager and make sure all processes related to the program are stopped.
3.) Edit your Host file to include
127.0.0.1 www.swp2009.com
127.0.0.1 www.spyprotect2009.com
127.0.0.1 www.sp-protect2009.com
4.) go to file location and delete files
I found...
sysguard.exe
ugobamom.dll
Vsizujuzesec.dll
names apear random so don't expect them to be the same on your system I just used date-time stamps to find all process added around the same time as the program
sorry if this is a little unorganized I am writing it as I go...
So now I am using process explorer to find out what the deal is with those dlls and how to kill everything using them.
I also did a search in the registry and under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
I find 3 entries to delete, the first two appear to start the DLLs and the last seems to make defender hide. So I am deleting those names for referance are
Xriwiwoniqi
Wfarawumifora
Windows Defender
Once again all appear to be random names and actually I just removed the hide flag to defender instead of deleting it
This appears to do it lets restart and see
This site helped alot
http://www.spywarevoid.com/spyware-protect-2009.html
Steps I took to resolve
1.) open regedit and find currentuser>software you should find two new entries one should begin with like a A(Sorry already deleted it) and another one is like protection suite
also look in currentuser>software>microsoft>windows>run and there should be an entry for a exe that begins with s. Note the location of the file and delete
2.) Open Task manager and make sure all processes related to the program are stopped.
3.) Edit your Host file to include
127.0.0.1 www.swp2009.com
127.0.0.1 www.spyprotect2009.com
127.0.0.1 www.sp-protect2009.com
4.) go to file location and delete files
I found...
sysguard.exe
ugobamom.dll
Vsizujuzesec.dll
names apear random so don't expect them to be the same on your system I just used date-time stamps to find all process added around the same time as the program
sorry if this is a little unorganized I am writing it as I go...
So now I am using process explorer to find out what the deal is with those dlls and how to kill everything using them.
I also did a search in the registry and under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
I find 3 entries to delete, the first two appear to start the DLLs and the last seems to make defender hide. So I am deleting those names for referance are
Xriwiwoniqi
Wfarawumifora
Windows Defender
Once again all appear to be random names and actually I just removed the hide flag to defender instead of deleting it
This appears to do it lets restart and see
Monday, January 5, 2009
Happy New Year Everyone!
Well today is a big day here in the capital city, our Buckeyes take on the Texas Longhorns. Hopefully this is a good game and OSU wins but we will see.
Also I saw a troubling article about how Microsoft plans to lay off 17% of their workforce. I am not sure if this is a sign of the economic times, or Microsoft's failed Vista Operating System, but we will see.
Personally the more I work with Linux and Mac I see the only way to save Windows is to reimagine it using a Unix/GNU instead of Win32 kernel.
Hope you All have a great 2009!
Article
Also I saw a troubling article about how Microsoft plans to lay off 17% of their workforce. I am not sure if this is a sign of the economic times, or Microsoft's failed Vista Operating System, but we will see.
Personally the more I work with Linux and Mac I see the only way to save Windows is to reimagine it using a Unix/GNU instead of Win32 kernel.
Hope you All have a great 2009!
Article
Thursday, December 18, 2008
Need some more shows!
Here is my list for the next month and I am already finding some great acts! Let me know if you are going or have any other good shows in the Ohio, Michigan, and Illinois area let me know
21 Janurary Cursive Columbus, OH
30 Janurary Jeff Tweedy Solo Friday ANN ARBOR, MI
11 February Los Campesinos Columbus, Oh
21 Janurary Cursive Columbus, OH
30 Janurary Jeff Tweedy Solo Friday ANN ARBOR, MI
11 February Los Campesinos Columbus, Oh
Thursday, December 11, 2008
Retrieving XML declaration Information Using SAX
So the other day I was notified that for a project that uses SAX I would need to maintain Encoding information it the XML Declaration. This seemed pretty straight forward, however, it really wasn't and in fact I am not sure why one or two things are done. So to try to save others the hassle here is how I did it...
Just so you know I am doing this with the org.xml.sax.helpers.XMLReaderFactory and XmlReader so if you are using a different parser this may be a little different.
First off if you are like me you were calling the XmlReader.parse method and passing it an input location. This will not work because it overrides the encoding with whatever the InputLocation's encoding. This means we have to go ahead and use the other override which takes a string in the form of a URI.
If you are like me you think EASY! and pass it the file path, this will not work you need to require a Java.net uri in the following way
String uri = new File(*filepath*).toURI().toString()
Now we have a proper uri and we are ready to parse just like normal. After it starts though we need to find a way to get the information about the declaration we do this by capturing the Locater. A Locater, according to Sun, is an "Interface for associating a SAX event with a document location." So the document's properties are essentially stored there. Here is how you get it, this is in the handler class...
Locator locator
...
public void setDocumentLocator(Locator locator){
this.locator = locator
}
And of course just to add a little wrinkle to things retrieving the encoding and XML version were Only added in SAX v2.0 and we can't access the information till we are inside the document. So we need to add the following to the handler class...
Integer elementDepth = 0
...
public void startElement(String uri, String name,
String qName, Attributes atts) {
if (elementDepth++ == 0) {
if (locator != null) {
if (locator instanceof Locator2) {
Locator2 loc = (Locator2) locator;
println loc.getXMLVersion();
println loc.getEncoding();
}
}
}
...
}
And as you can see now you are able to access the encoding and version information!!!!!
Feel free to comment if this helped you or if you know of a better way to do this!
Just so you know I am doing this with the org.xml.sax.helpers.XMLReaderFactory and XmlReader so if you are using a different parser this may be a little different.
First off if you are like me you were calling the XmlReader.parse method and passing it an input location. This will not work because it overrides the encoding with whatever the InputLocation's encoding. This means we have to go ahead and use the other override which takes a string in the form of a URI.
If you are like me you think EASY! and pass it the file path, this will not work you need to require a Java.net uri in the following way
String uri = new File(*filepath*).toURI().toString()
Now we have a proper uri and we are ready to parse just like normal. After it starts though we need to find a way to get the information about the declaration we do this by capturing the Locater. A Locater, according to Sun, is an "Interface for associating a SAX event with a document location." So the document's properties are essentially stored there. Here is how you get it, this is in the handler class...
Locator locator
...
public void setDocumentLocator(Locator locator){
this.locator = locator
}
And of course just to add a little wrinkle to things retrieving the encoding and XML version were Only added in SAX v2.0 and we can't access the information till we are inside the document. So we need to add the following to the handler class...
Integer elementDepth = 0
...
public void startElement(String uri, String name,
String qName, Attributes atts) {
if (elementDepth++ == 0) {
if (locator != null) {
if (locator instanceof Locator2) {
Locator2 loc = (Locator2) locator;
println loc.getXMLVersion();
println loc.getEncoding();
}
}
}
...
}
And as you can see now you are able to access the encoding and version information!!!!!
Feel free to comment if this helped you or if you know of a better way to do this!
Subscribe to:
Posts (Atom)