use of org.apache.catalina.deploy.MessageDestinationRef in project tomcat70 by apache.
the class WebAnnotationSet method addResource.
protected static void addResource(Context context, Resource annotation, String defaultName, Class<?> defaultType) {
String name = getName(annotation, defaultName);
String type = getType(annotation, defaultType);
if (type.equals("java.lang.String") || type.equals("java.lang.Character") || type.equals("java.lang.Integer") || type.equals("java.lang.Boolean") || type.equals("java.lang.Double") || type.equals("java.lang.Byte") || type.equals("java.lang.Short") || type.equals("java.lang.Long") || type.equals("java.lang.Float")) {
// env-ref element
ContextEnvironment resource = new ContextEnvironment();
resource.setName(name);
resource.setType(type);
resource.setDescription(annotation.description());
resource.setValue(annotation.mappedName());
resource.setLookupName(annotation.lookup());
context.getNamingResources().addEnvironment(resource);
} else if (type.equals("javax.xml.rpc.Service")) {
// service-ref element
ContextService service = new ContextService();
service.setName(name);
service.setWsdlfile(annotation.mappedName());
service.setType(type);
service.setDescription(annotation.description());
service.setLookupName(annotation.lookup());
context.getNamingResources().addService(service);
} else if (type.equals("javax.sql.DataSource") || type.equals("javax.jms.ConnectionFactory") || type.equals("javax.jms.QueueConnectionFactory") || type.equals("javax.jms.TopicConnectionFactory") || type.equals("javax.mail.Session") || type.equals("java.net.URL") || type.equals("javax.resource.cci.ConnectionFactory") || type.equals("org.omg.CORBA_2_3.ORB") || type.endsWith("ConnectionFactory")) {
// resource-ref element
ContextResource resource = new ContextResource();
resource.setName(name);
resource.setType(type);
if (annotation.authenticationType() == Resource.AuthenticationType.CONTAINER) {
resource.setAuth("Container");
} else if (annotation.authenticationType() == Resource.AuthenticationType.APPLICATION) {
resource.setAuth("Application");
}
resource.setScope(annotation.shareable() ? "Shareable" : "Unshareable");
resource.setProperty("mappedName", annotation.mappedName());
resource.setDescription(annotation.description());
resource.setLookupName(annotation.lookup());
context.getNamingResources().addResource(resource);
} else if (type.equals("javax.jms.Queue") || type.equals("javax.jms.Topic")) {
// message-destination-ref
MessageDestinationRef resource = new MessageDestinationRef();
resource.setName(name);
resource.setType(type);
resource.setUsage(annotation.mappedName());
resource.setDescription(annotation.description());
resource.setLookupName(annotation.lookup());
context.getNamingResources().addMessageDestinationRef(resource);
} else {
/*
* General case. Also used for:
* - javax.resource.cci.InteractionSpec
* - javax.transaction.UserTransaction
*/
// resource-env-ref
ContextResourceEnvRef resource = new ContextResourceEnvRef();
resource.setName(name);
resource.setType(type);
resource.setProperty("mappedName", annotation.mappedName());
resource.setDescription(annotation.description());
resource.setLookupName(annotation.lookup());
context.getNamingResources().addResourceEnvRef(resource);
}
}
Aggregations