View Javadoc
1   package org.andromda.cartridges.hibernate.metafacades;
2   
3   import org.apache.commons.lang.ObjectUtils;
4   import org.apache.commons.lang.StringUtils;
5   
6   /**
7    * MetafacadeLogic implementation for
8    * org.andromda.cartridges.hibernate.metafacades.HibernateService.
9    *
10   * @see org.andromda.cartridges.hibernate.metafacades.HibernateService
11   */
12  public class HibernateServiceLogicImpl
13      extends HibernateServiceLogic
14  {
15      private static final long serialVersionUID = 34L;
16      /**
17       * @param metaObject
18       * @param context
19       */
20      public HibernateServiceLogicImpl(
21          Object metaObject,
22          String context)
23      {
24          super(metaObject, context);
25      }
26  
27      /**
28       * @see org.andromda.cartridges.hibernate.metafacades.HibernateService#getEjbJndiName()
29       */
30      @Override
31      protected String handleGetEjbJndiName()
32      {
33          StringBuilder jndiName = new StringBuilder();
34          String jndiNamePrefix = StringUtils.trimToEmpty(this.getEjbJndiNamePrefix());
35          if (StringUtils.isNotBlank(jndiNamePrefix))
36          {
37              jndiName.append(jndiNamePrefix);
38              jndiName.append('/');
39          }
40          jndiName.append("ejb/");
41          jndiName.append(this.getFullyQualifiedName());
42          return jndiName.toString();
43      }
44  
45      /**
46       * @see org.andromda.cartridges.hibernate.metafacades.HibernateService#getEjbViewType()
47       */
48      @Override
49      protected String handleGetEjbViewType()
50      {
51          String defaultViewType = String.valueOf(this.getConfiguredProperty("ejbViewType"));
52          return HibernateMetafacadeUtils.getViewType(this, defaultViewType);
53      }
54  
55      /**
56       * Gets the <code>ejbJndiNamePrefix</code> for this EJB.
57       *
58       * @return the EJB Jndi name prefix.
59       */
60      protected String getEjbJndiNamePrefix()
61      {
62          final String property = "ejbJndiNamePrefix";
63          return this.isConfiguredProperty(property) ? ObjectUtils.toString(this.getConfiguredProperty(property)) : null;
64      }
65  
66      /**
67       * @see org.andromda.cartridges.hibernate.metafacades.HibernateService#isEjbStateful()
68       */
69      @Override
70      protected boolean handleIsEjbStateful()
71      {
72          return !this.getAttributes().isEmpty();
73      }
74  
75      /**
76       * The value used to indicate the interfaces for an EJB are remote.
77       */
78      private static final String VIEW_TYPE_REMOTE = "remote";
79  
80      /**
81       * @see org.andromda.cartridges.hibernate.metafacades.HibernateService#isEjbRemoteView()
82       */
83      @Override
84      protected boolean handleIsEjbRemoteView()
85      {
86          return this.getEjbViewType().equalsIgnoreCase(VIEW_TYPE_REMOTE);
87      }
88  }