/*
   * (non-Javadoc)
   *
   * @see com.fan.service.ServiceFactory#getService(java.lang.Class)
   */
  @SuppressWarnings("unchecked")
  @Override
  public GenericService<?> getService(Class<? extends GenericService<?>> serviceClass)
      throws Exception {

    try {
      GenericService<?> service = (GenericService<?>) serviceClass.newInstance();

      String className = serviceClass.getName();

      // Removendo pacote de serviço
      String servicePackage = GenericServiceFactory.class.getName();
      servicePackage = servicePackage.substring(0, servicePackage.lastIndexOf('.'));

      String daoPackage = GenericDAOFactory.class.getName();
      daoPackage = daoPackage.substring(0, daoPackage.lastIndexOf('.'));

      // Trocando o nome do pacote service por dao
      className = serviceClass.getName().replaceAll(servicePackage, daoPackage);

      className = className.substring(0, className.lastIndexOf('.') + 1);

      className += service.getEntityClass().getSimpleName() + "DAO";

      // Setando dao
      service.setDao(
          getDAOFactory().getDAO((Class<? extends GenericDAO<?>>) Class.forName(className)));

      return service;

    } catch (Exception e) {
      e.printStackTrace(); // TODO logger
      throw e;
    }
  }
Ejemplo n.º 2
0
  @Override
  public void onCreate() {
    super.onCreate();

    createServiceRosterStub();
    createServiceChatStub();

    mPAlarmIntent =
        PendingIntent.getBroadcast(this, 0, mAlarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    registerReceiver(mAlarmReceiver, new IntentFilter(RECONNECT_ALARM));

    // for the initial connection, check if autoConnect is set
    mConnectionDemanded.set(mConfig.autoConnect);
    YaximBroadcastReceiver.initNetworkStatus(getApplicationContext());

    if (mConfig.autoConnect) {
      /*
       * start our own service so it remains in background even when
       * unbound
       */
      Intent xmppServiceIntent = new Intent(this, XMPPService.class);
      xmppServiceIntent.setAction("org.yaxim.androidclient.XMPPSERVICE");
      startService(xmppServiceIntent);
    }

    mServiceNotification = ServiceNotification.getInstance();
  }
Ejemplo n.º 3
0
 @Override
 public void onRebind(Intent intent) {
   super.onRebind(intent);
   String chatPartner = intent.getDataString();
   if ((chatPartner != null)) {
     mIsBoundTo.add(chatPartner);
     resetNotificationCounter(chatPartner);
   }
 }
Ejemplo n.º 4
0
  @Override
  public void onDestroy() {
    super.onDestroy();

    ((AlarmManager) getSystemService(Context.ALARM_SERVICE)).cancel(mPAlarmIntent);
    mRosterCallbacks.kill();
    performDisconnect();
    unregisterReceiver(mAlarmReceiver);
  }
Ejemplo n.º 5
0
  @Override
  public IBinder onBind(Intent intent) {
    super.onBind(intent);
    String chatPartner = intent.getDataString();
    if ((chatPartner != null)) {
      resetNotificationCounter(chatPartner);
      mIsBoundTo.add(chatPartner);
      return mServiceChatConnection;
    }

    return mService2RosterConnection;
  }
Ejemplo n.º 6
0
  @Override
  public void saveOrUpdate(Produto bean) {
    if (bean.getPro_cd() == null) bean.setPro_cd(produtoDAO.proximoId());

    super.saveOrUpdate(bean);
  }
 @RolesAllowed({ALUNO})
 @Override
 public void remover(Atividade entidadeNegocio) throws NegocioException {
   super.remover(entidadeNegocio);
 }