public Object getObjectInstance(Object object, Name name, Context context, Hashtable environment) throws Exception { Reference ref = (Reference) object; // the jndi context to use for the lookup (usually null which is the default context) String jndiProviderId = getProperty(ref, JNDI_PROVIDER_ID); // the jndi name String jndiName = getProperty(ref, JNDI_NAME); if (jndiName == null) { jndiName = buildJndiName(ref); } // look up the reference Object value = lookup(jndiProviderId, jndiName); return value; }
public Object getObjectInstance(Object object, Name name, Context context, Hashtable environment) throws Exception { // ignore non ejb-refs if (!(object instanceof EjbRef)) { return null; } // lookup the value Object value = super.getObjectInstance(object, name, context, environment); // if this is an external reference, copy it into the local class loader if (isPropertyTrue((Reference) object, EXTERNAL)) { value = copy(value); } // done return value; }
@SuppressWarnings({"unchecked"}) public static<T> T getStaticValue(Reference ref) { return (T) getStaticValue(ref, null); }
public Object getObjectInstance(Object object, Name name, Context context, Hashtable environment) throws Exception { // ignore non resource-refs if (!(object instanceof ResourceRef)) { return null; } Reference ref = (Reference) object; Object value; if (getProperty(ref, JNDI_NAME) != null) { // lookup the value in JNDI value = super.getObjectInstance(object, name, context, environment); } else { // value is hard hard coded in the properties value = getStaticValue(ref); } return value; }
public static void setStaticValue(Resource resource, Object value) { setStaticValue(resource, null, value); }
public Object getObjectInstance(Object object, Name name, Context context, Hashtable environment) throws Exception { Reference reference = ((Reference) object); if (reference.getClassName().equals("java.net.URL")) { String resourceId = getProperty(reference, RESOURCE_ID); return new URL(resourceId); } return super.getObjectInstance(object, name, context, environment); }
public Object getObjectInstance(Object object, Name name, Context context, Hashtable environment) throws Exception { Reference ref = (Reference) object; // load the component type class String className = getProperty(ref, COMPONENT_TYPE); Class<?> clazz = loadClass(className); if (clazz == null) return null; // lookup the value Object value = SystemInstance.get().getComponent(clazz); return value; } }
public static boolean hasAnnotationProcessingSupport(){ switch (get()) { case v40: case v41: case v50: case v55: return false; default: return true; } }
protected String buildJndiName(Reference reference) throws NamingException { // get and verify interface type String resourceId = getProperty(reference, RESOURCE_ID); if (resourceId == null) { resourceId = getProperty(reference, NAME); } if (resourceId == null) throw new NamingException("Resource reference id is null"); // build jndi name using the deploymentId and interface type String jndiName = "java:openejb/Resource/" + resourceId; return jndiName; }
protected Object lookup(String jndiProviderId, String jndiName) throws NamingException { Context externalContext = getContext(jndiProviderId); synchronized (externalContext) { /* According to the JNDI SPI specification multiple threads may not access the same JNDI Context *instance* concurrently. Since we don't know the origines of the federated context we must synchonrize access to it. JNDI SPI Sepecifiation 1.2 Section 2.2 */ return externalContext.lookup(jndiName); } }
protected void postConstruct(Object object) { try { annotationProcessor.postConstruct(object); } catch (Exception e) { throw new IllegalStateException("PostConstruct Failed " + object.getClass(), e); } }
public static void setStaticValue(Resource resource, String name, Object value) { name = name != null ? "-" + name : ""; String token = "" + id.incrementAndGet(); registry.put(token, value); resource.setProperty("static-token" + name, token); }
protected void processAnnotations(Object object) { try { annotationProcessor.processAnnotations(object); } catch (Exception e) { throw new IllegalStateException("Dependency Injection Failed " + object.getClass(), e); } }
protected void preDestroy(Object object) { try { annotationProcessor.preDestroy(object); } catch (Exception e) { throw new IllegalStateException("PreDestroy Failed " + object.getClass(), e); } } }
/** * Returns the directory representing {@link #catalinaHomeDir}/lib for Tomcat 6. For Tomcat 5.x it returns {@link #catalinaHomeDir}/server/lib * @return the directory representing {@link #catalinaHomeDir}/lib */ public File getCatalinaLibDir() { File catalinaHomeDir = getCatalinaHomeDir(); if (catalinaHomeDir == null) return null; if (TomcatVersion.v6.isTheVersion()) { return new File(catalinaHomeDir, "lib"); } else { return new File(new File(catalinaHomeDir, "server"), "lib"); } } /**
public Object getObjectInstance(Object object, Name name, Context context, Hashtable environment) throws Exception { // ignore non resource-refs if (!(object instanceof ResourceRef)) { return null; } Reference ref = (Reference) object; Object value; if (getProperty(ref, JNDI_NAME) != null) { // lookup the value in JNDI value = super.getObjectInstance(object, name, context, environment); } else { // value is hard hard coded in the properties value = getStaticValue(ref); } return value; }
private void setResource(ContextResource resource, String name, Object object) { setStaticValue(new Resource(resource), name, object); }
public boolean isTheVersion() { return get() == this; }
@SuppressWarnings({"unchecked"}) public static <T> T getStaticValue(Reference ref, String name) { name = name != null ? "-" + name : ""; String token = getProperty(ref, "static-token" + name); if (token == null) { return null; } T object = (T) registry.get(token); return object; }
private void setResource(ContextResource resource, Object object) { setStaticValue(new Resource(resource), object); }