Package org.jboss.ejb3.proxy.impl.factory

Examples of org.jboss.ejb3.proxy.impl.factory.ProxyFactory


   protected ProxyFactory createRemoteProxyFactory(final String name, final String containerName,
         final String containerGuid, final JBossSessionBeanMetaData smd, final ClassLoader cl, final String url,
         final Advisor advisor, final String interceptorStackName)
   {
      // Create
      ProxyFactory factory = new StatefulSessionRemoteProxyFactory(name, containerName, containerGuid, smd, cl, url,
            advisor, interceptorStackName);

      // Register with Remoting
      log.debug("Registering with Remoting Dispatcher under name \"" + factory.getName() + "\": " + factory);
      Dispatcher.singleton.registerTarget(factory.getName(), factory);

      // Return
      return factory;
   }
View Full Code Here


         // Get the default remote JNDI Name
         String defaultRemoteJndiName = smd.getJndiName();

         // Create and register a remote proxy factory
         String defaultRemoteProxyFactoryKey = this.getProxyFactoryRegistryKey(defaultRemoteJndiName, smd, false);
         ProxyFactory factory = this.createRemoteProxyFactory(defaultRemoteProxyFactoryKey, containerName,
               containerGuid, smd, cl, defaultClientBindUrl, advisor, null);
         try
         {
            this.registerProxyFactory(defaultRemoteProxyFactoryKey, factory, smd);
         }
         catch (DuplicateBindException dbe)
         {
            throw new RuntimeException(dbe);
         }

         // Get Classname to set for Reference
         String defaultRemoteClassName = this.getHumanReadableListOfInterfacesInRefAddrs(refAddrsForRemote);

         // Create a Reference
         Reference defaultRemoteRef = createStandardReference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX
               + defaultRemoteClassName, defaultRemoteProxyFactoryKey, containerName, false);

         /*
          * Set up references for Home
          */

         // Determine if remote home and business remotes are bound to same JNDI Address
         boolean bindRemoteAndHomeTogether = this.isHomeAndBusinessBoundTogether(smd, false);
         if (bindRemoteAndHomeTogether)
         {
            // Add a Reference Address for the Remote Home
            String home = smd.getHome();
            assert home != null : "Home and Business set to be bound together, yet no home is defined";
            RefAddr refAddr = new StringRefAddr(
                  ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_EJB2x_INTERFACE_HOME_REMOTE, home);
            refAddrsForRemote.add(refAddr);
         }
         // Bind Home (not bound together) if exists
         else if (smd.getHome() != null && smd.getHome().trim().length() > 0)
         {
            String homeType = smd.getHome();
            RefAddr refAddrHomeInterface = new StringRefAddr(
                  ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_EJB2x_INTERFACE_HOME_REMOTE, homeType);
            RefAddr refAddrRemoting = this.createRemotingRefAddr(defaultClientBindUrl);
            Reference homeRef = createStandardReference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX
                  + homeType, defaultRemoteProxyFactoryKey, containerName, false);
            homeRef.add(refAddrHomeInterface);
            homeRef.add(refAddrRemoting);

            String homeAddress = smd.getHomeJndiName();
            assert homeAddress != null && !homeAddress.equals("") : "JNDI Address for Remote Home must be defined";
            log.debug("Remote Home View for EJB " + smd.getEjbName() + " to be bound into JNDI at \"" + homeAddress
                  + "\"");

            bindingSet.addHomeRemoteBinding(new JndiReferenceBinding(homeAddress, homeRef));
         }

         /*
          * If no @RemoteBindings are defined, make a default remote binding
          */

         // Get RemoteBindings
         List<RemoteBindingMetaData> remoteBindings = smd.getRemoteBindings();

         // If there are no @RemoteBindings defined and there's a remote business (EJB3) view
         if (remoteBindings == null && hasRemoteBusinessView)
         {
            // Use the default Client Bind URL
            String clientBindUrl = defaultClientBindUrl;

            // Create a default remote remoting RefAddr, using the default (as none was explicitly-specified)
            RefAddr defaultRemoteRemotingRefAddr = this.createRemotingRefAddr(clientBindUrl);

            // Add a Reference Address for the Remoting URL
            refAddrsForRemote.add(defaultRemoteRemotingRefAddr);

            /*
             * Bind ObjectFactory for default remote businesses (and home if bound together)
             */

            // Add all Reference Addresses for Default Remote Reference
            for (RefAddr refAddr : refAddrsForRemote)
            {
               log.debug("Adding " + RefAddr.class.getSimpleName() + " to Default Remote "
                     + Reference.class.getSimpleName() + ": Type \"" + refAddr.getType() + "\", Content \""
                     + refAddr.getContent() + "\"");
               defaultRemoteRef.add(refAddr);
            }

            // Bind the Default Remote Reference to JNDI
            log.debug("Default Remote Business View for EJB " + smd.getEjbName() + " to be bound into JNDI at \""
                  + defaultRemoteJndiName + "\"");
            bindingSet.addDefaultRemoteBinding(new JndiReferenceBinding(defaultRemoteJndiName, defaultRemoteRef));

         }

         /*
          * If there are @RemoteBindings and a remote view
          */

         // Remote Bindings are defined, create a binding for each
         else if (remoteBindings != null && hasRemoteView)
         {

            /*
             * Bind all explicitly-declared remote bindings
             */

            // For each of the explicitly-defined @RemoteBindings
            for (RemoteBindingMetaData binding : remoteBindings)
            {
               // Get the defined JNDI Name
               String remoteBindingJndiName = binding.getJndiName();

               // If the JNDI Name isn't defined
               if (remoteBindingJndiName == null || remoteBindingJndiName.trim().length() == 0)
               {
                  // Set a default remote binding JNDI name
                  remoteBindingJndiName = smd.getJndiName();
               }

               // Get the client bind URL
               String clientBindUrl = defaultClientBindUrl;

               // Override the client bind URL with that associated with @RemoteBinding.invokerName
               String remoteBindingInvokerBindName = binding.getInvokerName();
               boolean remoteBindingInvokerNameDefined = remoteBindingInvokerBindName != null
                     && remoteBindingInvokerBindName.trim().length() > 0;
               if (remoteBindingInvokerNameDefined)
               {
                  clientBindUrl = ProxyRemotingUtils.getClientBinding(remoteBindingInvokerBindName);
                  log.debug("Using client bind URL of " + clientBindUrl + " as specified by invokerName "
                        + remoteBindingInvokerBindName + " for EJB " + smd.getName() + " with JNDI Binding: "
                        + remoteBindingJndiName);
               }

               // Override the client bind URL with that specified from @RemoteBinding.clientBindUrl
               String remoteBindingClientBindUrl = binding.getClientBindUrl();
               if (remoteBindingClientBindUrl != null && remoteBindingClientBindUrl.trim().length() > 0)
               {
                  clientBindUrl = remoteBindingClientBindUrl;
                  log.debug("Using client bind URL of " + clientBindUrl + " as specified by clientBindUrl "
                        + remoteBindingClientBindUrl + " for EJB " + smd.getName() + " with JNDI Binding: "
                        + remoteBindingJndiName);

                  // Warn the user if he's provided two overrides
                  if (remoteBindingInvokerNameDefined)
                  {
                     log.warn("Both invokerName and clientBindUrl have been specified on "
                           + RemoteBindingMetaData.class.getSimpleName() + " for EJB " + smd.getName()
                           + "; clientBindUrl takes priority");
                  }
               }

               // Get the interceptor stack
               String interceptorStack = binding.getInterceptorStack();

               /*
                * Obtain a Proxy Factory for this Binding
                */

               // Create and register a remote proxy factory specific to this binding
               String remoteBindingProxyFactoryKey = this.getProxyFactoryRegistryKey(remoteBindingJndiName, smd, false);
               ProxyFactory remoteBindingProxyFactory = null;
               boolean reregister = true;
               try
               {
                  // Check if it's already available
                  remoteBindingProxyFactory = Ejb3RegistrarLocator.locateRegistrar().lookup(
                        remoteBindingProxyFactoryKey, ProxyFactory.class);
               }
               catch (NotBoundException nbe)
               {
                  reregister = false;
               }

               // If we need to reregister with this newly-defined Proxy Factory
               if (reregister)
               {
                  Ejb3RegistrarLocator.locateRegistrar().unbind(remoteBindingProxyFactoryKey);
               }

               // Create the Proxy Factory
               remoteBindingProxyFactory = this.createRemoteProxyFactory(remoteBindingProxyFactoryKey, containerName,
                     containerGuid, smd, cl, clientBindUrl, advisor, interceptorStack);
               try
               {
                  this.registerProxyFactory(remoteBindingProxyFactoryKey, remoteBindingProxyFactory, smd);
               }
               catch (DuplicateBindException dbe)
               {
                  throw new RuntimeException(dbe);
               }

               // Create a default remote remoting RefAddr, using the default (as none was explicitly-specified)
               RefAddr remoteBindingRemotingRefAddr = this.createRemotingRefAddr(clientBindUrl);

               // Create a Reference
               Reference remoteBindingRef = createStandardReference(
                     JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX + defaultRemoteClassName,
                     remoteBindingProxyFactoryKey, containerName, false);

               // Add a Reference Address for the Remoting URL
               log.debug("Adding " + RefAddr.class.getSimpleName() + " to @RemoteBinding "
                     + Reference.class.getSimpleName() + ": Type \"" + remoteBindingRemotingRefAddr.getType()
                     + "\", Content \"" + remoteBindingRemotingRefAddr.getContent() + "\"");
               remoteBindingRef.add(remoteBindingRemotingRefAddr);

               // Add all Reference Addresses for @RemoteBinding Reference
               for (RefAddr refAddr : refAddrsForRemote)
               {
                  log.debug("Adding " + RefAddr.class.getSimpleName() + " to @RemoteBinding "
                        + Reference.class.getSimpleName() + ": Type \"" + refAddr.getType() + "\", Content \""
                        + refAddr.getContent() + "\"");
                  remoteBindingRef.add(refAddr);
               }

               // Create the binding
               JndiReferenceBinding remoteBindingJndiBinding = new JndiReferenceBinding(remoteBindingJndiName,
                     remoteBindingRef);

               // Add the binding
               bindingSet.addDefaultRemoteBinding(remoteBindingJndiBinding);

            }
         }

         // Bind ObjectFactory specific to each Remote Business Interface
         if (businessRemotes != null)
         {
            for (String businessRemote : businessRemotes)
            {
               RefAddr refAddrBusinessInterface = new StringRefAddr(
                     ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_REMOTE, businessRemote);
               RefAddr refAddrRemoting = this.createRemotingRefAddr(defaultClientBindUrl);
               Reference ref = createStandardReference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX
                     + businessRemote, defaultRemoteProxyFactoryKey, containerName, false);
               ref.add(refAddrBusinessInterface);
               ref.add(refAddrRemoting);
               String address = JbossSessionBeanJndiNameResolver.resolveJndiName(smd, businessRemote);
               log.debug("Remote Business View for " + businessRemote + " of EJB " + smd.getEjbName()
                     + " to be bound into JNDI at \"" + address + "\"");

               bindingSet.addBusinessRemoteBinding(businessRemote, new JndiReferenceBinding(address, ref));
            }
         }
      }
      // If there's a local view
      if (hasLocalView)
      {
         // Get the default local JNDI Name
         String defaultLocalJndiName = smd.getLocalJndiName();

         // Create and register a local proxy factory
         String localProxyFactoryKey = this.getProxyFactoryRegistryKey(defaultLocalJndiName, smd, true);
         ProxyFactory factory = this.createLocalProxyFactory(localProxyFactoryKey, containerName, containerGuid, smd,
               cl, advisor);
         try
         {
            this.registerProxyFactory(localProxyFactoryKey, factory, smd);
         }
View Full Code Here

   protected ProxyFactory createRemoteProxyFactory(final String name, final String containerName,
         final String containerGuid, final JBossSessionBeanMetaData smd, final ClassLoader cl, final String url,
         final Advisor advisor, final String interceptorStackName)
   {
      // Create
      ProxyFactory factory = new StatelessSessionRemoteProxyFactory(name, containerName, containerGuid, smd, cl, url,
            advisor, interceptorStackName);

      // Register with Remoting
      log.debug("Registering with Remoting Dispatcher under name \"" + factory.getName() + "\": " + factory);
      Dispatcher.singleton.registerTarget(factory.getName(), factory);

      // Return
      return factory;
   }
View Full Code Here

      // Cast
      JBossServiceBeanMetaData serviceMd = (JBossServiceBeanMetaData) smd;

      // Create
      ProxyFactory factory = new ServiceRemoteProxyFactory(name, containerName, containerGuid, serviceMd, cl, url,
            advisor, interceptorStackName);

      // Register with Remoting
      log.debug("Registering with Remoting Dispatcher under name \"" + factory.getName() + "\": " + factory);
      Dispatcher.singleton.registerTarget(factory.getName(), factory);

      // Return
      return factory;
   }
