User: ejort Date: 02/01/05 04:08:50 Modified: src/main/org/jboss/ejb Container.java ContainerFactory.java StatelessSessionContainer.java Log: Guarded debug logging Revision Changes Path 1.68 +72 -56 jboss/src/main/org/jboss/ejb/Container.java Index: Container.java =================================================================== RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/ejb/Container.java,v retrieving revision 1.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- Container.java 2002/01/04 17:59:57 1.67 +++ Container.java 2002/01/05 12:08:50 1.68 @@ -78,7 +78,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a> * @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>. * @author <a href="[EMAIL PROTECTED]">Bill Burke</a> - * @version $Revision: 1.67 $ + * @version $Revision: 1.68 $ * * <p><b>Revisions:</b> * @@ -546,16 +546,16 @@ public Object invoke(String actionName, Object[] params, String[] signature) throws MBeanException, ReflectionException { - - + + if( params != null && params.length == 1 && (params[0] instanceof Invocation) == false ) throw new MBeanException(new IllegalArgumentException("Expected zero or single Invocation argument")); - + Object value = null; Invocation mi = null; if( params != null && params.length == 1 ) mi = (Invocation) params[0]; - + ClassLoader callerClassLoader = Thread.currentThread().getContextClassLoader(); try { @@ -563,13 +563,13 @@ // Check against home, remote, localHome, local, getHome, getRemote, getLocalHome, getLocal if( actionName.equals("remote") ) { - - if (mi instanceof MarshalledInvocation) - + + if (mi instanceof MarshalledInvocation) + { ((MarshalledInvocation) mi).setMethodMap(marshalledInvocationMapping); - - if (log.isDebugEnabled()) + + if (log.isDebugEnabled()) // FIXME FIXME FIXME FIXME REMOVE WHEN CL ARE INTEGRATED log.debug("METHOD REMOTE INVOKE "+mi.getContainer()+"||"+mi.getMethod().getName()+"||"); @@ -705,10 +705,10 @@ { Thread.currentThread().setContextClassLoader(callerClassLoader); } - + return value; } - + /** * Build the container MBean information on attributes, contstructors, * operations, and notifications. Currently there are no attributes, no @@ -744,17 +744,17 @@ return new MBeanInfo(getClass().getName(), "EJB Container MBean", null, ctorInfo, opInfo, notifyInfo); } - + // End DynamicMBean interface - + // Protected ----------------------------------------------------- - + abstract Interceptor createContainerInterceptor(); - + public abstract void addInterceptor(Interceptor in); - + // Private ------------------------------------------------------- - + /** * This method sets up the naming environment of the bean. * We create the java:comp/env namespace with properties, EJB-References, @@ -763,15 +763,19 @@ private void setupEnvironment() throws DeploymentException { + boolean debug = log.isDebugEnabled(); try { BeanMetaData beanMetaData = getBeanMetaData(); - log.debug("Begin java:comp/env for EJB: "+beanMetaData.getEjbName()); - log.debug("TCL: "+Thread.currentThread().getContextClassLoader()); + if (debug) + { + log.debug("Begin java:comp/env for EJB: "+beanMetaData.getEjbName()); + log.debug("TCL: "+Thread.currentThread().getContextClassLoader()); + } // Since the BCL is already associated with this thread we can start using the java: namespace directly Context ctx = (Context) new InitialContext().lookup("java:comp"); Context envCtx = ctx.createSubcontext("env"); - + // Bind environment properties { Iterator enum = beanMetaData.getEnvironmentEntries(); @@ -780,7 +784,8 @@ EnvEntryMetaData entry = (EnvEntryMetaData)enum.next(); try { - log.debug("Binding env-entry: "+entry.getName()+" of type: "+entry.getType()+" to value:"+entry.getValue()); + if (debug) + log.debug("Binding env-entry: "+entry.getName()+" of type: "+entry.getType()+" to value:"+entry.getValue()); EnvEntryMetaData.bindEnvEntry(envCtx, entry); } catch(ClassNotFoundException e) @@ -790,25 +795,27 @@ } } } - + // Bind EJB references { Iterator enum = beanMetaData.getEjbReferences(); while(enum.hasNext()) { - + EjbRefMetaData ref = (EjbRefMetaData)enum.next(); - log.debug("Binding an EJBReference "+ref.getName()); - + if (debug) + log.debug("Binding an EJBReference "+ref.getName()); + if (ref.getLink() != null) { // Internal link - log.debug("Binding "+ref.getName()+" to internal JNDI source: "+ref.getLink()); + if (debug) + log.debug("Binding "+ref.getName()+" to internal JNDI source: "+ref.getLink()); Container refContainer = getApplication().getContainer(ref.getLink()); if (refContainer == null) throw new DeploymentException ("Bean "+ref.getLink()+" not found within this application."); bind(envCtx, ref.getName(), new LinkRef(refContainer.getBeanMetaData().getJndiName())); - + // bind(envCtx, ref.getName(), new Reference(ref.getHome(), new StringRefAddr("Container",ref.getLink()), getClass().getName()+".EjbReferenceFactory", null)); // bind(envCtx, ref.getName(), new LinkRef(ref.getLink())); } @@ -819,12 +826,13 @@ { throw new DeploymentException("ejb-ref "+ref.getName()+", expected either ejb-link in ejb-jar.xml or jndi-name in jboss.xml"); } - log.debug("Binding "+ref.getName()+" to external JNDI source: "+ref.getJndiName()); + if (debug) + log.debug("Binding "+ref.getName()+" to external JNDI source: "+ref.getJndiName()); bind(envCtx, ref.getName(), new LinkRef(ref.getJndiName())); } } } - + // Bind Local EJB references { Iterator enum = beanMetaData.getEjbLocalReferences(); @@ -832,25 +840,27 @@ String uniqueKey = Long.toString( (new java.util.Date()).getTime() ); while(enum.hasNext()) { - + EjbLocalRefMetaData ref = (EjbLocalRefMetaData)enum.next(); - log.debug("Binding an EJBLocalReference "+ref.getName()); - + if (debug) + log.debug("Binding an EJBLocalReference "+ref.getName()); + if (ref.getLink() != null) { // Internal link - log.debug("Binding "+ref.getName()+" to bean source: "+ref.getLink()); + if (debug) + log.debug("Binding "+ref.getName()+" to bean source: "+ref.getLink()); if (getApplication().getContainer(ref.getLink()) == null) throw new DeploymentException ("Bean "+ref.getLink()+" not found within this application."); // get local home // bind it into the local namespace - LocalHomeObjectFactory.rebind( uniqueKey + ref.getName(), + LocalHomeObjectFactory.rebind( uniqueKey + ref.getName(), getApplication(), getApplication().getContainer(ref.getLink()) ); StringRefAddr refAddr = new StringRefAddr("nns", uniqueKey+ref.getName() ); Reference jndiRef = new Reference(ref.getLocalHome(), refAddr, LocalHomeObjectFactory.class.getName(), null ); bind(envCtx, ref.getName(), jndiRef ); - + } else { @@ -858,30 +868,30 @@ } } } - + // Bind resource references { Iterator enum = beanMetaData.getResourceReferences(); - + // let's play guess the cast game ;) New metadata should fix this. ApplicationMetaData application = beanMetaData.getApplicationMetaData(); - + while(enum.hasNext()) { ResourceRefMetaData ref = (ResourceRefMetaData)enum.next(); - + String resourceName = ref.getResourceName(); String finalName = application.getResourceByName(resourceName); /* If there was no resource-manager specified then an immeadiate jndi-name or res-url name should have been given */ if (finalName == null) finalName = ref.getJndiName(); - + if (finalName == null) { // the application assembler did not provide a resource manager // if the type is javax.sql.Datasoure use the default one - + if (ref.getType().equals("javax.sql.DataSource")) { // Go through JNDI and look for DataSource - use the first one @@ -893,10 +903,11 @@ finalName = "java:/DefaultDS"; } catch (Exception e) { - log.debug("failed to lookup DefaultDS; ignoring", e); + if (debug) + log.debug("failed to lookup DefaultDS; ignoring", e); } } - + // Default failed? Warn user and move on // POTENTIALLY DANGEROUS: should this be a critical error? if (finalName == null) @@ -905,13 +916,14 @@ continue; } } - + if (ref.getType().equals("java.net.URL")) { // URL bindings try { - log.debug("Binding URL: "+finalName+ " to JDNI ENC as: " +ref.getRefName()); + if (debug) + log.debug("Binding URL: "+finalName+ " to JDNI ENC as: " +ref.getRefName()); bind(envCtx, ref.getRefName(), new URL(finalName)); } catch (MalformedURLException e) { @@ -921,12 +933,13 @@ else { // Resource Manager bindings, should validate the type... - log.debug("Binding resource manager: "+finalName+ " to JDNI ENC as: " +ref.getRefName()); + if (debug) + log.debug("Binding resource manager: "+finalName+ " to JDNI ENC as: " +ref.getRefName()); bind(envCtx, ref.getRefName(), new LinkRef(finalName)); } } } - + // Bind resource env references { Iterator enum = beanMetaData.getResourceEnvReferences(); @@ -936,11 +949,12 @@ String encName = resRef.getRefName(); String jndiName = resRef.getJndiName(); // Should validate the type... - log.debug("Binding env resource: "+jndiName+ " to JDNI ENC as: " +encName); + if (debug) + log.debug("Binding env resource: "+jndiName+ " to JDNI ENC as: " +encName); bind(envCtx, encName, new LinkRef(jndiName)); } } - + /* Create a java:comp/env/security/security-domain link to the container or application security-domain if one exists so that access to the security manager can be made without knowing the global jndi name. @@ -950,12 +964,14 @@ securityDomain = metaData.getApplicationMetaData().getSecurityDomain(); if( securityDomain != null ) { - log.debug("Binding securityDomain: "+securityDomain+ " to JDNI ENC as: security/security-domain"); + if (debug) + log.debug("Binding securityDomain: "+securityDomain+ " to JDNI ENC as: security/security-domain"); bind(envCtx, "security/security-domain", new LinkRef(securityDomain)); bind(envCtx, "security/subject", new LinkRef(securityDomain+"/subject")); } - - log.debug("End java:comp/env for EJB: "+beanMetaData.getEjbName()); + + if (debug) + log.debug("End java:comp/env for EJB: "+beanMetaData.getEjbName()); } catch (NamingException e) { log.error("Could not set up environment", e); @@ -963,8 +979,8 @@ throw new DeploymentException("Could not set up environment", e); } } - - + + /** * Bind a value to a name in a JNDI-context, and create any missing * subcontexts. @@ -972,7 +988,7 @@ * @param ctx * @param name * @param val - * + * * @throws NamingException */ private void bind(Context ctx, String name, Object val) 1.108 +6 -4 jboss/src/main/org/jboss/ejb/ContainerFactory.java Index: ContainerFactory.java =================================================================== RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/ejb/ContainerFactory.java,v retrieving revision 1.107 retrieving revision 1.108 diff -u -r1.107 -r1.108 --- ContainerFactory.java 2002/01/03 04:00:57 1.107 +++ ContainerFactory.java 2002/01/05 12:08:50 1.108 @@ -71,7 +71,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a>. * @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a> * @author <a href="mailto:[EMAIL PROTECTED]">Sacha Labourey</a> -* @version $Revision: 1.107 $ +* @version $Revision: 1.108 $ */ public class ContainerFactory extends ServiceMBeanSupport @@ -977,9 +977,11 @@ logger */ final Logger logger = ContainerFactory.this.getLog(); + final boolean debug = logger.isDebugEnabled(); public void beanChecked( VerificationEvent event ) { - logger.debug( event.getMessage() ); + if (debug) + logger.debug( event.getMessage() ); } public void specViolation( VerificationEvent event ) { @@ -989,10 +991,10 @@ logger.info( event.getMessage() ); } } - + protected ObjectName getServiceControllerName() throws DeploymentException { - try + try { return new ObjectName(SERVICE_CONTROLLER_NAME); } 1.32 +17 -9 jboss/src/main/org/jboss/ejb/StatelessSessionContainer.java Index: StatelessSessionContainer.java =================================================================== RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/ejb/StatelessSessionContainer.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- StatelessSessionContainer.java 2001/12/20 18:26:44 1.31 +++ StatelessSessionContainer.java 2002/01/05 12:08:50 1.32 @@ -32,7 +32,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Rickard Öberg</a> * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a> * @author <a href="mailto:[EMAIL PROTECTED]">Daniel OConnor</a> -* @version $Revision: 1.31 $ +* @version $Revision: 1.32 $ * <p><b>2001219 marc fleury</b> * <ul> * <li> move to the new invocation layer and Invocation object @@ -418,15 +418,18 @@ protected void setupHomeMapping() throws NoSuchMethodException { + boolean debug = log.isDebugEnabled(); + Map map = new HashMap(); - + if (homeInterface != null) { Method[] m = homeInterface.getMethods(); for (int i = 0; i < m.length; i++) { // Implemented by container - log.debug("Mapping "+m[i].getName()); + if (debug) + log.debug("Mapping "+m[i].getName()); map.put(m[i], getClass().getMethod(m[i].getName()+"Home", m[i].getParameterTypes())); } } @@ -436,31 +439,36 @@ for (int i = 0; i < m.length; i++) { // Implemented by container - log.debug("Mapping "+m[i].getName()); + if (debug) + log.debug("Mapping "+m[i].getName()); map.put(m[i], getClass().getMethod(m[i].getName()+"LocalHome", m[i].getParameterTypes())); } } - + homeMapping = map; } - + private void setUpBeanMappingImpl( Map map, Method[] m, String declaringClass ) throws NoSuchMethodException { + boolean debug = log.isDebugEnabled(); + for (int i = 0; i < m.length; i++) { if (!m[i].getDeclaringClass().getName().equals(declaringClass)) { // Implemented by bean map.put(m[i], beanClass.getMethod(m[i].getName(), m[i].getParameterTypes())); - log.debug("Mapped "+m[i].getName()+" "+m[i].hashCode()+"to "+map.get(m[i])); + if (debug) + log.debug("Mapped "+m[i].getName()+" "+m[i].hashCode()+"to "+map.get(m[i])); } else { try { // Implemented by container - log.debug("Mapped Container method "+m[i].getName() +" HASH "+m[i].hashCode()); + if (debug) + log.debug("Mapped Container method "+m[i].getName() +" HASH "+m[i].hashCode()); map.put(m[i], getClass().getMethod(m[i].getName(), new Class[] { Invocation.class })); } catch (NoSuchMethodException e) { @@ -469,7 +477,7 @@ } } } - + protected void setupBeanMapping() throws NoSuchMethodException {
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development