use of org.apache.openejb.OpenEJBRuntimeException in project tomee by apache.
the class JaxWsUtils method getName.
public static String getName(final Class<?> clazz) {
final WebService webService = clazz.getAnnotation(WebService.class);
if (webService != null) {
final String sei = webService.endpointInterface();
if (sei != null && sei.trim().length() != 0) {
try {
final Class seiClass = clazz.getClassLoader().loadClass(sei.trim());
return getNameFromInterface(seiClass);
} catch (final ClassNotFoundException e) {
throw new OpenEJBRuntimeException("Unable to load SEI class: " + sei, e);
}
}
return getName(clazz, webService.name());
}
final WebServiceProvider webServiceProvider = clazz.getAnnotation(WebServiceProvider.class);
if (webServiceProvider != null) {
return clazz.getName();
}
throw new IllegalArgumentException("The " + clazz.getName() + " is not annotated");
}
use of org.apache.openejb.OpenEJBRuntimeException in project tomee by apache.
the class EjbTimerServiceImpl method schedule.
/**
* Called from TimerData and start when a timer should be scheduled with the java.util.Timer.
*
* @param timerData the timer to schedule
*/
public void schedule(final TimerData timerData) throws TimerStoreException {
start();
if (scheduler == null) {
throw new TimerStoreException("Scheduler is not configured properly");
}
timerData.setScheduler(scheduler);
final Trigger trigger = timerData.getTrigger();
if (null == trigger) {
try {
if (!scheduler.isShutdown()) {
log.warning("Failed to schedule: " + timerData.getInfo());
}
} catch (final SchedulerException e) {
//Ignore
}
}
final AbstractTrigger<?> atrigger;
if (trigger instanceof AbstractTrigger) {
// is the case
atrigger = (AbstractTrigger<?>) trigger;
atrigger.setJobName(OPENEJB_TIMEOUT_JOB_NAME);
atrigger.setJobGroup(OPENEJB_TIMEOUT_JOB_GROUP_NAME);
} else {
throw new OpenEJBRuntimeException("the trigger was not an AbstractTrigger - Should not be possible: " + trigger);
}
final JobDataMap triggerDataMap = trigger.getJobDataMap();
triggerDataMap.put(EjbTimeoutJob.EJB_TIMERS_SERVICE, this);
triggerDataMap.put(EjbTimeoutJob.TIMER_DATA, timerData);
try {
final TriggerKey triggerKey = new TriggerKey(atrigger.getName(), atrigger.getGroup());
if (!scheduler.checkExists(triggerKey)) {
scheduler.scheduleJob(trigger);
} else if (Trigger.TriggerState.PAUSED.equals(scheduler.getTriggerState(triggerKey))) {
// redeployment
// more consistent in the semantic than a resume but resume would maybe be more relevant here
scheduler.unscheduleJob(triggerKey);
scheduler.scheduleJob(trigger);
}
} catch (final Exception e) {
//TODO Any other actions we could do ?
log.error("Could not schedule timer " + timerData, e);
}
}
use of org.apache.openejb.OpenEJBRuntimeException in project tomee by apache.
the class JndiBuilder method bind.
public void bind(final EjbJarInfo ejbJarInfo, final BeanContext bean, final EnterpriseBeanInfo beanInfo, final JndiNameStrategy strategy) {
// and we shouldn't need it
if (BeanContext.Comp.class.equals(bean.getBeanClass())) {
return;
}
final Bindings bindings = new Bindings();
bean.set(Bindings.class, bindings);
Reference simpleNameRef = null;
final Object id = bean.getDeploymentID();
try {
if (bean.isLocalbean()) {
final Class beanClass = bean.getBeanClass();
final BeanContext.BusinessLocalBeanHome home = bean.getBusinessLocalBeanHome();
final BusinessLocalBeanReference ref = new BusinessLocalBeanReference(home);
optionalBind(bindings, ref, "openejb/Deployment/" + format(id, beanClass.getName(), InterfaceType.LOCALBEAN));
// if the user inject the EJB using a parent class
if (!bean.getBeanClass().isInterface()) {
for (Class<?> clazz = bean.getBeanClass().getSuperclass(); !clazz.equals(Object.class); clazz = clazz.getSuperclass()) {
optionalBind(bindings, ref, "openejb/Deployment/" + format(id, clazz.getName(), InterfaceType.LOCALBEAN));
}
}
final String internalName = "openejb/Deployment/" + format(id, beanClass.getName(), InterfaceType.BUSINESS_LOCALBEAN_HOME);
bind(internalName, ref, bindings, beanInfo, beanClass);
final String name = strategy.getName(beanClass, DEFAULT_NAME_KEY, JndiNameStrategy.Interface.LOCALBEAN);
bind("openejb/local/" + name, ref, bindings, beanInfo, beanClass);
bindJava(bean, beanClass, ref, bindings, beanInfo);
if (USE_OLD_JNDI_NAMES) {
bean.getModuleContext().getAppContext().getBindings().put(name, ref);
}
simpleNameRef = ref;
}
} catch (final NamingException e) {
throw new OpenEJBRuntimeException("Unable to bind business remote deployment in jndi.", e);
}
try {
for (final Class interfce : bean.getBusinessLocalInterfaces()) {
final BeanContext.BusinessLocalHome home = bean.getBusinessLocalHome(interfce);
final BusinessLocalReference ref = new BusinessLocalReference(home);
optionalBind(bindings, ref, "openejb/Deployment/" + format(id, interfce.getName()));
final String internalName = "openejb/Deployment/" + format(id, interfce.getName(), InterfaceType.BUSINESS_LOCAL);
bind(internalName, ref, bindings, beanInfo, interfce);
final String name = strategy.getName(interfce, DEFAULT_NAME_KEY, JndiNameStrategy.Interface.BUSINESS_LOCAL);
final String externalName = "openejb/local/" + name;
bind(externalName, ref, bindings, beanInfo, interfce);
bindJava(bean, interfce, ref, bindings, beanInfo);
if (USE_OLD_JNDI_NAMES) {
bean.getModuleContext().getAppContext().getBindings().put(name, ref);
}
if (simpleNameRef == null) {
simpleNameRef = ref;
}
}
} catch (final NamingException e) {
throw new OpenEJBRuntimeException("Unable to bind business local interface for deployment " + id, e);
}
try {
for (final Class interfce : bean.getBusinessRemoteInterfaces()) {
final BeanContext.BusinessRemoteHome home = bean.getBusinessRemoteHome(interfce);
final BusinessRemoteReference ref = new BusinessRemoteReference(home);
optionalBind(bindings, ref, "openejb/Deployment/" + format(id, interfce.getName(), null));
final String internalName = "openejb/Deployment/" + format(id, interfce.getName(), InterfaceType.BUSINESS_REMOTE);
bind(internalName, ref, bindings, beanInfo, interfce);
final String name = strategy.getName(interfce, DEFAULT_NAME_KEY, JndiNameStrategy.Interface.BUSINESS_REMOTE);
bind("openejb/local/" + name, ref, bindings, beanInfo, interfce);
bind("openejb/remote/" + name, ref, bindings, beanInfo, interfce);
bind("openejb/remote/" + computeGlobalName(bean, interfce), ref, bindings, beanInfo, interfce);
bindJava(bean, interfce, ref, bindings, beanInfo);
if (USE_OLD_JNDI_NAMES) {
bean.getModuleContext().getAppContext().getBindings().put(name, ref);
}
if (simpleNameRef == null) {
simpleNameRef = ref;
}
}
} catch (final NamingException e) {
throw new OpenEJBRuntimeException("Unable to bind business remote deployment in jndi.", e);
}
try {
final Class localHomeInterface = bean.getLocalHomeInterface();
if (localHomeInterface != null) {
final ObjectReference ref = new ObjectReference(bean.getEJBLocalHome());
String name = strategy.getName(bean.getLocalHomeInterface(), DEFAULT_NAME_KEY, JndiNameStrategy.Interface.LOCAL_HOME);
bind("openejb/local/" + name, ref, bindings, beanInfo, localHomeInterface);
optionalBind(bindings, ref, "openejb/Deployment/" + format(id, localHomeInterface.getName(), InterfaceType.EJB_LOCAL_HOME));
name = "openejb/Deployment/" + format(id, bean.getLocalInterface().getName());
bind(name, ref, bindings, beanInfo, localHomeInterface);
name = "openejb/Deployment/" + format(id, bean.getLocalInterface().getName(), InterfaceType.EJB_LOCAL);
bind(name, ref, bindings, beanInfo, localHomeInterface);
bindJava(bean, localHomeInterface, ref, bindings, beanInfo);
if (simpleNameRef == null) {
simpleNameRef = ref;
}
}
} catch (final NamingException e) {
throw new OpenEJBRuntimeException("Unable to bind local home interface for deployment " + id, e);
}
try {
final Class homeInterface = bean.getHomeInterface();
if (homeInterface != null) {
final ObjectReference ref = new ObjectReference(bean.getEJBHome());
String name = strategy.getName(homeInterface, DEFAULT_NAME_KEY, JndiNameStrategy.Interface.REMOTE_HOME);
bind("openejb/local/" + name, ref, bindings, beanInfo, homeInterface);
bind("openejb/remote/" + name, ref, bindings, beanInfo, homeInterface);
optionalBind(bindings, ref, "openejb/Deployment/" + format(id, homeInterface.getName(), InterfaceType.EJB_HOME));
name = "openejb/Deployment/" + format(id, bean.getRemoteInterface().getName());
bind(name, ref, bindings, beanInfo, homeInterface);
name = "openejb/Deployment/" + format(id, bean.getRemoteInterface().getName(), InterfaceType.EJB_OBJECT);
bind(name, ref, bindings, beanInfo, homeInterface);
bindJava(bean, homeInterface, ref, bindings, beanInfo);
if (simpleNameRef == null) {
simpleNameRef = ref;
}
}
} catch (final NamingException e) {
throw new OpenEJBRuntimeException("Unable to bind remote home interface for deployment " + id, e);
}
try {
if (simpleNameRef != null) {
bindJava(bean, null, simpleNameRef, bindings, beanInfo);
}
} catch (final NamingException e) {
throw new OpenEJBRuntimeException("Unable to bind simple java:global name in jndi", e);
}
try {
if (MessageListener.class.equals(bean.getMdbInterface())) {
final String destinationId = bean.getDestinationId();
final String jndiName = "openejb/Resource/" + destinationId;
final Reference reference = new IntraVmJndiReference(jndiName);
final String deploymentId = id.toString();
bind("openejb/local/" + deploymentId, reference, bindings, beanInfo, MessageListener.class);
bind("openejb/remote/" + deploymentId, reference, bindings, beanInfo, MessageListener.class);
}
} catch (final NamingException e) {
throw new OpenEJBRuntimeException("Unable to bind mdb destination in jndi.", e);
} catch (final NoClassDefFoundError ncdfe) {
// no-op: no jms API
}
}
use of org.apache.openejb.OpenEJBRuntimeException in project tomee by apache.
the class Assembler method deployMBean.
@SuppressWarnings("unchecked")
private void deployMBean(final WebBeansContext wc, final ClassLoader cl, final String mbeanClass, final Properties appMbeans, final String id) {
if (LocalMBeanServer.isJMXActive()) {
final Class<?> clazz;
try {
clazz = cl.loadClass(mbeanClass);
} catch (final ClassNotFoundException e) {
throw new OpenEJBRuntimeException(e);
}
// cdi can be off so init with null bean in this case
final Bean<?> bean;
final BeanManager bm;
if (wc == null) {
bm = null;
bean = null;
} else {
bm = wc.getBeanManagerImpl();
final Set<Bean<?>> beans = bm.getBeans(clazz);
bean = bm.resolve(beans);
}
// create the MBean instance with cdi if possible or manually otherwise
final Object instance;
final CreationalContext creationalContext;
if (bean == null) {
try {
instance = clazz.newInstance();
} catch (final InstantiationException e) {
logger.error("the mbean " + mbeanClass + " can't be registered because it can't be instantiated", e);
return;
} catch (final IllegalAccessException e) {
logger.error("the mbean " + mbeanClass + " can't be registered because it can't be accessed", e);
return;
}
creationalContext = null;
} else {
creationalContext = bm.createCreationalContext(bean);
instance = bm.getReference(bean, clazz, creationalContext);
}
final MBeanServer server = LocalMBeanServer.get();
try {
final MBean annotation = clazz.getAnnotation(MBean.class);
final ObjectName leaf = annotation == null || annotation.objectName().isEmpty() ? new ObjectNameBuilder("openejb.user.mbeans").set("application", id).set("group", clazz.getPackage().getName()).set("name", clazz.getSimpleName()).build() : new ObjectName(annotation.objectName());
server.registerMBean(new DynamicMBeanWrapper(wc, instance), leaf);
appMbeans.put(mbeanClass, leaf.getCanonicalName());
if (creationalContext != null && (bean.getScope() == null || Dependent.class.equals(bean.getScope()))) {
creationalContextForAppMbeans.put(leaf, creationalContext);
}
logger.info("Deployed MBean(" + leaf.getCanonicalName() + ")");
} catch (final Exception e) {
logger.error("the mbean " + mbeanClass + " can't be registered", e);
}
}
}
use of org.apache.openejb.OpenEJBRuntimeException in project tomee by apache.
the class Assembler method doCreateResource.
private Object doCreateResource(final Collection<ServiceInfo> infos, final ResourceInfo serviceInfo) throws OpenEJBException {
// do it early otherwise we can loose it
final String skipPropertiesFallback = (String) serviceInfo.properties.remove("SkipPropertiesFallback");
final ObjectRecipe serviceRecipe = createRecipe(infos, serviceInfo);
final boolean properties = PropertiesFactory.class.getName().equals(serviceInfo.className);
if ("false".equalsIgnoreCase(serviceInfo.properties.getProperty("SkipImplicitAttributes", "false")) && !properties) {
serviceRecipe.setProperty("transactionManager", transactionManager);
serviceRecipe.setProperty("ServiceId", serviceInfo.id);
}
serviceInfo.properties.remove("SkipImplicitAttributes");
// if custom instance allow to skip properties fallback to avoid to set unexpectedly it - connectionProps of DBs
final AtomicReference<Properties> injectedProperties = new AtomicReference<>();
if (!"true".equalsIgnoreCase(skipPropertiesFallback)) {
serviceRecipe.setProperty("properties", new UnsetPropertiesRecipe() {
@Override
protected Object internalCreate(final Type expectedType, final boolean lazyRefAllowed) throws ConstructionException {
final Map<String, Object> original = serviceRecipe.getUnsetProperties();
final Properties properties = new SuperProperties() {
@Override
public Object remove(final Object key) {
// avoid to log them then
original.remove(key);
return super.remove(key);
}
}.caseInsensitive(// keep our nice case insensitive feature
true);
for (final Map.Entry<String, Object> entry : original.entrySet()) {
properties.put(entry.getKey(), entry.getValue());
}
injectedProperties.set(properties);
return properties;
}
});
} else {
// this is not the best fallback we have but since it is super limited it is acceptable
final Map<String, Object> unsetProperties = serviceRecipe.getUnsetProperties();
injectedProperties.set(new Properties() {
@Override
public String getProperty(final String key) {
final Object obj = unsetProperties.get(key);
return String.class.isInstance(obj) ? String.valueOf(obj) : null;
}
@Override
public Set<String> stringPropertyNames() {
return unsetProperties.keySet();
}
@Override
public Set<Object> keySet() {
//noinspection unchecked
return Set.class.cast(unsetProperties.keySet());
}
@Override
public synchronized boolean containsKey(final Object key) {
return getProperty(String.valueOf(key)) != null;
}
});
}
if (serviceInfo.types.contains("DataSource") || serviceInfo.types.contains(DataSource.class.getName())) {
final Properties props = PropertyPlaceHolderHelper.simpleHolds(serviceInfo.properties);
if (serviceInfo.properties.containsKey("Definition")) {
final Object encoding = serviceInfo.properties.remove("DefinitionEncoding");
try {
// we catch classcast etc..., if it fails it is not important
final InputStream is = new ByteArrayInputStream(serviceInfo.properties.getProperty("Definition").getBytes(encoding != null ? encoding.toString() : "ISO-8859-1"));
final Properties p = new SuperProperties();
IO.readProperties(is, p);
for (final Entry<Object, Object> entry : p.entrySet()) {
final String key = entry.getKey().toString();
if (!props.containsKey(key) && !(key.equalsIgnoreCase("url") && props.containsKey("JdbcUrl"))) {
// with @DataSource we can get both, see org.apache.openejb.config.ConvertDataSourceDefinitions.rawDefinition()
props.put(key, entry.getValue());
}
}
} catch (final Exception e) {
// ignored
}
}
serviceRecipe.setProperty("Definition", PropertiesHelper.propertiesToString(props));
}
// else: any other kind of resource relying on it? shouldnt be
replaceResourceAdapterProperty(serviceRecipe);
ClassLoader loader = Thread.currentThread().getContextClassLoader();
boolean customLoader = false;
try {
if (serviceInfo.classpath != null && serviceInfo.classpath.length > 0) {
final URL[] urls = new URL[serviceInfo.classpath.length];
for (int i = 0; i < serviceInfo.classpath.length; i++) {
urls[i] = serviceInfo.classpath[i].toURL();
}
loader = new URLClassLoaderFirst(urls, loader);
customLoader = true;
serviceRecipe.setProperty("OpenEJBResourceClasspath", "true");
}
} catch (final MalformedURLException e) {
throw new OpenEJBException("Unable to create a classloader for " + serviceInfo.id, e);
}
if (!customLoader && serviceInfo.classpathAPI != null) {
throw new IllegalArgumentException("custom-api provided but not classpath used for " + serviceInfo.id);
}
Object service = serviceRecipe.create(loader);
if (customLoader) {
final Collection<Class<?>> apis;
if (serviceInfo.classpathAPI == null) {
apis = new ArrayList<Class<?>>(Arrays.asList(service.getClass().getInterfaces()));
} else {
final String[] split = serviceInfo.classpathAPI.split(" *, *");
apis = new ArrayList<>(split.length);
final ClassLoader apiLoader = Thread.currentThread().getContextClassLoader();
for (final String fqn : split) {
try {
apis.add(apiLoader.loadClass(fqn));
} catch (final ClassNotFoundException e) {
throw new IllegalArgumentException(fqn + " not usable as API for " + serviceInfo.id, e);
}
}
}
if (apis.size() - (apis.contains(Serializable.class) ? 1 : 0) - (apis.contains(Externalizable.class) ? 1 : 0) > 0) {
service = Proxy.newProxyInstance(loader, apis.toArray(new Class<?>[apis.size()]), new ClassLoaderAwareHandler(null, service, loader));
}
// else proxy would be useless
}
serviceInfo.unsetProperties = injectedProperties.get();
// Java Connector spec ResourceAdapters and ManagedConnectionFactories need special activation
if (service instanceof ResourceAdapter) {
final ResourceAdapter resourceAdapter = (ResourceAdapter) service;
// Create a thead pool for work manager
final int threadPoolSize = getIntProperty(serviceInfo.properties, "threadPoolSize", 30);
final Executor threadPool;
if (threadPoolSize <= 0) {
logger.warning("Thread pool for '" + serviceInfo.id + "' is (unbounded), consider setting a size using: " + serviceInfo.id + ".QueueSize=[size]");
threadPool = Executors.newCachedThreadPool(new DaemonThreadFactory(serviceInfo.id + "-worker-"));
} else {
threadPool = new ExecutorBuilder().size(threadPoolSize).prefix(serviceInfo.id).threadFactory(new DaemonThreadFactory(serviceInfo.id + "-worker-")).build(new Options(serviceInfo.properties, SystemInstance.get().getOptions()));
logger.info("Thread pool size for '" + serviceInfo.id + "' is (" + threadPoolSize + ")");
}
// WorkManager: the resource adapter can use this to dispatch messages or perform tasks
final WorkManager workManager;
if (GeronimoTransactionManager.class.isInstance(transactionManager)) {
final GeronimoTransactionManager geronimoTransactionManager = (GeronimoTransactionManager) transactionManager;
final TransactionContextHandler txWorkContextHandler = new TransactionContextHandler(geronimoTransactionManager);
// use id as default realm name if realm is not specified in service properties
final String securityRealmName = getStringProperty(serviceInfo.properties, "realm", serviceInfo.id);
final SecurityContextHandler securityContextHandler = new SecurityContextHandler(securityRealmName);
final HintsContextHandler hintsContextHandler = new HintsContextHandler();
final Collection<WorkContextHandler> workContextHandlers = new ArrayList<WorkContextHandler>();
workContextHandlers.add(txWorkContextHandler);
workContextHandlers.add(securityContextHandler);
workContextHandlers.add(hintsContextHandler);
workManager = new GeronimoWorkManager(threadPool, threadPool, threadPool, workContextHandlers);
} else {
workManager = new SimpleWorkManager(threadPool);
}
// BootstrapContext: wraps the WorkMananger and XATerminator
final BootstrapContext bootstrapContext;
if (transactionManager instanceof GeronimoTransactionManager) {
bootstrapContext = new GeronimoBootstrapContext(GeronimoWorkManager.class.cast(workManager), (GeronimoTransactionManager) transactionManager, (GeronimoTransactionManager) transactionManager);
} else if (transactionManager instanceof XATerminator) {
bootstrapContext = new SimpleBootstrapContext(workManager, (XATerminator) transactionManager);
} else {
bootstrapContext = new SimpleBootstrapContext(workManager);
}
// start the resource adapter
try {
logger.debug("createResource.startingResourceAdapter", serviceInfo.id, service.getClass().getName());
resourceAdapter.start(bootstrapContext);
} catch (final ResourceAdapterInternalException e) {
throw new OpenEJBException(e);
}
final Map<String, Object> unset = serviceRecipe.getUnsetProperties();
unset.remove("threadPoolSize");
logUnusedProperties(unset, serviceInfo);
service = new ResourceAdapterReference(resourceAdapter, threadPool, OPENEJB_RESOURCE_JNDI_PREFIX + serviceInfo.id);
} else if (service instanceof ManagedConnectionFactory) {
final ManagedConnectionFactory managedConnectionFactory = (ManagedConnectionFactory) service;
// connection manager is constructed via a recipe so we automatically expose all cmf properties
final ObjectRecipe connectionManagerRecipe = new ObjectRecipe(GeronimoConnectionManagerFactory.class, "create");
connectionManagerRecipe.allow(Option.CASE_INSENSITIVE_PROPERTIES);
connectionManagerRecipe.allow(Option.IGNORE_MISSING_PROPERTIES);
connectionManagerRecipe.setAllProperties(serviceInfo.properties);
connectionManagerRecipe.setProperty("name", serviceInfo.id);
connectionManagerRecipe.setProperty("mcf", managedConnectionFactory);
// standard properties
connectionManagerRecipe.setProperty("transactionManager", transactionManager);
ClassLoader classLoader = loader;
if (classLoader == null) {
classLoader = getClass().getClassLoader();
}
if (classLoader == null) {
classLoader = ClassLoader.getSystemClassLoader();
}
connectionManagerRecipe.setProperty("classLoader", classLoader);
logger.getChildLogger("service").info("createResource.createConnectionManager", serviceInfo.id, service.getClass().getName());
// create the connection manager
final ConnectionManager connectionManager = (ConnectionManager) connectionManagerRecipe.create();
if (connectionManager == null) {
throw new OpenEJBRuntimeException(messages.format("assembler.invalidConnectionManager", serviceInfo.id));
}
final Map<String, Object> unsetA = serviceRecipe.getUnsetProperties();
final Map<String, Object> unsetB = connectionManagerRecipe.getUnsetProperties();
final Map<String, Object> unset = new HashMap<String, Object>();
for (final Entry<String, Object> entry : unsetA.entrySet()) {
if (unsetB.containsKey(entry.getKey())) {
unset.put(entry.getKey(), entry.getValue());
}
}
// service becomes a ConnectorReference which merges connection manager and mcf
service = new ConnectorReference(connectionManager, managedConnectionFactory);
// init cm if needed
final Object eagerInit = unset.remove("eagerInit");
if (eagerInit != null && eagerInit instanceof String && "true".equalsIgnoreCase((String) eagerInit) && connectionManager instanceof AbstractConnectionManager) {
try {
((AbstractConnectionManager) connectionManager).doStart();
try {
final Object cf = managedConnectionFactory.createConnectionFactory(connectionManager);
if (cf instanceof ConnectionFactory) {
final Connection connection = ((ConnectionFactory) cf).getConnection();
connection.getMetaData();
connection.close();
}
} catch (final Exception e) {
// no-op: just to force eager init of pool
}
} catch (final Exception e) {
logger.warning("Can't start connection manager", e);
}
}
logUnusedProperties(unset, serviceInfo);
} else if (service instanceof DataSource) {
ClassLoader classLoader = loader;
if (classLoader == null) {
classLoader = getClass().getClassLoader();
}
final ImportSql importer = new ImportSql(classLoader, serviceInfo.id, (DataSource) service);
if (importer.hasSomethingToImport()) {
importer.doImport();
}
final ObjectRecipe recipe = DataSourceFactory.forgetRecipe(service, serviceRecipe);
if (recipe != serviceRecipe || !serviceInfo.properties.containsKey("XaDataSource")) {
logUnusedProperties(recipe, serviceInfo);
}
// else logged on xadatasource itself
final Properties prop = serviceInfo.properties;
String url = prop.getProperty("JdbcUrl", prop.getProperty("url"));
if (url == null) {
url = prop.getProperty("jdbcUrl");
}
if (url == null) {
logger.debug("Unable to find url for " + serviceInfo.id + " will not monitor it");
} else {
final String host = extractHost(url);
if (host != null) {
remoteResourceMonitor.addHost(host);
remoteResourceMonitor.registerIfNot();
}
}
} else if (!Properties.class.isInstance(service)) {
if (serviceInfo.unsetProperties == null || isTemplatizedResource(serviceInfo)) {
logUnusedProperties(serviceRecipe, serviceInfo);
}
// else wait post construct
}
final ResourceCreated event = new ResourceCreated(service, serviceInfo.id);
SystemInstance.get().fireEvent(event);
return event.getReplacement() == null ? service : event.getReplacement();
}
Aggregations