Tuesday, September 4, 2012

Whats the encoding of my file? Compile complaints....

on Linux use... file -bi option
[cpcdev@dpcpca01 cpc]$ file -bi ./src/main/java/com/fedex/ground/dispatch/cpcs/actions/OnCallDetailActionHandler.java
text/x-java; charset=unknown
[cpcdev@dpcpca01 cpc]$ 
Or in Mac OSX
file -I --mime-encoding /prod/PersistanceLayer/src/java/domain/server/toplink/Equipment.java

Class Magic Number And Bytecode compatibility on Linux

Based on the general layout (see item #7)we need the 8th hex number to get the value. And then match the major version number with the JDK version compatibility.
major version number of the class file format being used.
J2SE 7 = 51 (0x33 hex),
J2SE 6.0 = 50 (0x32 hex),
J2SE 5.0 = 49 (0x31 hex),
JDK 1.4 = 48 (0x30 hex),
JDK 1.3 = 47 (0x2F hex),
JDK 1.2 = 46 (0x2E hex),
JDK 1.1 = 45 (0x2D hex).
In this case
[me@hostandre]$ xxd -p  org/apache/xmlbeans/impl/xsd2inst/SampleXmlUtil.class  | head -n 1 | cut -c-16
cafebabe00000030
[me@hostandre]$
The answer is: JDK 1.4 compiled and compatible...

Friday, August 17, 2012

Quick Ref

print AdminConfig.attributes('Application')
List Enterprise Applications
print AdminConfig.list('ApplicationDeployment') - EAR level

List Contents in Enterprise Applications
print AdminConfig.list('WebModuleDeployment') - WAR level

Print the first application name
app=AdminControl.queryNames('type=Application,*').split('\n')[0]
obj=AdminControl.completeObjectName(app) - Getting the object


The following commands are available for the AdminConfig object:

* attributes
* checkin
* convertToCluster
* create
* createClusterMember
* createDocument
* createUsingTemplate
* defaults
* deleteDocument
* existsDocument
* extract
* getCrossDocumentValidationEnabled
* getid
* getObjectName
* getSaveMode
* getValidationLevel
* getValidationSeverityResult
* hasChanges
* help
* installResourceAdapter
* list
* listTemplates
* modify
* parents
* queryChanges
* remove
* required
* reset
* save
* setCrossDocumentValidationEnabled
* setSaveMode
* setValidationLevel
* show
* showall
* showAttribute
* types
* uninstallResourceAdapter
* validate


The following commands are available for the AdminApp object:


* deleteUserAndGroupEntries
* edit
* editInteractive
* export
* exportDDL
* getDeployStatus
* help
* install
* installInteractive
* isAppReady
* list
* listModules
* options
* publishWSDL
* searchJNDIReferences
* taskInfo
* uninstall
* update
* updateAccessIDs
* updateInteractive
* view



The following commands are available for the AdminControl object:

* completeObjectName
* getAttribute
* getAttribute_jmx
* getAttributes
* getAttributes_jmx
* getCell
* getConfigId
* getDefaultDomain
* getDomainName
* getHost
* getMBeanCount
* getMBeanInfo_jmx
* getNode
* #rxml_admincontrol__cmd14
* getPort
* getPropertiesForDataSource (Deprecated)
* getType
* help
* invoke
* invoke_jmx
* isRegistered
* isRegistered_jmx
* makeObjectName
* #rxml_admincontrol__cmd24
* queryNames
* queryNames_jmx
* reconnect
* setAttribute
* setAttribute_jmx
* setAttributes
* setAttributes_jmx
* startServer
* stopServer
* testConnection
* trace

The following AdminTask commands are available but do not belong to a group:

* createServerType
* createTCPEndPoint
* getTCPEndPoint
* help
* listSSLRepertoires
* listTCPEndPoints
* listTCPThreadPools
* updateAppOnCluster

find all the dependencies

usr@host:~/BUILD/foo-bar-root
$ find . -name 'pom.xml' -print -exec perl -ne 'BEGIN {my @k;} if (// ... /<\/plugin>/) { push @k, $_; } else { @k=undef;};  if (@k and grep {/<\/plugin>/} @k and grep {/pmd/} @k ) {print join("",@k);@k=undef}  ' {} \; -print 

Adding XmlRootElement

 
  <plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.7.4</version>
    <executions>
     <execution>
      <id>generate-domain1</id>
      <goals>
       <goal>generate</goal>
      </goals>
      <configuration>
       <strict>true</strict>
       <schemaDirectory>src/main/schema</schemaDirectory>
       <schemaIncludes>
        <value>*.xsd</value>
       </schemaIncludes>
       <bindingIncludes>
        <include>bindings.xjb</include>
       </bindingIncludes>
       <verbose>true</verbose>
       <extension>true</extension>
       <args>
        <arg>-Xannotate</arg>
       </args>
       <generateDirectory>${project.build.directory}/generated-sources/xjc</generateDirectory>
       <plugins>
        <plugin>
         <groupId>org.jvnet.jaxb2_commons</groupId>
         <artifactId>jaxb2-basics</artifactId>
         <version>0.6.0</version>
        </plugin>
        <plugin>
         <groupId>org.jvnet.jaxb2_commons</groupId>
         <artifactId>jaxb2-basics-annotate</artifactId>
         <version>0.6.0</version>
        </plugin>
       </plugins>
      </configuration>
     </execution>
    </executions>
   </plugin>

XJC XmlRootElement and SOAPAction, WebServiceTemplate spring-ws

If you want to create client stubs by means of spring-ws and you do not have the notation of the @Endpoint and @Payload definitions it is sometimes problematic getting the right SOAPAction and XmlRootElement defined.

The first try you can generate with the xjc:simple binding
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
version="2.0" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:annox="http://annox.dev.java.net"
jaxb:extensionBindingPrefixes="xjc annox">
<jaxb:globalBindings>
 <xjc:simple />
</jaxb:globalBindings>
 
<!-- FILE: PickupAudit.xsd --> 

 <jaxb:bindings schemaLocation="PickupAudit.xsd" node="/xs:schema">
   <jaxb:bindings node="xs:complexType[@name='PickupAudit']">
      <annox:annotate>
    <annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement" name="PickupAudit" />
      </annox:annotate>
    </jaxb:bindings>
   <jaxb:bindings node="xs:complexType[@name='PickupAuditType']">
      <annox:annotate>
    <annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement" name="PickupAudit" />
      </annox:annotate>
    </jaxb:bindings>
  </jaxb:bindings>

</jaxb:bindings>


Generating the @XmlRootElement("something")
<plugin>
 <groupId>org.jvnet.jaxb2.maven2</groupId>
 <artifactId>maven-jaxb2-plugin</artifactId>
 <version>0.7.4</version>
 <executions>
  <execution>
   <id>generate-domain1</id>
   <goals>
    <goal>generate</goal>
   </goals>
   <configuration>
    <strict>true</strict>
    <schemaDirectory>src/main/schema</schemaDirectory>
    <schemaIncludes>
     <value>*.xsd</value>
    </schemaIncludes>
    <bindingIncludes>
     <include>bindings.xjb</include>
    </bindingIncludes>
    <verbose>true</verbose>
    <extension>true</extension>
    <args>
     <arg>-Xannotate</arg>
    </args>
    <generateDirectory>${project.build.directory}/generated-sources/xjc</generateDirectory>
    <plugins>
     <plugin>
      <groupId>org.jvnet.jaxb2_commons</groupId>
      <artifactId>jaxb2-basics</artifactId>
      <version>0.6.0</version>
     </plugin>
     <plugin>
      <groupId>org.jvnet.jaxb2_commons</groupId>
      <artifactId>jaxb2-basics-annotate</artifactId>
      <version>0.6.0</version>
     </plugin>
    </plugins>
   </configuration>
  </execution>
 </executions>
</plugin>

Wednesday, August 15, 2012

Zip up my logfiles between 10 and 15 days old from a remote host...

Sledgehammering the logs archiving for perticular days and using zip... Tar always gives me a headache because of the -c vs -u option... why can't it just create the tar... anyway with zip its smoother and "smaller"!!
$ cat list  | xargs -i% -t ssh % 'find ./logs/ -mtime +10 -mtime -15 -exec zip -@ /tmp/my.zip "{}" \; -print '
Where list contains
me@host1
me@host2
me@host3