Freitag, 24. Februar 2012

Quick ref of managed Beans config in Spring

Within your service


@ManagedResource
(objectName="bean:name=SampleService",
description="Properties Service", log=true)
public class SampleImpl implements ISampleService

      @ManagedAttribute
      public void setName(String name) {
            ...
      }


Within your startup of your weblogic or whatever app container

 
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8088
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false



Startup jconsole and enter the hostname and the port within the "Remote Process" field.

done.


The full address to the remote process is

service:jmx:rmi:///jndi/rmi://SERVERNAME:PORT/jmxrmi



Donnerstag, 9. Februar 2012

Buffered File writing Snip

        byte[] content  = "Content is overrated".getBytes();
        String filename = "C:/temp/hirsch." + lieferung.getFormat();
        BufferedOutputStream bos = null;
        try {
            FileOutputStream fos = new FileOutputStream(new File(filename));
            bos = new BufferedOutputStream(fos);
            bos.write(content);
        } catch (Exception e) {
            LOG.error("Write Exception" , e);
        } finally {
            if (bos != null) {
                try {
                    bos.flush();
                    bos.close();
                } catch (Exception e) {
                    LOG.error("Close or Flush Exception" , e);
                }
            }
        }