/** * Get the CarbonRuntime service. This is the bind method that gets called for CarbonRuntime * service registration that satisfy the policy. * * @param carbonRuntime the CarbonRuntime service that is registered as a service. */ @Reference( name = "carbon.runtime.service", service = CarbonRuntime.class, cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC, unbind = "unregisterCarbonRuntime") protected void registerCarbonRuntime(CarbonRuntime carbonRuntime) { DataHolder.getInstance().setCarbonRuntime(carbonRuntime); }
private void promptOperation() { String stockSymbol = getInput("Please enter the stock symbol : "); DataHolder dataHolder = DataHolder.getInstance(); Stock stock = null; if (stockSymbol != null) { stock = dataHolder.getStock(stockSymbol.toUpperCase()); } if (stock != null) { System.out.println(stock); promptMarketPrice(stock); } else { System.out.println("Invalid stock symbol! "); promptOperation(); } fetchStockPerformance(stock); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); DataHolder.InitDataHolder(getApplicationContext()); nextButton = (Button) findViewById(R.id.nextButton); editTeamsButton = (Button) findViewById(R.id.toEditTeam); mTeamSpinner = (Spinner) (findViewById(R.id.teamSelectSpinnerId)); Hashtable teamsHashtable = DataHolder.getInstance().getTeams(); ArrayList<String> initTeams = new ArrayList<String>(teamsHashtable.size()); Enumeration<String> keys = teamsHashtable.keys(); String tempString; while (keys.hasMoreElements()) { tempString = keys.nextElement(); initTeams.add(tempString); } mSpinnerAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, initTeams); mSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mTeamSpinner.setAdapter(mSpinnerAdapter); mPlayerListView = (ListView) findViewById(R.id.listViewPlayers); Team jaredTeam = (Team) teamsHashtable.get("Jared"); Hashtable playersHashtable = jaredTeam.getmPlayers(); ArrayList<Player> tempList = makePlayerArrayList(playersHashtable); mListViewAdapter = new PlayerListAdapter(this, tempList); mPlayerListView.setAdapter(mListViewAdapter); mTeamSpinner.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String teamName = (String) mTeamSpinner.getSelectedItem(); Team currentTeam = (Team) DataHolder.getInstance().getTeams().get(teamName); Hashtable currentPlayers = currentTeam.getmPlayers(); ListView teamList = (ListView) findViewById(R.id.listViewPlayers); PlayerListAdapter tempAdp = (PlayerListAdapter) teamList.getAdapter(); ArrayList<Player> tempList = makePlayerArrayList(currentPlayers); tempAdp.clear(); tempAdp.addAll(tempList); tempAdp.notifyDataSetChanged(); } @Override public void onNothingSelected(AdapterView<?> parent) {} }); }
/* (non-Javadoc) * @see org.wso2.carbon.identity.application.authentication.framework.AbstractApplicationAuthenticator#initiateAuthenticationRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext) */ @Override protected void initiateAuthenticationRequest( HttpServletRequest request, HttpServletResponse response, AuthenticationContext context) throws AuthenticationFailedException { String loginPage = ConfigurationFacade.getInstance().getAuthenticationEndpointURL(); String queryParams = FrameworkUtils.getQueryStringWithFrameworkContextId( context.getQueryParams(), context.getCallerSessionKey(), context.getContextIdentifier()); try { String retryParam = ""; if (context.isRetrying()) { retryParam = "&authFailure=true&authFailureMsg=login.fail.message"; } else { // Insert entry to DB only if this is not a retry DBUtils.insertUserResponse( context.getContextIdentifier(), String.valueOf(MSSAuthenticator.UserResponse.PENDING)); } // MSISDN will be saved in the context in the MSISDNAuthenticator String msisdn = (String) context.getProperty("msisdn"); MSSRequest mssRequest = new MSSRequest(); mssRequest.setMsisdnNo("+" + msisdn); mssRequest.setSendString( DataHolder.getInstance().getMobileConnectConfig().getMSS().getMssText()); String contextIdentifier = context.getContextIdentifier(); MSSRestClient mssRestClient = new MSSRestClient(contextIdentifier, mssRequest); mssRestClient.start(); response.sendRedirect( response.encodeRedirectURL(loginPage + ("?" + queryParams)) + "&authenticators=" + getName() + ":" + "LOCAL" + retryParam); } catch (IOException e) { throw new AuthenticationFailedException(e.getMessage(), e); } catch (AuthenticatorException e) { throw new AuthenticationFailedException(e.getMessage(), e); } }
/** * This is the unbind method for the above reference that gets called for CarbonRuntime instance * un-registrations. * * @param carbonRuntime the CarbonRuntime service that get unregistered. */ protected void unregisterCarbonRuntime(CarbonRuntime carbonRuntime) { DataHolder.getInstance().setCarbonRuntime(null); }