View Full Code Here

       * locally via the Ejb3Registry, or
       * via the remote Dispatcher
       */

      // Obtain Proxy Factory
      ProxyFactory proxyFactory = null;

      // Determine if Remote or Local (EJBTHREE-1403)
      String isLocalStringFromRefAddr = this.getSingleRequiredReferenceAddressValue(name, refAddrs,
            ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_IS_LOCAL);
      assert isLocalStringFromRefAddr != null && isLocalStringFromRefAddr.trim().length() > 0 : "Required "
View Full Code Here

               // Create and register a remote proxy factory specific to this binding
               String remoteBindingProxyFactoryKey = this.getProxyFactoryRegistryKey(remoteBindingJndiName, smd, false);
               if ( defaultRemoteProxyFactoryKey.equals ( remoteBindingProxyFactoryKey ) )
                  bindDefaultFactory = false;

               ProxyFactory remoteBindingProxyFactory = null;
               boolean reregister = true;
               try
               {
                  // Check if it's already available
                  remoteBindingProxyFactory = Ejb3RegistrarLocator.locateRegistrar().lookup(
                        remoteBindingProxyFactoryKey, ProxyFactory.class);
               }
               catch (NotBoundException nbe)
               {
                  reregister = false;
               }

               // If we need to reregister with this newly-defined Proxy Factory
               if (reregister)
               {
                  Ejb3RegistrarLocator.locateRegistrar().unbind(remoteBindingProxyFactoryKey);
               }

               // Create the Proxy Factory
               remoteBindingProxyFactory = this.createRemoteProxyFactory(remoteBindingProxyFactoryKey, containerName,
                     containerGuid, smd, cl, clientBindUrl, advisor, interceptorStack);
               try
               {
                  this.registerProxyFactory(remoteBindingProxyFactoryKey, remoteBindingProxyFactory, smd);
               }
               catch (DuplicateBindException dbe)
               {
                  throw new RuntimeException(dbe);
               }

               // Create a default remote remoting RefAddr, using the default (as none was explicitly-specified)
               RefAddr remoteBindingRemotingRefAddr = this.createRemotingRefAddr(clientBindUrl);

               // Create a Reference
               Reference remoteBindingRef = createStandardReference(
                     JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX + defaultRemoteClassName,
                     remoteBindingProxyFactoryKey, containerName, false);

               // Also bind the remote proxy factory to jndi (after unbinding any existing instances)
               if (reregister)
               {
                  unbind(context, remoteBindingProxyFactoryKey);
               }
               this.bindRemoteProxyFactory(context, remoteBindingProxyFactoryKey, clientBindUrl,
                     remoteBindingProxyFactory, cl, smd);

               // Add a Reference Address for the Remoting URL
               log.debug("Adding " + RefAddr.class.getSimpleName() + " to @RemoteBinding "
                     + Reference.class.getSimpleName() + ": Type \"" + remoteBindingRemotingRefAddr.getType()
                     + "\", Content \"" + remoteBindingRemotingRefAddr.getContent() + "\"");
               remoteBindingRef.add(remoteBindingRemotingRefAddr);

               // Add all Reference Addresses for @RemoteBinding Reference
               for (RefAddr refAddr : refAddrsForRemote)
               {
                  log.debug("Adding " + RefAddr.class.getSimpleName() + " to @RemoteBinding "
                        + Reference.class.getSimpleName() + ": Type \"" + refAddr.getType() + "\", Content \""
                        + refAddr.getContent() + "\"");
                  remoteBindingRef.add(refAddr);
               }

               // Create the binding
               JndiReferenceBinding remoteBindingJndiBinding = new JndiReferenceBinding(remoteBindingJndiName,
                     remoteBindingRef);

               // Add the binding
               bindingSet.addDefaultRemoteBinding(remoteBindingJndiBinding);

            }
         }

         // Only bind the default if there are no remote bindings defined.
         if (bindDefaultFactory)
         {
            ProxyFactory factory = this.createRemoteProxyFactory(defaultRemoteProxyFactoryKey, containerName,
                  containerGuid, smd, cl, defaultClientBindUrl, advisor, null);
            try
            {
               this.registerProxyFactory(defaultRemoteProxyFactoryKey, factory, smd);
            }
            catch (DuplicateBindException dbe)
            {
               throw new RuntimeException(dbe);
            }

            // Also bind remote proxy factory to jndi
            this.bindRemoteProxyFactory(context, defaultRemoteProxyFactoryKey, defaultClientBindUrl, factory, cl, smd);
         }

         // Bind ObjectFactory specific to each Remote Business Interface
         if (businessRemotes != null)
         {
            for (String businessRemote : businessRemotes)
            {
               RefAddr refAddrBusinessInterface = new StringRefAddr(
                     ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_REMOTE, businessRemote);
               RefAddr refAddrRemoting = this.createRemotingRefAddr(defaultClientBindUrl);
               Reference ref = createStandardReference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX
                     + businessRemote, defaultRemoteProxyFactoryKey, containerName, false);
               ref.add(refAddrBusinessInterface);
               ref.add(refAddrRemoting);
               String address = JbossSessionBeanJndiNameResolver.resolveJndiName(smd, businessRemote);
               log.debug("Remote Business View for " + businessRemote + " of EJB " + smd.getEjbName()
                     + " to be bound into JNDI at \"" + address + "\"");

               bindingSet.addBusinessRemoteBinding(businessRemote, new JndiReferenceBinding(address, ref));
            }
         }
      }
      // If there's a local view
      if (hasLocalView)
      {
         // Get the default local JNDI Name
         String defaultLocalJndiName = smd.getLocalJndiName();

         // Create and register a local proxy factory
         String localProxyFactoryKey = this.getProxyFactoryRegistryKey(defaultLocalJndiName, smd, true);
         ProxyFactory factory = this.createLocalProxyFactory(localProxyFactoryKey, containerName, containerGuid, smd,
               cl, advisor);
         try
         {
            this.registerProxyFactory(localProxyFactoryKey, factory, smd);
         }
View Full Code Here

    */
   protected void bindRemoteProxyFactory(Context context, String proxyFactoryKey, String remotingUrl,
         ProxyFactory proxyFactory, ClassLoader cl, JBossEnterpriseBeanMetaData smd)
   {

      ProxyFactory proxyToProxyFactory = this.createProxyToProxyFactory(proxyFactoryKey, remotingUrl, proxyFactory, cl,
            smd);
      // now bind
      try
      {
         log.debug("Binding remote ProxyFactory to JNDI, at key " + proxyFactoryKey);
View Full Code Here

      {
         this.id = null;
      }
      else
      {
         SessionProxyInvocationHandler handler = (SessionProxyInvocationHandler) Proxy.getInvocationHandler(reference);
         id = (Serializable) handler.getTarget();
      }

      @Deprecated
      Ejb3Registrar registrar = Ejb3RegistrarLocator.locateRegistrar();
View Full Code Here

      {
         final AsyncLocalBusiness bean = (AsyncLocalBusiness) NAMING_CONTEXT.lookup(AsyncBean.class.getSimpleName()
               + JNDI_SUFFIX_LOCAL_BUSINESS);
         log.info(bean.toString());
         log.info(bean.getClass().toString());
         final SessionProxyInvocationHandlerBase handler = (SessionProxyInvocationHandlerBase) Proxy
               .getInvocationHandler(bean);
         log.info("INTERCEPTORS: " + Arrays.asList(handler.getInterceptors()).toString());

         final Future<Thread> invocation = bean.getThreadOfExecution();

         // Block and test
         final Thread beanThread = invocation.get(3, TimeUnit.SECONDS);
View Full Code Here

    * @return
    */
   private TimerService createTimerService()
   {
      // get the TimedObjectInvoker
      TimedObjectInvoker timedObjectInvoker = this.getTimedObjectInvoker();
      // if there's no TimedObjectInvoker, we can't do anything, so just
      // throw an exception
      if (timedObjectInvoker == null)
      {
         throw new IllegalStateException("Cannot create timerservice for EJB " + this.getEjbName()
View Full Code Here

TOP

Related Classes of org.jboss.ejb3.proxy.impl.factory.ProxyFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.