/** * tomcat uses a hastable to store entry type, null values are not allowed * <p/> * These occur when the reference is declared using a 'lookup' attribute These do not have a type associated * * @param ref */ private void normalize(final ResourceBase ref) { final String name = ref.getName(); if (name.startsWith(JAVA_PREFIX)) { // tomcat adds mbeans and a ":" in a mbean is not very cool for the objectname ref.setName(name.substring(JAVA_PREFIX.length())); } else if (name.startsWith("openejb/Resource/")) { final String id = (String) ref.getProperty(NamingUtil.RESOURCE_ID); if (id != null) { // id can be != substring (else) in case of app resource scope ref.setProperty(NamingUtil.JNDI_NAME, "openejb:Resource/" + id); } else { ref.setProperty(NamingUtil.JNDI_NAME, "openejb:" + name.substring("openejb/".length())); } } if (ref.getType() == null) { ref.setType(""); } }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!super.equals(obj)) { return false; } if (getClass() != obj.getClass()) { return false; } ContextResourceEnvRef other = (ContextResourceEnvRef) obj; if (override != other.override) { return false; } return true; } }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + (override ? 1231 : 1237); return result; }
/** * Gets look up reference from resource if exist. * * @param resourceBase resource base object * @return lookup ref */ private LookupRef lookForLookupRef(ResourceBase resourceBase) { String lookupName = resourceBase.getLookupName(); if ((lookupName != null && !lookupName.equals(""))) { return new LookupRef(resourceBase.getType(), lookupName); } return null; } }
private void bindResource(final ResourceBase res) { try { final Context globalNamingContext = standardServer.getGlobalNamingContext(); final Object value = globalNamingContext.lookup(res.getName()); final String type = res.getType(); bindResource(res.getName(), value, type); } catch (final NamingException e) { logger.error("Unable to lookup Global Tomcat resource " + res.getName(), e); } }
if (resource.getInjectionTargets() == null || resource.getInjectionTargets().size() == 0) { String typeName = resource.getType(); Class<?> typeClass = null; if (typeName != null) { resource.setType(compatibleClass.getCanonicalName()); return true;
private static <T extends ResourceBase> boolean mergeResourceMap( Map<String, T> fragmentResources, Map<String, T> mainResources, Map<String, T> tempResources, WebXml fragment) { for (T resource : fragmentResources.values()) { String resourceName = resource.getName(); if (mainResources.containsKey(resourceName)) { mainResources.get(resourceName).getInjectionTargets().addAll( resource.getInjectionTargets()); } else { // Not defined in main web.xml T existingResource = tempResources.get(resourceName); if (existingResource != null) { if (!existingResource.equals(resource)) { log.error(sm.getString( "webXml.mergeConflictResource", resourceName, fragment.getName(), fragment.getURL())); return false; } } else { tempResources.put(resourceName, resource); } } } return true; }
final OpenEJBNamingResource nr = (OpenEJBNamingResource) standardContext.getNamingResources(); for (final ResourceBase resource : nr.getTomcatResources()) { final String name = resource.getName(); final boolean isDataSource = DataSource.class.getName().equals(resource.getType()); final boolean isAlreadyCreated = ContextResource.class.isInstance(resource) && ContextResource.class.cast(resource).getSingleton() && isDataSource; newResource = new Resource(name, resource.getType()); final Iterator<String> params = resource.listProperties(); while (params.hasNext()) { final String paramName = params.next(); final String paramValue = (String) resource.getProperty(paramName); newResource = new Resource(name, resource.getType(), "org.apache.tomee:ProvidedByTomcat"); properties.setProperty("factory", (String) resource.getProperty("factory"));
private static Reference createReference(final ResourceBase resource) { final Reference ref; if (resource instanceof ContextResource) { final ContextResource cr = (ContextResource) resource; ref = new ResourceRef(resource.getType(), resource.getDescription(), cr.getScope(), cr.getAuth(), cr.getSingleton()); } else { ref = new ResourceEnvRef(resource.getType()); } final Iterator<String> params = resource.listProperties(); while (params.hasNext()) { final String paramName = params.next(); final String paramValue = (String) resource.getProperty(paramName); final StringRefAddr refAddr = new StringRefAddr(paramName, paramValue); ref.add(refAddr); } return ref; }
/** * Process the body text of this element. * * @param namespace the namespace URI of the matching element, or an * empty string if the parser is not namespace aware or the element has * no namespace * @param name the local name if the parser is namespace aware, or just * the element name otherwise * @param text The body text of this element */ @Override public void body(String namespace, String name, String text) throws Exception { ResourceBase resourceBase = (ResourceBase) digester.peek(); resourceBase.setProperty("mappedName", text.trim()); } }
for (InjectionTarget injectionTarget : resource.getInjectionTargets()) { Class<?> clazz = Introspection.loadClass( context, injectionTarget.getTargetClass());
for (Iterator<String> iter = resource.listProperties(); iter.hasNext();) { String name = iter.next(); Object value = resource.getProperty(name); if (!isPersistable(value.getClass())) { continue;
if (resource.getInjectionTargets() == null || resource.getInjectionTargets().size() == 0) { String typeName = resource.getType(); Class<?> typeClass = null; if (typeName != null) { resource.setType(compatibleClass.getCanonicalName()); return true;
private <T extends ResourceBase> boolean mergeResourceMap( Map<String, T> fragmentResources, Map<String, T> mainResources, Map<String, T> tempResources, WebXml fragment) { for (T resource : fragmentResources.values()) { String resourceName = resource.getName(); if (mainResources.containsKey(resourceName)) { mainResources.get(resourceName).getInjectionTargets().addAll( resource.getInjectionTargets()); } else { // Not defined in main web.xml T existingResource = tempResources.get(resourceName); if (existingResource != null) { if (!existingResource.equals(resource)) { log.error(sm.getString( "webXml.mergeConflictResource", resourceName, fragment.getName(), fragment.getURL())); return false; } } else { tempResources.put(resourceName, resource); } } } return true; }
/** * Gets look up reference from resource if exist. * * @param resourceBase resource base object * @return lookup ref */ private LookupRef lookForLookupRef(ResourceBase resourceBase) { String lookupName = resourceBase.getLookupName(); if ((lookupName != null && !lookupName.equals(""))) { return new LookupRef(resourceBase.getType(), lookupName); } return null; } }
/** * Process the body text of this element. * * @param namespace the namespace URI of the matching element, or an * empty string if the parser is not namespace aware or the element has * no namespace * @param name the local name if the parser is namespace aware, or just * the element name otherwise * @param text The body text of this element */ @Override public void body(String namespace, String name, String text) throws Exception { ResourceBase resourceBase = (ResourceBase) digester.peek(); resourceBase.setProperty("mappedName", text.trim()); } }
for (InjectionTarget injectionTarget : resource.getInjectionTargets()) { Class<?> clazz = Introspection.loadClass( context, injectionTarget.getTargetClass());
if (resource.getInjectionTargets() == null || resource.getInjectionTargets().size() == 0) { String typeName = resource.getType(); Class<?> typeClass = null; if (typeName != null) { resource.setType(compatibleClass.getCanonicalName()); return true;
private <T extends ResourceBase> boolean mergeResourceMap( Map<String, T> fragmentResources, Map<String, T> mainResources, Map<String, T> tempResources, WebXml fragment) { for (T resource : fragmentResources.values()) { String resourceName = resource.getName(); if (mainResources.containsKey(resourceName)) { mainResources.get(resourceName).getInjectionTargets().addAll( resource.getInjectionTargets()); } else { // Not defined in main web.xml T existingResource = tempResources.get(resourceName); if (existingResource != null) { if (!existingResource.equals(resource)) { log.error(sm.getString( "webXml.mergeConflictResource", resourceName, fragment.getName(), fragment.getURL())); return false; } } else { tempResources.put(resourceName, resource); } } } return true; }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + (override ? 1231 : 1237); return result; }