25 Nisan 2022 Pazartesi

Jakarta EE @Connector Anotasyonu

Giriş
Şu satırı dahil ederiz
import javax.resource.spi.Connector;
Jakarta EE ResourceAdapter Arayüzünü tanımlarken pek çok bilgi XML içindedir. XML içindeki tag'lerden bazılarını @Connector Anotasyonu ile koda almak mümkün. 

displayName Alanı
Örnek
src/main/resources/META-INF/ra.xml dosyasında şöyle olsun
<connector ...> 
  <description></description>
  <display-name>MyResourceAdapter</display-name>
  <vendor-name>Java EE Tutorial</vendor-name>
  <eis-type></eis-type>
  <resourceadapter-version></resourceadapter-version>                                  
  <resourceadapter>
  
    <resourceadapter-class>
      com.foo.MyResourceAdapter
     </resourceadapter-class>
	  
      <config-property>
        <config-property-name>input</config-property-name>
	  <config-property-type>java.lang.String</config-property-type>
	  <config-property-value>mystring value</config-property-value>
      </config-property>
		
		
      <inbound-resourceadapter>
        <messageadapter>
          <messagelistener>
	    <messagelistener-type>com.InboundMessageEndpoint</messagelistener-type>
	      <activationspec>
	        <activationspec-class>com.EndpointActivationSpec</activationspec-class>
              </activationspec>
	  </messagelistener>
	</messageadapter>
      </inbound-resourceadapter>
	
  </resourceadapter>
</connector>
connector tag'indeki bazı bilgileri koda almak için şöyle yaparız
@Connector(
  displayName = "MyResourceAdapter",
  vendorName = "Java EE Tutorial",
  version = "7.0"
)
public class TrafficResourceAdapter implements ResourceAdapter, Serializable {
  ...
}
description Alanı
Örnek
Şöyle yaparız
@Connector(description = "Sample Resource Adapter", 
  displayName = "Sample Resource Adapter", 
  eisType = "Sample Resource Adapter", 
  version = "1.0")
public class SlackResourceAdapter implements ResourceAdapter {

  public void start(final BootstrapContext bootstrapContext) 
    throws ResourceAdapterInternalException {
  }

  public void stop() {
  }

  public void endpointActivation(MessageEndpointFactory messageEndpointFactory,
    ActivationSpec activationSpec)
    throws ResourceException {
  }

  public void endpointDeactivation(MessageEndpointFactory messageEndpointFactory,
    ActivationSpec activationSpec) {
  }

  public XAResource[] getXAResources(final ActivationSpec[] activationSpecs)
    throws ResourceException {
      return new XAResource[0];
  }
}

Hiç yorum yok:

Yorum Gönder

Bean Validation @GroupSequence Anotasyonu

Örnek Elimizde şöyle bir kod olsun public class SampleRequest {   @NotNull   LocalDate startDate;   @NotNull   LocalDate endDate;   @AssertT...