use of com.sun.enterprise.deployment.annotation.context.RarBundleContext in project Payara by payara.
the class AuthenticationMechanismHandler method processAnnotation.
public HandlerProcessingResult processAnnotation(AnnotationInfo element) throws AnnotationProcessorException {
AnnotatedElementHandler aeHandler = element.getProcessingContext().getHandler();
AuthenticationMechanism authMechanism = (AuthenticationMechanism) element.getAnnotation();
if (aeHandler instanceof RarBundleContext) {
boolean isConnectionDefinition = hasConnectorAnnotation(element);
if (isConnectionDefinition) {
RarBundleContext rarContext = (RarBundleContext) aeHandler;
ConnectorDescriptor desc = rarContext.getDescriptor();
if (!desc.getOutBoundDefined()) {
OutboundResourceAdapter ora = new OutboundResourceAdapter();
desc.setOutboundResourceAdapter(ora);
}
OutboundResourceAdapter ora = desc.getOutboundResourceAdapter();
String[] description = authMechanism.description();
int authMechanismValue = getAuthMechVal(authMechanism.authMechanism());
AuthenticationMechanism.CredentialInterface ci = authMechanism.credentialInterface();
String credentialInterface = ora.getCredentialInterfaceName(ci);
// XXX: Siva: For now use the first description
String firstDesc = "";
if (description.length > 0) {
firstDesc = description[0];
}
AuthMechanism auth = new AuthMechanism(firstDesc, authMechanismValue, credentialInterface);
ora.addAuthMechanism(auth);
} else {
getFailureResult(element, "Not a @Connector annotation : @AuthenticationMechanism must " + "be specified along with @Connector annotation", true);
}
} else {
getFailureResult(element, "Not a rar bundle context", true);
}
return getDefaultProcessedResult();
}
use of com.sun.enterprise.deployment.annotation.context.RarBundleContext in project Payara by payara.
the class ConnectionDefinitionHandler method handleAnnotation.
private void handleAnnotation(AnnotatedElementHandler aeHandler, ConnectionDefinition connDefn, AnnotationInfo element) {
RarBundleContext rarContext = (RarBundleContext) aeHandler;
ConnectorDescriptor desc = rarContext.getDescriptor();
Class c = (Class) element.getAnnotatedElement();
String targetClassName = c.getName();
if (ManagedConnectionFactory.class.isAssignableFrom(c)) {
if (!desc.getOutBoundDefined()) {
OutboundResourceAdapter ora = new OutboundResourceAdapter();
desc.setOutboundResourceAdapter(ora);
}
OutboundResourceAdapter ora = desc.getOutboundResourceAdapter();
if (!ora.hasConnectionDefDescriptor(connDefn.connectionFactory().getName())) {
ConnectionDefDescriptor cdd = new ConnectionDefDescriptor();
cdd.setConnectionFactoryImpl(connDefn.connectionFactoryImpl().getName());
cdd.setConnectionFactoryIntf(connDefn.connectionFactory().getName());
cdd.setConnectionIntf(connDefn.connection().getName());
cdd.setConnectionImpl(connDefn.connectionImpl().getName());
cdd.setManagedConnectionFactoryImpl(targetClassName);
ora.addConnectionDefDescriptor(cdd);
}
// else {
// ignore the duplicates
// duplicates can be via :
// (i) connection-definition defined in DD
// (ii) as part of this particular annotation processing,
// already this connection-definition is defined
// TODO V3 how to handle (ii)
// }
} else {
getFailureResult(element, "Cant handle ConnectionDefinition annotation as the annotated class does not" + "implement ManagedConnectionFactory", true);
}
}
Aggregations