My understanding of the question:
Is there a way to execute the method of a class after the deployment
of my EAR?
is that you want to have a means of executing a method right or soon after an admin deploys an application regardless of its type and contents. My understanding of your needs is that you want it to work for cases when your application is only installed and has not been started yet which excludes the Java EE API like servlets with -1, ServletContextListeners or Startup Beans. If that's correct, read on.
I think you may want to use JMX as a means of administering WebSphere Application Server from your custom clients.
According to Developing an administrative client program:
4 Register for events.
In addition to managing resources, the JMX API also supports
application monitoring for specific administrative events. Certain
events produce notifications, for example, when a server starts.
Administrative applications can register as listeners for these
notifications. The WebSphere Application Server provides a full
implementation of the JMX notification model, and provides additional
function so you can receive notifications in a distributed
environment. For a complete list of the notifications emitted from
product MBeans, refer to the
com.ibm.websphere.management.NotificationConstants class in the MBean
API documentation.
I think that it merits attention and in fact answers the question.
Looking at the javadoc of com.ibm.websphere.management.NotificationConstants you may find the TYPE_APPMANAGEMENT_INSTALL constant which is
Notification type for application installation events
While I haven't tried it out myself yet, I think the WebSphere MBeans and JMX Notification is the way to go.